Projects STRLCPY afrog Commits 554ae3ff
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    cmd/api/main.go
    skipped 43 lines
    44 44   // 扫描进度实时显示
    45 45   fmt.Printf("\r%d/%d | %d%% ", options.CurrentCount, options.Count, options.CurrentCount*100/options.Count)
    46 46   })
     47 + 
    47 48   if err != nil {
    48 49   fmt.Println(err)
    49 50   }
    skipped 2 lines
  • ■ ■ ■ ■ ■
    cmd/title/main.go
    skipped 1 lines
    2 2   
    3 3  import (
    4 4   "fmt"
    5  - "math/rand"
    6 5   "net/http"
    7 6   "regexp"
    8  - "time"
     7 + "strconv"
    9 8   "unicode/utf8"
    10 9   
    11 10   "github.com/axgle/mahonia"
    skipped 9 lines
    21 20  )
    22 21   
    23 22  func main() {
     23 + // for i := 1; i < 255; i++ {
     24 + // ip1 := "192.168.66." + strconv.Itoa(i)
     25 + // fmt.Println(ip1)
     26 + // }
     27 + 
     28 + // return
    24 29   urls, err := utils.ReadFileLineByLine("./test2.txt")
    25 30   if err != nil {
    26 31   fmt.Println("urls is empty.")
    skipped 7 lines
    34 39   options.Config = config
    35 40   http2.Init(options)
    36 41   
    37  - rand.Seed(time.Now().UnixNano())
     42 + // rand.Seed(time.Now().UnixNano())
    38 43   
    39  - // Typical use-case:
    40  - // 50 queries must be executed as quick as possible
    41  - // but without overloading the database, so only
    42  - // 8 routines should be started concurrently.
    43  - swg := sizedwaitgroup.New(20)
     44 + swg := sizedwaitgroup.New(50)
    44 45   for _, url := range urls {
    45 46   swg.Add()
    46 47   go func(url string) {
    47 48   defer swg.Done()
    48  - title(url)
     49 + ipscan(url)
    49 50   }(url)
    50 51   }
    51 52   
    skipped 1 lines
    53 54   
    54 55  }
    55 56   
    56  -func title(url string) {
     57 +func ipscan(url string) {
     58 + // Typical use-case:
     59 + // 50 queries must be executed as quick as possible
     60 + // but without overloading the database, so only
     61 + // 8 routines should be started concurrently.
     62 + portSlice := []int{80, 443, 8080, 7001}
     63 + swg := sizedwaitgroup.New(500)
     64 + // for i := 1; i < 65535; i++ {
     65 + for _, i := range portSlice {
     66 + swg.Add()
     67 + go func(url string, i int) {
     68 + defer swg.Done()
     69 + err := title(url, i, 0)
     70 + if err != nil {
     71 + title(url, i, 1)
     72 + }
     73 + }(url, i)
     74 + }
     75 + 
     76 + swg.Wait()
     77 +}
     78 + 
     79 +func title(url string, port, https int) error {
     80 + if https == 0 {
     81 + url = "http://" + url + ":" + strconv.Itoa(port)
     82 + } else {
     83 + url = "https://" + url + ":" + strconv.Itoa(port)
     84 + }
    57 85   req, err := http.NewRequest("GET", url, nil)
    58 86   if err != nil {
    59  - //fmt.Println("NewRequest", url, err.Error())
    60  - return
     87 + return err
    61 88   }
    62 89   resp, status, err := http2.GetTitleRedirect(req, 3)
    63 90   if err != nil {
    64  - //fmt.Println("FastRequest", url, resp, err.Error())
    65  - return
     91 + return err
     92 + }
     93 + if status < 200 || (status >= 300 && status < 400) || status >= 600 {
     94 + return err
    66 95   }
    67 96   titleArr := pTitle.FindStringSubmatch(string(resp))
    68 97   if titleArr != nil {
    skipped 7 lines
    76 105   } else {
    77 106   fmt.Println(url, status)
    78 107   }
     108 + return nil
    79 109  }
    80 110   
  • ■ ■ ■ ■
    cmd/workgroup/main.go
    skipped 15 lines
    16 16   // but without overloading the database, so only
    17 17   // 8 routines should be started concurrently.
    18 18   swg := sizedwaitgroup.New(8)
    19  - for i := 0; i < 50; i++ {
     19 + for i := 1; i < 65535; i++ {
    20 20   swg.Add()
    21 21   go func(i int) {
    22 22   defer swg.Done()
    skipped 13 lines
Please wait...
Page is in error, reload to recover