-
Notifications
You must be signed in to change notification settings - Fork 25
/
gtfo.py
executable file
·73 lines (60 loc) · 2.8 KB
/
gtfo.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
#!/usr/bin/env python3
# coding=utf-8
import argparse
import json
import os
from string import Template
from colorama import Fore, Style
from pygments import highlight, formatters, lexers
banner = '''
__ ___ __ _
___ _ / /_ / _/ ___ / / (_) ___ ___
/ _ `// __/ / _/ / _ \ / _ \ / / / _ \ (_-<
\_, / \__/ /_/ \___//_.__//_/ /_//_//___/
/___/
'''
data_dir = "data/"
json_ext = ".json"
info = Template(Style.BRIGHT + '[ ' + Fore.GREEN + '*' + Fore.RESET + ' ] ' + Style.RESET_ALL + '$text')
fail = Template(Style.BRIGHT + '[ ' + Fore.RED + '-' + Fore.RESET + ' ] ' + Style.RESET_ALL + '$text')
title = Template(
'\n' + Style.BRIGHT + '---------- [ ' + Fore.CYAN + '$title' + Fore.RESET + ' ] ----------' + Style.RESET_ALL + '\n'
)
description = Template(Style.DIM + '# ' + '$description' + Style.RESET_ALL)
divider = '\n' + Style.BRIGHT + ' - ' * 10 + Style.RESET_ALL + '\n'
def parse_args():
parser = argparse.ArgumentParser(usage="python3 gtfo.py [binary]",
description="Command-line program for GTFOBins. "
"It helps you to bypass system security restrictions. Version 1.0")
parser.add_argument('-v', '--version', action='version', version='%(prog)s 1.0')
parser.add_argument('binary', metavar='[binary]', action='store', help='specifies the binary file')
return parser.parse_args()
def main(binary):
file_path = data_dir + binary + json_ext
if os.path.isfile(file_path):
print(info.safe_substitute(text="Supplied binary: " + binary))
print(info.safe_substitute(text="Please wait, loading data ... "))
with open(file_path) as source:
data = source.read()
json_data = json.loads(data)
if 'description' in json_data:
print('\n' + description.safe_substitute(description=json_data['description']))
for vector in json_data['functions']:
print(title.safe_substitute(title=str(vector).upper()))
index = 0
for code in json_data['functions'][vector]:
index = index + 1
if 'description' in code:
print(description.safe_substitute(description=code['description']) + '\n')
print(highlight(code['code'], lexers.BashLexer(),
formatters.TerminalTrueColorFormatter(style='igor')).strip())
if index != len(json_data['functions'][vector]):
print(divider)
print('\n' + info.safe_substitute(text="Goodbye, friend."))
else:
print(fail.safe_substitute(text="Sorry, couldn't find anything for " + binary))
if __name__ == '__main__':
os.system('cls' if os.name == 'nt' else 'clear')
print(banner)
args = parse_args()
main(binary=args.binary)