Empire/empire

51 lines
1.9 KiB
Python
Executable File

#!/usr/bin/python
import sqlite3, argparse, time, sys, os, subprocess, logging
# Empire imports
from lib.common import empire
from lib.common import listeners
from lib.common import http
from lib.common import packets
from lib.common import messages
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--debug', nargs='?', const='1', help='Debug level for output (default of 1).')
parser.add_argument('-s', '--stager', nargs='?', const="list", help='Specify a stager to generate. Lists all stagers if none is specified.')
parser.add_argument('-o', '--stager-options', nargs='*', help="Supply options to set for a stager in OPTION=VALUE format. Lists options if nothing is specified.")
parser.add_argument('-l', '--listener', nargs='?', const="list", help='Display listener options. Displays all listeners if nothing is specified.')
parser.add_argument('-v', '--version', action='store_true', help='Display current Empire version.')
parser.add_argument('--headless', action='store_true', help='Run Empire and the RESTful API headless without the usual interface.')
args = parser.parse_args()
if args.version:
print empire.VERSION
else:
main = empire.MainMenu(args=args)
if args.headless:
# start the ./empire-rest API handler
restAPI = subprocess.Popen(["./empire-rest", "--suppress"])
# suppress all stdout and don't initiate the main cmdloop
oldStdout = sys.stdout
sys.stdout = open(os.devnull, 'w')
try:
time.sleep(100)
except KeyboardInterrupt as e:
# shutdown the controller on ^C
main.shutdown()
# repair stdout
sys.stdout.close()
sys.stdout = oldStdout
# shut down ./empire-rest
restAPI.terminate()
else:
main.cmdloop()