SlideShare ist ein Scribd-Unternehmen logo
1 von 58
Bypass firewalls, application
white lists, secure remote
desktops in 20 seconds
Zoltan Balazs
DEF CON 22, 2014
Hungary
root@bt:~# whoami
Zoltán Balázs
root@bt:~# whoami
root@bt:~# whoami
AV testing
AV bypass
root@bt:~# whoami
OSCP: Occasional Satire Captain Punk
CISSP: Certified Interspecie-ial Sheep Shearing Professional
CPTS: Certified Pajama Toaster Specialist
MCP: Microsoft Certified Psychopath
OSWP: Official Sexiest Weasel Popstar
CHFI: Chronic Hopeless Flux Incompetent
I’m NOT a CEH
CyberLympics@2012 CTF
2nd runners up – gula.sh
Creator of the Zombie Browser Toolkit
https://github.com/Z6543/ZombieBrowserPack
I love hacking
How do you hack high security
systems?
How do you hack high security
systems when you are not Tom Cruise?
The mission
I’m a spy
I want access to a hardened secure RDP (remote
desktop) server
E.g. server contains confidential documents
I need persistent C&C access to the RDP server
To upload/download files
Interactive remote code execution
The solution (in an ideal world)
Infected
workstation
Secure remote
desktop server
1. Infect client’s
desktop
2. Steal RDP password
3. Connect to RDP
4. Drop malware
5. Command and Control
6. Profit
The challenges
RDP server is not reachable from the Internet
Directly …
Two factor authentication is used to access the RDP server
No access to the token seeds ;)
Drive mapping disabled – no direct file copy
Restricted hardware firewall
Allows workstation -> server TCP port 3389 IPv4 only
Application white list is used on the RDP server
M$ Applocker in my case with default policy
Firewall, port 3389 allowed only
Is this realistic?
Similar environment at a client
•Had no time to hack it
Infected
workstation
Secure remote
desktop server
Target
Company
The Internet
Attacker
Firewall, port 3389 allowed only
“In hacking, there is no such thing
as impossible.
Only things that are more
challenging.”
Already achieved
I have remote code execution with C&C on a user’s
workstation
I have access to a test RDP server, and I know how the
files on the server look like, what services are installed
This is post-exploitation
Why should you care about this?
Red team/pentester
• New tools
Blue team
• New things to look for during log
analysis/incident response
Divide et impera!
Divide the problem into smaller pieces and rule them
all, one by one
1. drop malware into the RDP server
2. execute any code on RDP server
3. elevate to admin privileges
4. bypass hardware firewall
Divide et impera!
Divide the problem into smaller pieces and rule them
all, one by one
1. drop malware into the RDP server –> new shiny tool
2. execute any code on RDP server –> nothing new here
3. elevate to admin privileges –> nothing new, no 0day for
you
4. bypass hardware firewall -> new shiny tool
1. Drop malware into RDP server
1. Drop malware into RDP server
Malware waits for the user to connect to RDP server
Creates screenshot (or new animation)
Optionally blocks user keyboard, mouse ~20 seconds
Uses the keyboard and the clipboard – simulates user
1. Starts M$ Word on RDP server
2. Drops encoded ASCII payload
3. Creates Macro code
4. Macro writes binary
5. Macro starts binaries
Alternative usage of “user
simulator”
1. Add directory to be excluded from AV scans
use the AV GUI!
only if the user has the privileges and no UAC
2. Install new trusted root certification authority and
accept warning – and MiTM SSL connections
CA pinning does not stop
this attack
2. What is Applocker?
2. Execute any code, bypass
Applocker
„AppLocker can only control VBScript, JScript, .bat
files, .cmd files and Windows PowerShell scripts. It
does not control all interpreted code that runs within a
host process, for example Perl scripts and macros.
Applications could contain flags that are passed to
functions that signal AppLocker to circumvent the rules
and allow another .exe or .dll file to be loaded.
The administrator on the local computer can modify
the AppLocker policies defined in the local GPO.”
Execute any code, bypass
Applocker
Load DLL with Word Macro!
Even shellcode execution is possible!
http://blog.didierstevens.com/2008/06/05/bpmtk-
how-about-srp-whitelists/
Private Declare PtrSafe Function FreeLibrary Lib "kernel32" (ByVal hLibModule As
Long) As Long
Private Declare PtrSafe Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA"
(ByVal lpLibFileName As String) As Long
hLibrary = LoadLibrary(outputdir + "hack_service.dll")
3. Elevate to admin
3. Elevate to admin
Why do I need admin?
• It is needed for the last phase, hardware firewall bypass
Possibilities
• Local priv esc zero day for Win 2012
• Exploit unpatched vulnerability
• Exploit vulnerable 3rd party program service
• Etc.
Processes started with admin (or higher) privileges are
not restricted by AppLocker!
Elevate to admin - Service exploit
C:> accesschk.exe –l mvulnservice.exe
[0] ACCESS_ALLOWED_ACE_TYPE: NT AUTHORITYTERMINAL SERVER USER
FILE_APPEND_DATA
FILE_EXECUTE
FILE_READ_ATTRIBUTES
FILE_READ_DATA
FILE_READ_EA
FILE_WRITE_ATTRIBUTES
FILE_WRITE_DATA
FILE_WRITE_EA
SYNCHRONIZE
READ_CONTROLs
C:> sc sdshow myvulnservice
D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)
(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRCRPWP;;;IU)(A;;CCLCSWLOCRRC;;;SU)
Elevate to admin - Service exploit
C:> accesschk.exe –l mvulnservice.exe
[0] ACCESS_ALLOWED_ACE_TYPE: NT AUTHORITYTERMINAL SERVER USER
FILE_APPEND_DATA
FILE_EXECUTE
FILE_READ_ATTRIBUTES
FILE_READ_DATA
FILE_READ_EA
FILE_WRITE_ATTRIBUTES
FILE_WRITE_DATA
FILE_WRITE_EA
SYNCHRONIZE
READ_CONTROLs
C:> sc sdshow myvulnservice
D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)
(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRCRPWP;;;IU)(A;;CCLCSWLOCRRC;;;SU)
Allow
Service start
Service stop
Interactively
logged on
user
Quiz
Quiz
What’s the name of the company which published the
first paper about packet filter firewalls
in 1988?
Quiz
What’s the name of the company which published the
first paper about packet filter firewalls
in 1988?
The company developed VAX
Quiz
What’s the name of the company which published the
first paper about packet filter firewalls
in 1988?
Digital
Equipment
Corporation
4. Bypass hardware firewall
First (bad) idea
After malware dropped
Mark every packet to be special
• start with magic bytes
And let the kernel network filter driver select the packets
Problem
• Every (hacker) application has to be rewritten, or rerouted
through a custom wrapper proxy (both server and client side)
Bypass HW firewall – second idea
TCP source port!
• E.g. port 1337 is always special
Limitations
• NAT from the attacker side
• But who cares?
Bypassing hardware firewalls
Linux
Use code at Kernel level (with root)
if tcp_source_port === 1337
redirect to bind shell
iptables -t nat -A PREROUTING -p tcp --dport 22 --
sport 1337 -j REDIRECT --to-ports 31337
• 31337 is the bind shell port
Attacker or
infected
workstation
Firewall, port 3389 allowed only Secure remote
desktop server
Src port
1337
Dst port
3389
Dst port
3389
Dst port
31337
Bypassing hardware firewalls on
Windows x64
Installing a kernel driver in Windows x64 is not easy
• Trusted signed driver is needed
Thanks to basil for WinDivert project (Nemea Software
Development)
• Trusted signed kernel driver already included!
• You can interface with the kernel driver
Alternatively, patchguard bypass could be used
http://www.codeproject.com/Articles/28318/Bypassing-
PatchGuard
Uroburos rootkit – Bring Your Own Vuln
Install root CA first with user simulator ;)
How to set TCP source port for
meterpreter bind shell?
Netcat to da rescue!
• Nmap build is used
ncat -kl 4444 -c
"ncat -p 1337 RDP.SER.VER.IP 3389"
Demo
Alternative usage of “hw fw
bypass”
You have admin on webserver
but persistent outbound C&C is blocked
Instead of local port forward, use netcat to port
forward to other machines in the DMZ
Backdoor traffic to hide your
communication inside the
legitim network traffic
The solution – as a whole
Create screenshot from user desktop
Put screenshot on the screen
Disable keyboard/mouse
Drop malware by simulating user keyboard events +
clipboard for large (ASCII) data transfer
Start WORD, create new macro code
Bypass application whitelist using DLL loading from
Word macro code
The solution
Escalate privileges to admin (vulnerable service)
Install hwfwbypass.exe with kernel driver
Drop meterpreter
Profit!
Demo
Demo 2 – as seen by the user
Lessons learned for red team
You have two new tools for your post exploitation
• tool to drop malware into the remote desktop
• If you have admin on a server, you can bypass/fool
hardware firewalls using my driver
Lessons learned for the blue team
Every additional layer of security can still be bypassed
Restricted remote desktop is a real interface for
malware infection
Use application/protocol aware (NG) firewall instead
of port based ones
Can be bypassed ;)
Don’t trust your firewall logs
Code release now?
References
http://reqrypt.org/windivert.html
http://inputsimulator.codeplex.com/ - modified
http://www.blackhat.com/presentations/bh-usa-06/BH-
US-06-Tereshkin.pdf
http://blog.didierstevens.com/2011/01/24/circumventing-
srp-and-applocker-by-design/
http://www.room362.com/blog/2014/01/16/application-
whitelist-bypass-using-ieexec-dot-exe
http://leastprivilege.blogspot.fr/2013/04/bypass-
applocker-by-loading-dlls-from.html?m=1
https://www.mandiant.com/blog/hikit-rootkit-advanced-
persistent-attack-techniques-part-2/
one more thing …
two more things …
User simulator available as Metasploit post module
HW FW bypass available as Metasploit post module
Hack The Planet!!!
Code released(?) under GPL
https://github.com/Z6543/.......
zoltan.balazs@mrg-effitas.com
https://hu.linkedin.com/in/zbalazs
Twitter – @zh4ck
www.slideshare.net/bz98
Greetz to @hekkcamp
JumpESPJump.blogspot.com

Weitere ähnliche Inhalte

Was ist angesagt?

2012 S&P Paper Reading Session1
2012 S&P Paper Reading Session12012 S&P Paper Reading Session1
2012 S&P Paper Reading Session1
Chong-Kuan Chen
 
Malware collection and analysis
Malware collection and analysisMalware collection and analysis
Malware collection and analysis
Chong-Kuan Chen
 
BlueHat v18 || Linear time shellcode detection using state machines and opera...
BlueHat v18 || Linear time shellcode detection using state machines and opera...BlueHat v18 || Linear time shellcode detection using state machines and opera...
BlueHat v18 || Linear time shellcode detection using state machines and opera...
BlueHat Security Conference
 
CSW2017 Yuhao song+Huimingliu cyber_wmd_vulnerable_IoT
CSW2017 Yuhao song+Huimingliu cyber_wmd_vulnerable_IoTCSW2017 Yuhao song+Huimingliu cyber_wmd_vulnerable_IoT
CSW2017 Yuhao song+Huimingliu cyber_wmd_vulnerable_IoT
CanSecWest
 
Penetration testing, What’s this?
Penetration testing, What’s this?Penetration testing, What’s this?
Penetration testing, What’s this?
Dmitry Evteev
 

Was ist angesagt? (20)

The Dark Side of PowerShell by George Dobrea
The Dark Side of PowerShell by George DobreaThe Dark Side of PowerShell by George Dobrea
The Dark Side of PowerShell by George Dobrea
 
