Skip to content

Commit

Permalink
Merge pull request fortra#727 from 0xdeaddood/timestamp
Browse files Browse the repository at this point in the history
Add the timestamp option to several scripts
  • Loading branch information
asolino authored Jan 6, 2020
2 parents bdf2e3d + 3b41d48 commit 0502d59
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 39 deletions.
6 changes: 4 additions & 2 deletions examples/GetADUsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ def run(self):

# Process command-line arguments.
if __name__ == '__main__':
# Init the example's logger theme
logger.init()
print((version.BANNER))

parser = argparse.ArgumentParser(add_help = True, description = "Queries target domain for users data")
Expand All @@ -188,6 +186,7 @@ def run(self):
parser.add_argument('-all', action='store_true', help='Return all users, including those with no email '
'addresses and disabled accounts. When used with -user it '
'will return user\'s info even if the account is disabled')
parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output')
parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON')

group = parser.add_argument_group('authentication')
Expand All @@ -210,6 +209,9 @@ def run(self):

options = parser.parse_args()

# Init the example's logger theme
logger.init(options.ts)

if options.debug is True:
logging.getLogger().setLevel(logging.DEBUG)
else:
Expand Down
6 changes: 4 additions & 2 deletions examples/GetNPUsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,6 @@ def request_multiple_TGTs(self, usernames):

# Process command-line arguments.
if __name__ == '__main__':
# Init the example's logger theme
logger.init()
print(version.BANNER)

parser = argparse.ArgumentParser(add_help = True, description = "Queries target domain for users with "
Expand All @@ -358,6 +356,7 @@ def request_multiple_TGTs(self, usernames):

parser.add_argument('-usersfile', help='File with user per line to test')

parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output')
parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON')

group = parser.add_argument_group('authentication')
Expand Down Expand Up @@ -394,6 +393,9 @@ def request_multiple_TGTs(self, usernames):

options = parser.parse_args()

# Init the example's logger theme
logger.init(options.ts)

if options.debug is True:
logging.getLogger().setLevel(logging.DEBUG)
else:
Expand Down
10 changes: 6 additions & 4 deletions examples/atexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,12 @@ def output_callback(data):
# Process command-line arguments.
if __name__ == '__main__':
print(version.BANNER)
# Init the example's logger theme
logger.init()

logging.warning("This will work ONLY on Windows >= Vista")

parser = argparse.ArgumentParser()

parser.add_argument('target', action='store', help='[[domain/]username[:password]@]<targetName or address>')
parser.add_argument('command', action='store', nargs='*', default = ' ', help='command to execute at the target ')
parser.add_argument('-ts', action='store_true', help='adds timestamp to every logging output')
parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON')

group = parser.add_argument_group('authentication')
Expand All @@ -207,6 +204,11 @@ def output_callback(data):

options = parser.parse_args()

# Init the example's logger theme
logger.init(options.ts)

logging.warning("This will work ONLY on Windows >= Vista")

if ''.join(options.command) == ' ':
logging.error('You need to specify a command to execute!')
sys.exit(1)
Expand Down
6 changes: 4 additions & 2 deletions examples/dcomexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,6 @@ def load_smbclient_auth_file(path):

# Process command-line arguments.
if __name__ == '__main__':
# Init the example's logger theme
logger.init()
print(version.BANNER)

parser = argparse.ArgumentParser(add_help = True, description = "Executes a semi-interactive shell using the "
Expand All @@ -507,6 +505,7 @@ def load_smbclient_auth_file(path):
'(default ADMIN$)')
parser.add_argument('-nooutput', action='store_true', default = False, help='whether or not to print the output '
'(no SMB connection created)')
parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output')
parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON')
parser.add_argument('-object', choices=['ShellWindows', 'ShellBrowserWindow', 'MMC20'], nargs='?', default='ShellWindows',
help='DCOM object to be used to execute the shell command (default=ShellWindows)')
Expand Down Expand Up @@ -534,6 +533,9 @@ def load_smbclient_auth_file(path):

options = parser.parse_args()

# Init the example's logger theme
logger.init(options.ts)

if ' '.join(options.command) == ' ' and options.nooutput is True:
logging.error("-nooutput switch and interactive shell not supported")
sys.exit(1)
Expand Down
6 changes: 4 additions & 2 deletions examples/getST.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,6 @@ def run(self):
self.saveTicket(tgs,oldSessionKey)

if __name__ == '__main__':
# Init the example's logger theme
logger.init()
print(version.BANNER)

parser = argparse.ArgumentParser(add_help=True, description="Given a password, hash or aesKey, it will request a "
Expand All @@ -398,6 +396,7 @@ def run(self):
' for quering the ST. Keep in mind this will only work if '
'the identity provided in this scripts is allowed for '
'delegation to the SPN specified')
parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output')
parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON')

group = parser.add_argument_group('authentication')
Expand All @@ -421,6 +420,9 @@ def run(self):

options = parser.parse_args()

# Init the example's logger theme
logger.init(options.ts)

if options.debug is True:
logging.getLogger().setLevel(logging.DEBUG)
else:
Expand Down
6 changes: 4 additions & 2 deletions examples/getTGT.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,12 @@ def run(self):
self.saveTicket(tgt,oldSessionKey)

if __name__ == '__main__':
# Init the example's logger theme
logger.init()
print(version.BANNER)

parser = argparse.ArgumentParser(add_help=True, description="Given a password, hash or aesKey, it will request a "
"TGT and save it as ccache")
parser.add_argument('identity', action='store', help='[domain/]username[:password]')
parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output')
parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON')

group = parser.add_argument_group('authentication')
Expand All @@ -88,6 +87,9 @@ def run(self):

options = parser.parse_args()

# Init the example's logger theme
logger.init(options.ts)

if options.debug is True:
logging.getLogger().setLevel(logging.DEBUG)
else:
Expand Down
6 changes: 4 additions & 2 deletions examples/goldenPac.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,8 +1036,6 @@ def exploit(self):
executer.run(self.__target)

if __name__ == '__main__':
# Init the example's logger theme
logger.init()
import argparse
import sys
try:
Expand Down Expand Up @@ -1073,6 +1071,7 @@ def exploit(self):
"target or saves the TGT for later use.")

