Guest User

Untitled

a guest
Jun 12th, 2020
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. func Check(line string) {
  2. req, err := http.NewRequest("GET", "https://"+line , nil)
  3. if err != nil {
  4. return
  5. }
  6. req.Close = true
  7.  
  8. resp, err := client.Do(req)
  9. if err != nil {
  10. fmt.Println(err)
  11. return
  12. }
  13. defer resp.Body.Close()
  14.  
  15. if resp.StatusCode == http.StatusOK {
  16. bodyBytes, err := ioutil.ReadAll(resp.Body)
  17. if err != nil {
  18. return
  19. }
  20.  
  21. if strings.Contains(string(bodyBytes), "word") {
  22. good++
  23. fmt.Printf("Scanned: %d, Good: %d\n", targetsComplete, good)
  24. }
  25. }
  26. }
  27.  
  28. func CheckingThread(ch chan string) {
  29. wg.Add(1)
  30. defer func() { wg.Done() }()
  31.  
  32. for {
  33. if targetsComplete == targetsTotal {
  34. return
  35. }
  36.  
  37. line := <-ch
  38. targetsComplete++
  39. Check(line)
  40. }
  41. }
  42.  
  43. func main() {
  44. t0 := time.Now()
  45. targets := config.Targets()
  46. targetsTotal = len(targets)
  47. fmt.Println("Total targets: ", targetsTotal)
  48.  
  49. ch := make(chan string, len(targets))
  50. for _, target := range targets {
  51. ch <- target
  52. }
  53.  
  54. client = &http.Client{
  55. Timeout: 5 * time.Second,
  56. Transport: &http.Transport{
  57. TLSClientConfig: &tls.Config{
  58. InsecureSkipVerify: true,
  59. },
  60. },
  61. }
  62.  
  63. for i := 0; i < cfg.Threads; i++ {
  64. go CheckingThread(ch)
  65. }
  66.  
  67. wg.Wait()
  68.  
  69. fmt.Println("Good: ", good)
  70. t1 := time.Now()
  71. fmt.Printf("Elapsed time: %v", t1.Sub(t0))
  72. }
Add Comment
Please, Sign In to add comment