From 078d4052e5b2543b2485556ea02f58bc395753ec Mon Sep 17 00:00:00 2001 From: Hubble Date: Tue, 22 Oct 2019 00:09:22 -0400 Subject: [PATCH 01/57] python 3 stage one updates --- data/agent/agent.py | 19 +- data/agent/stagers/common/diffiehellman.py | 1 + data/agent/stagers/common/rc4.py | 5 +- data/misc/inactive_modules/redirector.py | 7 +- .../python/management/socks-src.py | 2 +- empire | 21 +- lib/common/__init__.py | 8 +- lib/common/agents.py | 42 +- lib/common/bypasses.py | 3 +- lib/common/credentials.py | 10 +- lib/common/empire.py | 406 ++--- lib/common/encryption.py | 1 + lib/common/helpers.py | 21 +- lib/common/http.py | 5 +- lib/common/listeners.py | 50 +- lib/common/messages.py | 186 +- lib/common/modules.py | 10 +- lib/common/packets.py | 3 +- lib/common/plugins.py | 1 + lib/common/pylnk.py | 1579 +++++++++-------- lib/common/stagers.py | 28 +- lib/listeners/dbx.py | 27 +- lib/listeners/http.py | 33 +- lib/listeners/http_com.py | 29 +- lib/listeners/http_foreign.py | 19 +- lib/listeners/http_hop.py | 23 +- lib/listeners/http_mapi.py | 29 +- lib/listeners/meterpreter.py | 17 +- lib/listeners/onedrive.py | 53 +- lib/listeners/redirector.py | 41 +- lib/listeners/template.py | 19 +- .../exfiltration/Invoke_ExfilDataToGitHub.py | 3 +- lib/modules/external/generate_agent.py | 11 +- .../code_execution/invoke_dllinjection.py | 3 +- .../invoke_metasploitpayload.py | 3 +- .../powershell/code_execution/invoke_ntsd.py | 7 +- .../invoke_reflectivepeinjection.py | 7 +- .../code_execution/invoke_shellcode.py | 5 +- .../code_execution/invoke_shellcodemsil.py | 3 +- .../powershell/collection/ChromeDump.py | 3 +- lib/modules/powershell/collection/FoxDump.py | 3 +- .../powershell/collection/USBKeylogger.py | 3 +- .../powershell/collection/browser_data.py | 3 +- .../collection/clipboard_monitor.py | 3 +- .../powershell/collection/file_finder.py | 3 +- .../collection/find_interesting_file.py | 3 +- .../powershell/collection/get-winupdates.py | 5 +- .../powershell/collection/get_indexed_item.py | 3 +- .../collection/get_sql_column_sample_data.py | 5 +- .../powershell/collection/get_sql_query.py | 3 +- lib/modules/powershell/collection/inveigh.py | 3 +- .../powershell/collection/keylogger.py | 3 +- lib/modules/powershell/collection/minidump.py | 3 +- .../powershell/collection/netripper.py | 3 +- .../powershell/collection/ninjacopy.py | 3 +- lib/modules/powershell/collection/toasted.py | 3 +- .../vaults/add_keepass_config_trigger.py | 3 +- .../collection/vaults/find_keepass_config.py | 3 +- .../vaults/get_keepass_config_trigger.py | 3 +- .../powershell/collection/vaults/keethief.py | 3 +- .../vaults/remove_keepass_config_trigger.py | 3 +- .../credentials/credential_injection.py | 11 +- .../powershell/credentials/enum_cred_store.py | 3 +- .../credentials/invoke_kerberoast.py | 3 +- .../powershell/credentials/mimikatz/cache.py | 3 +- .../powershell/credentials/mimikatz/certs.py | 3 +- .../credentials/mimikatz/command.py | 3 +- .../powershell/credentials/mimikatz/dcsync.py | 3 +- .../credentials/mimikatz/dcsync_hashdump.py | 3 +- .../credentials/mimikatz/extract_tickets.py | 3 +- .../credentials/mimikatz/golden_ticket.py | 9 +- .../powershell/credentials/mimikatz/keys.py | 3 +- .../credentials/mimikatz/logonpasswords.py | 3 +- .../credentials/mimikatz/lsadump.py | 3 +- .../credentials/mimikatz/mimitokens.py | 5 +- .../powershell/credentials/mimikatz/pth.py | 9 +- .../powershell/credentials/mimikatz/purge.py | 3 +- .../powershell/credentials/mimikatz/sam.py | 3 +- .../credentials/mimikatz/silver_ticket.py | 13 +- .../credentials/mimikatz/trust_keys.py | 3 +- .../powershell/credentials/powerdump.py | 3 +- .../powershell/credentials/sessiongopher.py | 3 +- lib/modules/powershell/credentials/tokens.py | 3 +- .../credentials/vault_credential.py | 3 +- .../powershell/exfiltration/egresscheck.py | 3 +- .../exploitation/exploit_eternalblue.py | 3 +- .../powershell/exploitation/exploit_jboss.py | 3 +- .../exploitation/exploit_jenkins.py | 3 +- .../lateral_movement/inveigh_relay.py | 5 +- .../lateral_movement/invoke_dcom.py | 7 +- .../lateral_movement/invoke_executemsbuild.py | 7 +- .../lateral_movement/invoke_psexec.py | 7 +- .../lateral_movement/invoke_psremoting.py | 5 +- .../lateral_movement/invoke_smbexec.py | 7 +- .../lateral_movement/invoke_sqloscmd.py | 7 +- .../lateral_movement/invoke_sshcommand.py | 9 +- .../powershell/lateral_movement/invoke_wmi.py | 5 +- .../lateral_movement/invoke_wmi_debugger.py | 5 +- .../jenkins_script_console.py | 7 +- .../new_gpo_immediate_task.py | 5 +- .../management/downgrade_account.py | 3 +- .../powershell/management/enable_multi_rdp.py | 3 +- .../powershell/management/get_domain_sid.py | 3 +- .../powershell/management/honeyhash.py | 3 +- .../powershell/management/invoke_script.py | 3 +- .../management/mailraider/disable_security.py | 3 +- .../management/mailraider/get_emailitems.py | 3 +- .../management/mailraider/get_subfolders.py | 3 +- .../management/mailraider/mail_search.py | 3 +- .../management/mailraider/search_gal.py | 3 +- .../management/mailraider/send_mail.py | 3 +- .../management/mailraider/view_email.py | 3 +- lib/modules/powershell/management/phant0m.py | 5 +- lib/modules/powershell/management/psinject.py | 11 +- .../management/reflective_inject.py | 9 +- lib/modules/powershell/management/runas.py | 9 +- lib/modules/powershell/management/shinject.py | 7 +- lib/modules/powershell/management/spawn.py | 3 +- lib/modules/powershell/management/spawnas.py | 5 +- .../powershell/management/switch_listener.py | 3 +- .../powershell/management/timestomp.py | 3 +- lib/modules/powershell/management/vnc.py | 3 +- .../persistence/elevated/registry.py | 9 +- .../persistence/elevated/schtasks.py | 11 +- .../powershell/persistence/elevated/wmi.py | 11 +- .../persistence/elevated/wmi_updater.py | 7 +- .../persistence/misc/add_netuser.py | 3 +- .../persistence/misc/add_sid_history.py | 3 +- .../powershell/persistence/misc/debugger.py | 3 +- .../powershell/persistence/misc/memssp.py | 3 +- .../persistence/misc/skeleton_key.py | 3 +- .../persistence/powerbreach/deaduser.py | 5 +- .../persistence/powerbreach/eventlog.py | 7 +- .../persistence/powerbreach/resolver.py | 5 +- .../persistence/userland/backdoor_lnk.py | 9 +- .../persistence/userland/registry.py | 11 +- .../persistence/userland/schtasks.py | 11 +- lib/modules/powershell/privesc/ask.py | 5 +- lib/modules/powershell/privesc/bypassuac.py | 7 +- .../powershell/privesc/bypassuac_env.py | 7 +- .../powershell/privesc/bypassuac_eventvwr.py | 7 +- .../powershell/privesc/bypassuac_fodhelper.py | 7 +- .../privesc/bypassuac_sdctlbypass.py | 7 +- .../privesc/bypassuac_tokenmanipulation.py | 3 +- .../powershell/privesc/bypassuac_wscript.py | 7 +- lib/modules/powershell/privesc/getsystem.py | 3 +- lib/modules/powershell/privesc/gpp.py | 3 +- .../powershell/privesc/mcafee_sitelist.py | 3 +- lib/modules/powershell/privesc/ms16-032.py | 3 +- lib/modules/powershell/privesc/ms16-135.py | 3 +- .../powershell/privesc/powerup/allchecks.py | 3 +- .../privesc/powerup/find_dllhijack.py | 3 +- .../privesc/powerup/service_exe_restore.py | 3 +- .../privesc/powerup/service_exe_stager.py | 5 +- .../privesc/powerup/service_exe_useradd.py | 3 +- .../privesc/powerup/service_stager.py | 5 +- .../privesc/powerup/service_useradd.py | 3 +- .../privesc/powerup/write_dllhijacker.py | 5 +- lib/modules/powershell/privesc/tater.py | 3 +- .../powershell/recon/fetch_brute_local.py | 7 +- lib/modules/powershell/recon/find_fruit.py | 3 +- .../recon/get_sql_server_login_default_pw.py | 5 +- lib/modules/powershell/recon/http_login.py | 3 +- .../host/computerdetails.py | 3 +- .../host/findtrusteddocuments.py | 3 +- .../situational_awareness/host/get_pathacl.py | 3 +- .../situational_awareness/host/get_proxy.py | 3 +- .../situational_awareness/host/hostrecon.py | 3 +- .../host/monitortcpconnections.py | 3 +- .../situational_awareness/host/paranoia.py | 3 +- .../situational_awareness/host/winenum.py | 3 +- .../situational_awareness/network/arpscan.py | 3 +- .../network/bloodhound.py | 3 +- .../network/get_exploitable_system.py | 3 +- .../network/get_kerberos_service_ticket.py | 3 +- .../situational_awareness/network/get_spn.py | 3 +- .../network/get_sql_instance_domain.py | 3 +- .../network/get_sql_server_info.py | 5 +- .../situational_awareness/network/portscan.py | 3 +- .../network/powerview/find_foreign_group.py | 3 +- .../network/powerview/find_foreign_user.py | 3 +- .../powerview/find_gpo_computer_admin.py | 3 +- .../network/powerview/find_gpo_location.py | 3 +- .../powerview/find_localadmin_access.py | 3 +- .../powerview/find_managed_security_group.py | 3 +- .../powerview/get_cached_rdpconnection.py | 3 +- .../network/powerview/get_computer.py | 3 +- .../network/powerview/get_dfs_share.py | 3 +- .../powerview/get_domain_controller.py | 3 +- .../network/powerview/get_domain_policy.py | 3 +- .../network/powerview/get_domain_trust.py | 3 +- .../network/powerview/get_fileserver.py | 3 +- .../network/powerview/get_forest.py | 3 +- .../network/powerview/get_forest_domain.py | 3 +- .../network/powerview/get_gpo.py | 3 +- .../network/powerview/get_group.py | 3 +- .../network/powerview/get_group_member.py | 3 +- .../network/powerview/get_localgroup.py | 3 +- .../network/powerview/get_loggedon.py | 3 +- .../network/powerview/get_object_acl.py | 3 +- .../network/powerview/get_ou.py | 3 +- .../network/powerview/get_rdp_session.py | 3 +- .../network/powerview/get_session.py | 3 +- .../network/powerview/get_site.py | 3 +- .../network/powerview/get_subnet.py | 3 +- .../network/powerview/get_subnet_ranges.py | 3 +- .../network/powerview/get_user.py | 3 +- .../network/powerview/map_domain_trust.py | 3 +- .../network/powerview/process_hunter.py | 3 +- .../network/powerview/set_ad_object.py | 3 +- .../network/powerview/share_finder.py | 3 +- .../network/powerview/user_hunter.py | 3 +- .../network/reverse_dns.py | 3 +- .../network/smbautobrute.py | 3 +- .../network/smbscanner.py | 7 +- .../powershell/trollsploit/rick_astley.py | 3 +- .../powershell/trollsploit/wallpaper.py | 5 +- lib/modules/powershell_template.py | 3 +- .../lateral_movement/multi/ssh_launcher.py | 3 +- lib/modules/python/management/multi/socks.py | 5 +- lib/modules/python/management/multi/spawn.py | 3 +- .../management/osx/shellcodeinject64.py | 3 +- .../python/privesc/multi/sudo_spawn.py | 3 +- .../python/privesc/osx/dyld_print_to_file.py | 3 +- lib/modules/python/privesc/osx/piggyback.py | 3 +- lib/modules/python_template.py | 3 +- lib/stagers/multi/bash.py | 3 +- lib/stagers/multi/launcher.py | 3 +- lib/stagers/multi/macro.py | 5 +- lib/stagers/multi/pyinstaller.py | 7 +- lib/stagers/multi/war.py | 3 +- lib/stagers/osx/applescript.py | 3 +- lib/stagers/osx/application.py | 3 +- lib/stagers/osx/ducky.py | 3 +- lib/stagers/osx/dylib.py | 5 +- lib/stagers/osx/jar.py | 3 +- lib/stagers/osx/launcher.py | 3 +- lib/stagers/osx/macho.py | 3 +- lib/stagers/osx/macro.py | 3 +- lib/stagers/osx/pkg.py | 3 +- lib/stagers/osx/safari_launcher.py | 3 +- lib/stagers/osx/shellcode.py | 5 +- lib/stagers/osx/teensy.py | 3 +- lib/stagers/windows/backdoorLnkMacro.py | 11 +- lib/stagers/windows/bunny.py | 3 +- lib/stagers/windows/csharp_exe.py | 7 +- lib/stagers/windows/dll.py | 7 +- lib/stagers/windows/ducky.py | 3 +- lib/stagers/windows/hta.py | 3 +- lib/stagers/windows/launcher_bat.py | 3 +- lib/stagers/windows/launcher_lnk.py | 3 +- lib/stagers/windows/launcher_sct.py | 3 +- lib/stagers/windows/launcher_vbs.py | 5 +- lib/stagers/windows/launcher_xml.py | 5 +- lib/stagers/windows/macro.py | 3 +- lib/stagers/windows/macroless_msword.py | 5 +- lib/stagers/windows/shellcode.py | 7 +- lib/stagers/windows/teensy.py | 5 +- lib/stagers/windows/wmic.py | 3 +- plugins/example.py | 1 + setup/setup_database.py | 3 +- 261 files changed, 1959 insertions(+), 1691 deletions(-) diff --git a/data/agent/agent.py b/data/agent/agent.py index 34b2a1773..b1fc61568 100644 --- a/data/agent/agent.py +++ b/data/agent/agent.py @@ -1,3 +1,4 @@ +from __future__ import print_function import __future__ import struct import time @@ -242,7 +243,7 @@ def process_job_tasking(result): # send packets send_message(resultPackets) except Exception as e: - print "processJobTasking exception:",e + print("processJobTasking exception:",e) pass @@ -380,7 +381,7 @@ def process_packet(packetType, data, resultID): buffer = StringIO() sys.stdout = buffer code_obj = compile(data, '', 'exec') - exec code_obj in globals() + exec(code_obj, globals()) sys.stdout = sys.__stdout__ results = buffer.getvalue() return build_response_packet(100, str(results), resultID) @@ -397,7 +398,7 @@ def process_packet(packetType, data, resultID): buffer = StringIO() sys.stdout = buffer code_obj = compile(data, '', 'exec') - exec code_obj in globals() + exec(code_obj, globals()) sys.stdout = sys.__stdout__ c = compress() start_crc32 = c.crc32_data(buffer.getvalue()) @@ -428,7 +429,7 @@ def process_packet(packetType, data, resultID): os.remove(implantPath) result += "\n[*] Module path was properly removed: %s" %(implantPath) except Exception as e: - print "error removing module filed: %s" %(e) + print("error removing module filed: %s" %(e)) fileCheck = os.path.isfile(implantPath) if fileCheck: result += "\n\nError removing module file, please verify path: " + str(implantPath) @@ -455,7 +456,7 @@ def process_packet(packetType, data, resultID): buffer = StringIO() sys.stdout = buffer code_obj = compile(script, '', 'exec') - exec code_obj in globals() + exec(code_obj, globals()) sys.stdout = sys.__stdout__ result = str(buffer.getvalue()) return build_response_packet(121, result, resultID) @@ -590,7 +591,7 @@ def load_module(self, fullname): mod.__name__ = fullname if is_package: mod.__path__ = [os.path.dirname(mod.__file__)] - exec code in mod.__dict__ + exec(code, mod.__dict__) return mod def get_data(self, fullpath): @@ -796,7 +797,7 @@ def start_job(code): code_obj = compile(codeBlock, '', 'exec') # code needs to be in the global listing # not the locals() scope - exec code_obj in globals() + exec(code_obj, globals()) # create/processPacketstart/return the thread # call the job_func so sys data can be cpatured @@ -829,7 +830,7 @@ def job_message_buffer(message): jobMessageBuffer += str(message) except Exception as e: - print e + print(e) def get_job_message_buffer(): global jobMessageBuffer @@ -1054,5 +1055,5 @@ def get_file_part(filePath, offset=0, chunkSize=512000, base64=True): # print "invalid code:",code except Exception as e: - print "main() exception: %s" % (e) + print("main() exception: %s" % (e)) diff --git a/data/agent/stagers/common/diffiehellman.py b/data/agent/stagers/common/diffiehellman.py index 4c6fe9c4e..76296c0fb 100644 --- a/data/agent/stagers/common/diffiehellman.py +++ b/data/agent/stagers/common/diffiehellman.py @@ -1,5 +1,6 @@ """ Implements Diffie-Hellman as a Jinja2 partial for use in stagers DH code from: https://github.com/lowazo/pyDHE """ +from __future__ import print_function import os import hashlib diff --git a/data/agent/stagers/common/rc4.py b/data/agent/stagers/common/rc4.py index c053ecb93..6ad8bd9e0 100644 --- a/data/agent/stagers/common/rc4.py +++ b/data/agent/stagers/common/rc4.py @@ -1,3 +1,4 @@ +from __future__ import print_function import os import struct @@ -102,11 +103,11 @@ def parse_routing_packet(stagingKey, data): return results else: - print "[*] parse_agent_data() data length incorrect: %s" % (len(data)) + print("[*] parse_agent_data() data length incorrect: %s" % (len(data))) return None else: - print "[*] parse_agent_data() data is None" + print("[*] parse_agent_data() data is None") return None diff --git a/data/misc/inactive_modules/redirector.py b/data/misc/inactive_modules/redirector.py index e0c6bd5a5..d65444855 100644 --- a/data/misc/inactive_modules/redirector.py +++ b/data/misc/inactive_modules/redirector.py @@ -1,3 +1,4 @@ +from __future__ import print_function from lib.common import helpers class Module: @@ -160,7 +161,7 @@ def generate(self, obfuscate=False, obfuscationCommand=""): if option.lower() == "listener" and values['Value'] != '': # extract out all options from a listener if one is set if not self.mainMenu.listeners.is_listener_valid(values['Value']): - print helpers.color("[!] Invalid listener set") + print(helpers.color("[!] Invalid listener set")) return "" else: listenerName = values['Value'] @@ -186,9 +187,9 @@ def generate(self, obfuscate=False, obfuscationCommand=""): agent = self.options['Agent']['Value'] port = self.options['ListenPort']['Value'] self.mainMenu.listeners.add_pivot_listener(listenerName, agent, port) - print helpers.color("[*] Added pivot listener on port " + str(port)) + print(helpers.color("[*] Added pivot listener on port " + str(port))) else: - print helpers.color("[!] Listener not set, pivot listener not added.") + print(helpers.color("[!] Listener not set, pivot listener not added.")) return "" if obfuscate: script = helpers.obfuscate(psScript=script, obfuscationCommand=obfuscationCommand) diff --git a/data/module_source/python/management/socks-src.py b/data/module_source/python/management/socks-src.py index 7ca966f29..4a64be4e3 100644 --- a/data/module_source/python/management/socks-src.py +++ b/data/module_source/python/management/socks-src.py @@ -327,7 +327,7 @@ def monitor_sockets(self): if self.socks_socket is not None and self.socks_socket in r: s, addr = self.socks_socket.accept() addr = '{}:{}'.format(*addr) - c = self.tunnel.open_channel(self.next_channel_id.next(), remote=True) + c = self.tunnel.open_channel(next(self.next_channel_id), remote=True) c.local_peer_addr = addr c.socket = s self.logger.info('Created new channel: {}'.format(c)) diff --git a/empire b/empire index 3db286b07..fd7c1be0b 100755 --- a/empire +++ b/empire @@ -1,5 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function import sqlite3, argparse, sys, argparse, logging, json, string, subprocess import os, re, time, signal, copy, base64, pickle, random from flask import Flask, request, jsonify, make_response, abort, url_for @@ -32,7 +33,7 @@ def database_check_docker(): """ if os.path.exists('/.dockerenv'): if not os.path.exists('data/empire.db'): - print '[*] Fresh start in docker, running reset.sh for you' + print('[*] Fresh start in docker, running reset.sh for you') subprocess.call(['./setup/reset.sh']) @@ -49,8 +50,8 @@ def database_connect(): return conn except Exception: - print helpers.color("[!] Could not connect to database") - print helpers.color("[!] Please run setup_database.py") + print(helpers.color("[!] Could not connect to database")) + print(helpers.color("[!] Please run setup_database.py")) sys.exit() @@ -194,15 +195,15 @@ def start_restful_api(empireMenu, suppress=False, username=None, password=None, password = password[0] - print '' + print('') - print " * Starting Empire RESTful API on port: %s" %(port) + print(" * Starting Empire RESTful API on port: %s" %(port)) # refresh the token for the RESTful API apiToken = refresh_api_token(conn) - print " * RESTful API token: %s" %(apiToken) + print(" * RESTful API token: %s" %(apiToken)) permanentApiToken = get_permanent_token(conn) tokenAllowed = re.compile("^[0-9a-z]{40}") @@ -1278,7 +1279,7 @@ def start_restful_api(empireMenu, suppress=False, username=None, password=None, if not os.path.exists('./data/empire-chain.pem'): - print "[!] Error: cannot find certificate ./data/empire-chain.pem" + print("[!] Error: cannot find certificate ./data/empire-chain.pem") sys.exit() @@ -1293,13 +1294,13 @@ def start_restful_api(empireMenu, suppress=False, username=None, password=None, sys.stdout.close() sys.stdout = oldStdout - print "\n * Shutting down Empire RESTful API" + print("\n * Shutting down Empire RESTful API") if conn: conn.close() if suppress: - print " * Shutting down the Empire instance" + print(" * Shutting down the Empire instance") main.shutdown() serverExitCommand = 'shutdown' @@ -1390,7 +1391,7 @@ if __name__ == '__main__': args.restport = args.restport[0] if args.version: - print empire.VERSION + print(empire.VERSION) elif args.rest: # start an Empire instance and RESTful API diff --git a/lib/common/__init__.py b/lib/common/__init__.py index e3d500787..389fdc145 100644 --- a/lib/common/__init__.py +++ b/lib/common/__init__.py @@ -1,11 +1,13 @@ """ Connect to the default database at ./data/empire.db. """ +from __future__ import print_function +from __future__ import absolute_import import sys import sqlite3 -import helpers +from . import helpers def connect_to_db(): try: @@ -16,8 +18,8 @@ def connect_to_db(): return conn except Exception: - print helpers.color("[!] Could not connect to database") - print helpers.color("[!] Please run database_setup.py") + print(helpers.color("[!] Could not connect to database")) + print(helpers.color("[!] Please run database_setup.py")) sys.exit() db = connect_to_db() diff --git a/lib/common/agents.py b/lib/common/agents.py index 3db4d9b6d..8001b6162 100644 --- a/lib/common/agents.py +++ b/lib/common/agents.py @@ -55,6 +55,8 @@ Most methods utilize self.lock to deal with the concurreny issue of kicking off threaded listeners. """ +from __future__ import print_function +from __future__ import absolute_import # -*- encoding: utf-8 -*- import os import json @@ -65,11 +67,11 @@ from zlib_wrapper import decompress # Empire imports -import encryption -import helpers -import packets -import messages -import events +from . import encryption +from . import helpers +from . import packets +from . import messages +from . import events class Agents: @@ -276,10 +278,10 @@ def save_file(self, sessionID, path, data, append=False): f = open("%s/%s" % (save_path, filename), 'ab') if "python" in lang: - print helpers.color("\n[*] Compressed size of %s download: %s" %(filename, helpers.get_file_size(data)), color="green") + print(helpers.color("\n[*] Compressed size of %s download: %s" %(filename, helpers.get_file_size(data)), color="green")) d = decompress.decompress() dec_data = d.dec_data(data) - print helpers.color("[*] Final size of %s wrote: %s" %(filename, helpers.get_file_size(dec_data['data'])), color="green") + print(helpers.color("[*] Final size of %s wrote: %s" %(filename, helpers.get_file_size(dec_data['data'])), color="green")) if not dec_data['crc32_check']: message = "[!] WARNING: File agent {} failed crc32 check during decompression!\n[!] HEADER: Start crc32: %s -- Received crc32: %s -- Crc32 pass: %s!".format(nameid, dec_data['header_crc32'], dec_data['dec_crc32'], dec_data['crc32_check']) signal = json.dumps({ @@ -317,10 +319,10 @@ def save_module_file(self, sessionID, path, data): # decompress data if coming from a python agent: if "python" in lang: - print helpers.color("\n[*] Compressed size of %s download: %s" %(filename, helpers.get_file_size(data)), color="green") + print(helpers.color("\n[*] Compressed size of %s download: %s" %(filename, helpers.get_file_size(data)), color="green")) d = decompress.decompress() dec_data = d.dec_data(data) - print helpers.color("[*] Final size of %s wrote: %s" %(filename, helpers.get_file_size(dec_data['data'])), color="green") + print(helpers.color("[*] Final size of %s wrote: %s" %(filename, helpers.get_file_size(dec_data['data'])), color="green")) if not dec_data['crc32_check']: message = "[!] WARNING: File agent {} failed crc32 check during decompression!\n[!] HEADER: Start crc32: %s -- Received crc32: %s -- Crc32 pass: %s!".format(nameid, dec_data['header_crc32'], dec_data['dec_crc32'], dec_data['crc32_check']) signal = json.dumps({ @@ -617,7 +619,7 @@ def get_agent_results_db(self, sessionID): sessionID = nameid if sessionID not in self.agents: - print helpers.color("[!] Agent %s not active." % (agent_name)) + print(helpers.color("[!] Agent %s not active." % (agent_name))) else: conn = self.get_db_connection() try: @@ -944,7 +946,7 @@ def rename_agent(self, oldname, newname): """ if not newname.isalnum(): - print helpers.color("[!] Only alphanumeric characters allowed for names.") + print(helpers.color("[!] Only alphanumeric characters allowed for names.")) return False conn = self.get_db_connection() @@ -957,7 +959,7 @@ def rename_agent(self, oldname, newname): # check if the folder is already used if os.path.exists(newPath): - print helpers.color("[!] Name already used by current or past agent.") + print(helpers.color("[!] Name already used by current or past agent.")) retVal = False else: # move the old folder path to the new one @@ -1023,8 +1025,8 @@ def set_autoruns_db(self, taskCommand, moduleData): cur.execute("UPDATE config SET autorun_data=?", [moduleData]) cur.close() except Exception: - print helpers.color("[!] Error: script autoruns not a database field, run ./setup_database.py to reset DB schema.") - print helpers.color("[!] Warning: this will reset ALL agent connections!") + print(helpers.color("[!] Error: script autoruns not a database field, run ./setup_database.py to reset DB schema.")) + print(helpers.color("[!] Warning: this will reset ALL agent connections!")) def clear_autoruns_db(self): @@ -1062,7 +1064,7 @@ def add_agent_task_db(self, sessionID, taskName, task=''): sessionID = nameid if sessionID not in self.agents: - print helpers.color("[!] Agent %s not active." % (agentName)) + print(helpers.color("[!] Agent %s not active." % (agentName))) else: if sessionID: message = "[*] Tasked {} to run {}".format(sessionID, taskName) @@ -1134,7 +1136,7 @@ def get_agent_tasks_db(self, sessionID): sessionID = nameid if sessionID not in self.agents: - print helpers.color("[!] Agent %s not active." % (agentName)) + print(helpers.color("[!] Agent %s not active." % (agentName))) return [] else: conn = self.get_db_connection() @@ -1252,7 +1254,7 @@ def handle_agent_staging(self, sessionID, language, meta, additional, encData, s try: message = encryption.aes_decrypt_and_verify(stagingKey, encData) except Exception as e: - print 'exception e:' + str(e) + print('exception e:' + str(e)) # if we have an error during decryption message = "[!] HMAC verification failed from '{}'".format(sessionID) signal = json.dumps({ @@ -1480,7 +1482,7 @@ def handle_agent_staging(self, sessionID, language, meta, additional, encData, s if autorun and autorun[0] != '' and autorun[1] != '': self.add_agent_task_db(sessionID, autorun[0], autorun[1]) - if self.mainMenu.autoRuns.has_key(language.lower()) and len(self.mainMenu.autoRuns[language.lower()]) > 0: + if language.lower() in self.mainMenu.autoRuns and len(self.mainMenu.autoRuns[language.lower()]) > 0: autorunCmds = ["interact %s" % sessionID] autorunCmds.extend(self.mainMenu.autoRuns[language.lower()]) autorunCmds.extend(["lastautoruncmd"]) @@ -1764,7 +1766,7 @@ def process_agent_packet(self, sessionID, responseName, taskID, data): }) dispatcher.send(signal, sender="agents/{}".format(sessionID)) else: - print "sysinfo:",data + print("sysinfo:",data) # extract appropriate system information listener = unicode(parts[1], 'utf-8') domainname = unicode(parts[2], 'utf-8') @@ -2051,4 +2053,4 @@ def process_agent_packet(self, sessionID, responseName, taskID, data): dispatcher.send(signal, sender="agents/{}".format(sessionID)) else: - print helpers.color("[!] Unknown response %s from %s" % (responseName, sessionID)) + print(helpers.color("[!] Unknown response %s from %s" % (responseName, sessionID))) diff --git a/lib/common/bypasses.py b/lib/common/bypasses.py index d07474276..a80905dcf 100644 --- a/lib/common/bypasses.py +++ b/lib/common/bypasses.py @@ -1,4 +1,5 @@ -import helpers +from __future__ import absolute_import +from . import helpers def scriptBlockLogBypass(): diff --git a/lib/common/credentials.py b/lib/common/credentials.py index c7211a9e1..e0d347aaa 100644 --- a/lib/common/credentials.py +++ b/lib/common/credentials.py @@ -3,8 +3,10 @@ Credential handling functionality for Empire. """ +from __future__ import print_function +from __future__ import absolute_import -import helpers +from . import helpers import os # import sqlite3 @@ -136,7 +138,7 @@ def export_credentials(self, export_path=''): """ if export_path == '': - print helpers.color("[!] Export path cannot be ''") + print(helpers.color("[!] Export path cannot be ''")) export_path += ".csv" @@ -153,7 +155,7 @@ def export_credentials(self, export_path=''): creds = self.get_credentials() if len(creds) == 0: - print helpers.color("[!] No credentials in the database.") + print(helpers.color("[!] No credentials in the database.")) return output_file = open(export_path, 'w') @@ -161,5 +163,5 @@ def export_credentials(self, export_path=''): for cred in creds: output_file.write("\"%s\"\n" % ('","'.join([str(x) for x in cred]))) - print "\n" + helpers.color("[*] Credentials exported to %s\n" % (export_path)) + print("\n" + helpers.color("[*] Credentials exported to %s\n" % (export_path))) output_file.close() diff --git a/lib/common/empire.py b/lib/common/empire.py index d45fe4339..c7e608406 100644 --- a/lib/common/empire.py +++ b/lib/common/empire.py @@ -7,6 +7,8 @@ menu loops. """ +from __future__ import print_function +from __future__ import absolute_import # make version for Empire VERSION = "2.5 BC-Security Fork" @@ -29,15 +31,15 @@ import json # Empire imports -import helpers -import messages -import agents -import listeners -import modules -import stagers -import credentials -import plugins -from events import log_event +from . import helpers +from . import messages +from . import agents +from . import listeners +from . import modules +from . import stagers +from . import credentials +from . import plugins +from .events import log_event from zlib_wrapper import compress from zlib_wrapper import decompress @@ -181,7 +183,7 @@ def handle_event(self, signal, sender): if self.args.debug == '2': # if --debug 2, also print the output to the screen - print " %s : %s" % (sender, signal) + print(" %s : %s" % (sender, signal)) def check_root(self): @@ -193,7 +195,7 @@ def check_root(self): if os.geteuid() != 0: if self.isroot: messages.title(VERSION) - print "[!] Warning: Running Empire as non-root, after running as root will likely fail to access prior agents!" + print("[!] Warning: Running Empire as non-root, after running as root will likely fail to access prior agents!") while True: a = raw_input(helpers.color("[>] Are you sure you want to continue (y) or (n): ")) if a.startswith("y"): @@ -211,7 +213,7 @@ def check_root(self): cur.execute("UPDATE config SET rootuser = 1") cur.close() except Exception as e: - print e + print(e) def handle_args(self): @@ -238,16 +240,16 @@ def handle_args(self): # messages.display_listener_database(targetListener) # TODO: reimplement this logic else: - print helpers.color("\n[!] No active listeners with name '%s'\n" % (self.args.listener)) + print(helpers.color("\n[!] No active listeners with name '%s'\n" % (self.args.listener))) else: if self.args.stager == 'list': - print "\nStagers:\n" - print " Name Description" - print " ---- -----------" + print("\nStagers:\n") + print(" Name Description") + print(" ---- -----------") for stagerName, stager in self.stagers.stagers.iteritems(): - print " %s%s" % ('{0: <17}'.format(stagerName), stager.info['Description']) - print "\n" + print(" %s%s" % ('{0: <17}'.format(stagerName), stager.info['Description'])) + print("\n") else: stagerName = self.args.stager try: @@ -257,8 +259,8 @@ def handle_args(self): if self.args.stager_options: for option in self.args.stager_options: if '=' not in option: - print helpers.color("\n[!] Invalid option: '%s'" % (option)) - print helpers.color("[!] Please use Option=Value format\n") + print(helpers.color("\n[!] Invalid option: '%s'" % (option))) + print(helpers.color("[!] Please use Option=Value format\n")) if self.conn: self.conn.close() sys.exit() @@ -274,8 +276,8 @@ def handle_args(self): messages.display_stager(targetStager) except Exception as e: - print e - print helpers.color("\n[!] No current stager with name '%s'\n" % (stagerName)) + print(e) + print(helpers.color("\n[!] No current stager with name '%s'\n" % (stagerName))) # shutdown the database connection object if self.conn: @@ -288,7 +290,7 @@ def shutdown(self): """ Perform any shutdown actions. """ - print "\n" + helpers.color("[!] Shutting down...") + print("\n" + helpers.color("[!] Shutting down...")) message = "[*] Empire shutting down..." signal = json.dumps({ @@ -317,8 +319,8 @@ def database_connect(self): return self.conn except Exception: - print helpers.color("[!] Could not connect to database") - print helpers.color("[!] Please run database_setup.py") + print(helpers.color("[!] Could not connect to database")) + print(helpers.color("[!] Please run database_setup.py")) sys.exit() def cmdloop(self): @@ -354,9 +356,9 @@ def cmdloop(self): else: num_listeners = 0 - print " " + helpers.color(str(num_modules), "green") + " modules currently loaded\n" - print " " + helpers.color(str(num_listeners), "green") + " listeners currently active\n" - print " " + helpers.color(str(num_agents), "green") + " agents currently active\n\n" + print(" " + helpers.color(str(num_modules), "green") + " modules currently loaded\n") + print(" " + helpers.color(str(num_listeners), "green") + " listeners currently active\n") + print(" " + helpers.color(str(num_agents), "green") + " agents currently active\n\n") if len(self.resourceQueue) > 0: self.cmdqueue.append(self.resourceQueue.pop(0)) @@ -390,7 +392,7 @@ def cmdloop(self): self.menu_state = "Listeners" except Exception as e: - print helpers.color("[!] Exception: %s" % (e)) + print(helpers.color("[!] Exception: %s" % (e))) time.sleep(5) @@ -539,7 +541,7 @@ def do_usestager(self, line): parts = line.split(' ') if parts[0] not in self.stagers.stagers: - print helpers.color("[!] Error: invalid stager module") + print(helpers.color("[!] Error: invalid stager module")) elif len(parts) == 1: stager_menu = StagerMenu(self, parts[0]) @@ -547,13 +549,13 @@ def do_usestager(self, line): elif len(parts) == 2: listener = parts[1] if not self.listeners.is_listener_valid(listener): - print helpers.color("[!] Please enter a valid listener name or ID") + print(helpers.color("[!] Please enter a valid listener name or ID")) else: self.stagers.set_stager_option('Listener', listener) stager_menu = StagerMenu(self, parts[0]) stager_menu.cmdloop() else: - print helpers.color("[!] Error in MainMenu's do_userstager()") + print(helpers.color("[!] Error in MainMenu's do_userstager()")) except Exception as e: raise e @@ -563,7 +565,7 @@ def do_usemodule(self, line): # Strip asterisks added by MainMenu.complete_usemodule() line = line.rstrip("*") if line not in self.modules.modules: - print helpers.color("[!] Error: invalid module") + print(helpers.color("[!] Error: invalid module")) else: try: module_menu = ModuleMenu(self, line) @@ -614,7 +616,7 @@ def do_creds(self, line): self.credentials.add_credential(credType, domain, username, password, "", sid=sid, notes=notes) else: - print helpers.color("[!] Format is 'add domain username password ") + print(helpers.color("[!] Format is 'add domain username password ")) return creds = self.credentials.get_credentials() @@ -624,7 +626,7 @@ def do_creds(self, line): try: args = shlex.split(filterTerm)[1:] if len(args) != 1: - print helpers.color("[!] Format is 'remove //all'") + print(helpers.color("[!] Format is 'remove //all'")) else: if args[0].lower() == "all": choice = raw_input(helpers.color("[>] Remove all credentials from the database? [y/N] ", "red")) @@ -642,8 +644,8 @@ def do_creds(self, line): self.credentials.remove_credentials(args) except Exception: - print helpers.color("[!] Error in remove command parsing.") - print helpers.color("[!] Format is 'remove //all'") + print(helpers.color("[!] Error in remove command parsing.")) + print(helpers.color("[!] Format is 'remove //all'")) return @@ -652,7 +654,7 @@ def do_creds(self, line): args = shlex.split(filterTerm)[1:] if len(args) != 1: - print helpers.color("[!] Please supply an output filename/filepath.") + print(helpers.color("[!] Please supply an output filename/filepath.")) return else: self.credentials.export_credentials(args[0]) @@ -678,7 +680,7 @@ def do_set(self, line): parts = line.split(' ') if len(parts) == 1: - print helpers.color("[!] Please enter 'IP,IP-IP,IP/CIDR' or a file path.") + print(helpers.color("[!] Please enter 'IP,IP-IP,IP/CIDR' or a file path.")) else: if parts[0].lower() == "ip_whitelist": if parts[1] != "" and os.path.exists(parts[1]): @@ -688,7 +690,7 @@ def do_set(self, line): open_file.close() self.agents.ipWhiteList = helpers.generate_ip_list(ipData) except Exception: - print helpers.color("[!] Error opening ip file %s" % (parts[1])) + print(helpers.color("[!] Error opening ip file %s" % (parts[1]))) else: self.agents.ipWhiteList = helpers.generate_ip_list(",".join(parts[1:])) elif parts[0].lower() == "ip_blacklist": @@ -699,13 +701,13 @@ def do_set(self, line): open_file.close() self.agents.ipBlackList = helpers.generate_ip_list(ipData) except Exception: - print helpers.color("[!] Error opening ip file %s" % (parts[1])) + print(helpers.color("[!] Error opening ip file %s" % (parts[1]))) else: self.agents.ipBlackList = helpers.generate_ip_list(",".join(parts[1:])) elif parts[0].lower() == "obfuscate": if parts[1].lower() == "true": if not helpers.is_powershell_installed(): - print helpers.color("[!] PowerShell is not installed and is required to use obfuscation, please install it first.") + print(helpers.color("[!] PowerShell is not installed and is required to use obfuscation, please install it first.")) else: self.obfuscate = True @@ -727,11 +729,11 @@ def do_set(self, line): dispatcher.send(signal, sender="empire") else: - print helpers.color("[!] Valid options for obfuscate are 'true' or 'false'") + print(helpers.color("[!] Valid options for obfuscate are 'true' or 'false'")) elif parts[0].lower() == "obfuscate_command": self.obfuscateCommand = parts[1] else: - print helpers.color("[!] Please choose 'ip_whitelist', 'ip_blacklist', 'obfuscate', or 'obfuscate_command'") + print(helpers.color("[!] Please choose 'ip_whitelist', 'ip_blacklist', 'obfuscate', or 'obfuscate_command'")) def do_reset(self, line): @@ -747,20 +749,20 @@ def do_show(self, line): "Show a global option (e.g. IP whitelists)." if line.strip().lower() == "ip_whitelist": - print self.agents.ipWhiteList + print(self.agents.ipWhiteList) if line.strip().lower() == "ip_blacklist": - print self.agents.ipBlackList + print(self.agents.ipBlackList) if line.strip().lower() == "obfuscate": - print self.obfuscate + print(self.obfuscate) if line.strip().lower() == "obfuscate_command": - print self.obfuscateCommand + print(self.obfuscateCommand) def do_load(self, line): "Loads Empire modules from a non-standard folder." if line.strip() == '' or not os.path.isdir(line.strip()): - print helpers.color("[!] Please specify a valid folder to load modules from.") + print(helpers.color("[!] Please specify a valid folder to load modules from.")) else: self.modules.load_modules(rootPath=line.strip()) @@ -770,16 +772,16 @@ def do_reload(self, line): if line.strip().lower() == "all": # reload all modules - print "\n" + helpers.color("[*] Reloading all modules.") + "\n" + print("\n" + helpers.color("[*] Reloading all modules.") + "\n") self.modules.load_modules() elif os.path.isdir(line.strip()): # if we're loading an external directory self.modules.load_modules(rootPath=line.strip()) else: if line.strip() not in self.modules.modules: - print helpers.color("[!] Error: invalid module") + print(helpers.color("[!] Error: invalid module")) else: - print "\n" + helpers.color("[*] Reloading module: " + line) + "\n" + print("\n" + helpers.color("[*] Reloading module: " + line) + "\n") self.modules.reload_module(line) @@ -827,7 +829,7 @@ def do_list(self, line): messages.display_agents(agentsToDisplay) except Exception: - print helpers.color("[!] Please enter the minute window for agent checkin.") + print(helpers.color("[!] Please enter the minute window for agent checkin.")) else: messages.display_agents(allAgents) @@ -847,13 +849,13 @@ def do_interact(self, line): if sessionID and sessionID != '' and sessionID in self.agents.agents: AgentMenu(self, sessionID) else: - print helpers.color("[!] Please enter a valid agent name") + print(helpers.color("[!] Please enter a valid agent name")) def do_preobfuscate(self, line): "Preobfuscate PowerShell module_source files" if not helpers.is_powershell_installed(): - print helpers.color("[!] PowerShell is not installed and is required to use obfuscation, please install it first.") + print(helpers.color("[!] PowerShell is not installed and is required to use obfuscation, please install it first.")) return module = line.strip() @@ -875,7 +877,7 @@ def do_preobfuscate(self, line): else: module_source_fullpath = self.installPath + 'data/module_source/' + module if not os.path.isfile(module_source_fullpath): - print helpers.color("[!] The module_source file:" + module_source_fullpath + " does not exist.") + print(helpers.color("[!] The module_source file:" + module_source_fullpath + " does not exist.")) return choice = raw_input(helpers.color("[>] Preobfuscate the module_source file: " + module + " using obfuscation command: \"" + self.obfuscateCommand + "\"? [y/N] ", "red")) @@ -902,7 +904,7 @@ def do_preobfuscate(self, line): }) dispatcher.send(signal, sender="empire") else: - print helpers.color("[*] " + os.path.basename(file) + " was already obfuscated. Not reobfuscating.") + print(helpers.color("[*] " + os.path.basename(file) + " was already obfuscated. Not reobfuscating.")) helpers.obfuscate_module(file, self.obfuscateCommand, reobfuscate) def do_report(self, line): @@ -916,7 +918,7 @@ def do_report(self, line): cur.execute('select session_id, hostname, username, checkin_time from agents') rows = cur.fetchall() - print helpers.color("[*] Writing data/sessions.csv") + print(helpers.color("[*] Writing data/sessions.csv")) f = open('data/sessions.csv','w') f.write("SessionID, Hostname, User Name, First Check-in\n") for row in rows: @@ -940,7 +942,7 @@ def do_report(self, line): """) rows = cur.fetchall() - print helpers.color("[*] Writing data/credentials.csv") + print(helpers.color("[*] Writing data/credentials.csv")) f = open('data/credentials.csv','w') f.write('Domain, Username, Host, Cred Type, Password\n') for row in rows: @@ -966,7 +968,7 @@ def do_report(self, line): reporting.event_type == 'task' OR reporting.event_type == 'checkin' """) rows = cur.fetchall() - print helpers.color("[*] Writing data/master.log") + print(helpers.color("[*] Writing data/master.log")) f = open('data/master.log', 'w') f.write('Empire Master Taskings & Results Log by timestamp\n') f.write('='*50 + '\n\n') @@ -1193,7 +1195,7 @@ def do_autorun(self, line): "Read and execute a list of Empire commands from a file and execute on each new agent \"autorun \" e.g. \"autorun /root/ps.rc powershell\". Or clear any autorun setting with \"autorun clear\" and show current autorun settings with \"autorun show\"" line = line.strip() if not line: - print helpers.color("[!] You must specify a resource file, show or clear. e.g. 'autorun /root/res.rc powershell' or 'autorun clear'") + print(helpers.color("[!] You must specify a resource file, show or clear. e.g. 'autorun /root/res.rc powershell' or 'autorun clear'")) return cmds = line.split(' ') resourceFile = cmds[0] @@ -1201,24 +1203,24 @@ def do_autorun(self, line): if len(cmds) > 1: language = cmds[1].lower() elif not resourceFile == "show" and not resourceFile == "clear": - print helpers.color("[!] You must specify the agent language to run this module on. e.g. 'autorun /root/res.rc powershell' or 'autorun /root/res.rc python'") + print(helpers.color("[!] You must specify the agent language to run this module on. e.g. 'autorun /root/res.rc powershell' or 'autorun /root/res.rc python'")) return #show the current autorun settings by language or all if resourceFile == "show": if language: - if self.mainMenu.autoRuns.has_key(language): - print self.mainMenu.autoRuns[language] + if language in self.mainMenu.autoRuns: + print(self.mainMenu.autoRuns[language]) else: - print "No autorun commands for language %s" % language + print("No autorun commands for language %s" % language) else: - print self.mainMenu.autoRuns + print(self.mainMenu.autoRuns) #clear autorun settings by language or all elif resourceFile == "clear": if language and not language == "all": - if self.mainMenu.autoRuns.has_key(language): + if language in self.mainMenu.autoRuns: self.mainMenu.autoRuns.pop(language) else: - print "No autorun commands for language %s" % language + print("No autorun commands for language %s" % language) else: #clear all autoruns self.mainMenu.autoRuns.clear() @@ -1247,7 +1249,7 @@ def do_rename(self, line): # replace the old name with the new name self.mainMenu.agents.rename_agent(parts[0], parts[1]) else: - print helpers.color("[!] Please enter an agent name and new name") + print(helpers.color("[!] Please enter an agent name and new name")) def do_interact(self, line): @@ -1260,7 +1262,7 @@ def do_interact(self, line): if sessionID and sessionID != '' and sessionID in self.mainMenu.agents.agents: AgentMenu(self.mainMenu, sessionID) else: - print helpers.color("[!] Please enter a valid agent name") + print(helpers.color("[!] Please enter a valid agent name")) def do_kill(self, line): @@ -1277,7 +1279,7 @@ def do_kill(self, line): sessionID = agent['session_id'] self.mainMenu.agents.add_agent_task_db(sessionID, 'TASK_EXIT') except KeyboardInterrupt: - print '' + print('') else: # extract the sessionID and clear the agent tasking @@ -1289,9 +1291,9 @@ def do_kill(self, line): if choice.lower() != '' and choice.lower()[0] == 'y': self.mainMenu.agents.add_agent_task_db(sessionID, 'TASK_EXIT') except KeyboardInterrupt: - print '' + print('') else: - print helpers.color("[!] Invalid agent name") + print(helpers.color("[!] Invalid agent name")) def do_clear(self, line): "Clear one or more agent's taskings." @@ -1309,7 +1311,7 @@ def do_clear(self, line): if sessionID and len(sessionID) != 0: self.mainMenu.agents.clear_agent_tasks_db(sessionID) else: - print helpers.color("[!] Invalid agent name") + print(helpers.color("[!] Invalid agent name")) def do_sleep(self, line): @@ -1318,7 +1320,7 @@ def do_sleep(self, line): parts = line.strip().split(' ') if len(parts) == 1: - print helpers.color("[!] Please enter 'interval [jitter]'") + print(helpers.color("[!] Please enter 'interval [jitter]'")) elif parts[0].lower() == 'all': delay = parts[1] @@ -1377,7 +1379,7 @@ def do_sleep(self, line): self.mainMenu.agents.save_agent_log(sessionID, msg) else: - print helpers.color("[!] Invalid agent name") + print(helpers.color("[!] Invalid agent name")) def do_lostlimit(self, line): @@ -1386,7 +1388,7 @@ def do_lostlimit(self, line): parts = line.strip().split(' ') if len(parts) == 1: - print helpers.color("[!] Usage: 'lostlimit [agent/all] [number of missed callbacks]") + print(helpers.color("[!] Usage: 'lostlimit [agent/all] [number of missed callbacks]")) elif parts[0].lower() == 'all': lostLimit = parts[1] @@ -1435,7 +1437,7 @@ def do_lostlimit(self, line): self.mainMenu.agents.save_agent_log(sessionID, msg) else: - print helpers.color("[!] Invalid agent name") + print(helpers.color("[!] Invalid agent name")) def do_killdate(self, line): @@ -1444,7 +1446,7 @@ def do_killdate(self, line): parts = line.strip().split(' ') if len(parts) == 1: - print helpers.color("[!] Usage: 'killdate [agent/all] [01/01/2016]'") + print(helpers.color("[!] Usage: 'killdate [agent/all] [01/01/2016]'")) elif parts[0].lower() == 'all': date = parts[1] @@ -1494,7 +1496,7 @@ def do_killdate(self, line): self.mainMenu.agents.save_agent_log(sessionID, msg) else: - print helpers.color("[!] Invalid agent name") + print(helpers.color("[!] Invalid agent name")) def do_workinghours(self, line): @@ -1503,7 +1505,7 @@ def do_workinghours(self, line): parts = line.strip().split(' ') if len(parts) == 1: - print helpers.color("[!] Usage: 'workinghours [agent/all] [9:00-17:00]'") + print(helpers.color("[!] Usage: 'workinghours [agent/all] [9:00-17:00]'")) elif parts[0].lower() == 'all': hours = parts[1] @@ -1556,7 +1558,7 @@ def do_workinghours(self, line): self.mainMenu.agents.save_agent_log(sessionID, msg) else: - print helpers.color("[!] Invalid agent name") + print(helpers.color("[!] Invalid agent name")) def do_remove(self, line): @@ -1570,7 +1572,7 @@ def do_remove(self, line): if choice.lower() != '' and choice.lower()[0] == 'y': self.mainMenu.agents.remove_agent_db('%') except KeyboardInterrupt: - print '' + print('') elif name.lower() == 'stale': # remove 'stale' agents that have missed their checkin intervals @@ -1612,7 +1614,7 @@ def do_remove(self, line): self.mainMenu.agents.remove_agent_db(sessionID) except: - print helpers.color("[!] Please enter the minute window for agent checkin.") + print(helpers.color("[!] Please enter the minute window for agent checkin.")) else: # extract the sessionID and clear the agent tasking @@ -1621,7 +1623,7 @@ def do_remove(self, line): if sessionID and len(sessionID) != 0: self.mainMenu.agents.remove_agent_db(sessionID) else: - print helpers.color("[!] Invalid agent name") + print(helpers.color("[!] Invalid agent name")) def do_usestager(self, line): @@ -1630,7 +1632,7 @@ def do_usestager(self, line): parts = line.split(' ') if parts[0] not in self.mainMenu.stagers.stagers: - print helpers.color("[!] Error: invalid stager module") + print(helpers.color("[!] Error: invalid stager module")) elif len(parts) == 1: stager_menu = StagerMenu(self.mainMenu, parts[0]) @@ -1638,13 +1640,13 @@ def do_usestager(self, line): elif len(parts) == 2: listener = parts[1] if not self.mainMenu.listeners.is_listener_valid(listener): - print helpers.color("[!] Please enter a valid listener name or ID") + print(helpers.color("[!] Please enter a valid listener name or ID")) else: self.mainMenu.stagers.set_stager_option('Listener', listener) stager_menu = StagerMenu(self.mainMenu, parts[0]) stager_menu.cmdloop() else: - print helpers.color("[!] Error in AgentsMenu's do_userstager()") + print(helpers.color("[!] Error in AgentsMenu's do_userstager()")) def do_usemodule(self, line): @@ -1654,7 +1656,7 @@ def do_usemodule(self, line): module = line.strip().rstrip("*") if module not in self.mainMenu.modules.modules: - print helpers.color("[!] Error: invalid module") + print(helpers.color("[!] Error: invalid module")) else: # set agent to "all" module_menu = ModuleMenu(self.mainMenu, line, agent="all") @@ -1667,7 +1669,7 @@ def do_searchmodule(self, line): searchTerm = line.strip() if searchTerm.strip() == "": - print helpers.color("[!] Please enter a search term.") + print(helpers.color("[!] Please enter a search term.")) else: self.mainMenu.modules.search_modules(searchTerm) @@ -1775,7 +1777,7 @@ def __init__(self, mainMenu, sessionID): agent_menu = PythonAgentMenu(mainMenu, sessionID) agent_menu.cmdloop() else: - print helpers.color("[!] Agent language %s not recognized." % (agentLanguage)) + print(helpers.color("[!] Agent language %s not recognized." % (agentLanguage))) class PowerShellAgentMenu(SubMenu): @@ -1803,7 +1805,7 @@ def __init__(self, mainMenu, sessionID): # while we weren't interacting with the agent results = self.mainMenu.agents.get_agent_results_db(self.sessionID) if results: - print "\n" + results.rstrip('\r\n') + print("\n" + results.rstrip('\r\n')) # def preloop(self): # traceback.print_stack() @@ -1851,15 +1853,15 @@ def default(self, line): msg = "Tasked agent to run command " + line self.mainMenu.agents.save_agent_log(self.sessionID, msg) else: - print helpers.color("[!] Command not recognized.") - print helpers.color("[*] Use 'help' or 'help agentcmds' to see available commands.") + print(helpers.color("[!] Command not recognized.")) + print(helpers.color("[*] Use 'help' or 'help agentcmds' to see available commands.")) def do_help(self, *args): "Displays the help menu or syntax for particular commands." if args[0].lower() == "agentcmds": - print "\n" + helpers.color("[*] Available opsec-safe agent commands:\n") - print " " + messages.wrap_columns(", ".join(self.agentCommands), ' ', width1=50, width2=10, indent=5) + "\n" + print("\n" + helpers.color("[*] Available opsec-safe agent commands:\n")) + print(" " + messages.wrap_columns(", ".join(self.agentCommands), ' ', width1=50, width2=10, indent=5) + "\n") else: SubMenu.do_help(self, *args) @@ -1871,7 +1873,7 @@ def do_list(self, line): elif line.lower().startswith("agents"): self.mainMenu.do_list("agents " + str(' '.join(line.split(' ')[1:]))) else: - print helpers.color("[!] Please use 'list [agents/listeners] '.") + print(helpers.color("[!] Please use 'list [agents/listeners] '.")) def do_rename(self, line): "Rename the agent." @@ -1886,7 +1888,7 @@ def do_rename(self, line): if result: self.prompt = "(Empire: " + helpers.color(parts[0], 'red') + ") > " else: - print helpers.color("[!] Please enter a new name for the agent") + print(helpers.color("[!] Please enter a new name for the agent")) def do_info(self, line): "Display information about this agent" @@ -1917,7 +1919,7 @@ def do_exit(self, line): raise NavAgents except KeyboardInterrupt: - print "" + print("") def do_clear(self, line): @@ -1945,7 +1947,7 @@ def do_jobs(self, line): # update the agent log self.mainMenu.agents.save_agent_log(self.sessionID, "Tasked agent to get running jobs") else: - print helpers.color("[!] Please use form 'jobs kill JOB_ID'") + print(helpers.color("[!] Please use form 'jobs kill JOB_ID'")) elif len(parts) == 2: jobID = parts[1].strip() self.mainMenu.agents.add_agent_task_db(self.sessionID, "TASK_STOPJOB", jobID) @@ -2022,7 +2024,7 @@ def do_kill(self, line): process = parts[0] if process == "": - print helpers.color("[!] Please enter a process name or ID.") + print(helpers.color("[!] Please enter a process name or ID.")) else: # if we were passed a process ID if process.isdigit(): @@ -2212,7 +2214,7 @@ def do_upload(self, line): size = os.path.getsize(parts[0]) if size > 1048576: - print helpers.color("[!] File size is too large. Upload limit is 1MB.") + print(helpers.color("[!] File size is too large. Upload limit is 1MB.")) else: # dispatch this event message = "[*] Tasked agent to upload {}, {}".format(uploadname, helpers.get_file_size(file_data)) @@ -2234,7 +2236,7 @@ def do_upload(self, line): data = uploadname + "|" + file_data self.mainMenu.agents.add_agent_task_db(self.sessionID, "TASK_UPLOAD", data) else: - print helpers.color("[!] Please enter a valid file path to upload") + print(helpers.color("[!] Please enter a valid file path to upload")) def do_scriptimport(self, line): @@ -2274,7 +2276,7 @@ def do_scriptimport(self, line): self.mainMenu.agents.set_agent_functions_db(self.sessionID, functions) else: - print helpers.color("[!] Please enter a valid script path") + print(helpers.color("[!] Please enter a valid script path")) def do_scriptcmd(self, line): @@ -2304,7 +2306,7 @@ def do_usemodule(self, line): module = "powershell/%s" %(line.strip().rstrip("*")) if module not in self.mainMenu.modules.modules: - print helpers.color("[!] Error: invalid module") + print(helpers.color("[!] Error: invalid module")) else: module_menu = ModuleMenu(self.mainMenu, module, agent=self.sessionID) module_menu.cmdloop() @@ -2316,7 +2318,7 @@ def do_searchmodule(self, line): search_term = line.strip() if search_term.strip() == "": - print helpers.color("[!] Please enter a search term.") + print(helpers.color("[!] Please enter a search term.")) else: self.mainMenu.modules.search_modules(search_term) @@ -2341,7 +2343,7 @@ def do_updateprofile(self, line): profile = profile[0] if not profile.strip().startswith("\"/"): - print helpers.color("[!] Task URIs in profiles must start with / and be enclosed in quotes!") + print(helpers.color("[!] Task URIs in profiles must start with / and be enclosed in quotes!")) else: updatecmd = "Update-Profile " + profile @@ -2361,7 +2363,7 @@ def do_updateprofile(self, line): self.mainMenu.agents.save_agent_log(self.sessionID, msg) else: - print helpers.color("[*] Profile format is \"TaskURI1,TaskURI2,...|UserAgent|OptionalHeader2:Val1|OptionalHeader2:Val2...\"") + print(helpers.color("[*] Profile format is \"TaskURI1,TaskURI2,...|UserAgent|OptionalHeader2:Val1|OptionalHeader2:Val2...\"")) def do_updatecomms(self, line): "Dynamically update the agent comms to another listener" @@ -2370,7 +2372,7 @@ def do_updatecomms(self, line): if line: listenerID = line.strip() if not self.mainMenu.listeners.is_listener_valid(listenerID): - print helpers.color("[!] Please enter a valid listenername.") + print(helpers.color("[!] Please enter a valid listenername.")) else: activeListener = self.mainMenu.listeners.activeListeners[listenerID] if activeListener['moduleName'] != 'meterpreter' or activeListener['moduleName'] != 'http_mapi': @@ -2383,10 +2385,10 @@ def do_updatecomms(self, line): msg = "Tasked agent to update comms to %s listener" % listenerID self.mainMenu.agents.save_agent_log(self.sessionID, msg) else: - print helpers.color("[!] Ineligible listener for updatecomms command: %s" % activeListener['moduleName']) + print(helpers.color("[!] Ineligible listener for updatecomms command: %s" % activeListener['moduleName'])) else: - print helpers.color("[!] Please enter a valid listenername.") + print(helpers.color("[!] Please enter a valid listenername.")) def do_psinject(self, line): "Inject a launcher into a remote process. Ex. psinject " @@ -2415,13 +2417,13 @@ def do_psinject(self, line): module_menu.do_execute("") else: - print helpers.color("[!] Please enter ") + print(helpers.color("[!] Please enter ")) else: - print helpers.color("[!] powershell/management/psinject module not loaded") + print(helpers.color("[!] powershell/management/psinject module not loaded")) else: - print helpers.color("[!] Injection requires you to specify listener") + print(helpers.color("[!] Injection requires you to specify listener")) def do_shinject(self, line): @@ -2441,19 +2443,19 @@ def do_shinject(self, line): if target.isdigit(): module.options['ProcId']['Value'] = target else: - print helpers.color('[!] Please enter a valid process ID.') + print(helpers.color('[!] Please enter a valid process ID.')) module.options['Agent']['Value'] = self.mainMenu.agents.get_agent_name_db(self.sessionID) module_menu = ModuleMenu(self.mainMenu, 'powershell/management/shinject') module_menu.do_execute("") else: - print helpers.color('[!] Please select a valid listener') + print(helpers.color('[!] Please select a valid listener')) else: - print helpers.color("[!] powershell/management/psinject module not loaded") + print(helpers.color("[!] powershell/management/psinject module not loaded")) else: - print helpers.color("[!] Injection requires you to specify listener") + print(helpers.color("[!] Injection requires you to specify listener")) def do_injectshellcode(self, line): "Inject listener shellcode into a remote process. Ex. injectshellcode " @@ -2481,13 +2483,13 @@ def do_injectshellcode(self, line): module_menu.cmdloop() else: - print helpers.color("[!] Please enter ") + print(helpers.color("[!] Please enter ")) else: - print helpers.color("[!] powershell/code_execution/invoke_shellcode module not loaded") + print(helpers.color("[!] powershell/code_execution/invoke_shellcode module not loaded")) else: - print helpers.color("[!] Injection requires you to specify listener") + print(helpers.color("[!] Injection requires you to specify listener")) def do_sc(self, line): @@ -2499,7 +2501,7 @@ def do_sc(self, line): try: screenshot_ratio = str(int(line.strip())) except Exception: - print helpers.color("[*] JPEG Ratio incorrect. Has been set to 80.") + print(helpers.color("[*] JPEG Ratio incorrect. Has been set to 80.")) screenshot_ratio = "80" else: screenshot_ratio = '' @@ -2514,7 +2516,7 @@ def do_sc(self, line): module_menu.do_execute("") else: - print helpers.color("[!] powershell/collection/screenshot module not loaded") + print(helpers.color("[!] powershell/collection/screenshot module not loaded")) def do_spawn(self, line): @@ -2538,13 +2540,13 @@ def do_spawn(self, line): module_menu.cmdloop() else: - print helpers.color("[!] management/spawn module not loaded") + print(helpers.color("[!] management/spawn module not loaded")) else: - print helpers.color("[!] Please enter a valid listener name or ID.") + print(helpers.color("[!] Please enter a valid listener name or ID.")) else: - print helpers.color("[!] Please specify a listener name or ID.") + print(helpers.color("[!] Please specify a listener name or ID.")) def do_bypassuac(self, line): @@ -2568,13 +2570,13 @@ def do_bypassuac(self, line): module_menu.do_execute('') else: - print helpers.color("[!] powershell/privesc/bypassuac_eventvwr module not loaded") + print(helpers.color("[!] powershell/privesc/bypassuac_eventvwr module not loaded")) else: - print helpers.color("[!] Please enter a valid listener name or ID.") + print(helpers.color("[!] Please enter a valid listener name or ID.")) else: - print helpers.color("[!] Please specify a listener name or ID.") + print(helpers.color("[!] Please specify a listener name or ID.")) def do_mimikatz(self, line): @@ -2597,7 +2599,7 @@ def do_pth(self, line): credID = line.strip() if credID == '': - print helpers.color("[!] Please specify a .") + print(helpers.color("[!] Please specify a .")) return if self.mainMenu.modules.modules['powershell/credentials/mimikatz/pth']: @@ -2623,7 +2625,7 @@ def do_steal_token(self, line): processID = line.strip() if processID == '': - print helpers.color("[!] Please specify a process ID.") + print(helpers.color("[!] Please specify a process ID.")) return if self.mainMenu.modules.modules['powershell/credentials/tokens']: @@ -2782,7 +2784,7 @@ def __init__(self, mainMenu, sessionID): # while we weren't interacting with the agent results = self.mainMenu.agents.get_agent_results_db(self.sessionID) if results: - print "\n" + results.rstrip('\r\n') + print("\n" + results.rstrip('\r\n')) def handle_agent_event(self, signal, sender): """ @@ -2815,8 +2817,8 @@ def default(self, line): msg = "Tasked agent to run command " + line self.mainMenu.agents.save_agent_log(self.sessionID, msg) else: - print helpers.color("[!] Command not recognized.") - print helpers.color("[*] Use 'help' or 'help agentcmds' to see available commands.") + print(helpers.color("[!] Command not recognized.")) + print(helpers.color("[*] Use 'help' or 'help agentcmds' to see available commands.")) def do_help(self, *args): "Displays the help menu or syntax for particular commands." @@ -2831,7 +2833,7 @@ def do_list(self, line): elif line.lower().startswith("agents"): self.mainMenu.do_list("agents " + str(' '.join(line.split(' ')[1:]))) else: - print helpers.color("[!] Please use 'list [agents/listeners] '.") + print(helpers.color("[!] Please use 'list [agents/listeners] '.")) def do_rename(self, line): @@ -2847,7 +2849,7 @@ def do_rename(self, line): if result: self.prompt = "(Empire: " + helpers.color(parts[0], 'red') + ") > " else: - print helpers.color("[!] Please enter a new name for the agent") + print(helpers.color("[!] Please enter a new name for the agent")) def do_info(self, line): @@ -2880,7 +2882,7 @@ def do_exit(self, line): raise NavAgents except KeyboardInterrupt as e: - print "" + print("") def do_clear(self, line): @@ -2935,7 +2937,7 @@ def do_jobs(self, line): # update the agent log self.mainMenu.agents.save_agent_log(self.sessionID, "Tasked agent to get running jobs") else: - print helpers.color("[!] Please use form 'jobs kill JOB_ID'") + print(helpers.color("[!] Please use form 'jobs kill JOB_ID'")) elif len(parts) == 2: jobID = parts[1].strip() self.mainMenu.agents.add_agent_task_db(self.sessionID, "TASK_STOPJOB", jobID) @@ -2963,14 +2965,14 @@ def do_sleep(self, line): try: int(delay) except: - print helpers.color("[!] Please only enter integer for 'interval'") + print(helpers.color("[!] Please only enter integer for 'interval'")) return if len(parts) > 1: try: int(parts[1]) except: - print helpers.color("[!] Please only enter integer for '[jitter]'") + print(helpers.color("[!] Please only enter integer for '[jitter]'")) return if delay == "": @@ -3203,7 +3205,7 @@ def do_pythonscript(self, line): msg = "[*] Tasked agent to execute python script: "+filename self.mainMenu.agents.save_agent_log(self.sessionID, msg) else: - print helpers.color("[!] Please provide a valid path", color="red") + print(helpers.color("[!] Please provide a valid path", color="red")) def do_sysinfo(self, line): @@ -3272,9 +3274,9 @@ def do_upload(self, line): # Get file size size = os.path.getsize(parts[0]) if size > 1048576: - print helpers.color("[!] File size is too large. Upload limit is 1MB.") + print(helpers.color("[!] File size is too large. Upload limit is 1MB.")) else: - print helpers.color("[*] Original tasked size of %s for upload: %s" %(uploadname, helpers.get_file_size(fileData)), color="green") + print(helpers.color("[*] Original tasked size of %s for upload: %s" %(uploadname, helpers.get_file_size(fileData)), color="green")) original_md5 = hashlib.md5(fileData).hexdigest() # update the agent log with the filename and MD5 @@ -3304,7 +3306,7 @@ def do_upload(self, line): self.mainMenu.agents.add_agent_task_db(self.sessionID, "TASK_UPLOAD", data) else: - print helpers.color("[!] Please enter a valid file path to upload") + print(helpers.color("[!] Please enter a valid file path to upload")) def do_usemodule(self, line): @@ -3315,7 +3317,7 @@ def do_usemodule(self, line): if module not in self.mainMenu.modules.modules: - print helpers.color("[!] Error: invalid module") + print(helpers.color("[!] Error: invalid module")) else: module_menu = ModuleMenu(self.mainMenu, module, agent=self.sessionID) module_menu.cmdloop() @@ -3327,7 +3329,7 @@ def do_searchmodule(self, line): searchTerm = line.strip() if searchTerm.strip() == "": - print helpers.color("[!] Please enter a search term.") + print(helpers.color("[!] Please enter a search term.")) else: self.mainMenu.modules.search_modules(searchTerm) @@ -3340,7 +3342,7 @@ def do_osx_screenshot(self, line): #execute screenshot module msg = "[*] Tasked agent to take a screenshot" module_menu = ModuleMenu(self.mainMenu, 'python/collection/osx/native_screenshot') - print helpers.color(msg, color="green") + print(helpers.color(msg, color="green")) self.mainMenu.agents.save_agent_log(self.sessionID, msg) # dispatch this event @@ -3353,7 +3355,7 @@ def do_osx_screenshot(self, line): module_menu.do_execute("") else: - print helpers.color("[!] python/collection/osx/screenshot module not loaded") + print(helpers.color("[!] python/collection/osx/screenshot module not loaded")) def do_cat(self, line): "View the contents of a file" @@ -3420,7 +3422,7 @@ def do_loadpymodule(self, line): data = filename + '|' + module_data self.mainMenu.agents.add_agent_task_db(self.sessionID, "TASK_IMPORT_MODULE", data) else: - print helpers.color("[!] Please provide a valid zipfile path", color="red") + print(helpers.color("[!] Please provide a valid zipfile path", color="red")) def do_viewrepo(self, line): @@ -3456,7 +3458,7 @@ def do_removerepo(self, line): dispatcher.send(signal, sender="agents/{}".format(self.sessionID)) msg = "[*] Tasked agent to remove repo: "+repoName - print helpers.color(msg, color="green") + print(helpers.color(msg, color="green")) self.mainMenu.agents.save_agent_log(self.sessionID, msg) self.mainMenu.agents.add_agent_task_db(self.sessionID, "TASK_REMOVE_MODULE", repoName) @@ -3528,7 +3530,7 @@ def do_kill(self, line): if choice.lower() != '' and choice.lower()[0] == 'y': self.mainMenu.listeners.kill_listener('all') except KeyboardInterrupt: - print '' + print('') else: self.mainMenu.listeners.kill_listener(listenerID) @@ -3544,7 +3546,7 @@ def do_delete(self, line): if choice.lower() != '' and choice.lower()[0] == 'y': self.mainMenu.listeners.delete_listener("all") except KeyboardInterrupt: - print '' + print('') else: self.mainMenu.listeners.delete_listener(listener_id) @@ -3555,7 +3557,7 @@ def do_usestager(self, line): parts = line.split(' ') if parts[0] not in self.mainMenu.stagers.stagers: - print helpers.color("[!] Error: invalid stager module") + print(helpers.color("[!] Error: invalid stager module")) elif len(parts) == 1: stager_menu = StagerMenu(self.mainMenu, parts[0]) @@ -3563,13 +3565,13 @@ def do_usestager(self, line): elif len(parts) == 2: listener = parts[1] if not self.mainMenu.listeners.is_listener_valid(listener): - print helpers.color("[!] Please enter a valid listener name or ID") + print(helpers.color("[!] Please enter a valid listener name or ID")) else: self.mainMenu.stagers.set_stager_option('Listener', listener) stager_menu = StagerMenu(self.mainMenu, parts[0]) stager_menu.cmdloop() else: - print helpers.color("[!] Error in ListenerMenu's do_userstager()") + print(helpers.color("[!] Error in ListenerMenu's do_userstager()")) def do_uselistener(self, line): @@ -3578,7 +3580,7 @@ def do_uselistener(self, line): parts = line.split(' ') if parts[0] not in self.mainMenu.listeners.loadedListeners: - print helpers.color("[!] Error: invalid listener module") + print(helpers.color("[!] Error: invalid listener module")) else: listenerMenu = ListenerMenu(self.mainMenu, parts[0]) listenerMenu.cmdloop() @@ -3590,7 +3592,7 @@ def do_info(self, line): listenerName = line.strip() if listenerName not in self.mainMenu.listeners.activeListeners: - print helpers.color("[!] Invalid listener name") + print(helpers.color("[!] Invalid listener name")) else: messages.display_active_listener(self.mainMenu.listeners.activeListeners[listenerName]) @@ -3600,7 +3602,7 @@ def do_launcher(self, line): parts = line.strip().split() if len(parts) != 2: - print helpers.color("[!] Please enter 'launcher '") + print(helpers.color("[!] Please enter 'launcher '")) return else: language = parts[0].lower() @@ -3633,12 +3635,12 @@ def do_launcher(self, line): }) dispatcher.send(signal, sender="empire") - print stager.generate() + print(stager.generate()) except Exception as e: - print helpers.color("[!] Error generating launcher: %s" % (e)) + print(helpers.color("[!] Error generating launcher: %s" % (e))) else: - print helpers.color("[!] Please enter a valid listenerName") + print(helpers.color("[!] Please enter a valid listenerName")) def do_enable(self, line): "Enables and starts one or all listeners." @@ -3646,14 +3648,14 @@ def do_enable(self, line): listenerID = line.strip() if listenerID == '': - print helpers.color("[!] Please provide a listener name") + print(helpers.color("[!] Please provide a listener name")) elif listenerID.lower() == 'all': try: choice = raw_input(helpers.color('[>] Start all listeners? [y/N] ', 'red')) if choice.lower() != '' and choice.lower()[0] == 'y': self.mainMenu.listeners.enable_listener('all') except KeyboardInterrupt: - print '' + print('') else: self.mainMenu.listeners.enable_listener(listenerID) @@ -3669,7 +3671,7 @@ def do_disable(self, line): if choice.lower() != '' and choice.lower()[0] == 'y': self.mainMenu.listeners.shutdown_listener('all') except KeyboardInterrupt: - print '' + print('') else: self.mainMenu.listeners.disable_listener(listenerID) @@ -3679,13 +3681,13 @@ def do_edit(self,line): arguments = line.strip().split(" ") if len(arguments) < 2: - print helpers.color("[!] edit