Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
shadow1ng committed Nov 13, 2023
1 parent 6bf396d commit 1c63113
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Plugins/CVE-2020-0796.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ func SmbGhostScan(info *common.HostInfo) error {
ip, port, timeout := info.Host, 445, time.Duration(common.Timeout)*time.Second
addr := fmt.Sprintf("%s:%v", info.Host, port)
conn, err := common.WrapperTcpWithTimeout("tcp", addr, timeout)
defer conn.Close()
if err != nil {
return err
}
defer conn.Close()
_, err = conn.Write([]byte(pkt))
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions Plugins/NetBIOS.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ func NetBIOS1(info *common.HostInfo) (netbios NetBiosInfo, err error) {
realhost := fmt.Sprintf("%s:%v", info.Host, info.Ports)
var conn net.Conn
conn, err = common.WrapperTcpWithTimeout("tcp", realhost, time.Duration(common.Timeout)*time.Second)
defer conn.Close()
if err != nil {
return
}
defer conn.Close()
err = conn.SetDeadline(time.Now().Add(time.Duration(common.Timeout) * time.Second))
if err != nil {
return
Expand Down Expand Up @@ -89,10 +89,10 @@ func GetNbnsname(info *common.HostInfo) (netbios NetBiosInfo, err error) {
//senddata1 := []byte("ff\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00 CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\x00\x00!\x00\x01")
realhost := fmt.Sprintf("%s:137", info.Host)
conn, err := net.DialTimeout("udp", realhost, time.Duration(common.Timeout)*time.Second)
defer conn.Close()
if err != nil {
return
}
defer conn.Close()
err = conn.SetDeadline(time.Now().Add(time.Duration(common.Timeout) * time.Second))
if err != nil {
return
Expand Down
2 changes: 1 addition & 1 deletion Plugins/findnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ func Findnet(info *common.HostInfo) error {
func FindnetScan(info *common.HostInfo) error {
realhost := fmt.Sprintf("%s:%v", info.Host, 135)
conn, err := common.WrapperTcpWithTimeout("tcp", realhost, time.Duration(common.Timeout)*time.Second)
defer conn.Close()
if err != nil {
return err
}
defer conn.Close()
err = conn.SetDeadline(time.Now().Add(time.Duration(common.Timeout) * time.Second))
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion Plugins/ms17010.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ func MS17010Scan(info *common.HostInfo) error {
ip := info.Host
// connecting to a host in LAN if reachable should be very quick
conn, err := common.WrapperTcpWithTimeout("tcp", ip+":445", time.Duration(common.Timeout)*time.Second)
defer conn.Close()
if err != nil {
//fmt.Printf("failed to connect to %s\n", ip)
return err
}
defer conn.Close()
err = conn.SetDeadline(time.Now().Add(time.Duration(common.Timeout) * time.Second))
if err != nil {
//fmt.Printf("failed to connect to %s\n", ip)
Expand Down
2 changes: 1 addition & 1 deletion Plugins/portscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func PortScan(hostslist []string, ports string, timeout int64) []string {
func PortConnect(addr Addr, respondingHosts chan<- string, adjustedTimeout int64, wg *sync.WaitGroup) {
host, port := addr.ip, addr.port
conn, err := common.WrapperTcpWithTimeout("tcp4", fmt.Sprintf("%s:%v", host, port), time.Duration(adjustedTimeout)*time.Second)
defer conn.Close()
if err == nil {
defer conn.Close()
address := host + ":" + strconv.Itoa(port)
result := fmt.Sprintf("%s open", address)
common.LogSuccess(result)
Expand Down
2 changes: 1 addition & 1 deletion Plugins/rdp.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ func NewClient(host string, logLevel glog.LEVEL) *Client {

func (g *Client) Login(domain, user, pwd string, timeout int64) error {
conn, err := common.WrapperTcpWithTimeout("tcp", g.Host, time.Duration(timeout)*time.Second)
defer conn.Close()
if err != nil {
return fmt.Errorf("[dial err] %v", err)
}
defer conn.Close()
glog.Info(conn.LocalAddr().String())

g.tpkt = tpkt.New(core.NewSocketLayer(conn), nla.NewNTLMv2(domain, user, pwd))
Expand Down
4 changes: 2 additions & 2 deletions Plugins/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ func RedisConn(info *common.HostInfo, pass string) (flag bool, err error) {
flag = false
realhost := fmt.Sprintf("%s:%v", info.Host, info.Ports)
conn, err := common.WrapperTcpWithTimeout("tcp", realhost, time.Duration(common.Timeout)*time.Second)
defer conn.Close()
if err != nil {
return flag, err
}
defer conn.Close()
err = conn.SetReadDeadline(time.Now().Add(time.Duration(common.Timeout) * time.Second))
if err != nil {
return flag, err
Expand Down Expand Up @@ -84,10 +84,10 @@ func RedisUnauth(info *common.HostInfo) (flag bool, err error) {
flag = false
realhost := fmt.Sprintf("%s:%v", info.Host, info.Ports)
conn, err := common.WrapperTcpWithTimeout("tcp", realhost, time.Duration(common.Timeout)*time.Second)
defer conn.Close()
if err != nil {
return flag, err
}
defer conn.Close()
err = conn.SetReadDeadline(time.Now().Add(time.Duration(common.Timeout) * time.Second))
if err != nil {
return flag, err
Expand Down
10 changes: 5 additions & 5 deletions Plugins/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ func Scan(info common.HostInfo) {
}
var AlivePorts []string
if common.Scantype == "webonly" || common.Scantype == "webpoc" {
AlivePorts = NoPortScan(Hosts, info.Ports)
AlivePorts = NoPortScan(Hosts, common.Ports)
} else if common.Scantype == "hostname" {
info.Ports = "139"
AlivePorts = NoPortScan(Hosts, info.Ports)
common.Ports = "139"
AlivePorts = NoPortScan(Hosts, common.Ports)
} else if len(Hosts) > 0 {
AlivePorts = PortScan(Hosts, info.Ports, common.Timeout)
AlivePorts = PortScan(Hosts, common.Ports, common.Timeout)
fmt.Println("[*] alive ports len is:", len(AlivePorts))
if common.Scantype == "portscan" {
common.LogWG.Wait()
Expand Down Expand Up @@ -90,7 +90,7 @@ func Scan(info common.HostInfo) {
wg.Wait()
common.LogWG.Wait()
close(common.Results)
fmt.Println(fmt.Sprintf("已完成 %v/%v", common.End, common.Num))
fmt.Printf("已完成 %v/%v\n", common.End, common.Num)
}

var Mutex = &sync.Mutex{}
Expand Down
2 changes: 1 addition & 1 deletion Plugins/smb2.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ func SmbScan2(info *common.HostInfo) (tmperr error) {

func Smb2Con(info *common.HostInfo, user string, pass string, hash []byte, hasprint bool) (flag bool, err error, flag2 bool) {
conn, err := net.DialTimeout("tcp", info.Host+":445", time.Duration(common.Timeout)*time.Second)
defer conn.Close()
if err != nil {
return
}
defer conn.Close()
initiator := smb2.NTLMInitiator{
User: user,
Domain: common.Domain,
Expand Down
40 changes: 20 additions & 20 deletions common/Parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func ParsePass(Info *HostInfo) {
newport += port + ","
}
}
Info.Ports = newport
Ports = newport
}
}
}
Expand Down Expand Up @@ -140,15 +140,15 @@ func ParseInput(Info *HostInfo) {
IsSave = false
}

if Info.Ports == DefaultPorts {
Info.Ports += "," + Webport
if Ports == DefaultPorts {
Ports += "," + Webport
}

if PortAdd != "" {
if strings.HasSuffix(Info.Ports, ",") {
Info.Ports += PortAdd
if strings.HasSuffix(Ports, ",") {
Ports += PortAdd
} else {
Info.Ports += "," + PortAdd
Ports += "," + PortAdd
}
}

Expand Down Expand Up @@ -219,35 +219,35 @@ func ParseScantype(Info *HostInfo) {
if !ok {
showmode()
}
if Scantype != "all" && Info.Ports == DefaultPorts+","+Webport {
if Scantype != "all" && Ports == DefaultPorts+","+Webport {
switch Scantype {
case "wmiexec":
Info.Ports = "135"
Ports = "135"
case "wmiinfo":
Info.Ports = "135"
Ports = "135"
case "smbinfo":
Info.Ports = "445"
Ports = "445"
case "hostname":
Info.Ports = "135,137,139,445"
Ports = "135,137,139,445"
case "smb2":
Info.Ports = "445"
Ports = "445"
case "web":
Info.Ports = Webport
Ports = Webport
case "webonly":
Info.Ports = Webport
Ports = Webport
case "ms17010":
Info.Ports = "445"
Ports = "445"
case "cve20200796":
Info.Ports = "445"
Ports = "445"
case "portscan":
Info.Ports = DefaultPorts + "," + Webport
Ports = DefaultPorts + "," + Webport
case "main":
Info.Ports = DefaultPorts
Ports = DefaultPorts
default:
port, _ := PORTList[Scantype]
Info.Ports = strconv.Itoa(port)
Ports = strconv.Itoa(port)
}
fmt.Println("-m ", Scantype, " start scan the port:", Info.Ports)
fmt.Println("-m ", Scantype, " start scan the port:", Ports)
}
}

Expand Down
3 changes: 3 additions & 0 deletions common/ParsePort.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ func ParsePort(ports string) (scanPorts []int) {
if port == "" {
continue
}
if PortGroup[port] != "" {
port = PortGroup[port]
}
upper := port
if strings.Contains(port, "-") {
ranges := strings.Split(port, "-")
Expand Down
1 change: 1 addition & 0 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type PocInfo struct {
}

var (
Ports string
Path string
Scantype string
Command string
Expand Down
2 changes: 1 addition & 1 deletion common/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func Flag(Info *HostInfo) {
Banner()
flag.StringVar(&Info.Host, "h", "", "IP address of the host you want to scan,for example: 192.168.11.11 | 192.168.11.11-255 | 192.168.11.11,192.168.11.12")
flag.StringVar(&NoHosts, "hn", "", "the hosts no scan,as: -hn 192.168.1.1/24")
flag.StringVar(&Info.Ports, "p", DefaultPorts, "Select a port,for example: 22 | 1-65535 | 22,80,3306")
flag.StringVar(&Ports, "p", DefaultPorts, "Select a port,for example: 22 | 1-65535 | 22,80,3306")
flag.StringVar(&PortAdd, "pa", "", "add port base DefaultPorts,-pa 3389")
flag.StringVar(&UserAdd, "usera", "", "add a user base DefaultUsers,-usera user")
flag.StringVar(&PassAdd, "pwda", "", "add a password base DefaultPasses,-pwda password")
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ func main() {
common.Flag(&Info)
common.Parse(&Info)
Plugins.Scan(Info)
t := time.Since(start)
fmt.Printf("[*] 扫描结束,耗时: %s\n", t)
fmt.Printf("[*] 扫描结束,耗时: %s\n", time.Since(start))
}

0 comments on commit 1c63113

Please sign in to comment.