-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathFileDownloader.py
More file actions
75 lines (52 loc) · 1.94 KB
/
FileDownloader.py
File metadata and controls
75 lines (52 loc) · 1.94 KB
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
from ConfigDecrypter import ConfigDecrypter
from includes import BotConfig
from includes import C2Communications
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--file', help="file to download from C2", required=True)
parser.add_argument('-o', '--output', help="output file")
args = parser.parse_args()
bot = BotConfig.Bot()
servers = bot.get_servers()
for server in servers:
command = C2Communications.C2(bot, server)
print('trying server: {}'.format(server))
if not bot.config['registered']:
response = command.register()
result_code, data = response
if result_code != 200:
continue
bot.config['registered'] = True
response = command.get_main_config()
result_code, data = response
if result_code != 200:
continue
decrypter = ConfigDecrypter(data)
new_config = decrypter.decrypt()
bot.merge_server_list(new_config)
if args.file == 'main':
file_data = new_config
else:
response = command.get_file(args.file)
result_code, data = response
if result_code == 404:
print('Error: file does not exist')
exit(0)
if result_code == 403:
bot.config['registered'] = False
continue
elif result_code != 200:
continue
decrypter = ConfigDecrypter(data)
file_data = decrypter.decrypt()
if args.output:
output_file = open(args.output, 'w')
output_file.write(file_data)
output_file.close()
print('saved output to {}'.format(args.output))
else:
print(file_data)
bot.save_config()
exit(0)
raise RuntimeError("Failed to find a working C2, try finding a new list.")