Advertisement
Neonprimetime

2018-11-30 updated python script

Nov 30th, 2018
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. from urllib.request import urlopen
  2. from urllib.request import urlretrieve
  3. import re
  4. import sys
  5. import os
  6. filepath = 'urls.txt'
  7. with open(filepath) as fp:
  8. theurl = fp.readline()
  9. while theurl:
  10. if(not theurl.startswith('http')):
  11. if(":443" in theurl):
  12. theurl = 'https://' + theurl.strip()
  13. else:
  14. theurl = 'http://' + theurl.strip()
  15. theurl = theurl.strip()
  16. if(theurl.endswith("/") or theurl.endswith("\\")):
  17. theurl = theurl[:-1]
  18. stopnow = 0
  19. while stopnow == 0:
  20. try:
  21. domain = theurl.split("//")[-1].split("/")[0]
  22. currentfolder = theurl.split("/")[-1]
  23. try:
  24. if not theurl.endswith(".zip") and (len(theurl.split("//")[-1].split("/")) > 1):
  25. zipfile = domain + "___" + currentfolder + ".zip"
  26. phishkit = theurl + ".zip"
  27. urlretrieve(phishkit, zipfile)
  28. print("phishkit," + phishkit)
  29. except Exception as e:
  30. print("failedphishkit," + phishkit + "(" + str(e) + ")")
  31. html = urlopen(theurl, timeout=3)
  32. val = html.read()
  33. titles = re.findall(r'(?i)<title>(.*?)</title>',str(val))
  34. if len(titles) > 0:
  35. if titles[0].startswith('Index of'):
  36. print("opendir," + theurl + "(" + titles[0] + ")")
  37. zipfiles = re.findall(r'(?i)href\=\"[^\"]+\.zip\"\>',str(val))
  38. if len(zipfiles) > 0:
  39. for zipfile in zipfiles:
  40. zipfile = zipfile.replace('\"', '').replace('href=', '').replace('>','').replace("&amp;", "&")
  41. if theurl.endswith('/'):
  42. phishkit = theurl + zipfile
  43. else:
  44. phishkit = theurl + "/" + zipfile
  45. try:
  46. zipfile = domain + "___" + zipfile
  47. urlretrieve(phishkit, zipfile)
  48. print("phishkit," + phishkit)
  49. except Exception as e:
  50. print("failedphishkit," + phishkit + "(" + str(e) + ")")
  51. exefiles = re.findall(r'(?i)href\=\"[^\"]+\.exe\"\>',str(val))
  52. if len(exefiles) > 0:
  53. for exefile in exefiles:
  54. exefile = exefile.replace('\"', '').replace('href=', '').replace('>','').replace("&amp;", "&")
  55. if theurl.endswith('/'):
  56. malware = theurl + exefile
  57. else:
  58. malware = theurl + "/" + exefile
  59. try:
  60. urlretrieve(malware, exefile)
  61. print("malware," + malware)
  62. except Exception as e:
  63. print("failedmalware," + malware + "(" + str(e) + ")")
  64. panels = re.findall(r'(?i)href\=\"(panel|webpanel|fre\.php)\"\>',str(val))
  65. if len(panels) > 0:
  66. for panel in panels:
  67. panel = panel.replace('\"', '').replace('href=' ,'').replace('>', '').replace("&amp;", "&")
  68. if theurl.endswith('/'):
  69. panelurl = theurl + panel
  70. else:
  71. panelurl = theurl + "/" + panel
  72. print("panel," + panelurl)
  73. else:
  74. print("webpage," + theurl + "(" + titles[0] + ")")
  75. theurl = re.sub(r'\/[^\/]*$', '', theurl)
  76. if theurl.endswith('http:/') or theurl.endswith('https:/'):
  77. stopnow = 1
  78. except Exception as e:
  79. if "no host given" in str(e):
  80. stopnow = 1
  81. else:
  82. print("failedurl," + theurl + "(" + str(e) + ")")
  83. theurl = re.sub(r'\/[^\/]*$', '', theurl)
  84. theurl = fp.readline()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement