Skip to content

Commit c96db17

Browse files
authored
Merge pull request #5 from knownsec/dev
v0.3 dev
2 parents 03df32e + 2d6d4b2 commit c96db17

File tree

6 files changed

+27
-96126
lines changed

6 files changed

+27
-96126
lines changed

cmd/ksubdomain.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func test(options *core.Options) {
1212
sendog := core.SendDog{}
1313
ether := core.GetDevices(options)
1414
ether.DstMac = net.HardwareAddr{0x5c, 0xc9, 0x09, 0x33, 0x34, 0x80}
15-
sendog.Init(ether, []string{"8.8.8.8"}, 404)
15+
sendog.Init(ether, []string{"8.8.8.8"}, 404, false)
1616
defer sendog.Close()
1717
var index int64 = 0
1818
start := time.Now().UnixNano() / 1e6

core/banner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"ksubdomain/gologger"
55
)
66

7-
const Version = "0.2.1"
7+
const Version = "0.3"
88
const banner = `
99
_ __ _____ _ _ _
1010
| |/ / / ____| | | | | (_)

core/recv.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ func Recv(device string, options *Options, flagID uint16, retryChan chan RetrySt
2020
timeout time.Duration = -1 * time.Second
2121
)
2222
windowWith := GetWindowWith()
23+
if options.Silent {
24+
windowWith = 0
25+
}
2326
handle, _ := pcap.OpenLive(device, snapshotLen, promiscuous, timeout)
2427
err := handle.SetBPFFilter("udp and port 53")
2528
if err != nil {
@@ -98,12 +101,14 @@ func Recv(device string, options *Options, flagID uint16, retryChan chan RetrySt
98101
for _, v := range dns.Questions {
99102
msg += string(v.Name) + " => "
100103
}
101-
for _, v := range dns.Answers {
102-
msg += v.String()
103-
if isttl {
104-
msg += " ttl:" + strconv.Itoa(int(v.TTL))
104+
if !options.Silent {
105+
for _, v := range dns.Answers {
106+
msg += v.String()
107+
if isttl {
108+
msg += " ttl:" + strconv.Itoa(int(v.TTL))
109+
}
110+
msg += " => "
105111
}
106-
msg += " => "
107112
}
108113
msg = strings.Trim(msg, " => ")
109114
ff := windowWith - len(msg) - 1

core/send.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ type SendDog struct {
2121
increate_index bool // 是否使用index自增
2222
flagID uint16 // dnsid 前3位
2323
flagID2 uint16 // dnsid 后2位
24+
printStatus bool
2425
}
2526

26-
func (d *SendDog) Init(ether EthTable, dns []string, flagID uint16) {
27+
func (d *SendDog) Init(ether EthTable, dns []string, flagID uint16, printStatus bool) {
2728
d.ether = ether
2829
d.dns = dns
2930
d.flagID = flagID
@@ -41,6 +42,7 @@ func (d *SendDog) Init(ether EthTable, dns []string, flagID uint16) {
4142
d.index = 10000
4243
d.increate_index = true
4344
d.lock = &sync.RWMutex{}
45+
d.printStatus = printStatus
4446
//defer d.handle.Close()
4547
}
4648
func (d *SendDog) Lock() {
@@ -157,7 +159,9 @@ func (d *SendDog) Send(domain string, dnsname string, srcport uint16, flagid uin
157159
gologger.Warningf("WritePacketDate error:%s\n", err.Error())
158160
}
159161
atomic.AddUint64(&SentIndex, 1)
160-
PrintStatus()
162+
if d.printStatus {
163+
PrintStatus()
164+
}
161165
}
162166
func (d *SendDog) Close() {
163167
d.handle.Close()

core/start.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func Start(options *Options) {
2727
retryChan := make(chan RetryStruct, options.Rate)
2828
go Recv(ether.Device, options, flagID, retryChan)
2929
sendog := SendDog{}
30-
sendog.Init(ether, options.Resolvers, flagID)
30+
sendog.Init(ether, options.Resolvers, flagID, true)
3131

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

0 commit comments

Comments
 (0)