Helper functions for printing to the Beacon Console and Script Console. This includes:
- Modifying the Beacon Console output with Aggressor's undocumented
set BEACON_OUTPUTblocks. - Helper functions for coloring and styling text.
- Helper functions for creating ASCII tables and aligned text in the console.
Changing Beacon Console output (regular example):
def beacon_output(bid, contents):
return '<output>\n{}\n</output>'.format(contents)
console.register_modifier('beacon_output', beacon_output)
Changing Beacon Console output (decorator example):
@console.modifier('beacon_output')
def beacon_output(bid, contents):
return '<output>\n{}\n</output>'.format(contents)
Printing colored text to the Script Console:
engine.message(console.red('red text'));
I'm sort of color blind so orange might be red and cyan might be blue. To see all of Cobalt Strike's color options run this in the Script Console:
e for ($i = 0; $i < 100; $i++) { println($i . " \x03" . chr($i) . "test"); }
I've attempted to document the arguments to various output modifiers below.
This documentation is mostly based on Cobalt Strike's
default.cna.
Event Log messages
EVENT_PUBLIC: from, text, whenEVENT_PRIVATE: from, to, text, whenEVENT_ACTION: from, text, whenEVENT_JOIN: from, whenEVENT_QUIT: from, whenEVENT_NOTIFY: text, whenEVENT_NEWSITE: from, text, whenEVENT_NOUSER: to, whenEVENT_BEACON_INITIAL: from, whenEVENT_SSH_INITIAL: from, whenEVENT_USERS: usersEVENT_SBAR_LEFT: <no arguments?>EVENT_SBAR_RIGHT: lag
Web Log
WEB_HIT: method, uri, addr, ua, response, size, handler, when
Profiler
PROFILER_HIT:
Keystrokes
KEYLOGGER_HIT:
Beacon Console
BEACON_SBAR_LEFT: bid, metadataBEACON_SBAR_RIGHT: bid, metadataBEACON_CHECKIN: bid, messageBEACON_ERROR: bid, messageBEACON_TASKED: bid, messageBEACON_OUTPUT: bid, messageBEACON_OUTPUT_ALT: bid, messageBEACON_OUTPUT_PS: bid, output (seehelpers.parse_ps)BEACON_OUTPUT_LS: bid, output (seehelpers.parse_ls)BEACON_OUTPUT_JOBS: bid, output (seehelpers.parse_jobs)BEACON_OUTPUT_DOWNLOADS: bid, downloads={'name', 'path', 'size', 'rcvd'}BEACON_OUTPUT_EXPLOITS: <no arguments?>BEACON_OUTPUT_HELP: <no arguments?>BEACON_OUTPUT_HELP_COMMAND: commandBEACON_MODE: bid?, outputBEACON_INPUT: bid, user, text, when
Phishing
SENDMAIL_START: unknown, ntarget, attachment, bounceto, server, subject, templatef, urlSENDMAIL_PRE: unknown, destSENDMAIL_POST: cid, email, status, messageSENDMAIL_DONE: <no arguments?>
SSH Beacon Console
SSH_OUTPUT_HELP: <no arguments?>SSH_OUTPUT_HELP_COMMAND: commandSSH_SBAR_LEFT: bid, metadataSSH_SBAR_RIGHT: bid, metadataSSH_CHECKIN: bid, messageSSH_ERROR: bid, messageSSH_TASKED: bid, messageSSH_OUTPUT: bid, messageSSH_OUTPUT_ALT: bid, messageSSH_OUTPUT_DOWNLOADS: bid, downloads={'name', 'path', 'size', 'rcvd'}SSH_INPUT: bid, user, text, when
is_known_modifier(name)Check if a modifier is one of the known cobaltstrike ones
Arguments:
name: Name of modifier
Returns:
True if modifier is a known one
register_modifier(name, callback, known_only=True)Register a modifier callback.
Arguments:
name: Name of modifier (case-insensitive)callback: Modifier callbackknown_only: Only allow known modifiers
Returns:
Name of registered callback
unregister_modifier(callback)Unregister a modifier callback. There's no way to easily unregister a callback in Aggressor so this will forever leave us with broken callbacks coming back from the teamserver.
Arguments:
callback: Callback to unregister
Returns:
Name of unregistered callback
modifier(name, known_only=True)Decorator for output modifier registration
stripped_length(string)Get the length of a string without control codes
Arguments:
string: String
Returns:
Length of string minus control codes
justify(string, total, side='left', fill=' ')Justify a string for the console
Arguments:
string: String to justifytotal: Total size to justify toside: Side to justify to (center, left, or right)fill: Character to fill with
Returns:
Justified string
table(items, keys=None, show_headers=True)Make a pretty ASCII table
Arguments:
items: Items to make a table for (list of dictionaries)keys: Either a list of dictionary keys or a dictionary containing{key: pretty_header}show_headers: Show the table headers (default: True)
Returns:
Pretty ASCII table
strip(text)Strip control codes from a string.
Arguments:
text: String to strip
Returns:
Stripped string
bold(text)Style text bold for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
underline(text)Style text underlined for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
white(text)Style text white for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
black(text)Style text black for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
blue(text)Style text blue for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
green(text)Style text green for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
orange_red(text)Style text orange-red for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
red(text)Style text red for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
purple(text)Style text purple for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
orange(text)Style text orange for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
yellow(text)Style text yellow for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
bright_green(text)Style text bright-green for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
blue_green(text)Style text blue-green for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
cyan(text)Style text cyan for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
light_purple(text)Style text light-purple for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
pink(text)Style text pink for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text
grey(text)Style text grey for the Script Console and Beacon Console.
Arguments:
text: Text to style
Returns:
Styled text