Skip to content

Commit

Permalink
支持ScanMinRTT选项
Browse files Browse the repository at this point in the history
  • Loading branch information
Kisesy committed Jan 2, 2018
1 parent 6eea3e4 commit a3fef97
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
// 注意:
// [扫描并发数] 理论上设置越大扫的越快, 但是并不意味越大就可以扫到更多IP
// 大量的并发数, 会造成网络堵塞, 甚至触到系统网络的限制或造成路由器宕机而出现更多的问题
// 大量的并发, 会造成网络堵塞, 甚至触到系统网络的限制或造成路由器宕机而出现更多的问题
// 所以如果在你那里基本扫不到IP, 可以试着减小扫描并发数并增大超时时间

// 新添了 Level 设置
Expand Down
2 changes: 1 addition & 1 deletion gscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func main() {
log.Printf("All results writed to %s\n", cfg.OutputFile)
}
if Config.EnableBackup {
filename := operation + "_" + time.Now().Format("20060102_150405") + ".txt"
filename := fmt.Sprintf("%s_%s_lv%d.txt", operation, time.Now().Format("20060102_150405"), cfg.Level)
bakfilename := filepath.Join(Config.BackupDir, filename)
if err := ioutil.WriteFile(bakfilename, b.Bytes(), 0644); err != nil {
log.Printf("Failed to write output file:%s for reason:%v\n", bakfilename, err)
Expand Down
10 changes: 6 additions & 4 deletions quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ func testQuic(ip string, config *GScanConfig, record *ScanRecord) bool {
if resp.Body != nil {
defer resp.Body.Close()
// lv4 验证是否是 NoSuchBucket 错误

// 也许条件改为 || 更好
if config.Quic.Level > 3 && resp.Header.Get("Content-Type") == "application/xml; charset=UTF-8" {
if config.Quic.Level > 3 && resp.Header.Get("Content-Type") == "application/xml; charset=UTF-8" { // 也许条件改为 || 更好
body, err := ioutil.ReadAll(resp.Body)
if err != nil || bytes.Equal(body, errNoSuchBucket) {
return false
Expand All @@ -110,6 +108,10 @@ func testQuic(ip string, config *GScanConfig, record *ScanRecord) bool {
}
}

record.RTT = record.RTT + time.Since(start)
rtt := time.Since(start)
if rtt < config.Quic.ScanMinRTT {
return false
}
record.RTT += rtt
return true
}
12 changes: 8 additions & 4 deletions sni.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ func testSni(ip string, config *GScanConfig, record *ScanRecord) bool {
tlscfg := &tls.Config{
InsecureSkipVerify: true,
}
start := time.Now()

for _, serverName := range config.Sni.ServerName {
start := time.Now()
conn, err := net.DialTimeout("tcp", net.JoinHostPort(ip, "443"), config.Sni.ScanMaxRTT)
if err != nil {
return false
Expand Down Expand Up @@ -55,10 +55,14 @@ func testSni(ip string, config *GScanConfig, record *ScanRecord) bool {
return false
}
}

tlsconn.Close()
}

// record.RTT = record.RTT + time.Since(start)/time.Duration(len(config.Sni.ServerName))
record.RTT = record.RTT + time.Duration(int64(time.Since(start))/int64(len(config.Sni.ServerName)))
rtt := time.Since(start)
if rtt < config.Sni.ScanMinRTT {
return false
}
record.RTT += rtt
}
return true
}
6 changes: 5 additions & 1 deletion tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ func testTls(ip string, config *GScanConfig, record *ScanRecord) bool {
resp.Body.Close()
}
}
record.RTT = record.RTT + time.Since(start)
rtt := time.Since(start)
if rtt < config.Tls.ScanMinRTT {
return false
}
record.RTT += rtt
return true
}

0 comments on commit a3fef97

Please sign in to comment.