-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcopy_request_clj.tpl
59 lines (55 loc) · 1.78 KB
/
copy_request_clj.tpl
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
{% if common_code -%}
(require '[clj-http.client :as client])
(require '[clj-http.cookies :as cookies])
(import org.apache.http.impl.cookie.BasicClientCookie2)
(defn new-cookie
[name value domain]
(let [c (cookies/to-basic-client-cookie
[name
{:discard false
:domain domain
:path "/"
:secure false,
:expires nil
:value value}])]
(.setAttribute c BasicClientCookie2/DOMAIN_ATTR "true")
c))
(def my-cs (clj-http.cookies/cookie-store))
(def my-proxy {:proxy-host "localhost"
:proxy-port 8080})
(def use-proxy false)
(def common-opts (merge {:insecure? true
:cookie-policy :standard
:throw-exceptions false}
(when use-proxy
my-proxy)))
{% endif %}
{%- for info in items %}
{%- for c in info.cookies %}
(cookies/add-cookie my-cs (new-cookie {{ c.k }} {{ c.v }} {{ c.domain }}))
{%- endfor %}
(def burp{{ info.id }}-url "{{ info.url }}")
(def burp{{ info.id }}-headers {
{%- for hdr in info.headers -%}
{{ hdr[0] }} {{ hdr[1] }}
{% endfor %}})
(def burp{{ info.id }}
(client/request
(merge
common-opts
{:method {{ info.method }}
:url burp{{ info.id }}-url
:headers burp{{ info.id }}-headers
{%- if info.body -%}
{%- if info.content_type == "application/json" %}
:content-type :json
:form-params {{ info.body|ppstr }}
{%- elif info.content_type == "application/x-www-form-urlencoded" %}
:form-params {{ info.body }}
{%- else %}
:body (-> "{{ info.body }}"
(.getBytes "ISO-8859-1"))
{%- endif %}
{%- endif %}
:cookie-store my-cs})))
{% endfor -%}