added channel all clear command

This commit is contained in:
Mariusz B. / mgeeky 2021-03-24 04:36:30 +01:00
parent 51c6c8470f
commit 0fc012e832
2 changed files with 30 additions and 5 deletions

View File

@ -14,7 +14,7 @@ The script offers subcommands-kind of CLI interface, so after every command one
``` ```
PS D:\> py c3-client.py --help PS D:\> py c3-client.py --help
:: C3 Client - a lightweight automated companion with C3 voyages :: F-Secure's C3 Client - a lightweight automated companion with C3 voyages
Mariusz B. / mgeeky, <mb@binary-offensive.com> Mariusz B. / mgeeky, <mb@binary-offensive.com>
usage: usage:
@ -45,7 +45,7 @@ optional arguments:
``` ```
PS D:\> py c3-client.py -f text http://192.168.0.200:52935 alarm relay --help PS D:\> py c3-client.py -f text http://192.168.0.200:52935 alarm relay --help
:: C3 Client - a lightweight automated companion with C3 voyages :: F-Secure's C3 Client - a lightweight automated companion with C3 voyages
Mariusz B. / mgeeky, <mb@binary-offensive.com> Mariusz B. / mgeeky, <mb@binary-offensive.com>
usage: Usage: ./c3-client.py [options] <host> <command> [...] alarm relay [-h] [-e EXECUTE] [-x WEBHOOK] [-g gateway_id] usage: Usage: ./c3-client.py [options] <host> <command> [...] alarm relay [-h] [-e EXECUTE] [-x WEBHOOK] [-g gateway_id]
@ -81,6 +81,8 @@ Currently, following commands are supported:
- `ping` - ping selected Relays - `ping` - ping selected Relays
- `channel` - channel-specific commands - `channel` - channel-specific commands
- `all`
- `clear` - Clear message queue of every supported channel at once
- `mattermost` - `mattermost`
- `clear` - Clear Mattermost's channel messages to improve bandwidth - `clear` - Clear Mattermost's channel messages to improve bandwidth
- `ldap` - `ldap`
@ -105,7 +107,7 @@ This example shows how to keep all of your Relays pinged every 45 seconds:
``` ```
PS D:\> py c3-client.py http://192.168.0.200:52935 ping -k 45 PS D:\> py c3-client.py http://192.168.0.200:52935 ping -k 45
:: C3 Client - a lightweight automated companion with C3 voyages :: F-Secure's C3 Client - a lightweight automated companion with C3 voyages
Mariusz B. / mgeeky, <mb@binary-offensive.com> Mariusz B. / mgeeky, <mb@binary-offensive.com>
[.] Sending a ping every 45 seconds. [.] Sending a ping every 45 seconds.
@ -131,7 +133,7 @@ In this example setup an alarm that triggers upon new Relay checking-in. Wheneve
``` ```
PS D:\> py c3-client.py http://192.168.0.200:52935 alarm relay -g gate4 --execute "powershell -file speak.ps1 -message \`"New C3 Relay Inbound: <domain>/<userName>, computer: <computerName>\`"" PS D:\> py c3-client.py http://192.168.0.200:52935 alarm relay -g gate4 --execute "powershell -file speak.ps1 -message \`"New C3 Relay Inbound: <domain>/<userName>, computer: <computerName>\`""
:: C3 Client - a lightweight automated companion with C3 voyages :: F-Secure's C3 Client - a lightweight automated companion with C3 voyages
Mariusz B. / mgeeky, <mb@binary-offensive.com> Mariusz B. / mgeeky, <mb@binary-offensive.com>
[.] Entering infinite-loop awaiting for new Relays... [.] Entering infinite-loop awaiting for new Relays...

View File

@ -521,6 +521,21 @@ def getLastGatewayCommandID(gateway, secondOrder = True):
return lastId return lastId
def onAllChannelsClear(args):
channels = {
'LDAP' : onLDAPClear,
'MSSQL' : onMSSQLClearTable,
'Mattermost' : onMattermostPurge,
'GoogleDrive' : onGoogleDriveClear,
'Github' : onGithubClear,
'Dropbox' : onDropboxClear,
'UncShareFile' : onUncShareFileClear,
}
for k, v in channels.items():
print(f'\n[.] {k}: Clearing messages queue...')
v(args)
def onMattermostPurge(args): def onMattermostPurge(args):
data = { data = {
'data' : { 'data' : {
@ -1091,6 +1106,14 @@ def parseArgs(argv):
parser_channel.add_argument('-g', '--gateway-id', metavar='gateway_id', help = 'ID (or Name) of the Gateway which Relays should be pinged. If not given, will ping all relays in all gateways.') parser_channel.add_argument('-g', '--gateway-id', metavar='gateway_id', help = 'ID (or Name) of the Gateway which Relays should be pinged. If not given, will ping all relays in all gateways.')
parser_channel_sub = parser_channel.add_subparsers(help = 'Specify channel', required = True) parser_channel_sub = parser_channel.add_subparsers(help = 'Specify channel', required = True)
## All channels
all_channels = parser_channel_sub.add_parser('all', help = 'Commands that are common for all channels.')
all_channels_parser = all_channels.add_subparsers(help = 'Command to send', required = True)
### clear
all_channels_clear = all_channels_parser.add_parser('clear', help = 'Clear every channel\'s message queue.')
all_channels_clear.set_defaults(func = onAllChannelsClear)
## Mattermost ## Mattermost
mattermost = parser_channel_sub.add_parser('mattermost', help = 'Mattermost channel specific commands.') mattermost = parser_channel_sub.add_parser('mattermost', help = 'Mattermost channel specific commands.')
@ -1171,7 +1194,7 @@ def parseArgs(argv):
def main(argv): def main(argv):
print(''' print('''
:: C3 Client - a lightweight automated companion with C3 voyages :: F-Secure's C3 Client - a lightweight automated companion with C3 voyages
Mariusz B. / mgeeky, <mb@binary-offensive.com> Mariusz B. / mgeeky, <mb@binary-offensive.com>
''') ''')
parseArgs(argv) parseArgs(argv)