Skip to content

Commit

Permalink
Merge pull request #5 from knownsec/dev
Browse files Browse the repository at this point in the history
v0.3 dev
  • Loading branch information
boy-hack authored Sep 2, 2020
2 parents 03df32e + 2d6d4b2 commit c96db17
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 96,126 deletions.
2 changes: 1 addition & 1 deletion cmd/ksubdomain.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func test(options *core.Options) {
sendog := core.SendDog{}
ether := core.GetDevices(options)
ether.DstMac = net.HardwareAddr{0x5c, 0xc9, 0x09, 0x33, 0x34, 0x80}
sendog.Init(ether, []string{"8.8.8.8"}, 404)
sendog.Init(ether, []string{"8.8.8.8"}, 404, false)
defer sendog.Close()
var index int64 = 0
start := time.Now().UnixNano() / 1e6
Expand Down
2 changes: 1 addition & 1 deletion core/banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"ksubdomain/gologger"
)

const Version = "0.2.1"
const Version = "0.3"
const banner = `
_ __ _____ _ _ _
| |/ / / ____| | | | | (_)
Expand Down
15 changes: 10 additions & 5 deletions core/recv.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ func Recv(device string, options *Options, flagID uint16, retryChan chan RetrySt
timeout time.Duration = -1 * time.Second
)
windowWith := GetWindowWith()
if options.Silent {
windowWith = 0
}
handle, _ := pcap.OpenLive(device, snapshotLen, promiscuous, timeout)
err := handle.SetBPFFilter("udp and port 53")
if err != nil {
Expand Down Expand Up @@ -98,12 +101,14 @@ func Recv(device string, options *Options, flagID uint16, retryChan chan RetrySt
for _, v := range dns.Questions {
msg += string(v.Name) + " => "
}
for _, v := range dns.Answers {
msg += v.String()
if isttl {
msg += " ttl:" + strconv.Itoa(int(v.TTL))
if !options.Silent {
for _, v := range dns.Answers {
msg += v.String()
if isttl {
msg += " ttl:" + strconv.Itoa(int(v.TTL))
}
msg += " => "
}
msg += " => "
}
msg = strings.Trim(msg, " => ")
ff := windowWith - len(msg) - 1
Expand Down
8 changes: 6 additions & 2 deletions core/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ type SendDog struct {
increate_index bool // 是否使用index自增
flagID uint16 // dnsid 前3位
flagID2 uint16 // dnsid 后2位
printStatus bool
}

func (d *SendDog) Init(ether EthTable, dns []string, flagID uint16) {
func (d *SendDog) Init(ether EthTable, dns []string, flagID uint16, printStatus bool) {
d.ether = ether
d.dns = dns
d.flagID = flagID
Expand All @@ -41,6 +42,7 @@ func (d *SendDog) Init(ether EthTable, dns []string, flagID uint16) {
d.index = 10000
d.increate_index = true
d.lock = &sync.RWMutex{}
d.printStatus = printStatus
//defer d.handle.Close()
}
func (d *SendDog) Lock() {
Expand Down Expand Up @@ -157,7 +159,9 @@ func (d *SendDog) Send(domain string, dnsname string, srcport uint16, flagid uin
gologger.Warningf("WritePacketDate error:%s\n", err.Error())
}
atomic.AddUint64(&SentIndex, 1)
PrintStatus()
if d.printStatus {
PrintStatus()
}
}
func (d *SendDog) Close() {
d.handle.Close()
Expand Down
4 changes: 2 additions & 2 deletions core/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func Start(options *Options) {
retryChan := make(chan RetryStruct, options.Rate)
go Recv(ether.Device, options, flagID, retryChan)
sendog := SendDog{}
sendog.Init(ether, options.Resolvers, flagID)
sendog.Init(ether, options.Resolvers, flagID, true)

var f io.Reader
// handle Stdin
Expand All @@ -47,7 +47,7 @@ func Start(options *Options) {
if len(options.Domain) > 0 {
if options.FileName == "" {
gologger.Infof("加载内置字典\n")
f = strings.NewReader(DefaultSubdomain)
f = strings.NewReader(GetSubdomainData())
} else {
f2, err := os.Open(options.FileName)
defer f2.Close()
Expand Down
Loading

0 comments on commit c96db17

Please sign in to comment.