Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Launch ettercap like this: (run in same directory as shepherd)
- # sudo ettercap -Tq -d >> etter.log
- import threading, json, logging, time
- from src.comms import Communication
- from src.lib import log
- from src.webserver import HTTPServer
- from honeypot import Honeypot
- class Shepherd:
- def __init__(self):
- self.client_threads = []
- self.clients = []
- self.wall_of_sheep = []
- def banner(self):
- print()
- print(" _ _ _ _ ___ ")
- print(" ___| |__ ___ _ __ | |__ ___ _ __ __| | __ _/ | / _ \ ")
- print(" / __| '_ \ / _ \ '_ \| '_ \ / _ \ '__/ _` | \ \ / / || | | |")
- print(" \__ \ | | | __/ |_) | | | | __/ | | (_| | \ V /| || |_| |")
- print(" |___/_| |_|\___| .__/|_| |_|\___|_| \__,_| \_/ |_( )___/ ")
- print(" - Web based - |_| - Deep packet inspection tool - |/ ")
- print()
- def main(self):
- self.banner()
- logging.getLogger('WS-Server').setLevel(logging.CRITICAL)
- logging.getLogger('Communication').setLevel(logging.CRITICAL)
- #logging.getLogger('WS-Server').setLevel(logging.DEBUG)
- t = threading.Thread(target = EttercapParser, args = (self,))
- t.start()
- t = threading.Thread(target = Honeypot, args = (self,))
- t.start()
- listen_address = "127.0.0.1"
- listen_port = 5555
- self.Server = Communication()
- self.Server.start(listen_address, listen_port)
- print("Websocket server listening on port %d..." % listen_port)
- print()
- #starts web server:
- t = threading.Thread(target = HTTPServer, args = (8080,))
- t.start()
- while 1:
- sock = self.Server.accept()
- if not sock: break
- t = threading.Thread(target = Client, args = (sock, self))
- self.client_threads.append(t)
- t.start()
- class Client(threading.Thread):
- def __init__(self, Socket, Shepherd):
- threading.Thread.__init__(self)
- Shepherd.clients.append(self)
- self.Socket = Socket
- self.Shepherd = Shepherd
- self.ettercap_feed = None
- print("WebSocket Client connected from %s" % self.Socket.remote_address)
- self.handle()
- def handle(self):
- while 1:
- obj = self.Socket.recv()
- data = obj.data
- if data['type'] == 'close': break
- if data['type'] == "get_sheep":
- obj.send(self.Shepherd.wall_of_sheep)
- if data['type'] == "start_ettercap_feed":
- self.ettercap_feed = obj
- if data['type'] == "stop_ettercap_feed":
- self.ettercap_feed = None
- print("WebSocket Client disconnected!")
- class EttercapParser(threading.Thread):
- def __init__(self, Shepherd):
- threading.Thread.__init__(self)
- self.Shepherd = Shepherd
- self.parse("etter.log")
- def parse(self, file):
- print("Ettercap parser started!")
- with open(file, "r") as f:
- lines = f.readlines()
- for line in lines:
- #print(line, end="")
- self.parse_line(line)
- while 1:
- lines = f.readlines()
- if lines:
- for line in lines:
- #print(line, end="")
- self.parse_line(line)
- time.sleep(0.1)
- def parse_line(self, line):
- if line.startswith("HTTP"):
- self.parse_HTTP_cred(line)
- def parse_HTTP_cred(self, line):
- #HTTP : 162.13.83.46:80 -> USER: cats PASS: secretpass INFO: http://www.copyscape.com/login.php
- i = 7
- line = line[7:]
- i = line.find(" ")
- ip = line[:i]
- line = line[i:]
- line = line[10:]
- i = line.find(" ")
- user = line[:i]
- line = line[i:]
- line = line[8:]
- i = line.find(" ")
- password = line[:i]
- line = line[i:]
- line = line[8:]
- i = line.find("\n")
- info = line[:i]
- if len(info) >= 40:
- info = info[:40] + "..."5
- if not password: return
- data = {
- 'protocol': "HTTP",
- 'login': user,
- 'password': password,
- 'ip': ip,
- 'info': info
- }
- self.Shepherd.wall_of_sheep.append(data)
- self.notify_clients(data)
- def notify_clients(self, data):
- for client in self.Shepherd.clients:
- if client.ettercap_feed:
- client.ettercap_feed.send(data)
- herd = Shepherd()
- try:
- herd.main()
- except KeyboardInterrupt:
- pass
- print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement