Skip to content

Commit

Permalink
Merge remote-tracking branch 'au/main' into refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
artemkomyshan committed Jul 26, 2023
2 parents 29b746e + 18937e1 commit 31aba61
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
result.txt
4 changes: 2 additions & 2 deletions Plugins/NetBIOS.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func NetBIOS(info common.HostInfo, flags common.Flags) error {
netbios, _ := NetBIOS1(info, flags)
output := netbios.String()
if len(output) > 0 {
result := fmt.Sprintf("[*] NetBios: %-15s %s ", info.Host, output)
result := fmt.Sprintf("[*] NetBios: %-15s %s", info.Host, output)
common.LogSuccess(result)
return nil
}
Expand Down Expand Up @@ -238,7 +238,7 @@ func (info NetBiosInfo) String() (output string) {
}
if text == "" {
} else if info.DomainControllers != "" {
output = fmt.Sprintf("[+]DC %-24s", text)
output = fmt.Sprintf("[+] DC:%-24s", text)
} else {
output = fmt.Sprintf("%-30s", text)
}
Expand Down
5 changes: 3 additions & 2 deletions Plugins/icmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"sync"
"time"

"github.com/fatih/color"
"github.com/shadow1ng/fscan/common"
"golang.org/x/net/icmp"
)
Expand All @@ -29,9 +30,9 @@ func CheckLive(hostslist []string, ping bool, liveTop int) []string {
ExistHosts[ip] = struct{}{}
if !common.Silent {
if !ping {
fmt.Printf("(icmp) Target %-15s is alive\n", ip)
color.Green("(icmp) Target %-15s is alive\n", ip)
} else {
fmt.Printf("(ping) Target %-15s is alive\n", ip)
color.Green("(ping) Target %-15s is alive\n", ip)
}
}
AliveHosts = append(AliveHosts, ip)
Expand Down
9 changes: 5 additions & 4 deletions Plugins/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"
"sync"

"github.com/fatih/color"
"github.com/shadow1ng/fscan/WebScan/lib"
"github.com/shadow1ng/fscan/common"
)
Expand All @@ -24,9 +25,9 @@ func Scan(info common.HostInfo, flags common.Flags) {
web := strconv.Itoa(common.PORTList["web"])
ms17010 := strconv.Itoa(common.PORTList["ms17010"])
if len(Hosts) > 0 || len(info.HostPort) > 0 {
if !flags.NoPing && len(Hosts) > 0 {
if flags.NoPing == false && len(Hosts) > 0 {
Hosts = CheckLive(Hosts, flags.Ping, flags.LiveTop)
fmt.Println("[*] Icmp alive hosts len is:", len(Hosts))
color.Cyan("[*] Icmp alive hosts len is: %d", len(Hosts))
}
if flags.Scantype == "icmp" {
common.LogWG.Wait()
Expand All @@ -41,7 +42,7 @@ func Scan(info common.HostInfo, flags common.Flags) {
AlivePorts = NoPortScan(Hosts, info.Ports, flags)
} else if len(Hosts) > 0 {
AlivePorts = PortScan(Hosts, info.Ports, flags)
fmt.Println("[*] alive ports len is:", len(AlivePorts))
color.Cyan("[*] alive ports len is: %d", len(AlivePorts))
if flags.Scantype == "portscan" {
common.LogWG.Wait()
return
Expand All @@ -51,7 +52,7 @@ func Scan(info common.HostInfo, flags common.Flags) {
AlivePorts = append(AlivePorts, info.HostPort...)
AlivePorts = common.RemoveDuplicate(AlivePorts)
info.HostPort = nil
fmt.Println("[*] AlivePorts len is:", len(AlivePorts))
color.Cyan("[*] AlivePorts len is:", len(AlivePorts))
}

var severports []string //severports := []string{"21","22","135"."445","1433","3306","5432","6379","9200","11211","27017"...}
Expand Down
2 changes: 1 addition & 1 deletion WebScan/InfoScan.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func InfoCheck(Url string, CheckData *[]CheckDatas) []string {
infoname = removeDuplicateElement(infoname)

if len(infoname) > 0 {
result := fmt.Sprintf("[+] InfoScan:%-25v %s ", Url, infoname)
result := fmt.Sprintf("[+] InfoScan: %-25v %s ", Url, infoname)
common.LogSuccess(result)
return infoname
}
Expand Down
2 changes: 1 addition & 1 deletion WebScan/lib/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ func DoRequest(req *http.Request, redirect bool) (*Response, error) {
defer oResp.Body.Close()
resp, err := ParseResponse(oResp)
if err != nil {
common.LogError("[-]ParseResponse error: " + err.Error())
common.LogError("[-] ParseResponse error: " + err.Error())
//return nil, err
}
return resp, err
Expand Down
4 changes: 2 additions & 2 deletions common/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func Flag(inConfig *InConfig) {
flag.StringVar(&inConfig.Flags.Passfile, "pwdf", "", "password file")
flag.StringVar(&inConfig.Flags.PortFile, "portf", "", "Port File")
flag.StringVar(&inConfig.Flags.PocPath, "pocpath", "", "poc file path")
flag.StringVar(&inConfig.Flags.RedisFile, "rf", "", "redis file to write sshkey file (as: -rf id_rsa.pub) ")
flag.StringVar(&inConfig.Flags.RedisShell, "rs", "", "redis shell to write cron file (as: -rs 192.168.1.1:6666) ")
flag.StringVar(&inConfig.Flags.RedisFile, "rf", "", "redis file to write sshkey file (as: -rf id_rsa.pub)")
flag.StringVar(&inConfig.Flags.RedisShell, "rs", "", "redis shell to write cron file (as: -rs 192.168.1.1:6666)")
flag.BoolVar(&inConfig.Flags.IsWebCan, "nopoc", false, "not to scan web vul")
flag.BoolVar(&inConfig.Flags.IsBrute, "nobr", false, "not to Brute password")
flag.IntVar(&inConfig.Flags.BruteThread, "br", 1, "Brute threads")
Expand Down
32 changes: 22 additions & 10 deletions common/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"strings"
"sync"
"time"

"github.com/fatih/color"
)

var Num int64
Expand All @@ -32,12 +34,18 @@ func LogSuccess(result string) {

func SaveLog() {
for result := range Results {
if Silent == false || strings.Contains(*result, "[+]") || strings.Contains(*result, "[*]") {
fmt.Println(*result)
if !Silent {
if strings.Contains(*result, "[+]") {
color.Green(*result)
} else if strings.Contains(*result, "[*]") {
color.Cyan(*result)
}
}

if IsSave {
WriteFile(*result, Outputfile)
}

LogWG.Done()
}
}
Expand All @@ -49,19 +57,23 @@ func WriteFile(result string, filename string) {
fmt.Printf("Open %s error, %v\n", filename, err)
return
}
_, err = fl.Write(text)
fl.Close()
if err != nil {

defer func() {
_ = fl.Close()
}()

if _, err := fl.Write(text); err != nil {
fmt.Printf("Write %s error, %v\n", filename, err)
}
}

func LogError(errinfo interface{}) {
if WaitTime == 0 {
fmt.Printf("completed %v/%v %v \n", End, Num, errinfo)
} else if (time.Now().Unix()-LogSucTime) > WaitTime && (time.Now().Unix()-LogErrTime) > WaitTime {
fmt.Printf("completed %v/%v %v \n", End, Num, errinfo)
LogErrTime = time.Now().Unix()
if WaitTime == 0 || (time.Now().Unix()-LogSucTime) > WaitTime && (time.Now().Unix()-LogErrTime) > WaitTime {
color.Red(fmt.Sprintf("Completed %v/%v %v \n", End, Num, errinfo))

if WaitTime != 0 {
LogErrTime = time.Now().Unix()
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/geoffgarside/ber v1.1.0 // indirect
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
Expand All @@ -34,14 +35,16 @@ require (
github.com/huin/asn1ber v0.0.0-20120622192748-af09f62e6358 // indirect
github.com/icodeface/tls v0.0.0-20190904083142-17aec93c60e5 // indirect
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
go.uber.org/atomic v1.5.0 // indirect
go.uber.org/multierr v1.3.0 // indirect
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee // indirect
go.uber.org/zap v1.14.0 // indirect
golang.org/x/lint v0.0.0-20190930215403-16217165b5de // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/tools v0.1.12 // indirect
honnef.co/go/tools v0.0.1-2019.2.3 // indirect
)
Expand Down
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/geoffgarside/ber v1.1.0 h1:qTmFG4jJbwiSzSXoNJeHcOprVzZ8Ulde2Rrrifu5U9w=
Expand Down Expand Up @@ -156,7 +158,12 @@ github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 h1:EnfXoSqDfSNJv0
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40/go.mod h1:vy1vK6wD6j7xX6O6hXe621WabdtNkou2h7uRtTfRMyg=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
Expand Down Expand Up @@ -341,8 +348,12 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
19 changes: 19 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import (
"fmt"
"time"

"github.com/shadow1ng/fscan/Plugins"
"github.com/shadow1ng/fscan/common"
)

func main() {
start := time.Now()
var config common.InConfig
common.Flag(&config)
common.Parse(&config)
Plugins.Scan(config.HostInfo, config.Flags)
t := time.Now().Sub(start)
fmt.Printf("[*] 扫描结束,耗时: %s\n", t)
}

0 comments on commit 31aba61

Please sign in to comment.