-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from knownsec/dev
Dev
- Loading branch information
Showing
13 changed files
with
96,469 additions
and
192 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"ksubdomain/core" | ||
"net" | ||
"os" | ||
"time" | ||
) | ||
|
||
func test(options *core.Options) { | ||
sendog := core.SendDog{} | ||
ether := core.GetDevices(options.NetworkId) | ||
ether.DstMac = net.HardwareAddr{0x5c, 0xc9, 0x09, 0x33, 0x34, 0x80} | ||
sendog.Init(ether, []string{"8.8.8.8"}, 404) | ||
defer sendog.Close() | ||
var index int64 = 0 | ||
start := time.Now().UnixNano() / 1e6 | ||
flag := int64(15) // 15s | ||
var now int64 | ||
for { | ||
sendog.Send("seebug.org", "8.8.8.8", 1234, 1) | ||
index++ | ||
now = time.Now().UnixNano() / 1e6 | ||
tickTime := (now - start) / 1000 | ||
if tickTime >= flag { | ||
break | ||
} | ||
if (now-start)%1000 == 0 && now-start >= 900 { | ||
tickIndex := index / tickTime | ||
fmt.Printf("\r %ds 总发送:%d Packet 平均每秒速度:%dpps", tickTime, index, tickIndex) | ||
} | ||
} | ||
now = time.Now().UnixNano() / 1e6 | ||
tickTime := (now - start) / 1000 | ||
tickIndex := index / tickTime | ||
fmt.Printf("\r %ds 总发送:%d Packet 平均每秒速度:%dpps\n", tickTime, index, tickIndex) | ||
} | ||
func main() { | ||
options := core.ParseOptions() | ||
if options.Test { | ||
test(options) | ||
os.Exit(0) | ||
} | ||
core.Start(options) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package core | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
"os" | ||
"strconv" | ||
) | ||
|
||
type Options struct { | ||
Rate int64 | ||
Domain string | ||
FileName string | ||
Resolvers []string | ||
Output string | ||
Test bool | ||
NetworkId int | ||
Silent bool | ||
TTL bool | ||
Verify bool | ||
Stdin bool | ||
Debug bool | ||
} | ||
|
||
// ParseOptions parses the command line flags provided by a user | ||
func ParseOptions() *Options { | ||
ShowBanner() | ||
options := &Options{} | ||
bandwith := flag.String("b", "1M", "宽带的下行速度,可以5M,5K,5G") | ||
flag.StringVar(&options.Domain, "d", "", "爆破域名") | ||
flag.StringVar(&options.FileName, "f", "", "字典路径,-d下文件为子域名字典,-verify下文件为需要验证的域名") | ||
resolvers := flag.String("s", "", "resolvers文件路径,默认使用内置DNS") | ||
flag.StringVar(&options.Output, "o", "", "输出文件路径") | ||
flag.BoolVar(&options.Test, "test", false, "测试本地最大发包数") | ||
flag.IntVar(&options.NetworkId, "e", -1, "默认网络设备ID,默认-1,如果有多个网络设备会在命令行中选择") | ||
flag.BoolVar(&options.Silent, "silent", false, "使用后屏幕将不会输出结果") | ||
flag.BoolVar(&options.TTL, "ttl", false, "导出格式中包含TTL选项") | ||
flag.BoolVar(&options.Verify, "verify", false, "验证模式") | ||
flag.Parse() | ||
options.Stdin = hasStdin() | ||
// handle resolver | ||
if *resolvers != "" { | ||
rs, err := LinesInFile(*resolvers) | ||
if err != nil { | ||
log.Panic(err) | ||
} | ||
options.Resolvers = rs | ||
} else { | ||
defaultDns := []string{"223.5.5.5", "223.6.6.6", "180.76.76.76", "119.29.29.29", "182.254.116.116", "114.114.114.115"} | ||
options.Resolvers = defaultDns | ||
} | ||
var rate int64 | ||
suffix := string([]rune(*bandwith)[len(*bandwith)-1]) | ||
rate, _ = strconv.ParseInt(string([]rune(*bandwith)[0:len(*bandwith)-1]), 10, 64) | ||
switch suffix { | ||
case "G": | ||
fallthrough | ||
case "g": | ||
rate *= 1000000000 | ||
case "M": | ||
fallthrough | ||
case "m": | ||
rate *= 1000000 | ||
case "K": | ||
fallthrough | ||
case "k": | ||
rate *= 1000 | ||
default: | ||
fmt.Printf("unknown bandwith suffix '%s' (supported suffixes are G,M and K)\n", suffix) | ||
} | ||
packSize := int64(100) // 一个DNS包大概有74byte | ||
rate = rate / packSize | ||
options.Rate = rate | ||
if options.Domain == "" && !hasStdin() && (!options.Verify && options.FileName == "") && !options.Test { | ||
flag.Usage() | ||
os.Exit(0) | ||
} | ||
if options.FileName != "" && !FileExists(options.FileName) { | ||
fmt.Printf("文件:%s不存在!\n", options.FileName) | ||
os.Exit(0) | ||
} | ||
return options | ||
} | ||
func hasStdin() bool { | ||
fi, err := os.Stdin.Stat() | ||
if err != nil { | ||
return false | ||
} | ||
if fi.Mode()&os.ModeNamedPipe == 0 { | ||
return false | ||
} | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.