diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..ffa64bd --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Plugins/smb.go b/Plugins/smb.go index 4aca6cf..0bc1e5b 100644 --- a/Plugins/smb.go +++ b/Plugins/smb.go @@ -34,7 +34,7 @@ func SmblConn(info *common.HostInfo,user string,pass string)(flag bool,err error Host,Port,Username,Password := info.Host, common.PORTList["smb"],user, pass options := smb.Options{ Host: Host, - Port: Port, + Port: 445, User: Username, Password: Password, Domain: "", diff --git a/README.md b/README.md index 81e3632..b1e9fc0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # fscan - +# 简介 一款内网扫描工具,方便一键大保健。 支持主机存活探测、端口扫描、常见服务的爆破、ms17010、redis批量写私钥、计划任务反弹shell、读取win网卡信息等。 趁着最近有空,用go把f-scrack重构了一遍。使用go来编写,也有更好的扩展性及兼容性。 @@ -8,55 +8,59 @@ ## why +为什么有LadonGo、x-crack 、tscan、Gscan 这些工具了还要写fscan +答: + 因为用习惯了f-scrack,习惯一条命令跑完所有模块,省去一个个模块单独调用的时间,当然我附加了-m 指定模块的功能。 ## usege 简单用法 ``` go run main.go -h 192.168.1.1/24 -fscan.exe -h 192.168.1.1/24 +fscan.exe -h 192.168.1.1/24 (默认使用全部模块) fscan.exe -h 192.168.1.1/24 -rf id_rsa.pub (redis 写私钥) fscan.exe -h 192.168.1.1/24 -rs 192.168.1.1:6666 (redis 计划任务反弹shell) fscan.exe -h 192.168.1.1/24 -c whoami (ssh 爆破成功后,命令执行) fscan.exe -h 192.168.1.1/24 -m ssh -p 2222 (指定模块ssh和端口) +fscan.exe -h 192.168.1.1/24 -m ms17010 (指定模块) ``` 完整参数 ``` -Usage of C:\Users\shadow1ng\AppData\Local\Temp\___go_build_main_go__1_.exe: -c string - exec command (ssh) + exec command (ssh) -h string - IP address of the host you want to scan,for example: 192.168.11.11 | 192.168.11.11-255 | 192.168.11.11,192.168.11.12 + IP address of the host you want to scan,for example: 192.168.11.11 | 192.168.11.11-255 | 192.168.11.11,192.168.11.12 -m string - Select scan type ,as: -m ssh (default "all") + Select scan type ,as: -m ssh (default "all") -no - not to save output log + not to save output log -np - not to ping + not to ping -o string - Outputfile (default "result.txt") + Outputfile (default "result.txt") -p string - Select a port,for example: 22 | 1-65535 | 22,80,3306 (default "21,22,23,80,135,443,445,1433,1521,3306,5432,6379,7001,8080,8089,9000,9200,11211,27017") + Select a port,for example: 22 | 1-65535 | 22,80,3306 (default "21,22,23,80,135,443,445,1433,1521,3306,5432,6379,7001,8080,8089,9000,9200,11211,27017") -pwd string - password + password -pwdf string - password file + password file -rf string - redis file to write sshkey file (as: -rf id_rsa.pub) + redis file to write sshkey file (as: -rf id_rsa.pub) -rs string - redis shell to write cron file (as: -rs 127.0.0.1:4444) + redis shell to write cron file (as: -rs 192.168.1.1:6666) -t int - Thread nums (default 100) + Thread nums (default 100) -time int - Set timeout (default 3) + Set timeout (default 3) -user string - username + username -userf string - username file + username file ``` + `fscan.exe -h 192.168.x.x` ![](image/1.png) diff --git a/common/Parse.go b/common/Parse.go index 5db0504..81f5801 100644 --- a/common/Parse.go +++ b/common/Parse.go @@ -5,6 +5,7 @@ import ( "flag" "fmt" "os" + "strconv" "strings" ) @@ -114,4 +115,12 @@ func ParseScantype(Info *HostInfo){ } os.Exit(0) } + if Info.Scantype != "all" && Info.Ports != DefaultPorts{ + ScanPort := ParsePort(Info.Ports)[0] + Info.Ports = strconv.Itoa(ScanPort) + fmt.Println("if -m and -p only scan the first port:",Info.Ports) + for name,_:=range PORTList{ + PORTList[name] = ScanPort + } + } } \ No newline at end of file diff --git a/common/ParsePort.go b/common/ParsePort.go index a35fb62..59e76ee 100644 --- a/common/ParsePort.go +++ b/common/ParsePort.go @@ -1,60 +1,31 @@ package common -// -//import ( -// "errors" -// "strconv" -// "strings" -//) -// -//var ParsePortErr error =errors.New("Port parsing error") -// -//func ParsePort(port string)([]int,error){ -// RealPort,err:=strconv.Atoi(port) -// switch { -// case err==nil && CheckPort(RealPort): -// return []int{RealPort},nil -// case strings.Contains(port,","): -// return ParsePortB(port) -// case strings.Count(port,"-")==1: -// return ParsePortC(port) -// default: -// return nil,ParsePortErr -// } -//} -// -////Parsing multiple ports, for example: 22,80,3306 -//func ParsePortB(port string)([]int ,error){ -// var AllPort []int -// port1:=strings.Split(port,",") -// for _,p:=range port1{ -// RealPort,err:=strconv.Atoi(p) -// if !CheckPort(RealPort) && err!=nil{ -// return nil,ParsePortErr -// } -// AllPort=append(AllPort,RealPort) -// } -// return AllPort,nil -//} -// -////Parsing a range of port,for example: 22-3306 -//func ParsePortC(port string)([]int ,error){ -// var AllPort []int -// RangePort:=strings.Split(port,"-") -// port1,err1:=strconv.Atoi(RangePort[0]) -// port2,err2:=strconv.Atoi(RangePort[1]) -// if port1>port2 || err1!=nil || err2!=nil || !CheckPort(port1) || !CheckPort(port2){ -// return nil,ParsePortErr -// } -// for i:=port1;i<=port2;i++{ -// AllPort=append(AllPort,i) -// } -// return AllPort,nil -//} -// -// -//func CheckPort(port int)bool{ -// if port<=0 || port >65535{ -// return false -// } -// return true -//} \ No newline at end of file + +import ( + "sort" + "strconv" + "strings" +) + +func ParsePort(ports string) []int { + var scanPorts []int + slices := strings.Split(ports, ",") + for _, port := range slices { + port = strings.Trim(port, " ") + upper := port + if strings.Contains(port, "-") { + ranges := strings.Split(port, "-") + if len(ranges) < 2 { + continue + } + sort.Strings(ranges) + port = ranges[0] + upper = ranges[1] + } + start, _ := strconv.Atoi(port) + end, _ := strconv.Atoi(upper) + for i := start; i <= end; i++ { + scanPorts = append(scanPorts, i) + } + } + return scanPorts +} \ No newline at end of file diff --git a/common/config.go b/common/config.go index fbd8d85..1883250 100644 --- a/common/config.go +++ b/common/config.go @@ -34,6 +34,7 @@ var PORTList = map[string]int{ var Outputfile = "result.txt" var IsSave = true +var DefaultPorts = "21,22,23,80,135,443,445,1433,1521,3306,5432,6379,7001,8080,8089,9000,9200,11211,27017" type HostInfo struct { diff --git a/common/flag.go b/common/flag.go index eae6bdf..b227e03 100644 --- a/common/flag.go +++ b/common/flag.go @@ -21,9 +21,8 @@ func Banner(){ func Flag(Info *HostInfo) { Banner() - Ports := "21,22,23,80,135,443,445,1433,1521,3306,5432,6379,7001,8080,8089,9000,9200,11211,27017" flag.StringVar(&Info.Host,"h","","IP address of the host you want to scan,for example: 192.168.11.11 | 192.168.11.11-255 | 192.168.11.11,192.168.11.12") - flag.StringVar(&Info.Ports,"p",Ports,"Select a port,for example: 22 | 1-65535 | 22,80,3306") + flag.StringVar(&Info.Ports,"p",DefaultPorts,"Select a port,for example: 22 | 1-65535 | 22,80,3306") flag.StringVar(&Info.Command,"c","","exec command (ssh)") flag.IntVar(&Info.Threads,"t",100,"Thread nums") flag.BoolVar(&Info.Isping,"np",false,"not to ping") @@ -36,6 +35,6 @@ func Flag(Info *HostInfo) { flag.Int64Var(&Info.Timeout,"time",3,"Set timeout") flag.StringVar(&Info.Scantype,"m","all","Select scan type ,as: -m ssh") flag.StringVar(&Info.RedisFile,"rf","","redis file to write sshkey file (as: -rf id_rsa.pub) ") - flag.StringVar(&Info.RedisFile,"rs","","redis shell to write cron file (as: -rs 127.0.0.1:4444) ") + flag.StringVar(&Info.RedisFile,"rs","","redis shell to write cron file (as: -rs 192.168.1.1:6666) ") flag.Parse() } \ No newline at end of file diff --git a/fscan.exe b/fscan.exe new file mode 100644 index 0000000..1f89240 Binary files /dev/null and b/fscan.exe differ diff --git a/image/Snipaste_2020-11-13_22-51-04.png b/image/Snipaste_2020-11-13_22-51-04.png deleted file mode 100644 index 496459c..0000000 Binary files a/image/Snipaste_2020-11-13_22-51-04.png and /dev/null differ diff --git a/result.txt b/result.txt new file mode 100644 index 0000000..a40566e --- /dev/null +++ b/result.txt @@ -0,0 +1,4 @@ +127.0.0.1:445 open +127.0.0.1:445 open +127.0.0.1:445 open +127.0.0.1:445 open