-
Notifications
You must be signed in to change notification settings - Fork 0
/
vshell-pw.py
71 lines (63 loc) · 2.16 KB
/
vshell-pw.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
import paramiko
import socket
import time
import logging
import string
import random
#host='10.24.253.248'
host='10.24.254.181'
user='root'
initpw="aA@1234567"
psw="""aA@1234567"""
#0=match and min/max,1=unmatch
def gen(inp=0):
#chs=map(chr,range(32,127))
digits=map(chr,range(48,58))
symbols=map(chr,range(32,48)+range(58,65)+range(91,97)+range(123,127))
upletters=list(string.ascii_uppercase)
lowletters=list(string.lowercase)
ctrlchars=map(chr,range(0,32))
extendchars=map(chr,range(127,256))
if inp==0:
comb=digits+symbols+upletters+lowletters
pos_padding=''.join([random.choice(comb) for x in range(random.randint(4,28))])
out=random.choice(digits)+random.choice(symbols)+random.choice(upletters)+random.choice(lowletters)+pos_padding
print len(out)
print out
return out
elif inp==1:
comb=digits+symbols+upletters+lowletters+ctrlchars+extendchars
neg_padding=''.join([random.choice(comb) for x in range(random.randint(2,30))])
out=random.choice(digits)+random.choice(symbols)+random.choice(upletters)+random.choice(lowletters)+neg_padding
print len(out)
print out
return out
elif inp==2:
comb=random.choice([digits+symbols+upletters,digits+symbols+upletters+lowletters,digits+symbols+upletters+lowletters+ctrlchars+extendchars])
neg_padding=''.join([random.choice(comb) for x in range(random.randint(4,28))])
out=random.choice(digits)+random.choice(symbols)+random.choice(upletters)+neg_padding
print len(out)
print out
return out
def login(password=psw):
global psw
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host,username=user,password=password,timeout=30)
channel = ssh.invoke_shell()
channel.send('passwd\n')
#time.sleep(1)
psw=gen(1)
channel.send(psw+'\n')
time.sleep(1)
channel.send(psw+'\n')
ssh.close()
#for i in range(10):gen(2)
for i in range(10000):
try:
#print psw
login(password=initpw)
#print psw
except (socket.error, NameError) as e:
print e
pass