2012 S&P Paper Reading Session1
2012 S&P Paper Reading Session12012 S&P Paper Reading Session1
2012 S&P Paper Reading Session1
 
Defcon 22-colby-moore-patrick-wardle-synack-drop cam
Defcon 22-colby-moore-patrick-wardle-synack-drop camDefcon 22-colby-moore-patrick-wardle-synack-drop cam
Defcon 22-colby-moore-patrick-wardle-synack-drop cam
 
DEFCON 22: Bypass firewalls, application white lists, secure remote desktops ...
DEFCON 22: Bypass firewalls, application white lists, secure remote desktops ...DEFCON 22: Bypass firewalls, application white lists, secure remote desktops ...
DEFCON 22: Bypass firewalls, application white lists, secure remote desktops ...
 
Addios!
Addios!Addios!
Addios!
 
Malware collection and analysis
Malware collection and analysisMalware collection and analysis
Malware collection and analysis
 
Android Application Security
Android Application SecurityAndroid Application Security
Android Application Security
 
Internal Pentest: from z3r0 to h3r0
Internal Pentest: from z3r0 to h3r0Internal Pentest: from z3r0 to h3r0
Internal Pentest: from z3r0 to h3r0
 
Hacker Halted 2014 - Post-Exploitation After Having Remote Access
Hacker Halted 2014 - Post-Exploitation After Having Remote AccessHacker Halted 2014 - Post-Exploitation After Having Remote Access
Hacker Halted 2014 - Post-Exploitation After Having Remote Access
 
BlueHat v18 || Linear time shellcode detection using state machines and opera...
BlueHat v18 || Linear time shellcode detection using state machines and opera...BlueHat v18 || Linear time shellcode detection using state machines and opera...
BlueHat v18 || Linear time shellcode detection using state machines and opera...
 
CSW2017 Yuhao song+Huimingliu cyber_wmd_vulnerable_IoT
CSW2017 Yuhao song+Huimingliu cyber_wmd_vulnerable_IoTCSW2017 Yuhao song+Huimingliu cyber_wmd_vulnerable_IoT
CSW2017 Yuhao song+Huimingliu cyber_wmd_vulnerable_IoT
 
Improvement in Rogue Access Points - SensePost Defcon 22
Improvement in Rogue Access Points - SensePost Defcon 22Improvement in Rogue Access Points - SensePost Defcon 22
Improvement in Rogue Access Points - SensePost Defcon 22
 
Lateral Movement: How attackers quietly traverse your Network
Lateral Movement: How attackers quietly traverse your NetworkLateral Movement: How attackers quietly traverse your Network
Lateral Movement: How attackers quietly traverse your Network
 
BSides London 2015 - Proprietary network protocols - risky business on the wire.
BSides London 2015 - Proprietary network protocols - risky business on the wire.BSides London 2015 - Proprietary network protocols - risky business on the wire.
BSides London 2015 - Proprietary network protocols - risky business on the wire.
 
Zeronights 2015 - Big problems with big data - Hadoop interfaces security
Zeronights 2015 - Big problems with big data - Hadoop interfaces securityZeronights 2015 - Big problems with big data - Hadoop interfaces security
Zeronights 2015 - Big problems with big data - Hadoop interfaces security
 
Offence oriented Defence
Offence oriented DefenceOffence oriented Defence
Offence oriented Defence
 
Penetration testing, What’s this?
Penetration testing, What’s this?Penetration testing, What’s this?
Penetration testing, What’s this?
 
Shameful Secrets of Proprietary Network Protocols - OWASP AppSec EU 2014
Shameful Secrets of Proprietary Network Protocols - OWASP AppSec EU 2014Shameful Secrets of Proprietary Network Protocols - OWASP AppSec EU 2014
Shameful Secrets of Proprietary Network Protocols - OWASP AppSec EU 2014
 
Rat a-tat-tat
Rat a-tat-tatRat a-tat-tat
Rat a-tat-tat
 
