Skip to content

Commit 1f9429a

Browse files
committed
1、优化 pop3、pop3s 密码破解算法,每个目标相同端口,多个密码破解复用一次网络链接,提高破解效率; 2、支持pop3s 995port破解 2022-09-27
1 parent dace9dd commit 1f9429a

File tree

9 files changed

+460
-466
lines changed

9 files changed

+460
-466
lines changed

config/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"snmp_user": "pkg/hydra/dicts/snmp_user.txt",
5959
"snmp_pswd": "pkg/hydra/dicts/snmp_pswd.txt",
6060
"snmp_default": "pkg/hydra/dicts/snmp_default.txt",
61+
"nmapScan": "echo 'Miracle!@#123'|sudo -S nmap ",
6162
"nmap": "nmap -n --unique --resolve-all -Pn --min-hostgroup 64 --max-retries 0 --host-timeout 10m --script-timeout 3m -oX {filename} --version-intensity 9 --min-rate 10000 -T4 ",
6263
"HydraUser": "",
6364
"HydraPass": "",

engine/engine.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"context"
55
"github.com/codegangsta/inject"
66
"github.com/hktalent/scan4all/lib/util"
7+
"github.com/hktalent/scan4all/pkg/portScan"
78
"github.com/hktalent/scan4all/pocs_go"
8-
"github.com/hktalent/scan4all/projectdiscovery/nuclei_Yaml/masscan"
99
"github.com/panjf2000/ants/v2"
1010
"log"
1111
"sync"
@@ -63,7 +63,9 @@ func (e *Engine) DoCase(ed *EventData) interface{} {
6363
if nil != ed {
6464
switch ed.EventType {
6565
case "masscan":
66-
return masscan.ScanTarget
66+
return portScan.ScanTarget
67+
case "nmap":
68+
return portScan.ScanTarget
6769
default:
6870
return nil
6971
}
@@ -128,6 +130,7 @@ func init() {
128130
}(x1)
129131
})
130132
default:
133+
util.DoDelayClear()
131134
//var f01 float32 = float32(nCnt) / float32(nMax) * float32(100)
132135
//fmt.Printf(" Asynchronous go PoCs detection task %%%0.2f ....\r", f01)
133136
//<-time.After(time.Duration(1) * time.Second)

lib/util/delayClear.go

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package util
2+
3+
import (
4+
"sync"
5+
"time"
6+
)
7+
8+
// 延时自动初对象
9+
type delayClearObj struct {
10+
GetCacheObj func() interface{} // 返回缓存对象
11+
FnCbk func() // 回调函数
12+
Time int64 // 开始及时的时间
13+
DelayCall int64 // 延时多少秒调用FnCbk
14+
}
15+
16+
// cache 延时sec
17+
//var nCacheTime = time.Second * 60
18+
19+
// 内存清理注册
20+
var delayClear sync.Map
21+
22+
// 注册延时清理
23+
//
24+
// n0 0表示60秒后执行
25+
func RegDelayCbk(szKey string, fnCbk func(), cache func() interface{}, n0 int64, DelayCall int64) {
26+
delayClear.Store(szKey, &delayClearObj{Time: time.Now().Unix() - n0, FnCbk: fnCbk, GetCacheObj: cache})
27+
}
28+
29+
// 重时间计数器
30+
func UpTime(szKey string) {
31+
if o, ok := delayClear.Load(szKey); ok {
32+
x1 := o.(*delayClearObj)
33+
x1.Time = time.Now().Unix()
34+
delayClear.Store(szKey, x1)
35+
}
36+
}
37+
38+
// 获取缓存对象
39+
func GetCache(szKey string, bUpTime bool) interface{} {
40+
if o, ok := delayClear.Load(szKey); ok {
41+
x1 := o.(*delayClearObj)
42+
if bUpTime {
43+
UpTime(szKey)
44+
}
45+
return x1.GetCacheObj()
46+
}
47+
return nil
48+
}
49+
50+
// 立刻执行
51+
func DoNow(szKey string) {
52+
if o, ok := delayClear.Load(szKey); ok {
53+
x1 := o.(*delayClearObj)
54+
x1.FnCbk()
55+
delayClear.Delete(szKey)
56+
}
57+
}
58+
59+
// 单实例运行
60+
var IsDo = make(chan struct{}, 1)
61+
62+
// 延时清理
63+
func DoDelayClear() {
64+
defer func() {
65+
<-IsDo
66+
}()
67+
nN := time.Now().Unix()
68+
delayClear.Range(func(key, value any) bool {
69+
if nil == value {
70+
delayClear.Delete(key)
71+
return true
72+
}
73+
x1 := value.(*delayClearObj)
74+
n09 := nN - x1.Time
75+
//log.Printf("n09 = %d, now = %d, x1.Time = %d", n09, nN, x1.Time)
76+
if n09 >= x1.DelayCall {
77+
x1.FnCbk()
78+
delayClear.Delete(key)
79+
//log.Println("nuclei is closed : ", key)
80+
}
81+
return true
82+
})
83+
return
84+
}

pkg/hydra/doNmapResult.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func DoParseXml(s string, bf *bytes.Buffer) {
9797
FinalURL: szUlr,
9898
Checklog4j: false,
9999
}
100-
} else if bCheckWeakPassword && "110" == szPort && service == "pop3" {
100+
} else if bCheckWeakPassword && ("110" == szPort || "995" == szPort) && service == "pop3" {
101101
CheckWeakPassword(ip, service, port)
102102
} else if "2181" == szPort {
103103
util.PocCheck_pipe <- &util.PocCheck{

0 commit comments

Comments
 (0)