Skip to content

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” AI for Pentesting β€” Hands-On Assignment

Course: Cryptography and Network Security
University: Chanakya University, Bengaluru
Author: Baire Gowda | Reg: 25PG00157 | MCA – Cybersecurity & ML


πŸ“‹ Overview

This repository documents my hands-on penetration testing assignment where I used AI tools as assistants to find real vulnerabilities on intentionally vulnerable websites.

The key idea: AI is an assistant, not an autopilot. Every finding in this project was manually confirmed by me β€” AI only suggested where to look.


🎯 Targets

Target URL Type
Target 1 demo.testfire.net Altoro Mutual β€” fake banking app by HCL
Target 2 zero.webappsecurity.com Zero Bank β€” fake banking app by Micro Focus

Note: testphp.vulnweb.com (originally planned) was down β€” AWS cloud firewall blocked all ports. Switched to zero.webappsecurity.com. This itself is a real-world observation documented in the report.


πŸ€– AI Tools Used

AI Tool Role Rating
Claude (Anthropic) Primary assistant β€” recon analysis, attack strategy, payload suggestions, Python help 9/10
Gemini (Google) Tested for comparison β€” refused to give target-specific payloads even for authorized site 6/10
Perplexity AI Payload research with source citations 8/10

Why Claude Was Best

  • Understood technical context (exact URLs, parameter names)
  • Explained why attacks work, not just the payload
  • Helped write and debug Python scripts step by step
  • Honest when uncertain β€” never gave confident wrong answers

Gemini's Refusal = A Finding Itself

Gemini refused to give specific attack vectors even for this authorized training site:

"While I understand this is for an authorized penetration test... I cannot provide specific target URLs or tailored attack vectors."

This shows AI guardrails can block legitimate security research β€” documented in Section 7 of the report.


πŸ› οΈ Tools Used (All Free)

Tool Purpose Evidence
Nmap 7.98 Port scanning & service detection Found ports 80, 443, 8080 on both targets
ffuf Directory fuzzing Found /admin, /bank, /server-status
curl HTTP requests from terminal Headers, login testing, cookie capture
Firefox (Kali) Manual browser testing Confirmed XSS alert, SQL injection, SSL error
Python 3.13 Wrote 6 automated pentest scripts All with real terminal outputs
base64 (Linux) Decoded sensitive cookie data Found 2 credit card numbers in plaintext

🐍 Python Scripts

Target 1 β€” demo.testfire.net

scripts/target1/
β”œβ”€β”€ sqli_tester.py          # SQL injection tester β€” tests 5 payloads automatically
β”œβ”€β”€ xss_scanner.py          # XSS scanner β€” tests 3 payload types (script, img, svg)
└── port_scanner.py         # TCP port scanner using Python socket library only

Target 2 β€” zero.webappsecurity.com

scripts/target2/
β”œβ”€β”€ default_creds_tester.py      # Tests 7 common credential combinations
β”œβ”€β”€ security_headers_scanner.py  # Checks missing headers, CORS, exposed pages
└── port_scanner.py              # Port scanner with firewall detection

Running the Scripts

# Install dependency
pip install requests

# Target 1 β€” SQL Injection
python3 scripts/target1/sqli_tester.py

# Target 1 β€” XSS Scanner
python3 scripts/target1/xss_scanner.py

# Target 1 β€” Port Scanner
python3 scripts/target1/port_scanner.py

# Target 2 β€” Default Credentials
python3 scripts/target2/default_creds_tester.py

# Target 2 β€” Security Headers
python3 scripts/target2/security_headers_scanner.py

# Target 2 β€” Port Scanner
python3 scripts/target2/port_scanner.py

πŸ”΄ Vulnerabilities Found β€” Target 1 (demo.testfire.net)

# Vulnerability Severity CWE CVSS OWASP
1 SQL Injection β€” Auth Bypass CRITICAL CWE-89 9.8 A03:2021
2 Sensitive Data in Cookie (credit cards in base64) CRITICAL CWE-312 9.1 A02:2021
3 IDOR β€” Account Enumeration HIGH CWE-284 8.1 A01:2021
4 Admin Panel Exposed CRITICAL CWE-284 9.1 A01:2021
5 Reflected XSS (3 vectors) HIGH CWE-79 7.4 A03:2021

Key Finding β€” SQL Injection