Ransomware - what is it, how to protect against it
Ransomware - what is it, how to protect against itRansomware - what is it, how to protect against it
Ransomware - what is it, how to protect against it
 

Andere mochten auch

Defcon 22-david-wyde-client-side-http-cookie-security
Defcon 22-david-wyde-client-side-http-cookie-securityDefcon 22-david-wyde-client-side-http-cookie-security
Defcon 22-david-wyde-client-side-http-cookie-security
Priyanka Aash
 
Defcon 22-fatih-ozavci-vo ip-wars-attack-of-the-cisco-phones
Defcon 22-fatih-ozavci-vo ip-wars-attack-of-the-cisco-phonesDefcon 22-fatih-ozavci-vo ip-wars-attack-of-the-cisco-phones
Defcon 22-fatih-ozavci-vo ip-wars-attack-of-the-cisco-phones
Priyanka Aash
 

Andere mochten auch (20)

Risk Analysis using open FAIR and Adoption of right Security Controls
Risk Analysis using open FAIR and Adoption of right Security ControlsRisk Analysis using open FAIR and Adoption of right Security Controls
Risk Analysis using open FAIR and Adoption of right Security Controls
 
Network Forensics and Practical Packet Analysis
Network Forensics and Practical Packet AnalysisNetwork Forensics and Practical Packet Analysis
Network Forensics and Practical Packet Analysis
 
Defcon 22-david-wyde-client-side-http-cookie-security
Defcon 22-david-wyde-client-side-http-cookie-securityDefcon 22-david-wyde-client-side-http-cookie-security
Defcon 22-david-wyde-client-side-http-cookie-security
 
Defcon 22-alex zacharis-nikolaos-tsagkarakis-po s-attacking-t
Defcon 22-alex zacharis-nikolaos-tsagkarakis-po s-attacking-tDefcon 22-alex zacharis-nikolaos-tsagkarakis-po s-attacking-t
Defcon 22-alex zacharis-nikolaos-tsagkarakis-po s-attacking-t
 
Defcon 22-nir-valtman-a-journey-to-protect-pos
Defcon 22-nir-valtman-a-journey-to-protect-posDefcon 22-nir-valtman-a-journey-to-protect-pos
Defcon 22-nir-valtman-a-journey-to-protect-pos
 
Defcon 22-metacortex-grifter-darkside-of-the-internet
Defcon 22-metacortex-grifter-darkside-of-the-internetDefcon 22-metacortex-grifter-darkside-of-the-internet
Defcon 22-metacortex-grifter-darkside-of-the-internet
 
Practical Applications of Block Chain Technologies
Practical Applications of Block Chain Technologies Practical Applications of Block Chain Technologies
Practical Applications of Block Chain Technologies
 
Defcon 22-rmellendick-dakahuna-rf-penetration-testing-your-a
Defcon 22-rmellendick-dakahuna-rf-penetration-testing-your-aDefcon 22-rmellendick-dakahuna-rf-penetration-testing-your-a
Defcon 22-rmellendick-dakahuna-rf-penetration-testing-your-a
 
Defcon 22-fatih-ozavci-vo ip-wars-attack-of-the-cisco-phones
Defcon 22-fatih-ozavci-vo ip-wars-attack-of-the-cisco-phonesDefcon 22-fatih-ozavci-vo ip-wars-attack-of-the-cisco-phones
Defcon 22-fatih-ozavci-vo ip-wars-attack-of-the-cisco-phones
 
Defcon 22-phil-polstra-cyber-hijacking-airplanes-truth-or-fi
Defcon 22-phil-polstra-cyber-hijacking-airplanes-truth-or-fiDefcon 22-phil-polstra-cyber-hijacking-airplanes-truth-or-fi
Defcon 22-phil-polstra-cyber-hijacking-airplanes-truth-or-fi
 
Defcon 22-tim-mcguffin-one-man-shop
Defcon 22-tim-mcguffin-one-man-shopDefcon 22-tim-mcguffin-one-man-shop
Defcon 22-tim-mcguffin-one-man-shop
 
Defcon 22-graham-mc millan-tentler-masscaning-the-internet
Defcon 22-graham-mc millan-tentler-masscaning-the-internetDefcon 22-graham-mc millan-tentler-masscaning-the-internet
Defcon 22-graham-mc millan-tentler-masscaning-the-internet
 
Defcon 22-weston-hecker-burner-phone-ddos
Defcon 22-weston-hecker-burner-phone-ddosDefcon 22-weston-hecker-burner-phone-ddos
Defcon 22-weston-hecker-burner-phone-ddos
 
Defcon 22-richard-klafter-and-eric-swanson-check-your-finger
Defcon 22-richard-klafter-and-eric-swanson-check-your-fingerDefcon 22-richard-klafter-and-eric-swanson-check-your-finger
Defcon 22-richard-klafter-and-eric-swanson-check-your-finger
 
Defcon 22-tess-schrodinger-raxacoricofallapatorius-with-love
Defcon 22-tess-schrodinger-raxacoricofallapatorius-with-loveDefcon 22-tess-schrodinger-raxacoricofallapatorius-with-love
Defcon 22-tess-schrodinger-raxacoricofallapatorius-with-love
 
