forked from hakluke/haktrails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
historicaldns.go
33 lines (29 loc) · 881 Bytes
/
historicaldns.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
package main
import (
"encoding/json"
"fmt"
"strconv"
"sync"
)
func historicaldns(work chan string, wg *sync.WaitGroup, lookupType string) {
defer wg.Done()
for text := range work {
printAllPagesHistoricalDNS(text, lookupType)
}
}
func printAllPagesHistoricalDNS(domain string, lookupType string) {
response := getResponse("GET", "history/"+domain+"/dns/"+lookupType, "")
var results map[string]interface{}
json.Unmarshal([]byte(response), &results)
maxPage, ok := results["pages"].(float64) // total number of pages
if !ok { // response is rong
fmt.Println(response)
return
}
fmt.Println(response) // print the first page
// now print all the other pages
for i := 2; i <= int(maxPage); i++ {
response = getResponse("GET", "history/"+domain+"/dns/"+lookupType+"/?page="+strconv.Itoa(i), "")
fmt.Println(response)
}
}