parser.add_argument('target', action='store', help='[[domain/]username[:password]@]<targetName>')
parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output')
parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON')
parser.add_argument('command', nargs='*', default=' ',
help='command (or arguments if -c is used) to execute at the target (w/o path). Defaults to '
Expand Down Expand Up @@ -1106,6 +1105,9 @@ def exploit(self):

options = parser.parse_args()

# Init the example's logger theme
logger.init(options.ts)

import re

domain, username, password, address = re.compile('(?:(?:([^/@:]*)/)?([^@:]*)(?::([^@]*))?@)?(.*)').match(
Expand Down
6 changes: 4 additions & 2 deletions examples/lookupsid.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ def __bruteForce(self, rpctransport, maxRid):

# Process command-line arguments.
if __name__ == '__main__':
# Init the example's logger theme
logger.init()
# Explicitly changing the stdout encoding format
if sys.stdout.encoding is None:
# Output is redirected to a file
Expand All @@ -150,6 +148,7 @@ def __bruteForce(self, rpctransport, maxRid):

parser.add_argument('target', action='store', help='[[domain/]username[:password]@]<targetName or address>')
parser.add_argument('maxRid', action='store', default = '4000', nargs='?', help='max Rid to check (default 4000)')
parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output')

group = parser.add_argument_group('connection')

Expand All @@ -171,6 +170,9 @@ def __bruteForce(self, rpctransport, maxRid):

options = parser.parse_args()

# Init the example's logger theme
logger.init(options.ts)

import re

domain, username, password, remoteName = re.compile('(?:(?:([^/@:]*)/)?([^@:]*)(?::([^@]*))?@)?(.*)').match(
Expand Down
6 changes: 4 additions & 2 deletions examples/netview.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,6 @@ def stop(self):
# Process command-line arguments.
if __name__ == '__main__':
print(version.BANNER)
# Init the example's logger theme
logger.init()

parser = argparse.ArgumentParser()

Expand All @@ -453,6 +451,7 @@ def stop(self):
'(default 10 seconds)')
parser.add_argument('-max-connections', action='store', default='1000', help='Max amount of connections to keep '
'opened (default 1000)')
parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output')
parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON')

group = parser.add_argument_group('authentication')
Expand All @@ -473,6 +472,9 @@ def stop(self):

options = parser.parse_args()

# Init the example's logger theme
logger.init(options.ts)

if options.debug is True:
logging.getLogger().setLevel(logging.DEBUG)
else:
Expand Down
6 changes: 4 additions & 2 deletions examples/ntlmrelayx.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ def stop_servers(threads):
# Process command-line arguments.
if __name__ == '__main__':

# Init the example's logger theme
logger.init()
print(version.BANNER)
#Parse arguments
parser = argparse.ArgumentParser(add_help = False, description = "For every connection received, this module will "
Expand All @@ -201,6 +199,7 @@ def stop_servers(threads):

#Main arguments
parser.add_argument("-h","--help", action="help", help='show this help message and exit')
parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output')
parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON')
parser.add_argument('-t',"--target", action='store', metavar = 'TARGET', help='Target to relay the credentials to, '
'can be an IP, hostname or URL like smb://server:445 If unspecified, it will relay back to the client')
Expand Down Expand Up @@ -297,6 +296,9 @@ def stop_servers(threads):
logging.error(str(e))
sys.exit(1)

# Init the example's logger theme
logger.init(options.ts)

if options.debug is True:
logging.getLogger().setLevel(logging.DEBUG)
else:
Expand Down
6 changes: 4 additions & 2 deletions examples/psexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,6 @@ def run(self):

# Process command-line arguments.
if __name__ == '__main__':
# Init the example's logger theme
logger.init()
print(version.BANNER)

parser = argparse.ArgumentParser(add_help = True, description = "PSEXEC like functionality example using RemComSvc.")
Expand All @@ -431,6 +429,7 @@ def run(self):
'arguments are passed in the command option')
parser.add_argument('-path', action='store', help='path of the command to execute')
parser.add_argument('-file', action='store', help="alternative RemCom binary (be sure it doesn't require CRT)")
parser.add_argument('-ts', action='store_true', help='adds timestamp to every logging output')
parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON')

group = parser.add_argument_group('authentication')
Expand Down Expand Up @@ -461,6 +460,9 @@ def run(self):

options = parser.parse_args()

# Init the example's logger theme
logger.init(options.ts)

if options.debug is True:
logging.getLogger().setLevel(logging.DEBUG)
else:
Expand Down
6 changes: 4 additions & 2 deletions examples/raiseChild.py
Original file line number Diff line number Diff line change
Expand Up @@ -1211,15 +1211,14 @@ def exploit(self):
executer.run(self.__target)

if __name__ == '__main__':
# Init the example's logger theme
logger.init()

print(version.BANNER)

parser = argparse.ArgumentParser(add_help = True, description = "Privilege Escalation from a child domain up to its "
"forest")

parser.add_argument('target', action='store', help='domain/username[:password]')
parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output')
parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON')
parser.add_argument('-w', action='store',metavar = "pathname", help='writes the golden ticket in CCache format '
'into the <pathname> file')
Expand Down Expand Up @@ -1254,6 +1253,9 @@ def exploit(self):

options = parser.parse_args()

# Init the example's logger theme
logger.init(options.ts)

import re
# This is because I'm lazy with regex
# ToDo: We need to change the regex to fullfil domain/username[:password]
Expand Down
6 changes: 4 additions & 2 deletions examples/samrdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ def __fetchList(self, rpctransport):

# Process command-line arguments.
if __name__ == '__main__':
# Init the example's logger theme
logger.init()
# Explicitly changing the stdout encoding format
if sys.stdout.encoding is None:
# Output is redirected to a file
Expand All @@ -203,6 +201,7 @@ def __fetchList(self, rpctransport):

parser.add_argument('target', action='store', help='[[domain/]username[:password]@]<targetName or address>')
parser.add_argument('-csv', action='store_true', help='Turn CSV output')
parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output')
parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON')

group = parser.add_argument_group('connection')
Expand Down Expand Up @@ -231,6 +230,9 @@ def __fetchList(self, rpctransport):

options = parser.parse_args()

# Init the example's logger theme
logger.init(options.ts)

if options.debug is True:
logging.getLogger().setLevel(logging.DEBUG)
else:
Expand Down
6 changes: 4 additions & 2 deletions examples/secretsdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ def cleanup(self):

# Process command-line arguments.
if __name__ == '__main__':
# Init the example's logger theme
logger.init()
# Explicitly changing the stdout encoding format
if sys.stdout.encoding is None:
# Output is redirected to a file
Expand All @@ -281,6 +279,7 @@ def cleanup(self):

parser.add_argument('target', action='store', help='[[domain/]username[:password]@]<targetName or address> or LOCAL'
' (if you want to parse local files)')
parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output')
parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON')
parser.add_argument('-system', action='store', help='SYSTEM hive to parse')
parser.add_argument('-bootkey', action='store', help='bootkey for SYSTEM hive')
Expand Down Expand Up @@ -331,6 +330,9 @@ def cleanup(self):

options = parser.parse_args()

# Init the example's logger theme
logger.init(options.ts)

if options.debug is True:
logging.getLogger().setLevel(logging.DEBUG)
else:
Expand Down
Loading

0 comments on commit 0502d59

Please sign in to comment.