Skip to content

Commit

Permalink
up 2023-01-01
Browse files Browse the repository at this point in the history
  • Loading branch information
hktalent committed Jan 1, 2023
1 parent 019c68b commit 4db39c4
Show file tree
Hide file tree
Showing 1,224 changed files with 21,446 additions and 102,570 deletions.
27 changes: 27 additions & 0 deletions 3ee8307c128be7296b2fa2ad5453341a3d37c2b6.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions brute/dicts/filedic.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/Login.jsp
/login.jsp
/stats.json
/.well-known/security.txt
../../../../../../../../../../../../../../../../../../usr/local/cpanel/logs/login_log%00
../../../../../../../../../../../../../../../../../../usr/local/cpanel/logs/login_log
Expand Down
14 changes: 4 additions & 10 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@
"-c",20,
"-o","{PWD}/logs"
],
"uncover": [
"-q","",
"-e","shodan",
"-pc","{PWD}/config/uncover/provider-config.yaml",
"-config","{PWD}/config/uncover/config.yaml",
"-f","ip,port,host",
"-json","-o",""
],
"ffuf": [
"-u","",
"-w","{PWD}/brute/dicts/filedic.txt",
Expand Down Expand Up @@ -51,8 +43,10 @@
],
"uncover": [
"-q","",
"-engine","shodan",
"-provider","{PWD}/config/uncover/provider-config.yaml",
"-e","shodan",
"-pc","{PWD}/config/uncover/provider-config.yaml",
"-config","{PWD}/config/uncover/config.yaml",
"-f","ip,port,host",
"-shodan",
"-silent","-nc","-json","-o",""
],
Expand Down
2 changes: 1 addition & 1 deletion config/nuclei-templates
Submodule nuclei-templates updated 679 files
2 changes: 1 addition & 1 deletion config/uncover/provider-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
shodan:
- FfH1z0IR5MiktkLbfMlQD93M3lPe32vH
- ZRSzvyQ1GiKZkK0JfSZJKH4ucv8u1ude
censys: []
fofa: []
4 changes: 3 additions & 1 deletion doNaabu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ func DoInitAll() {

func TestDoUncover(t *testing.T) {
DoInitAll()
a := strings.Split(`'gov.cn'
a := strings.Split(`
'ssl:Alibaba'
'gov.cn'
'ssl:"gov.cn"'
'ssl:"China Lodging Group"'
'ssl:"huazhu"'
Expand Down
3 changes: 3 additions & 0 deletions engine/engineImp.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (e *Engine) initNodeId() {
}
}

// 优化使用websocket、或者webRTC
// "https://dt.51pwn.com/api/v1.0/syncResult/task/%d"
// curl -v -XPOST -d '{"Num":22,"task_ids":"","node_id":"xx","task_num":443}' https://127.0.0.1:8081/api/v1.0/syncResult/task/33
// 结果反馈 /api/v1.0/syncResult/task/%d
Expand Down Expand Up @@ -237,10 +238,12 @@ func (e *Engine) SendTask(s string) {
}
}

// 注册特定类型的事件处理
func (e *Engine) EngineFuncFactory(nT int64, fnCbk util.EngineFuncType) {
e.RegCaseScanFunc(nT, fnCbk)
}

// 注册特定类型的事件处理
func (e *Engine) RegCaseScanFunc(nType int64, fnCbk util.EngineFuncType) {
e.caseScanFunc.Store(nType, fnCbk)
}
Expand Down
155 changes: 41 additions & 114 deletions go.mod

Large diffs are not rendered by default.

826 changes: 81 additions & 745 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package api
import (
_ "github.com/hktalent/ProScan4all/engine"
"github.com/hktalent/ProScan4all/lib/util"
"github.com/hktalent/ProScan4all/pkg/hydra"
naaburunner "github.com/hktalent/ProScan4all/pkg/naabu/v2/pkg/runner"
jsoniter "github.com/json-iterator/go"
"github.com/projectdiscovery/gologger"
Expand Down Expand Up @@ -68,12 +67,13 @@ func StartScan(oOpts *map[string]interface{}) {
noScan := util.GetValAsBool("noScan")

// 直接使用 nmap xml结果文件
if hydra.DoNmapWithFile(options.HostsFile, &naaburunner.Naabubuffer) {
if util.DoNmapWithFile(options.HostsFile, &naaburunner.Naabubuffer) {
os.Setenv("noScan", "true")
naabuRunner.Close()
} else if noScan {
s1, err := naabuRunner.MergeToFile()
if nil == err {
util.DoInput(s1, &naaburunner.Naabubuffer)
data, err := ioutil.ReadFile(s1)
if nil == err {
naaburunner.Naabubuffer.Write(data)
Expand Down
7 changes: 5 additions & 2 deletions lib/util/Const.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import (
"context"
"fmt"
util "github.com/hktalent/go-utils"
jsoniter "github.com/json-iterator/go"
"github.com/remeh/sizedwaitgroup"
"net/http"
"os"
"regexp"
"strings"
)

var Json = jsoniter.ConfigCompatibleWithStandardLibrary

// 全局线程控制
var Wg *sizedwaitgroup.SizedWaitGroup

Expand Down Expand Up @@ -78,7 +81,7 @@ func SetHeader4Map(m *map[string]string) {
// 程序main整体等待
func DoSyncFunc(cbk func()) {
Wg.Add()
go func() {
DefaultPool.Submit(func() {
defer Wg.Done()
for {
select {
Expand All @@ -90,7 +93,7 @@ func DoSyncFunc(cbk func()) {
return
}
}
}()
})
}

// 检查 cookie
Expand Down
25 changes: 25 additions & 0 deletions lib/util/GLock.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package util

import (
"fmt"
"sync"
"time"
)

var lk sync.Mutex

// 全局统一锁,避免相同目标、相同任务重复执行
// 库级:不重复
// 执行第一次,就进行标记,第二次返回true
func IsDoIt(s string, nType int) bool {
lk.Lock()
defer lk.Unlock()
k := fmt.Sprintf("IsDo%s_%d", s, nType)
if o := clientHttpCc.Get(k); nil != o {
if v, ok := o.Value().(bool); ok && v {
return v
}
}
clientHttpCc.Set(k, true, time.Hour*24)
return false
}
37 changes: 37 additions & 0 deletions lib/util/SPool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package util

import (
"github.com/panjf2000/ants/v2"
"time"
)

const (
// DefaultAntsPoolSize sets up the capacity of worker pool, 256 * 1024.
DefaultAntsPoolSize = 1 << 18

// ExpiryDuration is the interval time to clean up those expired workers.
ExpiryDuration = 10 * time.Second

// Nonblocking decides what to do when submitting a new task to a full worker pool: waiting for a available worker
// or returning nil directly.
Nonblocking = true
)

// Pool is the alias of ants.Pool.
type Pool = ants.Pool

var DefaultPool *Pool

func create() *Pool {
options := ants.Options{ExpiryDuration: ExpiryDuration, Nonblocking: Nonblocking}
defaultAntsPool, _ := ants.NewPool(DefaultAntsPoolSize, ants.WithOptions(options))
return defaultAntsPool
}

func init() {
RegInitFunc4Hd(func() {
// It releases the default pool from ants.
ants.Release()
DefaultPool = create()
})
}
24 changes: 24 additions & 0 deletions lib/util/VulInfo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package util

type VulnInfo struct {
Name string
VulID []string
Version string
Author string
VulDate string
References []string
AppName string
AppPowerLink string
AppVersion string
VulType string
Description string
Category string
Dork QueryDork
}

type QueryDork struct {
Fofa string
Quake string
Zoomeye string
Shodan string
}
2 changes: 1 addition & 1 deletion lib/util/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func DoCmd(args ...string) (string, error) {
if nil != err {
return "", err
}
return string(outStr + "\n" + errStr), err
return outStr + "\n" + errStr, err
}

func doFile(config *embed.FS, s fs.DirEntry, szPath string) {
Expand Down
61 changes: 33 additions & 28 deletions pkg/hydra/doNmapResult.go → lib/util/doNmapResult.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package hydra
package util

import (
"bytes"
"fmt"
"github.com/antchfx/xmlquery"
"github.com/hktalent/ProScan4all/lib/util"
"github.com/hktalent/ProScan4all/pkg"
"github.com/hktalent/51pwnPlatform/lib/scan/Const"
"github.com/hktalent/51pwnPlatform/pkg/models"
"io/ioutil"
"log"
"os"
Expand All @@ -15,23 +15,24 @@ import (

// 弱口令检测
func CheckWeakPassword(ip, service string, port int) {
util.DoSyncFunc(func() {
// 在弱口令检测范围就开始检测,结果....
service = strings.ToLower(service)
if pkg.Contains(ProtocolList, service) {
//log.Println("start CheckWeakPassword ", ip, ":", port, "(", service, ")")
Start(ip, port, service)
}
})
if !bCheckWeakPassword {
return
}
// 在弱口令检测范围就开始检测,结果....
service = strings.ToLower(service)
SendEvent(&models.EventData{
EventType: Const.ScanType_Pswd4hydra,
EventData: []interface{}{ip, port, service},
}, Const.ScanType_Pswd4hydra)
}

// 开启了es
var enableEsSv, bCheckWeakPassword bool = false, true
var bCheckWeakPassword bool = true

func init() {
util.RegInitFunc(func() {
enableEsSv = util.GetValAsBool("enableEsSv")
bCheckWeakPassword = util.GetValAsBool("CheckWeakPassword")
RegInitFunc(func() {
EnableEsSv = GetValAsBool("EnableEsSv")
bCheckWeakPassword = GetValAsBool("CheckWeakPassword")
//log.Println("CheckWeakPassword = ", util.GetVal("CheckWeakPassword"), " bCheckWeakPassword = ", bCheckWeakPassword)
})
}
Expand All @@ -45,6 +46,11 @@ func GetAttr(att []xmlquery.Attr, name string) string {
return ""
}

// 解析 nmap、masscan 输出的xml结果
// 解析的结果保存到 bf 中
// 解析的同时:
// 1、触发端口弱口令检测,如果当前任务不需要,则,弱口令检测的入口处拦截、过滤
// 2、端口 POC 检测,如果当前任务不需要,则,弱口令检测的入口处拦截、过滤
func DoParseXml(s string, bf *bytes.Buffer) {
doc, err := xmlquery.Parse(strings.NewReader(s))
if err != nil {
Expand Down Expand Up @@ -80,7 +86,7 @@ func DoParseXml(s string, bf *bytes.Buffer) {
// 存储结果到其他地方
//x9 := AuthInfo{IPAddr: ip, Port: port, Protocol: service}
// 构造发送es等数据
if enableEsSv {
if EnableEsSv {
var xx09 = [][]string{}
if a1, ok := m1[ip]; ok {
xx09 = a1
Expand All @@ -94,21 +100,21 @@ func DoParseXml(s string, bf *bytes.Buffer) {
bf.Write([]byte(szUlr + "\n"))
if os.Getenv("NoPOC") != "true" {
if "445" == szPort && service == "microsoft-ds" || "135" == szPort && service == "msrpc" {
util.PocCheck_pipe <- &util.PocCheck{
PocCheck_pipe <- &PocCheck{
Wappalyzertechnologies: &[]string{service},
URL: szUlr,
FinalURL: szUlr,
Checklog4j: false,
}
} else if "8291" == szPort { // CVE_2018_14847
util.PocCheck_pipe <- &util.PocCheck{
} else if "8291" == szPort { // RouterOS CVE_2018_14847
PocCheck_pipe <- &PocCheck{
Wappalyzertechnologies: &[]string{"RouterOS"},
URL: szUlr,
FinalURL: szUlr,
Checklog4j: false,
}
} else if "2181" == szPort {
util.PocCheck_pipe <- &util.PocCheck{
} else if "2181" == szPort { // Zookeeper Unauthority
PocCheck_pipe <- &PocCheck{
Wappalyzertechnologies: &[]string{"ZookeeperUnauthority"},
URL: szUlr,
FinalURL: szUlr,
Expand All @@ -120,7 +126,7 @@ func DoParseXml(s string, bf *bytes.Buffer) {
}
// 若密码、破解
if bCheckWeakPassword {
if "8728" == szPort && service == "unknown" {
if "8728" == szPort && service == "unknown" { // router
CheckWeakPassword(ip, "router", port)
} else if ("5985" == szPort || "5986" == szPort) && -1 < strings.Index(service, "microsoft ") {
CheckWeakPassword(ip, "winrm", port)
Expand All @@ -130,22 +136,22 @@ func DoParseXml(s string, bf *bytes.Buffer) {
}

s1 := fmt.Sprintf("%s\t%d\t%s\n", ip, port, service)
util.SendLog(ip, "nmap", s1, "")
SendLog(ip, "nmap", s1, "")
log.Printf("%s", s1)
}
}
}
if enableEsSv {
if EnableEsSv {
if 0 < len(m1) {
for k, x := range m1 {
util.SendAData[[]string](k, x, util.Nmap)
SendAData[[]string](k, x, Nmap)
}
}
}
}

// 处理使用者自己扫描的结果
// 不能用异步,否则后续流程无法读取 buff
// 不能用异步,否则后续流程无法读取 buff
func DoNmapWithFile(s string, bf *bytes.Buffer) bool {
if strings.HasSuffix(strings.ToLower(s), ".xml") {
b, err := ioutil.ReadFile(s)
Expand All @@ -154,15 +160,14 @@ func DoNmapWithFile(s string, bf *bytes.Buffer) bool {
} else {
log.Println("DoNmapWithFile: ", err)
}

return true
}
return false
}

// 处理 naabu 端口扫描环节的结果文件
func DoNmapRst(bf *bytes.Buffer) {
if x1, ok := util.TmpFile[string(util.Naabu)]; ok {
if x1, ok := TmpFile[string(Naabu)]; ok {
for _, x := range x1 {
defer func(r *os.File) {
r.Close()
Expand Down
Loading

0 comments on commit 4db39c4

Please sign in to comment.