Skip to content

Commit 3e8f234

Browse files
committed
加入hash碰撞、wmiiexec无回显命令执行
1 parent 4908720 commit 3e8f234

File tree

17 files changed

+738
-228
lines changed

17 files changed

+738
-228
lines changed

Plugins/NetBIOS.go

Lines changed: 261 additions & 175 deletions
Large diffs are not rendered by default.

Plugins/base.go

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,44 @@
11
package Plugins
22

3+
import "net"
4+
35
var PluginList = map[string]interface{}{
4-
"21": FtpScan,
5-
"22": SshScan,
6-
"135": Findnet,
7-
"139": NetBIOS,
8-
"445": SmbScan,
9-
"1433": MssqlScan,
10-
"1521": OracleScan,
11-
"3306": MysqlScan,
12-
"3389": RdpScan,
13-
"5432": PostgresScan,
14-
"6379": RedisScan,
15-
"9000": FcgiScan,
16-
"11211": MemcachedScan,
17-
"27017": MongodbScan,
18-
"1000001": MS17010,
19-
"1000002": SmbGhost,
20-
"1000003": WebTitle,
21-
"10000031": WebTitle,
6+
"21": FtpScan,
7+
"22": SshScan,
8+
"135": Findnet,
9+
"139": NetBIOS,
10+
"445": SmbScan,
11+
"1433": MssqlScan,
12+
"1521": OracleScan,
13+
"3306": MysqlScan,
14+
"3389": RdpScan,
15+
"5432": PostgresScan,
16+
"6379": RedisScan,
17+
"9000": FcgiScan,
18+
"11211": MemcachedScan,
19+
"27017": MongodbScan,
20+
"1000001": MS17010,
21+
"1000002": SmbGhost,
22+
"1000003": WebTitle,
23+
"1000004": SmbScan2,
24+
"1000005": WmiExec,
25+
}
26+
27+
func ReadBytes(conn net.Conn) (result []byte, err error) {
28+
size := 4096
29+
buf := make([]byte, size)
30+
for {
31+
count, err := conn.Read(buf)
32+
if err != nil {
33+
break
34+
}
35+
result = append(result, buf[0:count]...)
36+
if count < size {
37+
break
38+
}
39+
}
40+
if len(result) > 0 {
41+
err = nil
42+
}
43+
return result, err
2244
}

Plugins/findnet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func read(text []byte, host string) error {
7070
encodedStr := hex.EncodeToString(text)
7171
hostnames := strings.Replace(encodedStr, "0700", "", -1)
7272
hostname := strings.Split(hostnames, "000000")
73-
result := "[+] NetInfo:\n[*]" + host
73+
result := "[*] NetInfo:\n[*]" + host
7474
for i := 0; i < len(hostname); i++ {
7575
hostname[i] = strings.Replace(hostname[i], "00", "", -1)
7676
host, err := hex.DecodeString(hostname[i])

Plugins/scanner.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ func Scan(info common.HostInfo) {
3333
}
3434
common.GC()
3535
var AlivePorts []string
36-
if common.Scantype == "webonly" {
36+
if common.Scantype == "webonly" || common.Scantype == "webpoc" {
37+
AlivePorts = NoPortScan(Hosts, info.Ports)
38+
} else if common.Scantype == "hostname" {
39+
info.Ports = "139"
3740
AlivePorts = NoPortScan(Hosts, info.Ports)
3841
} else if len(Hosts) > 0 {
3942
AlivePorts = PortScan(Hosts, info.Ports, common.Timeout)
@@ -59,6 +62,11 @@ func Scan(info common.HostInfo) {
5962
info.Host, info.Ports = strings.Split(targetIP, ":")[0], strings.Split(targetIP, ":")[1]
6063
if common.Scantype == "all" || common.Scantype == "main" {
6164
switch {
65+
case info.Ports == "135":
66+
AddScan(info.Ports, info, &ch, &wg) //findnet
67+
if common.IsWmi {
68+
AddScan("1000005", info, &ch, &wg) //wmiexec
69+
}
6270
case info.Ports == "445":
6371
AddScan(ms17010, info, &ch, &wg) //ms17010
6472
//AddScan(info.Ports, info, ch, &wg) //smb

Plugins/smb2.go

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
package Plugins
2+
3+
import (
4+
"fmt"
5+
"github.com/shadow1ng/fscan/common"
6+
"net"
7+
"os"
8+
"strings"
9+
"time"
10+
11+
"github.com/hirochachacha/go-smb2"
12+
)
13+
14+
func SmbScan2(info *common.HostInfo) (tmperr error) {
15+
if common.IsBrute {
16+
return nil
17+
}
18+
hasprint := false
19+
starttime := time.Now().Unix()
20+
hash := common.HashBytes
21+
for _, user := range common.Userdict["smb"] {
22+
PASS:
23+
for _, pass := range common.Passwords {
24+
pass = strings.Replace(pass, "{user}", user, -1)
25+
flag, err, flag2 := Smb2Con(info, user, pass, hash, hasprint)
26+
if flag2 {
27+
hasprint = true
28+
}
29+
if flag == true {
30+
var result string
31+
if common.Domain != "" {
32+
result = fmt.Sprintf("[+] SMB2:%v:%v:%v\\%v ", info.Host, info.Ports, common.Domain, user)
33+
} else {
34+
result = fmt.Sprintf("[+] SMB2:%v:%v:%v ", info.Host, info.Ports, user)
35+
}
36+
if len(hash) > 0 {
37+
result += "hash: " + common.Hash
38+
} else {
39+
result += pass
40+
}
41+
common.LogSuccess(result)
42+
return err
43+
} else {
44+
var errlog string
45+
if len(common.Hash) > 0 {
46+
errlog = fmt.Sprintf("[-] smb2 %v:%v %v %v %v", info.Host, 445, user, common.Hash, err)
47+
} else {
48+
errlog = fmt.Sprintf("[-] smb2 %v:%v %v %v %v", info.Host, 445, user, pass, err)
49+
}
50+
errlog = strings.Replace(errlog, "\n", " ", -1)
51+
common.LogError(errlog)
52+
tmperr = err
53+
if common.CheckErrs(err) {
54+
return err
55+
}
56+
if time.Now().Unix()-starttime > (int64(len(common.Userdict["smb"])*len(common.Passwords)) * common.Timeout) {
57+
return err
58+
}
59+
}
60+
if len(common.Hash) > 0 {
61+
break PASS
62+
}
63+
}
64+
}
65+
return tmperr
66+
}
67+
68+
func Smb2Con(info *common.HostInfo, user string, pass string, hash []byte, hasprint bool) (flag bool, err error, flag2 bool) {
69+
conn, err := net.DialTimeout("tcp", info.Host+":445", time.Duration(common.Timeout)*time.Second)
70+
defer func() {
71+
if conn != nil {
72+
conn.Close()
73+
}
74+
}()
75+
if err != nil {
76+
return
77+
}
78+
initiator := smb2.NTLMInitiator{
79+
User: user,
80+
Domain: common.Domain,
81+
}
82+
if len(hash) > 0 {
83+
initiator.Hash = hash
84+
} else {
85+
initiator.Password = pass
86+
}
87+
d := &smb2.Dialer{
88+
Initiator: &initiator,
89+
}
90+
91+
s, err := d.Dial(conn)
92+
if err != nil {
93+
return
94+
}
95+
defer s.Logoff()
96+
names, err := s.ListSharenames()
97+
if err != nil {
98+
return
99+
}
100+
if !hasprint {
101+
var result string
102+
if common.Domain != "" {
103+
result = fmt.Sprintf("[*] SMB2-shares:%v:%v:%v\\%v ", info.Host, info.Ports, common.Domain, user)
104+
} else {
105+
result = fmt.Sprintf("[*] SMB2-shares:%v:%v:%v ", info.Host, info.Ports, user)
106+
}
107+
if len(hash) > 0 {
108+
result += "hash: " + common.Hash
109+
} else {
110+
result += pass
111+
}
112+
result = fmt.Sprintf("%v shares: %v", result, names)
113+
common.LogSuccess(result)
114+
flag2 = true
115+
}
116+
fs, err := s.Mount("C$")
117+
if err != nil {
118+
return
119+
}
120+
defer fs.Umount()
121+
path := `Windows\win.ini`
122+
f, err := fs.OpenFile(path, os.O_RDONLY, 0666)
123+
if err != nil {
124+
return
125+
}
126+
defer f.Close()
127+
flag = true
128+
return
129+
//bs, err := ioutil.ReadAll(f)
130+
//if err != nil {
131+
// return
132+
//}
133+
//fmt.Println(string(bs))
134+
//return
135+
136+
}
137+
138+
//if info.Path == ""{
139+
//}
140+
//path = info.Path
141+
//f, err := fs.OpenFile(path, os.O_RDONLY, 0666)
142+
//if err != nil {
143+
// return
144+
//}
145+
//flag = true
146+
//_, err = f.Seek(0, io.SeekStart)
147+
//if err != nil {
148+
// return
149+
//}
150+
//bs, err := ioutil.ReadAll(f)
151+
//if err != nil {
152+
// return
153+
//}
154+
//fmt.Println(string(bs))
155+
//return
156+
//f, err := fs.Create(`Users\Public\Videos\hello.txt`)
157+
//if err != nil {
158+
// return
159+
//}
160+
//flag = true
161+
//
162+
//_, err = f.Write([]byte("Hello world!"))
163+
//if err != nil {
164+
// return
165+
//}
166+
//
167+
//_, err = f.Seek(0, io.SeekStart)
168+
//if err != nil {
169+
// return
170+
//}
171+
//bs, err := ioutil.ReadAll(f)
172+
//if err != nil {
173+
// return
174+
//}
175+
//fmt.Println(string(bs))
176+
//return

Plugins/webtitle.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ import (
1919
)
2020

2121
func WebTitle(info *common.HostInfo) error {
22+
if common.Scantype == "webpoc" {
23+
WebScan.WebScan(info)
24+
return nil
25+
}
2226
err, CheckData := GOWebTitle(info)
2327
info.Infostr = WebScan.InfoCheck(info.Url, &CheckData)
28+
2429
if common.IsWebCan == false && err == nil {
2530
WebScan.WebScan(info)
2631
} else {
@@ -102,10 +107,12 @@ func geturl(info *common.HostInfo, flag int, CheckData []WebScan.CheckDatas) (er
102107
if err != nil {
103108
return err, "", CheckData
104109
}
105-
req.Header.Set("User-agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36")
106-
req.Header.Set("Accept", "*/*")
110+
req.Header.Set("User-agent", common.UserAgent)
111+
req.Header.Set("Accept", common.Accept)
107112
req.Header.Set("Accept-Language", "zh-CN,zh;q=0.9")
108-
req.Header.Set("Cookie", common.Cookie)
113+
if common.Cookie != "" {
114+
req.Header.Set("Cookie", common.Cookie)
115+
}
109116
//if common.Pocinfo.Cookie != "" {
110117
// req.Header.Set("Cookie", "rememberMe=1;"+common.Pocinfo.Cookie)
111118
//} else {

0 commit comments

Comments
 (0)