forked from gitbrew/gawk-stealth
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgawk_http_bnc.gawk
76 lines (65 loc) · 1.57 KB
/
gawk_http_bnc.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/gawk -f
#
# gawk_http_bnc
# iadnah 2011
#
# gawk_http_bnc listens on a given port and whenever a client connects
# it performs an HTTP request as configured and sends the raw output
# to the client
#
# 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 /
#
# LPORT : port to listen on; default is 8888
#
BEGIN {
if (LPORT == "")
if ( length(ENVIRON["LPORT"]) > 0 ) {
LPORT=ENVIRON["LPORT"]
} else {
LPORT=8888
}
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)"
}
while (1 == 1) {
ListenService="/inet/tcp/" LPORT "/0/0"
ListenService |& getline
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 |& ListenService
close(NetService)
close(ListenService)
}
}