mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-07-14 13:22:35 +08:00
Update Parse.go
This commit is contained in:
parent
29acfb166b
commit
59983affb7
131
common/Parse.go
131
common/Parse.go
@ -11,28 +11,24 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Parse(inputConfig *InConfig) {
|
func Parse(Info *HostInfo) {
|
||||||
ParseUser(&inputConfig.Flags)
|
ParseUser()
|
||||||
ParsePass(&inputConfig.HostInfo, &inputConfig.Flags)
|
ParsePass(Info)
|
||||||
ParseInput(&inputConfig.HostInfo, &inputConfig.Flags)
|
ParseInput(Info)
|
||||||
ParseScantype(&inputConfig.HostInfo, &inputConfig.Flags)
|
ParseScantype(Info)
|
||||||
|
|
||||||
Outputfile = inputConfig.LogConfig.Outputfile
|
|
||||||
IsSave = !inputConfig.LogConfig.TmpSave
|
|
||||||
Cookie = inputConfig.Cookie
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseUser(flags *Flags) {
|
func ParseUser() {
|
||||||
if flags.Username == "" && flags.Userfile == "" {
|
if Username == "" && Userfile == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var Usernames []string
|
var Usernames []string
|
||||||
if flags.Username != "" {
|
if Username != "" {
|
||||||
Usernames = strings.Split(flags.Username, ",")
|
Usernames = strings.Split(Username, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags.Userfile != "" {
|
if Userfile != "" {
|
||||||
users, err := Readfile(flags.Userfile)
|
users, err := Readfile(Userfile)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
if user != "" {
|
if user != "" {
|
||||||
@ -48,10 +44,10 @@ func ParseUser(flags *Flags) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParsePass(Info *HostInfo, flags *Flags) {
|
func ParsePass(Info *HostInfo) {
|
||||||
var PwdList []string
|
var PwdList []string
|
||||||
if flags.Password != "" {
|
if Password != "" {
|
||||||
passs := strings.Split(flags.Password, ",")
|
passs := strings.Split(Password, ",")
|
||||||
for _, pass := range passs {
|
for _, pass := range passs {
|
||||||
if pass != "" {
|
if pass != "" {
|
||||||
PwdList = append(PwdList, pass)
|
PwdList = append(PwdList, pass)
|
||||||
@ -59,8 +55,8 @@ func ParsePass(Info *HostInfo, flags *Flags) {
|
|||||||
}
|
}
|
||||||
Passwords = PwdList
|
Passwords = PwdList
|
||||||
}
|
}
|
||||||
if flags.Passfile != "" {
|
if Passfile != "" {
|
||||||
passs, err := Readfile(flags.Passfile)
|
passs, err := Readfile(Passfile)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, pass := range passs {
|
for _, pass := range passs {
|
||||||
if pass != "" {
|
if pass != "" {
|
||||||
@ -70,35 +66,34 @@ func ParsePass(Info *HostInfo, flags *Flags) {
|
|||||||
Passwords = PwdList
|
Passwords = PwdList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if URL != "" {
|
||||||
if flags.URL != "" {
|
urls := strings.Split(URL, ",")
|
||||||
urls := strings.Split(flags.URL, ",")
|
|
||||||
TmpUrls := make(map[string]struct{})
|
TmpUrls := make(map[string]struct{})
|
||||||
for _, url := range urls {
|
for _, url := range urls {
|
||||||
if _, ok := TmpUrls[url]; !ok {
|
if _, ok := TmpUrls[url]; !ok {
|
||||||
TmpUrls[url] = struct{}{}
|
TmpUrls[url] = struct{}{}
|
||||||
if url != "" {
|
if url != "" {
|
||||||
flags.Urls = append(flags.Urls, url)
|
Urls = append(Urls, url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if flags.UrlFile != "" {
|
if UrlFile != "" {
|
||||||
urls, err := Readfile(flags.UrlFile)
|
urls, err := Readfile(UrlFile)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
TmpUrls := make(map[string]struct{})
|
TmpUrls := make(map[string]struct{})
|
||||||
for _, url := range urls {
|
for _, url := range urls {
|
||||||
if _, ok := TmpUrls[url]; !ok {
|
if _, ok := TmpUrls[url]; !ok {
|
||||||
TmpUrls[url] = struct{}{}
|
TmpUrls[url] = struct{}{}
|
||||||
if url != "" {
|
if url != "" {
|
||||||
flags.Urls = append(flags.Urls, url)
|
Urls = append(Urls, url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if flags.PortFile != "" {
|
if PortFile != "" {
|
||||||
ports, err := Readfile(flags.PortFile)
|
ports, err := Readfile(PortFile)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
newport := ""
|
newport := ""
|
||||||
for _, port := range ports {
|
for _, port := range ports {
|
||||||
@ -130,84 +125,88 @@ func Readfile(filename string) ([]string, error) {
|
|||||||
return content, nil
|
return content, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseInput(Info *HostInfo, flags *Flags) {
|
func ParseInput(Info *HostInfo) {
|
||||||
if Info.Host == "" && flags.HostFile == "" && flags.URL == "" && flags.UrlFile == "" {
|
if Info.Host == "" && HostFile == "" && URL == "" && UrlFile == "" {
|
||||||
fmt.Println("Host is none")
|
fmt.Println("Host is none")
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags.BruteThread <= 0 {
|
if BruteThread <= 0 {
|
||||||
flags.BruteThread = 1
|
BruteThread = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if TmpSave == true {
|
||||||
|
IsSave = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if Info.Ports == DefaultPorts {
|
if Info.Ports == DefaultPorts {
|
||||||
Info.Ports += "," + Webport
|
Info.Ports += "," + Webport
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags.PortAdd != "" {
|
if PortAdd != "" {
|
||||||
if strings.HasSuffix(Info.Ports, ",") {
|
if strings.HasSuffix(Info.Ports, ",") {
|
||||||
Info.Ports += flags.PortAdd
|
Info.Ports += PortAdd
|
||||||
} else {
|
} else {
|
||||||
Info.Ports += "," + flags.PortAdd
|
Info.Ports += "," + PortAdd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags.UserAdd != "" {
|
if UserAdd != "" {
|
||||||
user := strings.Split(flags.UserAdd, ",")
|
user := strings.Split(UserAdd, ",")
|
||||||
for a := range Userdict {
|
for a := range Userdict {
|
||||||
Userdict[a] = append(Userdict[a], user...)
|
Userdict[a] = append(Userdict[a], user...)
|
||||||
Userdict[a] = RemoveDuplicate(Userdict[a])
|
Userdict[a] = RemoveDuplicate(Userdict[a])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags.PassAdd != "" {
|
if PassAdd != "" {
|
||||||
pass := strings.Split(flags.PassAdd, ",")
|
pass := strings.Split(PassAdd, ",")
|
||||||
Passwords = append(Passwords, pass...)
|
Passwords = append(Passwords, pass...)
|
||||||
Passwords = RemoveDuplicate(Passwords)
|
Passwords = RemoveDuplicate(Passwords)
|
||||||
}
|
}
|
||||||
if flags.Socks5Proxy != "" && !strings.HasPrefix(flags.Socks5Proxy, "socks5://") {
|
if Socks5Proxy != "" && !strings.HasPrefix(Socks5Proxy, "socks5://") {
|
||||||
if !strings.Contains(flags.Socks5Proxy, ":") {
|
if !strings.Contains(Socks5Proxy, ":") {
|
||||||
flags.Socks5Proxy = "socks5://127.0.0.1" + flags.Socks5Proxy
|
Socks5Proxy = "socks5://127.0.0.1" + Socks5Proxy
|
||||||
} else {
|
} else {
|
||||||
flags.Socks5Proxy = "socks5://" + flags.Socks5Proxy
|
Socks5Proxy = "socks5://" + Socks5Proxy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if flags.Socks5Proxy != "" {
|
if Socks5Proxy != "" {
|
||||||
fmt.Println("Socks5Proxy:", flags.Socks5Proxy)
|
fmt.Println("Socks5Proxy:", Socks5Proxy)
|
||||||
_, err := url.Parse(flags.Socks5Proxy)
|
_, err := url.Parse(Socks5Proxy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Socks5Proxy parse error:", err)
|
fmt.Println("Socks5Proxy parse error:", err)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
flags.NoPing = true
|
NoPing = true
|
||||||
}
|
}
|
||||||
if flags.Proxy != "" {
|
if Proxy != "" {
|
||||||
if flags.Proxy == "1" {
|
if Proxy == "1" {
|
||||||
flags.Proxy = "http://127.0.0.1:8080"
|
Proxy = "http://127.0.0.1:8080"
|
||||||
} else if flags.Proxy == "2" {
|
} else if Proxy == "2" {
|
||||||
flags.Proxy = "socks5://127.0.0.1:1080"
|
Proxy = "socks5://127.0.0.1:1080"
|
||||||
} else if !strings.Contains(flags.Proxy, "://") {
|
} else if !strings.Contains(Proxy, "://") {
|
||||||
flags.Proxy = "http://127.0.0.1:" + flags.Proxy
|
Proxy = "http://127.0.0.1:" + Proxy
|
||||||
}
|
}
|
||||||
fmt.Println("Proxy:", flags.Proxy)
|
fmt.Println("Proxy:", Proxy)
|
||||||
if !strings.HasPrefix(flags.Proxy, "socks") && !strings.HasPrefix(flags.Proxy, "http") {
|
if !strings.HasPrefix(Proxy, "socks") && !strings.HasPrefix(Proxy, "http") {
|
||||||
fmt.Println("no support this proxy")
|
fmt.Println("no support this proxy")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
_, err := url.Parse(flags.Proxy)
|
_, err := url.Parse(Proxy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Proxy parse error:", err)
|
fmt.Println("Proxy parse error:", err)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags.Hash != "" && len(flags.Hash) != 32 {
|
if Hash != "" && len(Hash) != 32 {
|
||||||
fmt.Println("[-] Hash is error,len(hash) must be 32")
|
fmt.Println("[-] Hash is error,len(hash) must be 32")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
} else {
|
} else {
|
||||||
var err error
|
var err error
|
||||||
flags.HashBytes, err = hex.DecodeString(flags.Hash)
|
HashBytes, err = hex.DecodeString(Hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("[-] Hash is error,hex decode error")
|
fmt.Println("[-] Hash is error,hex decode error")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
@ -215,13 +214,13 @@ func ParseInput(Info *HostInfo, flags *Flags) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseScantype(Info *HostInfo, flags *Flags) {
|
func ParseScantype(Info *HostInfo) {
|
||||||
_, ok := PORTList[flags.Scantype]
|
_, ok := PORTList[Scantype]
|
||||||
if !ok {
|
if !ok {
|
||||||
showmode()
|
showmode()
|
||||||
}
|
}
|
||||||
if flags.Scantype != "all" && Info.Ports == DefaultPorts+","+Webport {
|
if Scantype != "all" && Info.Ports == DefaultPorts+","+Webport {
|
||||||
switch flags.Scantype {
|
switch Scantype {
|
||||||
case "wmiexec":
|
case "wmiexec":
|
||||||
Info.Ports = "135"
|
Info.Ports = "135"
|
||||||
case "wmiinfo":
|
case "wmiinfo":
|
||||||
@ -245,10 +244,10 @@ func ParseScantype(Info *HostInfo, flags *Flags) {
|
|||||||
case "main":
|
case "main":
|
||||||
Info.Ports = DefaultPorts
|
Info.Ports = DefaultPorts
|
||||||
default:
|
default:
|
||||||
port, _ := PORTList[flags.Scantype]
|
port, _ := PORTList[Scantype]
|
||||||
Info.Ports = strconv.Itoa(port)
|
Info.Ports = strconv.Itoa(port)
|
||||||
}
|
}
|
||||||
fmt.Println("-m ", flags.Scantype, " start scan the port:", Info.Ports)
|
fmt.Println("-m ", Scantype, " start scan the port:", Info.Ports)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user