|
8 | 8 | from empire.server.common.config import empire_config
|
9 | 9 | from empire.server.database import models
|
10 | 10 |
|
11 |
| -database_config = empire_config.yaml.get('database', {}).get('defaults', {}) |
| 11 | +database_config = empire_config.database.defaults |
12 | 12 |
|
13 | 13 |
|
14 | 14 | def get_default_hashed_password():
|
15 |
| - password = database_config.get('password', 'password123') |
16 |
| - password = bytes(password, 'UTF-8') |
| 15 | + password = database_config.get("password", "password123") |
| 16 | + password = bytes(password, "UTF-8") |
17 | 17 | return bcrypt.hashpw(password, bcrypt.gensalt())
|
18 | 18 |
|
19 | 19 |
|
20 | 20 | def get_default_user():
|
21 |
| - return models.User(username=database_config.get('username', 'empireadmin'), |
22 |
| - password=get_default_hashed_password(), |
23 |
| - enabled=True, |
24 |
| - admin=True) |
| 21 | + return models.User( |
| 22 | + username=database_config.get("username", "empireadmin"), |
| 23 | + password=get_default_hashed_password(), |
| 24 | + enabled=True, |
| 25 | + admin=True, |
| 26 | + ) |
25 | 27 |
|
26 | 28 |
|
27 | 29 | def get_default_config():
|
28 | 30 | # Calculate the install path. We know the project directory will always be two levels up of the current directory.
|
29 | 31 | # Any modifications of the folder structure will need to be applied here.
|
30 | 32 | install_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
31 |
| - return models.Config(staging_key=get_staging_key(), |
32 |
| - install_path=install_path, |
33 |
| - ip_whitelist=database_config.get('ip-whitelist', ''), |
34 |
| - ip_blacklist=database_config.get('ip-blacklist', ''), |
35 |
| - autorun_command="", |
36 |
| - autorun_data="", |
37 |
| - rootuser=True, |
38 |
| - obfuscate=database_config.get('obfuscate', False), |
39 |
| - obfuscate_command=database_config.get('obfuscate-command', r'Token\All\1')) |
| 33 | + return models.Config( |
| 34 | + staging_key=get_staging_key(), |
| 35 | + install_path=install_path, |
| 36 | + ip_whitelist=database_config.get("ip-whitelist", ""), |
| 37 | + ip_blacklist=database_config.get("ip-blacklist", ""), |
| 38 | + autorun_command="", |
| 39 | + autorun_data="", |
| 40 | + rootuser=True, |
| 41 | + obfuscate=database_config.get("obfuscate", False), |
| 42 | + obfuscate_command=database_config.get("obfuscate-command", r"Token\All\1"), |
| 43 | + ) |
40 | 44 |
|
41 | 45 |
|
42 | 46 | def get_default_functions():
|
43 | 47 | return [
|
44 |
| - models.Function(keyword='Invoke_Empire', |
45 |
| - replacement=''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(5))), |
46 |
| - models.Function(keyword='Invoke_Mimikatz', |
47 |
| - replacement=''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(5))) |
| 48 | + models.Function( |
| 49 | + keyword="Invoke_Empire", |
| 50 | + replacement="".join( |
| 51 | + random.choice(string.ascii_uppercase + string.digits) for _ in range(5) |
| 52 | + ), |
| 53 | + ), |
| 54 | + models.Function( |
| 55 | + keyword="Invoke_Mimikatz", |
| 56 | + replacement="".join( |
| 57 | + random.choice(string.ascii_uppercase + string.digits) for _ in range(5) |
| 58 | + ), |
| 59 | + ), |
48 | 60 | ]
|
49 | 61 |
|
50 | 62 |
|
51 | 63 | def get_staging_key():
|
52 | 64 | # Staging Key is set up via environmental variable or config.yaml. By setting RANDOM a randomly selected password
|
53 | 65 | # will automatically be selected.
|
54 |
| - staging_key = os.getenv('STAGING_KEY') or database_config.get('staging-key', 'BLANK') |
55 |
| - punctuation = '!#%&()*+,-./:;<=>?@[]^_{|}~' |
| 66 | + staging_key = os.getenv("STAGING_KEY") or database_config.get( |
| 67 | + "staging-key", "BLANK" |
| 68 | + ) |
| 69 | + punctuation = "!#%&()*+,-./:;<=>?@[]^_{|}~" |
56 | 70 | if staging_key == "BLANK":
|
57 |
| - choice = input("\n [>] Enter server negotiation password, enter for random generation: ") |
| 71 | + choice = input( |
| 72 | + "\n [>] Enter server negotiation password, enter for random generation: " |
| 73 | + ) |
58 | 74 | if choice != "" and choice != "RANDOM":
|
59 |
| - return hashlib.md5(choice.encode('utf-8')).hexdigest() |
| 75 | + return hashlib.md5(choice.encode("utf-8")).hexdigest() |
60 | 76 |
|
61 |
| - print('\x1b[1;34m[*] Generating random staging key\x1b[0m') |
62 |
| - return ''.join(random.sample(string.ascii_letters + string.digits + punctuation, 32)) |
| 77 | + print("\x1b[1;34m[*] Generating random staging key\x1b[0m") |
| 78 | + return "".join( |
| 79 | + random.sample(string.ascii_letters + string.digits + punctuation, 32) |
| 80 | + ) |
0 commit comments