-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathworker.go
50 lines (48 loc) · 1.26 KB
/
worker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package peepingJim
import (
"fmt"
"log"
"net/url"
"strings"
)
//Worker thread performs all the scanning
func (client *Client) Worker(queue chan string, db *[]map[string]string) {
for {
target := <-queue
if target == "" {
break
}
if client.Verbose {
fmt.Printf("Scanning %s\n", target)
} else {
fmt.Printf(".")
}
//Cleaning URL so we can write to a file
targetFixed := reg.ReplaceAllString(target, "")
targetFixed = strings.TrimSuffix(targetFixed, "/")
u, err := url.Parse(target)
if err != nil {
log.Println(err)
continue
}
imgName := fmt.Sprintf("%s.png", targetFixed)
srcName := fmt.Sprintf("%s.txt", targetFixed)
imgPath := fmt.Sprintf("%s/%s", client.Output, imgName)
srcPath := fmt.Sprintf("%s/%s", client.Output, srcName)
//Making a channel to store curl output to
c := make(chan string)
go getHeader(u, srcPath, client.TimeOut, c)
if err := client.takeScreenshot(u, imgPath); err != nil {
log.Println(err)
}
//Writing output to a hash map and appending it to an array
targetData := make(map[string]string)
targetData["url"] = target
targetData["imgPath"] = imgName
targetData["srcPath"] = srcName
targetData["headers"] = <-c
client.Sync.Lock()
*db = append(*db, targetData)
client.Sync.Unlock()
}
}