Defcon 22-phil-polstra-am-i-being-spied-on
Defcon 22-phil-polstra-am-i-being-spied-onDefcon 22-phil-polstra-am-i-being-spied-on
Defcon 22-phil-polstra-am-i-being-spied-on
 
Defcon 22-robert-rowley-detecting-defending-against-surveill
Defcon 22-robert-rowley-detecting-defending-against-surveillDefcon 22-robert-rowley-detecting-defending-against-surveill
Defcon 22-robert-rowley-detecting-defending-against-surveill
 
Defcon 22-gregory-pickett-abusing-software-defined-networks
Defcon 22-gregory-pickett-abusing-software-defined-networksDefcon 22-gregory-pickett-abusing-software-defined-networks
Defcon 22-gregory-pickett-abusing-software-defined-networks
 
Defcon 22-quaddi-r3plicant-hefley-hacking-911
Defcon 22-quaddi-r3plicant-hefley-hacking-911Defcon 22-quaddi-r3plicant-hefley-hacking-911
Defcon 22-quaddi-r3plicant-hefley-hacking-911
 
Defcon 22-deviant-ollam-and-howard-payne-elevator hacking-fr
Defcon 22-deviant-ollam-and-howard-payne-elevator hacking-frDefcon 22-deviant-ollam-and-howard-payne-elevator hacking-fr
Defcon 22-deviant-ollam-and-howard-payne-elevator hacking-fr
 

Ähnlich wie Defcon 22-zoltan-balazs-bypass-firewalls-application-whiteli

Kunal - Introduction to backtrack - ClubHack2008
Kunal - Introduction to backtrack - ClubHack2008Kunal - Introduction to backtrack - ClubHack2008
Kunal - Introduction to backtrack - ClubHack2008
ClubHack
 
Workshop on BackTrack live CD
Workshop on BackTrack live CDWorkshop on BackTrack live CD
Workshop on BackTrack live CD
amiable_indian
 
Kunal - Introduction to BackTrack - ClubHack2008
Kunal - Introduction to BackTrack - ClubHack2008Kunal - Introduction to BackTrack - ClubHack2008
Kunal - Introduction to BackTrack - ClubHack2008
ClubHack
 
Security & ethical hacking
Security & ethical hackingSecurity & ethical hacking
Security & ethical hacking
Amanpreet Singh
 
Lab-10 Malware Creation and Denial of Service (DoS) In t.docx
Lab-10 Malware Creation and Denial of Service (DoS)        In t.docxLab-10 Malware Creation and Denial of Service (DoS)        In t.docx
Lab-10 Malware Creation and Denial of Service (DoS) In t.docx
pauline234567
 
26.1.7 lab snort and firewall rules
26.1.7 lab   snort and firewall rules26.1.7 lab   snort and firewall rules
26.1.7 lab snort and firewall rules
Freddy Buenaño
 
Cracking Into Embedded Devices - HACK.LU 2K8
Cracking Into Embedded Devices - HACK.LU 2K8Cracking Into Embedded Devices - HACK.LU 2K8
Cracking Into Embedded Devices - HACK.LU 2K8
guest441c58b71
 

Ähnlich wie Defcon 22-zoltan-balazs-bypass-firewalls-application-whiteli (20)

Hacking Highly Secured Enterprise Environments by Zoltan Balazs
Hacking Highly Secured Enterprise Environments by Zoltan BalazsHacking Highly Secured Enterprise Environments by Zoltan Balazs
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
 
Kunal - Introduction to backtrack - ClubHack2008
Kunal - Introduction to backtrack - ClubHack2008Kunal - Introduction to backtrack - ClubHack2008
Kunal - Introduction to backtrack - ClubHack2008
 
Workshop on BackTrack live CD
Workshop on BackTrack live CDWorkshop on BackTrack live CD
Workshop on BackTrack live CD
 
Kunal - Introduction to BackTrack - ClubHack2008
Kunal - Introduction to BackTrack - ClubHack2008Kunal - Introduction to BackTrack - ClubHack2008
Kunal - Introduction to BackTrack - ClubHack2008
 
Placing backdoors-through-firewalls
Placing backdoors-through-firewallsPlacing backdoors-through-firewalls
Placing backdoors-through-firewalls
 
Security & ethical hacking p2
Security & ethical hacking p2Security & ethical hacking p2
Security & ethical hacking p2
 
DEF CON 27 - DANIEL ROMERO and MARIO RIVAS - why you should fear your mundane...
DEF CON 27 - DANIEL ROMERO and MARIO RIVAS - why you should fear your mundane...DEF CON 27 - DANIEL ROMERO and MARIO RIVAS - why you should fear your mundane...
DEF CON 27 - DANIEL ROMERO and MARIO RIVAS - why you should fear your mundane...
 
Home Automation Using RPI
Home Automation Using  RPIHome Automation Using  RPI
Home Automation Using RPI
 
Security & ethical hacking
Security & ethical hackingSecurity & ethical hacking
Security & ethical hacking
 
Inside the Matrix,How to Build Transparent Sandbox for Malware Analysis
Inside the Matrix,How to Build Transparent Sandbox for Malware AnalysisInside the Matrix,How to Build Transparent Sandbox for Malware Analysis
Inside the Matrix,How to Build Transparent Sandbox for Malware Analysis
 