# Payload used in username field:
' OR '1'='1'--

# Result: "Hello Admin User β€” Welcome to Altoro Mutual Online"
# Full admin access gained including Edit Users panel

Key Finding β€” Credit Cards in Cookie

echo "ODAwMDAwfkNvcnBvcmF0ZX4..." | base64 -d
# Output revealed: 4539082039396288~Credit Card, 4485983356242217~Credit Card
# Two full credit card numbers stored in browser cookie with only base64 encoding

πŸ”΄ Vulnerabilities Found β€” Target 2 (zero.webappsecurity.com)

# Vulnerability Severity CWE CVSS OWASP
1 Server Status Publicly Exposed HIGH CWE-200 7.5 A05:2021
2 Dangerous HTTP Methods (PUT, DELETE) HIGH CWE-749 7.3 A05:2021
3 Expired SSL + SSLv2 Enabled HIGH CWE-295 7.4 A02:2021
4 Default Credentials (username/password) CRITICAL CWE-1392 9.8 A07:2021
5 CORS Misconfiguration (Allow-Origin: *) MEDIUM CWE-942 5.3 A05:2021

Key Finding β€” Default Credentials

Username: username
Password: password
Result  : Full banking application access granted
Impact  : Anyone can log in without any hacking knowledge

Key Finding β€” Apache 2012 Exposed via /server-status

Server Version: Apache/2.2.22 (Win32) mod_ssl/2.2.22 OpenSSL/0.9.8t
Server Built  : Jan 28 2012 (14 years old!)
Publicly accessible at /server-status β€” no authentication required

🧠 Where AI Helped vs Failed

βœ… Where AI Helped

  • Attack vector planning after recon
  • Explaining SQL injection logic (not just payloads)
  • XSS payload progression
  • Python requests library β€” how to detect login bypass in response
  • Writing clear impact statements for report

❌ Where AI Failed

Failure What Happened Fix
Wrong field names AI gave generic names β€” didn't know uid and passw Manual curl recon
Gemini refused Wouldn't help with authorized training site Used Claude instead
Hallucinated path Claude suggested /bank/admin.aspx (doesn't exist) ffuf found real path /admin/admin.jsp
No session chaining AI couldn't maintain SQLi β†’ IDOR β†’ admin chain Manual multi-step attack

Core Lesson: AI gave me the map. I did the journey.


⚠️ Limitations of AI in Pentesting

  1. No real-time context β€” AI works on text only, can't observe live browser behavior
  2. Can't chain attacks β€” one question at a time, no attack chain awareness
  3. No business logic β€” can't understand what's logically wrong with an application
  4. Hallucination risk β€” confidently gives wrong paths, wrong field names
  5. Guardrails cause friction β€” Gemini blocked legitimate security research

πŸš€ Future Scope

  • PentestGPT (USENIX Security 2024) β€” agentic pentesting with multi-step attack chains
  • Penligent β€” enterprise platform connecting Nmap + Metasploit + Burp Suite via AI
  • VulnGPT β€” AI for automated source code vulnerability detection
  • Continuous AI Pentesting β€” real-time testing as code is deployed

πŸ“ Repository Structure

ai-pentest-assistant/
β”œβ”€β”€ README.md
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ target1/
β”‚   β”‚   β”œβ”€β”€ sqli_tester.py
β”‚   β”‚   β”œβ”€β”€ xss_scanner.py
β”‚   β”‚   └── port_scanner.py
β”‚   └── target2/
β”‚       β”œβ”€β”€ default_creds_tester.py
β”‚       β”œβ”€β”€ security_headers_scanner.py
β”‚       └── port_scanner.py
└── docs/
    └── AI_Pentesting_Report.pdf

βš–οΈ Disclaimer

All testing was performed exclusively on intentionally vulnerable training applications designed for security education:

  • demo.testfire.net β€” maintained by HCL Technologies for AppScan training
  • zero.webappsecurity.com β€” maintained by Micro Focus for Fortify training

No real systems, real users, or real data were accessed or harmed.
This project is for educational purposes only.


πŸ“¬ Contact

Baire Gowda
MCA – Cybersecurity & Machine Learning
Chanakya University, Bengaluru
Registration No: 25PG00157

About

AI-assisted penetration testing using Nmap, FFUF, Curl, and Python automation for vulnerability assessment, false-positive validation, and security analysis.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages