forked from k8gege/LadonGo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmb.go
73 lines (66 loc) · 1.5 KB
/
smb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package smb
//Ladon Scanner for golang
//Author: k8gege
//K8Blog: http://k8gege.org/Ladon
//Github: https://github.com/k8gege/LadonGo
import (
"github.com/stacktitan/smb/smb"
"github.com/k8gege/LadonGo/port"
"github.com/k8gege/LadonGo/dic"
"github.com/k8gege/LadonGo/logger"
"fmt"
"strings"
)
//Not Support 2003
func SmbAuth(ip string, port string, username string, password string) ( result bool,err error) {
result = false
options := smb.Options{
Host: ip,
Port: 445,
User: username,
Password: password,
Domain: "",
Workstation: "",
}
session, err := smb.NewSession(options, false)
if err == nil {
session.Close()
if session.IsAuthenticated {
result = true
}
}
return result,err
}
func SmbScan2(ScanType string,Target string) {
Loop:
for _, u := range dic.UserDic() {
for _, p := range dic.PassDic() {
fmt.Println("Check... "+Target+" "+u+" "+p)
res,err := SmbAuth(Target, "445", u, p)
if res==true && err==nil {
logger.PrintIsok(ScanType,Target,u, p)
break Loop
}
}
}
}
func SmbScan(ScanType string,Target string) {
if port.PortCheck(Target,445) {
if dic.UserPassIsExist() {
Loop:
for _, up := range dic.UserPassDic() {
s :=strings.Split(up, " ")
u := s[0]
p := s[1]
fmt.Println("Check... "+Target+" "+u+" "+p)
res,err := SmbAuth(Target, "445", u, p)
if res==true && err==nil {
logger.PrintIsok(ScanType,Target,u, p)
break Loop
}
}
} else {
SmbScan2(ScanType,Target)
}
}
}