Lab-10 Malware Creation and Denial of Service (DoS) In t.docx
Lab-10 Malware Creation and Denial of Service (DoS)        In t.docxLab-10 Malware Creation and Denial of Service (DoS)        In t.docx
Lab-10 Malware Creation and Denial of Service (DoS) In t.docx
 
Freeware Security Tools You Need
Freeware Security Tools You NeedFreeware Security Tools You Need
Freeware Security Tools You Need
 
Penetration Testing Project Game of Thrones CTF: 1
Penetration Testing Project Game of Thrones CTF: 1Penetration Testing Project Game of Thrones CTF: 1
Penetration Testing Project Game of Thrones CTF: 1
 
Time Series Database and Tick Stack
Time Series Database and Tick StackTime Series Database and Tick Stack
Time Series Database and Tick Stack
 
Advances in Open Source Password Cracking
Advances in Open Source Password CrackingAdvances in Open Source Password Cracking
Advances in Open Source Password Cracking
 
Penetrating Windows 8 with syringe utility
Penetrating Windows 8 with syringe utilityPenetrating Windows 8 with syringe utility
Penetrating Windows 8 with syringe utility
 
Teensy Programming for Everyone
Teensy Programming for EveryoneTeensy Programming for Everyone
Teensy Programming for Everyone
 
Two-For-One Talk: Malware Analysis for Everyone
Two-For-One Talk: Malware Analysis for EveryoneTwo-For-One Talk: Malware Analysis for Everyone
Two-For-One Talk: Malware Analysis for Everyone
 
26.1.7 lab snort and firewall rules
26.1.7 lab   snort and firewall rules26.1.7 lab   snort and firewall rules
26.1.7 lab snort and firewall rules
 
Cracking Into Embedded Devices - HACK.LU 2K8
Cracking Into Embedded Devices - HACK.LU 2K8Cracking Into Embedded Devices - HACK.LU 2K8
Cracking Into Embedded Devices - HACK.LU 2K8
 

Mehr von Priyanka Aash

Mehr von Priyanka Aash (20)

Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
 
Verizon Breach Investigation Report (VBIR).pdf
Verizon Breach Investigation Report (VBIR).pdfVerizon Breach Investigation Report (VBIR).pdf
Verizon Breach Investigation Report (VBIR).pdf
 
Top 10 Security Risks .pptx.pdf
Top 10 Security Risks .pptx.pdfTop 10 Security Risks .pptx.pdf
Top 10 Security Risks .pptx.pdf
 
Simplifying data privacy and protection.pdf
Simplifying data privacy and protection.pdfSimplifying data privacy and protection.pdf
Simplifying data privacy and protection.pdf
 
Generative AI and Security (1).pptx.pdf
Generative AI and Security (1).pptx.pdfGenerative AI and Security (1).pptx.pdf
Generative AI and Security (1).pptx.pdf
 
EVERY ATTACK INVOLVES EXPLOITATION OF A WEAKNESS.pdf
EVERY ATTACK INVOLVES EXPLOITATION OF A WEAKNESS.pdfEVERY ATTACK INVOLVES EXPLOITATION OF A WEAKNESS.pdf
EVERY ATTACK INVOLVES EXPLOITATION OF A WEAKNESS.pdf
 
DPDP Act 2023.pdf
DPDP Act 2023.pdfDPDP Act 2023.pdf
DPDP Act 2023.pdf
 
Cyber Truths_Are you Prepared version 1.1.pptx.pdf
Cyber Truths_Are you Prepared version 1.1.pptx.pdfCyber Truths_Are you Prepared version 1.1.pptx.pdf
Cyber Truths_Are you Prepared version 1.1.pptx.pdf
 
Cyber Crisis Management.pdf
Cyber Crisis Management.pdfCyber Crisis Management.pdf
Cyber Crisis Management.pdf
 
CISOPlatform journey.pptx.pdf
CISOPlatform journey.pptx.pdfCISOPlatform journey.pptx.pdf
CISOPlatform journey.pptx.pdf
 
Chennai Chapter.pptx.pdf
Chennai Chapter.pptx.pdfChennai Chapter.pptx.pdf
Chennai Chapter.pptx.pdf
 
Cloud attack vectors_Moshe.pdf
Cloud attack vectors_Moshe.pdfCloud attack vectors_Moshe.pdf
Cloud attack vectors_Moshe.pdf
 
Stories From The Web 3 Battlefield
Stories From The Web 3 BattlefieldStories From The Web 3 Battlefield
Stories From The Web 3 Battlefield
 
Lessons Learned From Ransomware Attacks
Lessons Learned From Ransomware AttacksLessons Learned From Ransomware Attacks
Lessons Learned From Ransomware Attacks
 
Emerging New Threats And Top CISO Priorities In 2022 (Chennai)
Emerging New Threats And Top CISO Priorities In 2022 (Chennai)Emerging New Threats And Top CISO Priorities In 2022 (Chennai)
Emerging New Threats And Top CISO Priorities In 2022 (Chennai)
 
Emerging New Threats And Top CISO Priorities In 2022 (Mumbai)
Emerging New Threats And Top CISO Priorities In 2022 (Mumbai)Emerging New Threats And Top CISO Priorities In 2022 (Mumbai)
Emerging New Threats And Top CISO Priorities In 2022 (Mumbai)
 
