-
Notifications
You must be signed in to change notification settings - Fork 1
/
analyze.go
60 lines (55 loc) · 1.45 KB
/
analyze.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
51
52
53
54
55
56
57
58
59
60
package pulsedive
import (
"crypto/tls"
"encoding/base64"
// "encoding/json"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
"time"
)
// Analyze adding to the Queue for Analyze
func Analyze(ioc string) ([]byte, error) {
iocEnc := base64.StdEncoding.EncodeToString([]byte(ioc))
data := url.Values{}
data.Set("ioc", iocEnc)
data.Set("enrich", "1")
data.Set("probe", "1")
data.Set("pretty", "1")
data.Set("key", apiKey)
req, err := http.NewRequest("POST", "https://pulsedive.com/api/analyze.php", strings.NewReader(data.Encode()))
if err != nil {
return nil, err
}
req.Header.Add("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
req.Header.Add("Content-Length", strconv.Itoa(len(data.Encode())))
trt := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
MaxIdleConns: 10,
IdleConnTimeout: 30 * time.Second,
DisableCompression: true,
}
client := &http.Client{Transport: trt}
resp, err := client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
resBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
// var results PDAResponse
// json.Unmarshal(resBody, &results)
return resBody, nil
}
// AnalyzeResult get result from Analyze Retrieving the Results api
func AnalyzeResult(qid int) ([]byte, error) {
q := url.Values{}
q.Add("pretty", pretty)
q.Add("key", apiKey)
q.Add("qid", strconv.Itoa(qid))
return Get(q.Encode(), "/analyze.php")
}