-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdirb.go
48 lines (42 loc) · 849 Bytes
/
dirb.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
package main
import (
"bufio"
"fmt"
"net/http"
"os"
)
func handleError(err error) {
if err != nil {
fmt.Println("Error Found: ", err)
}
}
func scanLines(filename string) ([]string, error) {
file, err := os.Open(filename)
handleError(err)
defer file.Close()
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
var lines []string
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
return lines, nil
}
func Tester() {
filename := os.Args[1]
url := os.Args[2]
words, err := scanLines(filename)
handleError(err)
for i := 0; i < len(words); i++ {
req, err1 := http.Get(url + "/" + words[i])
handleError(err1)
defer req.Body.Close()
fmt.Println("Test: ", url+"/"+words[i], "\t\tStatus", req.StatusCode)
if i == len(words) {
fmt.Println("All Urls tested")
}
}
}
func main() {
Tester()
}