mirror of
https://github.com/sairson/Yasso.git
synced 2026-11-03 22:24:18 +08:00
Compare commits
10 Commits
v0.0.3-mai
...
v0.0.4-mai
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6465c4f5bd | ||
|
|
9ef5cac578 | ||
|
|
db63f152dd | ||
|
|
f5a4c5dd92 | ||
|
|
d7556c9f77 | ||
|
|
6d71582279 | ||
|
|
6bd260e56d | ||
|
|
5097db4a8e | ||
|
|
2a57e57cbb | ||
|
|
3ae05c363f |
11
cmd/all.go
11
cmd/all.go
@@ -25,7 +25,8 @@ var allCmd = &cobra.Command{
|
||||
func init() {
|
||||
allCmd.Flags().StringVarP(&Hosts, "host", "H", "", "Set `hosts`(The format is similar to Nmap) or ips.txt file path")
|
||||
allCmd.Flags().StringVarP(&Ports, "ports", "P", "", "Set `ports`(The format is similar to Nmap)")
|
||||
allCmd.Flags().BoolVar(&PingBool, "noping", true, "No use ping to scanner alive host")
|
||||
allCmd.Flags().BoolVar(&PingBool, "noping", false, "No use ping to scanner alive host")
|
||||
allCmd.Flags().BoolVar(&RunICMP, "icmp", false, "Use icmp to scanner alive host")
|
||||
allCmd.Flags().IntVar(&Runtime, "runtime", 100, "Set scanner ants pool thread")
|
||||
allCmd.Flags().StringVar(&ProxyHost, "proxy", "", "Set socks5 proxy")
|
||||
allCmd.Flags().DurationVar(&TimeDuration, "time", 1*time.Second, "Set timeout ")
|
||||
@@ -33,6 +34,9 @@ func init() {
|
||||
}
|
||||
|
||||
func allRun(hostString string, portString string, log bool, runtime int, noping bool) {
|
||||
defer func() {
|
||||
fmt.Println("[Yasso] scan task is completed")
|
||||
}()
|
||||
var (
|
||||
ips []string
|
||||
ports []int
|
||||
@@ -57,12 +61,13 @@ func allRun(hostString string, portString string, log bool, runtime int, noping
|
||||
} else {
|
||||
// 执行 ping 操作
|
||||
fmt.Println("----- [Yasso] Start do ping scan -----")
|
||||
alive = execute(ips)
|
||||
alive = execute(ips, RunICMP)
|
||||
}
|
||||
fmt.Println("[Yasoo get alive host] is", len(alive))
|
||||
// 做漏洞扫描
|
||||
if len(alive) > 0 {
|
||||
fmt.Println("----- [Yasso] Start do vuln scan -----")
|
||||
VulScan(alive, false, true, false) // 做全扫描
|
||||
VulScan(alive, false, true, false) // 做漏洞扫描
|
||||
if len(alive) != 0 {
|
||||
fmt.Println("----- [Yasso] Start do port scan -----")
|
||||
}
|
||||
|
||||
@@ -33,8 +33,9 @@ var DisMapCmd = &cobra.Command{
|
||||
var ports []int
|
||||
hosts, _ := ResolveIPS(Hosts)
|
||||
var runhosts []string
|
||||
|
||||
if PingBool == true {
|
||||
runhosts = execute(hosts)
|
||||
runhosts = execute(hosts, false)
|
||||
} else {
|
||||
runhosts = hosts
|
||||
}
|
||||
|
||||
52
cmd/icmp.go
52
cmd/icmp.go
@@ -14,9 +14,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
tunnel = make(chan string, 20)
|
||||
OS = runtime.GOOS
|
||||
Alive []string // 存活的ip列表
|
||||
OS = runtime.GOOS // 系统架构
|
||||
Alive []string // 存活的ip列表
|
||||
)
|
||||
var pingCmd = &cobra.Command{
|
||||
Use: "ping",
|
||||
@@ -34,7 +33,7 @@ var pingCmd = &cobra.Command{
|
||||
return
|
||||
}
|
||||
Println(fmt.Sprintf("[Yasso] will ping %d host", len(ips)))
|
||||
_ = execute(ips)
|
||||
_ = execute(ips, RunICMP)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -44,31 +43,26 @@ func init() {
|
||||
rootCmd.AddCommand(pingCmd)
|
||||
}
|
||||
|
||||
func execute(ips []string) []string {
|
||||
func execute(ips []string, r bool) []string {
|
||||
var wg sync.WaitGroup
|
||||
|
||||
go func() {
|
||||
for _, ip := range ips {
|
||||
tunnel <- ip
|
||||
}
|
||||
}()
|
||||
for i := 0; i < len(ips); i++ {
|
||||
wg.Add(1)
|
||||
_ = ants.Submit(func() {
|
||||
ip := <-tunnel
|
||||
if RunICMP == true {
|
||||
if icmp(ip) {
|
||||
Println(fmt.Sprintf("[+] Find %v (icmp)", ip))
|
||||
Alive = append(Alive, ip)
|
||||
}
|
||||
} else {
|
||||
if ping(ip) {
|
||||
Println(fmt.Sprintf("[+] Find %v (ping)", ip))
|
||||
Alive = append(Alive, ip)
|
||||
}
|
||||
// 修改ants池的并发方式
|
||||
p, _ := ants.NewPoolWithFunc(len(ips), func(ip interface{}) {
|
||||
if r == true {
|
||||
if icmp(ip.(string)) {
|
||||
Println(fmt.Sprintf("[+] Find %v (icmp)", ip))
|
||||
Alive = append(Alive, ip.(string))
|
||||
}
|
||||
wg.Done()
|
||||
})
|
||||
} else {
|
||||
if ping(ip.(string)) {
|
||||
Println(fmt.Sprintf("[+] Find %v (ping)", ip))
|
||||
Alive = append(Alive, ip.(string))
|
||||
}
|
||||
}
|
||||
wg.Done()
|
||||
})
|
||||
for _, ip := range ips {
|
||||
wg.Add(1)
|
||||
_ = p.Invoke(ip)
|
||||
}
|
||||
wg.Wait()
|
||||
return Alive
|
||||
@@ -82,7 +76,9 @@ func ping(ip string) bool {
|
||||
case "linux":
|
||||
cmd = exec.Command("/bin/bash", "-c", "ping -c 1 -w 1 "+ip+" >/dev/null && echo true || echo false")
|
||||
case "darwin":
|
||||
cmd = exec.Command("/bin/bash", "-c", "ping -c 1 -w 1 "+ip+" >/dev/null && echo true || echo false")
|
||||
cmd = exec.Command("/bin/bash", "-c", "ping -c 1 "+ip+" >/dev/null && echo true || echo false")
|
||||
default:
|
||||
cmd = exec.Command("/bin/bash", "-c", "ping -c 1"+ip+" >/dev/null && echo true || echo false")
|
||||
}
|
||||
info := bytes.Buffer{}
|
||||
cmd.Stdout = &info
|
||||
|
||||
@@ -15,7 +15,7 @@ func Println(s string) {
|
||||
fmt.Println("[!] open log file failed", err)
|
||||
return
|
||||
}
|
||||
file.WriteString("\n" + s)
|
||||
_, _ = file.WriteString("\n" + s)
|
||||
}
|
||||
|
||||
func CreateLogFile(filename string) {
|
||||
|
||||
18
cmd/ps.go
18
cmd/ps.go
@@ -61,23 +61,21 @@ func init() {
|
||||
func PortScan(host []string, ports []int) []PortResult {
|
||||
var tempPort []PortResult
|
||||
var wg sync.WaitGroup
|
||||
go func() {
|
||||
for _, ip := range host {
|
||||
tunnel <- ip
|
||||
}
|
||||
}()
|
||||
for i := 0; i < len(host); i++ {
|
||||
wg.Add(1)
|
||||
|
||||
p, _ := ants.NewPoolWithFunc(len(host), func(ip interface{}) {
|
||||
_ = ants.Submit(func() {
|
||||
ip := <-tunnel
|
||||
aport := EachScan(ip, ports)
|
||||
aport := EachScan(ip.(string), ports)
|
||||
//Println()(aport)
|
||||
if len(aport) != 0 {
|
||||
// 扫描完成,加入扫描结果队列
|
||||
tempPort = append(tempPort, PortResult{ip, aport})
|
||||
tempPort = append(tempPort, PortResult{ip.(string), aport})
|
||||
} // 将ip赋值给AlivePort*/
|
||||
wg.Done()
|
||||
})
|
||||
})
|
||||
for _, ip := range host {
|
||||
wg.Add(1)
|
||||
_ = p.Invoke(ip)
|
||||
}
|
||||
wg.Wait()
|
||||
return tempPort
|
||||
|
||||
46
cmd/vuln.go
46
cmd/vuln.go
@@ -24,7 +24,7 @@ var VulCmd = &cobra.Command{
|
||||
return
|
||||
}
|
||||
if Hosts != "" {
|
||||
ips, _ = ResolveIPS(Hosts) // resolve ip to []string ips
|
||||
ips, _ = ResolveIPS(Hosts)
|
||||
} else {
|
||||
Println("Yasso scanner need a hosts")
|
||||
return
|
||||
@@ -41,38 +41,34 @@ func init() {
|
||||
VulCmd.Flags().StringVar(&ProxyHost, "proxy", "", "Set socks5 proxy")
|
||||
VulCmd.Flags().BoolVar(&smbGohstbool, "gs", false, "scan smbghost")
|
||||
VulCmd.Flags().BoolVar(&ms17010bool, "ms", false, "scan ms17010")
|
||||
VulCmd.Flags().BoolVar(&allbool, "all", false, "scan all vuln contains ms17010,smbghost")
|
||||
VulCmd.Flags().BoolVar(&allbool, "all", true, "scan all vuln contains ms17010,smbghost")
|
||||
rootCmd.AddCommand(VulCmd)
|
||||
}
|
||||
|
||||
func VulScan(ips []string, ms17010bool bool, allbool bool, smbGohstbool bool) {
|
||||
var wg sync.WaitGroup
|
||||
|
||||
go func() {
|
||||
for _, ip := range ips {
|
||||
tunnel <- ip
|
||||
p, _ := ants.NewPoolWithFunc(len(ips), func(ip interface{}) {
|
||||
if ms17010bool == true || allbool == true {
|
||||
Ms17010Conn(config.HostIn{
|
||||
Host: ip.(string),
|
||||
Port: 445,
|
||||
TimeOut: TimeDuration,
|
||||
})
|
||||
}
|
||||
}()
|
||||
for i := 0; i < len(ips); i++ {
|
||||
if smbGohstbool == true || allbool == true {
|
||||
SmbGhostConn(config.HostIn{
|
||||
Host: ip.(string),
|
||||
Port: 445,
|
||||
TimeOut: TimeDuration,
|
||||
})
|
||||
}
|
||||
wg.Done()
|
||||
})
|
||||
|
||||
for _, ip := range ips {
|
||||
wg.Add(1)
|
||||
_ = ants.Submit(func() {
|
||||
ip := <-tunnel
|
||||
if ms17010bool == true || allbool == true {
|
||||
Ms17010Conn(config.HostIn{
|
||||
Host: ip,
|
||||
Port: 445,
|
||||
TimeOut: TimeDuration,
|
||||
})
|
||||
}
|
||||
if smbGohstbool == true || allbool == true {
|
||||
SmbGhostConn(config.HostIn{
|
||||
Host: ip,
|
||||
Port: 445,
|
||||
TimeOut: TimeDuration,
|
||||
})
|
||||
}
|
||||
wg.Done()
|
||||
})
|
||||
_ = p.Invoke(ip)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
8
ips.txt
8
ips.txt
@@ -1,4 +1,4 @@
|
||||
192.168.248.1
|
||||
192.168.248.219
|
||||
192.168.248.212
|
||||
192.168.248.128
|
||||
192.168.248.1
|
||||
192.168.248.219
|
||||
192.168.248.212
|
||||
192.168.248.128
|
||||
|
||||
Reference in New Issue
Block a user