-
Notifications
You must be signed in to change notification settings - Fork 24
/
http.cna
46 lines (34 loc) · 1.07 KB
/
http.cna
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
# http.cna
# utilities for http requests from Aggressor scripts
# 001SPARTaN
sub http_get {
local('$output');
$url = [new java.net.URL: $1];
$stream = [$url openStream];
$handle = [SleepUtils getIOHandle: $stream, $null];
@content = readAll($handle);
foreach $line (@content) {
$output .= $line . "\r\n";
}
println($output);
}
http_get("https://ipinfo.io/json");
sub http_post {
local('$output');
$url = [new java.net.URL: $1];
$conn = [$url openConnection];
[$conn setDoOutput: true];
$payload = "testing";
println("Payload: $payload");
println("Content-Length: " . strlen($payload));
[$conn setRequestProperty: "Content-Length", strlen($payload)];
[$conn setRequestProperty: "Content-Type", "text/plain"];
$handle = [SleepUtils getIOHandle: [$conn getInputStream], [$conn getOutputStream]];
println($handle, $payload);
@content = readAll($handle);
foreach $line (@content) {
$output .= $line . "\r\n";
}
println($output);
}
http_post("http://localhost/test?param=param1");