mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-24 20:21:52 +08:00
refactor: 重构涉及文件更新
This commit is contained in:
+65
-39
@@ -5,13 +5,14 @@ import (
|
||||
"encoding/hex"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/shadow1ng/fscan/Config"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Parse(Info *HostInfo) {
|
||||
func Parse(Info *Config.HostInfo) {
|
||||
ParseUser()
|
||||
ParsePass(Info)
|
||||
ParseInput(Info)
|
||||
@@ -44,7 +45,7 @@ func ParseUser() {
|
||||
}
|
||||
}
|
||||
|
||||
func ParsePass(Info *HostInfo) {
|
||||
func ParsePass(Info *Config.HostInfo) {
|
||||
var PwdList []string
|
||||
if Password != "" {
|
||||
passs := strings.Split(Password, ",")
|
||||
@@ -140,7 +141,7 @@ func Readfile(filename string) ([]string, error) {
|
||||
return content, nil
|
||||
}
|
||||
|
||||
func ParseInput(Info *HostInfo) {
|
||||
func ParseInput(Info *Config.HostInfo) {
|
||||
if Info.Host == "" && HostFile == "" && URL == "" && UrlFile == "" {
|
||||
fmt.Println("Host is none")
|
||||
flag.Usage()
|
||||
@@ -235,49 +236,74 @@ func ParseInput(Info *HostInfo) {
|
||||
Hashs = []string{}
|
||||
}
|
||||
|
||||
func ParseScantype(Info *HostInfo) {
|
||||
if _, validType := PORTList[Scantype]; !validType {
|
||||
showmode()
|
||||
return
|
||||
// ParseScantype 解析扫描类型并设置对应的端口
|
||||
func ParseScantype(Info *Config.HostInfo) error {
|
||||
// 先处理特殊扫描类型
|
||||
specialTypes := map[string]string{
|
||||
"hostname": "135,137,139,445",
|
||||
"webonly": Webport,
|
||||
"webpoc": Webport,
|
||||
"web": Webport,
|
||||
"portscan": DefaultPorts + "," + Webport,
|
||||
"main": DefaultPorts,
|
||||
"all": DefaultPorts + "," + Webport,
|
||||
"icmp": "", // ICMP不需要端口
|
||||
}
|
||||
|
||||
if Scantype != "all" && Ports == DefaultPorts+","+Webport {
|
||||
switch Scantype {
|
||||
case "hostname":
|
||||
Ports = "135,137,139,445"
|
||||
case "web", "webonly", "webpoc":
|
||||
Ports = Webport
|
||||
case "portscan":
|
||||
Ports = DefaultPorts + "," + Webport
|
||||
case "main":
|
||||
Ports = DefaultPorts
|
||||
default:
|
||||
if port := PORTList[Scantype]; port > 0 {
|
||||
Ports = strconv.Itoa(port)
|
||||
}
|
||||
// 如果是特殊扫描类型
|
||||
if customPorts, isSpecial := specialTypes[Scantype]; isSpecial {
|
||||
if Scantype != "all" && Ports == DefaultPorts+","+Webport {
|
||||
Ports = customPorts
|
||||
}
|
||||
|
||||
fmt.Printf("[*] Scan type: %s, target ports: %s\n", Scantype, Ports)
|
||||
fmt.Printf("[*] 扫描类型: %s, 目标端口: %s\n", Scantype, Ports)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 检查是否是注册的插件类型
|
||||
plugin, validType := Config.PluginManager[Scantype]
|
||||
if !validType {
|
||||
showmode()
|
||||
return fmt.Errorf("无效的扫描类型: %s", Scantype)
|
||||
}
|
||||
|
||||
// 如果是插件扫描且使用默认端口配置
|
||||
if Ports == DefaultPorts+","+Webport {
|
||||
if plugin.Port > 0 {
|
||||
Ports = strconv.Itoa(plugin.Port)
|
||||
}
|
||||
fmt.Printf("[*] 扫描类型: %s, 目标端口: %s\n", plugin.Name, Ports)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//func CheckErr(text string, err error, flag bool) {
|
||||
// if err != nil {
|
||||
// fmt.Println("Parse", text, "error: ", err.Error())
|
||||
// if flag {
|
||||
// if err != ParseIPErr {
|
||||
// fmt.Println(ParseIPErr)
|
||||
// }
|
||||
// os.Exit(0)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
// showmode 显示所有支持的扫描类型
|
||||
func showmode() {
|
||||
fmt.Println("The specified scan type does not exist")
|
||||
fmt.Println("-m")
|
||||
for name := range PORTList {
|
||||
fmt.Println(" [" + name + "]")
|
||||
fmt.Println("[!] 指定的扫描类型不存在")
|
||||
fmt.Println("[*] 支持的扫描类型:")
|
||||
|
||||
// 显示常规服务扫描类型
|
||||
fmt.Println("\n[+] 常规服务扫描:")
|
||||
for name, plugin := range Config.PluginManager {
|
||||
if plugin.Port > 0 && plugin.Port < 1000000 {
|
||||
fmt.Printf(" - %-10s (端口: %d)\n", name, plugin.Port)
|
||||
}
|
||||
}
|
||||
|
||||
// 显示特殊漏洞扫描类型
|
||||
fmt.Println("\n[+] 特殊漏洞扫描:")
|
||||
for name, plugin := range Config.PluginManager {
|
||||
if plugin.Port >= 1000000 || plugin.Port == 0 {
|
||||
fmt.Printf(" - %-10s\n", name)
|
||||
}
|
||||
}
|
||||
|
||||
// 显示其他扫描类型
|
||||
fmt.Println("\n[+] 其他扫描类型:")
|
||||
specialTypes := []string{"all", "portscan", "icmp", "main", "webonly", "webpoc"}
|
||||
for _, name := range specialTypes {
|
||||
fmt.Printf(" - %s\n", name)
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
@@ -14,44 +14,6 @@ var Userdict = map[string][]string{
|
||||
}
|
||||
|
||||
var Passwords = []string{"123456", "admin", "admin123", "root", "", "pass123", "pass@123", "password", "123123", "654321", "111111", "123", "1", "admin@123", "Admin@123", "admin123!@#", "{user}", "{user}1", "{user}111", "{user}123", "{user}@123", "{user}_123", "{user}#123", "{user}@111", "{user}@2019", "{user}@123#4", "P@ssw0rd!", "P@ssw0rd", "Passw0rd", "qwe123", "12345678", "test", "test123", "123qwe", "123qwe!@#", "123456789", "123321", "666666", "a123456.", "123456~a", "123456!a", "000000", "1234567890", "8888888", "!QAZ2wsx", "1qaz2wsx", "abc123", "abc123456", "1qaz@WSX", "a11111", "a12345", "Aa1234", "Aa1234.", "Aa12345", "a123456", "a123123", "Aa123123", "Aa123456", "Aa12345.", "sysadmin", "system", "1qaz!QAZ", "2wsx@WSX", "qwe123!@#", "Aa123456!", "A123456s!", "sa123456", "1q2w3e", "Charge123", "Aa123456789"}
|
||||
var PORTList = map[string]int{
|
||||
// 常规服务端口
|
||||
"ftp": 21,
|
||||
"ssh": 22,
|
||||
"findnet": 135,
|
||||
"netbios": 139,
|
||||
"smb": 445,
|
||||
"mssql": 1433,
|
||||
"oracle": 1521,
|
||||
"mysql": 3306,
|
||||
"rdp": 3389,
|
||||
"psql": 5432,
|
||||
"redis": 6379,
|
||||
"fcgi": 9000,
|
||||
"mem": 11211,
|
||||
"mgo": 27017,
|
||||
|
||||
// 特定端口的扫描类型
|
||||
"wmiexec": 135,
|
||||
"wmiinfo": 135,
|
||||
"smbinfo": 445,
|
||||
"smb2": 445,
|
||||
"ms17010": 445,
|
||||
"cve20200796": 445,
|
||||
|
||||
// Web相关
|
||||
"web": 0, // 使用Webport
|
||||
"webonly": 0, // 使用Webport
|
||||
"webpoc": 0, // 使用Webport
|
||||
|
||||
// 特殊扫描类型
|
||||
"hostname": 0, // 使用135,137,139,445
|
||||
"all": 0, // 全部扫描
|
||||
"portscan": 0, // 使用DefaultPorts + Webport
|
||||
"icmp": 0, // ICMP检测
|
||||
"main": 0, // 使用DefaultPorts
|
||||
"localinfo": 0, // 本地信息收集
|
||||
}
|
||||
|
||||
var PortGroup = map[string]string{
|
||||
"ftp": "21",
|
||||
@@ -81,13 +43,6 @@ var IsSave = true
|
||||
var Webport = "80,81,82,83,84,85,86,87,88,89,90,91,92,98,99,443,800,801,808,880,888,889,1000,1010,1080,1081,1082,1099,1118,1888,2008,2020,2100,2375,2379,3000,3008,3128,3505,5555,6080,6648,6868,7000,7001,7002,7003,7004,7005,7007,7008,7070,7071,7074,7078,7080,7088,7200,7680,7687,7688,7777,7890,8000,8001,8002,8003,8004,8006,8008,8009,8010,8011,8012,8016,8018,8020,8028,8030,8038,8042,8044,8046,8048,8053,8060,8069,8070,8080,8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,8091,8092,8093,8094,8095,8096,8097,8098,8099,8100,8101,8108,8118,8161,8172,8180,8181,8200,8222,8244,8258,8280,8288,8300,8360,8443,8448,8484,8800,8834,8838,8848,8858,8868,8879,8880,8881,8888,8899,8983,8989,9000,9001,9002,9008,9010,9043,9060,9080,9081,9082,9083,9084,9085,9086,9087,9088,9089,9090,9091,9092,9093,9094,9095,9096,9097,9098,9099,9100,9200,9443,9448,9800,9981,9986,9988,9998,9999,10000,10001,10002,10004,10008,10010,10250,12018,12443,14000,16080,18000,18001,18002,18004,18008,18080,18082,18088,18090,18098,19001,20000,20720,21000,21501,21502,28018,20880"
|
||||
var DefaultPorts = "21,22,80,81,135,139,443,445,1433,1521,3306,5432,6379,7001,8000,8080,8089,9000,9200,11211,27017"
|
||||
|
||||
type HostInfo struct {
|
||||
Host string
|
||||
Ports string
|
||||
Url string
|
||||
Infostr []string
|
||||
}
|
||||
|
||||
type PocInfo struct {
|
||||
Target string
|
||||
PocName string
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@ package common
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"github.com/shadow1ng/fscan/Config"
|
||||
)
|
||||
|
||||
func Banner() {
|
||||
@@ -16,7 +17,7 @@ func Banner() {
|
||||
print(banner)
|
||||
}
|
||||
|
||||
func Flag(Info *HostInfo) {
|
||||
func Flag(Info *Config.HostInfo) {
|
||||
Banner()
|
||||
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(&NoHosts, "hn", "", "the hosts no scan,as: -hn 192.168.1.1/24")
|
||||
|
||||
Reference in New Issue
Block a user