Emerging New Threats And Top CISO Priorities in 2022 (Bangalore)
Emerging New Threats And Top CISO Priorities in 2022 (Bangalore)Emerging New Threats And Top CISO Priorities in 2022 (Bangalore)
Emerging New Threats And Top CISO Priorities in 2022 (Bangalore)
 
Cloud Security: Limitations of Cloud Security Groups and Flow Logs
Cloud Security: Limitations of Cloud Security Groups and Flow LogsCloud Security: Limitations of Cloud Security Groups and Flow Logs
Cloud Security: Limitations of Cloud Security Groups and Flow Logs
 
Cyber Security Governance
Cyber Security GovernanceCyber Security Governance
Cyber Security Governance
 
Ethical Hacking
Ethical HackingEthical Hacking
Ethical Hacking
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Defcon 22-zoltan-balazs-bypass-firewalls-application-whiteli

  • 1. Bypass firewalls, application white lists, secure remote desktops in 20 seconds Zoltan Balazs DEF CON 22, 2014
  • 6. root@bt:~# whoami OSCP: Occasional Satire Captain Punk CISSP: Certified Interspecie-ial Sheep Shearing Professional CPTS: Certified Pajama Toaster Specialist MCP: Microsoft Certified Psychopath OSWP: Official Sexiest Weasel Popstar CHFI: Chronic Hopeless Flux Incompetent I’m NOT a CEH CyberLympics@2012 CTF 2nd runners up – gula.sh Creator of the Zombie Browser Toolkit https://github.com/Z6543/ZombieBrowserPack
  • 8. How do you hack high security systems?
  • 9. How do you hack high security systems when you are not Tom Cruise?
  • 10. The mission I’m a spy I want access to a hardened secure RDP (remote desktop) server E.g. server contains confidential documents I need persistent C&C access to the RDP server To upload/download files Interactive remote code execution
  • 11. The solution (in an ideal world) Infected workstation Secure remote desktop server 1. Infect client’s desktop 2. Steal RDP password 3. Connect to RDP 4. Drop malware 5. Command and Control 6. Profit
  • 12. The challenges RDP server is not reachable from the Internet Directly … Two factor authentication is used to access the RDP server No access to the token seeds ;) Drive mapping disabled – no direct file copy Restricted hardware firewall Allows workstation -> server TCP port 3389 IPv4 only Application white list is used on the RDP server M$ Applocker in my case with default policy Firewall, port 3389 allowed only
  • 13. Is this realistic? Similar environment at a client •Had no time to hack it
  • 14.
  • 15. Infected workstation Secure remote desktop server Target Company The Internet Attacker Firewall, port 3389 allowed only
  • 16. “In hacking, there is no such thing as impossible. Only things that are more challenging.”
  • 17. Already achieved I have remote code execution with C&C on a user’s workstation I have access to a test RDP server, and I know how the files on the server look like, what services are installed This is post-exploitation
  • 18. Why should you care about this? Red team/pentester • New tools Blue team • New things to look for during log analysis/incident response
  • 19. Divide et impera! Divide the problem into smaller pieces and rule them all, one by one 1. drop malware into the RDP server 2. execute any code on RDP server 3. elevate to admin privileges 4. bypass hardware firewall
  • 20. Divide et impera! Divide the problem into smaller pieces and rule them all, one by one 1. drop malware into the RDP server –> new shiny tool 2. execute any code on RDP server –> nothing new here 3. elevate to admin privileges –> nothing new, no 0day for you 4. bypass hardware firewall -> new shiny tool
  • 21. 1. Drop malware into RDP server
  • 22. 1. Drop malware into RDP server Malware waits for the user to connect to RDP server Creates screenshot (or new animation) Optionally blocks user keyboard, mouse ~20 seconds Uses the keyboard and the clipboard – simulates user 1. Starts M$ Word on RDP server 2. Drops encoded ASCII payload 3. Creates Macro code 4. Macro writes binary 5. Macro starts binaries
  • 23. Alternative usage of “user simulator” 1. Add directory to be excluded from AV scans use the AV GUI! only if the user has the privileges and no UAC 2. Install new trusted root certification authority and accept warning – and MiTM SSL connections CA pinning does not stop this attack
  • 24. 2. What is Applocker?
  • 25. 2. Execute any code, bypass Applocker „AppLocker can only control VBScript, JScript, .bat files, .cmd files and Windows PowerShell scripts. It does not control all interpreted code that runs within a host process, for example Perl scripts and macros. Applications could contain flags that are passed to functions that signal AppLocker to circumvent the rules and allow another .exe or .dll file to be loaded. The administrator on the local computer can modify the AppLocker policies defined in the local GPO.”
  • 26. Execute any code, bypass Applocker Load DLL with Word Macro! Even shellcode execution is possible! http://blog.didierstevens.com/2008/06/05/bpmtk- how-about-srp-whitelists/ Private Declare PtrSafe Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long Private Declare PtrSafe Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long hLibrary = LoadLibrary(outputdir + "hack_service.dll")
  • 27. 3. Elevate to admin
  • 28. 3. Elevate to admin Why do I need admin? • It is needed for the last phase, hardware firewall bypass Possibilities • Local priv esc zero day for Win 2012 • Exploit unpatched vulnerability • Exploit vulnerable 3rd party program service • Etc. Processes started with admin (or higher) privileges are not restricted by AppLocker!
  • 29. Elevate to admin - Service exploit C:> accesschk.exe –l mvulnservice.exe [0] ACCESS_ALLOWED_ACE_TYPE: NT AUTHORITYTERMINAL SERVER USER FILE_APPEND_DATA FILE_EXECUTE FILE_READ_ATTRIBUTES FILE_READ_DATA FILE_READ_EA FILE_WRITE_ATTRIBUTES FILE_WRITE_DATA FILE_WRITE_EA SYNCHRONIZE READ_CONTROLs C:> sc sdshow myvulnservice D:(A;;CCLCSWRPWPDTLOCRRC;;;SY) (A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRCRPWP;;;IU)(A;;CCLCSWLOCRRC;;;SU)
  • 30. Elevate to admin - Service exploit C:> accesschk.exe –l mvulnservice.exe [0] ACCESS_ALLOWED_ACE_TYPE: NT AUTHORITYTERMINAL SERVER USER FILE_APPEND_DATA FILE_EXECUTE FILE_READ_ATTRIBUTES FILE_READ_DATA FILE_READ_EA FILE_WRITE_ATTRIBUTES FILE_WRITE_DATA FILE_WRITE_EA SYNCHRONIZE READ_CONTROLs C:> sc sdshow myvulnservice D:(A;;CCLCSWRPWPDTLOCRRC;;;SY) (A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRCRPWP;;;IU)(A;;CCLCSWLOCRRC;;;SU) Allow Service start Service stop Interactively logged on user
  • 31. Quiz
  • 32. Quiz What’s the name of the company which published the first paper about packet filter firewalls in 1988?
  • 33. Quiz What’s the name of the company which published the first paper about packet filter firewalls in 1988? The company developed VAX
  • 34. Quiz What’s the name of the company which published the first paper about packet filter firewalls in 1988? Digital Equipment Corporation
  • 35. 4. Bypass hardware firewall First (bad) idea After malware dropped Mark every packet to be special • start with magic bytes And let the kernel network filter driver select the packets Problem • Every (hacker) application has to be rewritten, or rerouted through a custom wrapper proxy (both server and client side)
  • 36. Bypass HW firewall – second idea TCP source port! • E.g. port 1337 is always special Limitations • NAT from the attacker side • But who cares?
  • 37. Bypassing hardware firewalls Linux Use code at Kernel level (with root) if tcp_source_port === 1337 redirect to bind shell iptables -t nat -A PREROUTING -p tcp --dport 22 -- sport 1337 -j REDIRECT --to-ports 31337 • 31337 is the bind shell port
  • 38. Attacker or infected workstation Firewall, port 3389 allowed only Secure remote desktop server Src port 1337 Dst port 3389 Dst port 3389 Dst port 31337
  • 39.
  • 40.
  • 41.
  • 42.
  • 43. Bypassing hardware firewalls on Windows x64 Installing a kernel driver in Windows x64 is not easy • Trusted signed driver is needed Thanks to basil for WinDivert project (Nemea Software Development) • Trusted signed kernel driver already included! • You can interface with the kernel driver Alternatively, patchguard bypass could be used http://www.codeproject.com/Articles/28318/Bypassing- PatchGuard Uroburos rootkit – Bring Your Own Vuln Install root CA first with user simulator ;)
  • 44. How to set TCP source port for meterpreter bind shell? Netcat to da rescue! • Nmap build is used ncat -kl 4444 -c "ncat -p 1337 RDP.SER.VER.IP 3389"
  • 45. Demo
  • 46. Alternative usage of “hw fw bypass” You have admin on webserver but persistent outbound C&C is blocked Instead of local port forward, use netcat to port forward to other machines in the DMZ Backdoor traffic to hide your communication inside the legitim network traffic
  • 47. The solution – as a whole Create screenshot from user desktop Put screenshot on the screen Disable keyboard/mouse Drop malware by simulating user keyboard events + clipboard for large (ASCII) data transfer Start WORD, create new macro code Bypass application whitelist using DLL loading from Word macro code
  • 48. The solution Escalate privileges to admin (vulnerable service) Install hwfwbypass.exe with kernel driver Drop meterpreter Profit!
  • 49.
  • 50. Demo
  • 51. Demo 2 – as seen by the user
  • 52. Lessons learned for red team You have two new tools for your post exploitation • tool to drop malware into the remote desktop • If you have admin on a server, you can bypass/fool hardware firewalls using my driver
  • 53. Lessons learned for the blue team Every additional layer of security can still be bypassed Restricted remote desktop is a real interface for malware infection Use application/protocol aware (NG) firewall instead of port based ones Can be bypassed ;) Don’t trust your firewall logs
  • 57. two more things … User simulator available as Metasploit post module HW FW bypass available as Metasploit post module
  • 58. Hack The Planet!!! Code released(?) under GPL https://github.com/Z6543/....... zoltan.balazs@mrg-effitas.com https://hu.linkedin.com/in/zbalazs Twitter – @zh4ck www.slideshare.net/bz98 Greetz to @hekkcamp JumpESPJump.blogspot.com