mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-11-05 10:45:27 +00:00
Update NetBIOS.go
This commit is contained in:
parent
fddfd08d01
commit
019544cd07
@ -4,19 +4,18 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/shadow1ng/fscan/common"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/shadow1ng/fscan/common"
|
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var errNetBIOS = errors.New("netbios error")
|
var errNetBIOS = errors.New("netbios error")
|
||||||
|
|
||||||
func NetBIOS(info common.HostInfo, flags common.Flags) error {
|
func NetBIOS(info *common.HostInfo) error {
|
||||||
netbios, _ := NetBIOS1(info, flags)
|
netbios, _ := NetBIOS1(info)
|
||||||
output := netbios.String()
|
output := netbios.String()
|
||||||
if len(output) > 0 {
|
if len(output) > 0 {
|
||||||
result := fmt.Sprintf("[*] NetBios: %-15s %s", info.Host, output)
|
result := fmt.Sprintf("[*] NetBios: %-15s %s", info.Host, output)
|
||||||
@ -26,8 +25,8 @@ func NetBIOS(info common.HostInfo, flags common.Flags) error {
|
|||||||
return errNetBIOS
|
return errNetBIOS
|
||||||
}
|
}
|
||||||
|
|
||||||
func NetBIOS1(info common.HostInfo, flags common.Flags) (netbios NetBiosInfo, err error) {
|
func NetBIOS1(info *common.HostInfo) (netbios NetBiosInfo, err error) {
|
||||||
netbios, err = GetNbnsname(info, flags.Timeout)
|
netbios, err = GetNbnsname(info)
|
||||||
var payload0 []byte
|
var payload0 []byte
|
||||||
if netbios.ServerService != "" || netbios.WorkstationService != "" {
|
if netbios.ServerService != "" || netbios.WorkstationService != "" {
|
||||||
ss := netbios.ServerService
|
ss := netbios.ServerService
|
||||||
@ -41,7 +40,7 @@ func NetBIOS1(info common.HostInfo, flags common.Flags) (netbios NetBiosInfo, er
|
|||||||
}
|
}
|
||||||
realhost := fmt.Sprintf("%s:%v", info.Host, info.Ports)
|
realhost := fmt.Sprintf("%s:%v", info.Host, info.Ports)
|
||||||
var conn net.Conn
|
var conn net.Conn
|
||||||
conn, err = common.WrapperTcpWithTimeout("tcp", realhost, common.Socks5{Address: flags.Socks5Proxy}, time.Duration(flags.Timeout)*time.Second)
|
conn, err = common.WrapperTcpWithTimeout("tcp", realhost, time.Duration(common.Timeout)*time.Second)
|
||||||
defer func() {
|
defer func() {
|
||||||
if conn != nil {
|
if conn != nil {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
@ -50,7 +49,7 @@ func NetBIOS1(info common.HostInfo, flags common.Flags) (netbios NetBiosInfo, er
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = conn.SetDeadline(time.Now().Add(time.Duration(flags.Timeout) * time.Second))
|
err = conn.SetDeadline(time.Now().Add(time.Duration(common.Timeout) * time.Second))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -89,11 +88,11 @@ func NetBIOS1(info common.HostInfo, flags common.Flags) (netbios NetBiosInfo, er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetNbnsname(info common.HostInfo, timeout int64) (netbios NetBiosInfo, err error) {
|
func GetNbnsname(info *common.HostInfo) (netbios NetBiosInfo, err error) {
|
||||||
senddata1 := []byte{102, 102, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 32, 67, 75, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 0, 33, 0, 1}
|
senddata1 := []byte{102, 102, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 32, 67, 75, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 0, 33, 0, 1}
|
||||||
//senddata1 := []byte("ff\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00 CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\x00\x00!\x00\x01")
|
//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)
|
realhost := fmt.Sprintf("%s:137", info.Host)
|
||||||
conn, err := net.DialTimeout("udp", realhost, time.Duration(timeout)*time.Second)
|
conn, err := net.DialTimeout("udp", realhost, time.Duration(common.Timeout)*time.Second)
|
||||||
defer func() {
|
defer func() {
|
||||||
if conn != nil {
|
if conn != nil {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
@ -102,7 +101,7 @@ func GetNbnsname(info common.HostInfo, timeout int64) (netbios NetBiosInfo, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = conn.SetDeadline(time.Now().Add(time.Duration(timeout) * time.Second))
|
err = conn.SetDeadline(time.Now().Add(time.Duration(common.Timeout) * time.Second))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -209,7 +208,7 @@ type NetBiosInfo struct {
|
|||||||
NetComputerName string `yaml:"NetBiosComputerName"`
|
NetComputerName string `yaml:"NetBiosComputerName"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (info NetBiosInfo) String() (output string) {
|
func (info *NetBiosInfo) String() (output string) {
|
||||||
var text string
|
var text string
|
||||||
//ComputerName 信息比较全
|
//ComputerName 信息比较全
|
||||||
if info.ComputerName != "" {
|
if info.ComputerName != "" {
|
||||||
@ -329,7 +328,7 @@ func ParseNTLM(ret []byte) (netbios NetBiosInfo, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
length = num1 + num2*256
|
length = num1 + num2*256
|
||||||
_, err = bytetoint(ret[start+44 : start+45][0])
|
num1, err = bytetoint(ret[start+44 : start+45][0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user