forked from gitbrew/gawk-stealth
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gawk_get.gawk
59 lines (50 loc) · 1.19 KB
/
gawk_get.gawk
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
#!/usr/bin/gawk -f
#
# gawk_get
# iadnah 2011
#
# gawk_get makes an HTTP request (no https) and dumps the raw output
#
# Config variables:
# VHOST : where to connect to; site to request
# USERAGENT : specify a custom user agent
# PORT : port to connect to; default is 80
# HEADERS : any extra HTTP headers to send
# FILE : url path to request; default is /
#
BEGIN {
if (VHOST == "")
if ( length(ENVIRON["VHOST"]) > 0 ) {
VHOST=ENVIRON["VHOST"]
} else {
VHOST="www.something.com"
}
if (PORT == "")
if ( length(ENVIRON["PORT"]) > 0 ) {
PORT=ENVIRON["PORT"]
} else {
PORT=80
}
if (FILE == "")
if ( length(ENVIRON["FILE"]) > 0 ) {
FILE=ENVIRON["FILE"]
} else {
FILE="/"
}
if (HEADERS == "")
if ( length(ENVIRON["HEADERS"]) > 0 ) {
HEADERS=ENVIRON["HEADERS"]
}
if (USERAGENT == "")
if ( length(ENVIRON["USERAGENT"]) > 0 ) {
USERAGENT=ENVIRON["USERAGENT"]
} else {
USERAGENT="Gawkget (0.0.1/iadnah)"
}
NetService="/inet/tcp/0/" VHOST "/" PORT
REQUEST="GET " FILE " HTTP/1.0\r\nHost: " VHOST "\r\nUser-Agent: " USERAGENT "\r\n" HEADERS "\r\n\r\n"
print REQUEST |& NetService
while ((NetService |& getline) > 0)
print $0
close(NetService)
}