1
0
mirror of https://github.com/sairson/Yasso.git synced 2026-06-16 07:07:55 +08:00

Add files via upload

This commit is contained in:
SaiRson
2022-01-09 10:53:47 +08:00
committed by GitHub
parent bbcc45a2c1
commit 5097db4a8e
6 changed files with 59 additions and 67 deletions

View File

@@ -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 ")
@@ -57,8 +58,9 @@ 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 -----")
@@ -122,4 +124,5 @@ func allRun(hostString string, portString string, log bool, runtime int, noping
fmt.Println("----- [Yasso] Start do web service scan -----")
DisMapScan(alive, webports)
}
fmt.Println("[Yasso] scan task is completed")
}

View File

@@ -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
}

View File

@@ -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

View File

@@ -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

View File

@@ -48,31 +48,27 @@ func init() {
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()
}

View File

@@ -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