SlideShare a Scribd company logo
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
Hacking Highly Secured
Enterprise Environments
Zoltan Balazs
Shakacon, 2015
root@kali:~# whoami
Zoltán Balázs
Hungary
root@kali:~# whoami
root@kali:~# whoami
AV testing
AV bypass
root@kali:~# whoami
I’m NOT a CEH
Member of the Anonym CTF
addict’s organization
Still in recovery phase
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 (with low budget)
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
Restrictive 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
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
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
I know how the files on the server look like, what services
are installed
This is Spartaaaa 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
Policy maker/business
• Funny pictures
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), show in foreground
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
The AV is alive.
Nope, Chuck Testa ™
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 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 myvulnservice.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 myvulnservice.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
Restrictive firewall
• No Bind shell
• No Reverse shell
• No covert channel
• DNS, ICMP, IPv6, UDP, proxy
• No shell!!!
In a different scenario
• TCP socket reuse shell possible (not persistent)
• Webshell (lame) possible
• But not in this case (no exploit, no webserver)
4. Bypass hardware firewall
First (bad) idea
After malware dropped,
mark every packet to be special
• start with magic bytes
and let a 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
Use 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) && (tcp_dest_port
=== 22)) then:
redirect to bind shell on port 31337
iptables -t nat -A PREROUTING -p tcp --dport 22 --
sport 1337 -j REDIRECT --to-ports 31337
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
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
Bypassing hardware firewalls on
Windows x64
Installing a kernel driver in Windows x64 is not trivial
• Trusted signed driver is needed
Thanks to basil for WinDivert project (and 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 (or any
program)?
Netcat (Nmap build) to da rescue!
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
legit network traffic
The solution – as a whole
Malware waits for the user to login to RDP with 2FA
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!
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
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 Windows 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
blindly
How to bypass NG Firewall?
NCAT LUA to da rescue!
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!
https://github.com/MRGEffitas/Write-into-screen
https://github.com/MRGEffitas/hwfwbypass
zoltan.balazs@mrg-effitas.com
https://hu.linkedin.com/in/zbalazs
Twitter – @zh4ck
www.slideshare.net/bz98
Greetz to @hekkcamp, @CrySySLab
JumpESPJump.blogspot.com

More Related Content

PDF
Breaking Vaults - Stealing Lastpass Protected Secrets by Martin Vigo
PDF
Richard wartell malware is hard. let's go shopping!!
PDF
Socially Acceptable Methods to Walk in the Front Door
PDF
44CON 2014 - Breaking AV Software
PDF
Inside the Matrix,How to Build Transparent Sandbox for Malware Analysis
ODP
Joxean Koret - Database Security Paradise [Rooted CON 2011]
PDF
BlueHat v18 || The matrix has you - protecting linux using deception
PDF
TeelTech - Advancing Mobile Device Forensics (online version)
Breaking Vaults - Stealing Lastpass Protected Secrets by Martin Vigo
Richard wartell malware is hard. let's go shopping!!
Socially Acceptable Methods to Walk in the Front Door
44CON 2014 - Breaking AV Software
Inside the Matrix,How to Build Transparent Sandbox for Malware Analysis
Joxean Koret - Database Security Paradise [Rooted CON 2011]
BlueHat v18 || The matrix has you - protecting linux using deception
TeelTech - Advancing Mobile Device Forensics (online version)

What's hot (20)

PDF
Defcon 22-colby-moore-patrick-wardle-synack-drop cam
PPTX
Indicators of compromise: From malware analysis to eradication
PDF
Awesome_fuzzing_for _pentester_red-pill_2017
PPTX
How to drive a malware analyst crazy
PDF
Threat stack aws
PDF
Raúl Siles - Browser Exploitation for Fun and Profit Revolutions [RootedCON 2...
PDF
Possibility of arbitrary code execution by Step-Oriented Programming
PDF
Reverse Engineering the TomTom Runner pt. 2
PPTX
How Safe is your Link ?
PDF
When is something overflowing
PDF
44CON London - Attacking VxWorks: from Stone Age to Interstellar
PPTX
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
PDF
How to Make Android's Bootable Recovery Work For You by Drew Suarez
PDF
44CON London 2015 - 15-Minute Linux Incident Response Live Analysis
PPTX
ShinoBOT Suite
PDF
Sheila Ayelen Berta - The Art of Persistence: "Mr. Windows… I don’t wanna go ...
PDF
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
PDF
1000 to 0
PDF
Automated Malware Analysis and Cyber Security Intelligence
PPTX
Rooted2020 roapt evil-mass_storage_-_tu-ya_aqui_-_david_reguera_-_abel_valero
Defcon 22-colby-moore-patrick-wardle-synack-drop cam
Indicators of compromise: From malware analysis to eradication
Awesome_fuzzing_for _pentester_red-pill_2017
How to drive a malware analyst crazy
Threat stack aws
Raúl Siles - Browser Exploitation for Fun and Profit Revolutions [RootedCON 2...
Possibility of arbitrary code execution by Step-Oriented Programming
Reverse Engineering the TomTom Runner pt. 2
How Safe is your Link ?
When is something overflowing
44CON London - Attacking VxWorks: from Stone Age to Interstellar
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
How to Make Android's Bootable Recovery Work For You by Drew Suarez
44CON London 2015 - 15-Minute Linux Incident Response Live Analysis
ShinoBOT Suite
Sheila Ayelen Berta - The Art of Persistence: "Mr. Windows… I don’t wanna go ...
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
1000 to 0
Automated Malware Analysis and Cyber Security Intelligence
Rooted2020 roapt evil-mass_storage_-_tu-ya_aqui_-_david_reguera_-_abel_valero

Similar to Hacking Highly Secured Enterprise Environments by Zoltan Balazs (20)

PDF
DEFCON 22: Bypass firewalls, application white lists, secure remote desktops ...
PDF
Defcon 22-zoltan-balazs-bypass-firewalls-application-whiteli
PPTX
Hacker Halted 2014 - Post-Exploitation After Having Remote Access
PPS
Workshop on BackTrack live CD
PPT
Kunal - Introduction to backtrack - ClubHack2008
PPT
Kunal - Introduction to BackTrack - ClubHack2008
PDF
DEF CON 27 - DANIEL ROMERO and MARIO RIVAS - why you should fear your mundane...
PDF
Home Automation Using RPI
PDF
Placing backdoors-through-firewalls
PDF
Time Series Database and Tick Stack
PPT
Security & ethical hacking p2
ODP
Cracking Into Embedded Devices - HACK.LU 2K8
PPTX
Creating Havoc using Human Interface Device
PDF
Typhoon Managed Execution Toolkit
PPT
Security & ethical hacking
PDF
FreeBSD and Hardening Web Server
PPTX
Jesse Burke RDPwned HackMiami7
PDF
RAT - Repurposing Adversarial Tradecraft
PDF
Piratng Avs to bypass exploit mitigation
PDF
Captain Hook: Pirating AVs to Bypass Exploit Mitigations
DEFCON 22: Bypass firewalls, application white lists, secure remote desktops ...
Defcon 22-zoltan-balazs-bypass-firewalls-application-whiteli
Hacker Halted 2014 - Post-Exploitation After Having Remote Access
Workshop on BackTrack live CD
Kunal - Introduction to backtrack - ClubHack2008
Kunal - Introduction to BackTrack - ClubHack2008
DEF CON 27 - DANIEL ROMERO and MARIO RIVAS - why you should fear your mundane...
Home Automation Using RPI
Placing backdoors-through-firewalls
Time Series Database and Tick Stack
Security & ethical hacking p2
Cracking Into Embedded Devices - HACK.LU 2K8
Creating Havoc using Human Interface Device
Typhoon Managed Execution Toolkit
Security & ethical hacking
FreeBSD and Hardening Web Server
Jesse Burke RDPwned HackMiami7
RAT - Repurposing Adversarial Tradecraft
Piratng Avs to bypass exploit mitigation
Captain Hook: Pirating AVs to Bypass Exploit Mitigations

More from Shakacon (20)

PDF
Web (dis)assembly
PDF
Macdoored
PDF
I can be apple and so can you
PDF
Cloud forensics putting the bits back together
PDF
Pwned in Translation - from Subtitles to RCE
PDF
Oversight: Exposing spies on macOS
PDF
Modern Reconnaissance Phase on APT - protection layer
PDF
Shamoon
PDF
A Decompiler for Blackhain-Based Smart Contracts Bytecode
PPTX
Honey, I Stole Your C2 Server: A Dive into Attacker Infrastructure
PPTX
Dock ir incident response in a containerized, immutable, continually deploy...
PDF
Reviewing the Security of ASoC Drivers in Android Kernel
PDF
Silent Protest: A Wearable Protest Network
PDF
WiFi-Based IMSI Catcher
PPTX
Sad Panda Analysts: Devolving Malware
PDF
reductio [ad absurdum]
PDF
XFLTReat: a new dimension in tunnelling
PDF
Windows Systems & Code Signing Protection by Paul Rascagneres
PDF
When Encryption is Not Enough...Sumanth Naropanth, Chandra Prakash Gopalaiah ...
PDF
The Search for the Perfect Door - Deviant Ollam
Web (dis)assembly
Macdoored
I can be apple and so can you
Cloud forensics putting the bits back together
Pwned in Translation - from Subtitles to RCE
Oversight: Exposing spies on macOS
Modern Reconnaissance Phase on APT - protection layer
Shamoon
A Decompiler for Blackhain-Based Smart Contracts Bytecode
Honey, I Stole Your C2 Server: A Dive into Attacker Infrastructure
Dock ir incident response in a containerized, immutable, continually deploy...
Reviewing the Security of ASoC Drivers in Android Kernel
Silent Protest: A Wearable Protest Network
WiFi-Based IMSI Catcher
Sad Panda Analysts: Devolving Malware
reductio [ad absurdum]
XFLTReat: a new dimension in tunnelling
Windows Systems & Code Signing Protection by Paul Rascagneres
When Encryption is Not Enough...Sumanth Naropanth, Chandra Prakash Gopalaiah ...
The Search for the Perfect Door - Deviant Ollam

Recently uploaded (20)

PPTX
Tartificialntelligence_presentation.pptx
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
TLE Review Electricity (Electricity).pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
project resource management chapter-09.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
1. Introduction to Computer Programming.pptx
PDF
Mushroom cultivation and it's methods.pdf
Tartificialntelligence_presentation.pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
OMC Textile Division Presentation 2021.pptx
Univ-Connecticut-ChatGPT-Presentaion.pdf
TLE Review Electricity (Electricity).pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Zenith AI: Advanced Artificial Intelligence
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Encapsulation theory and applications.pdf
cloud_computing_Infrastucture_as_cloud_p
SOPHOS-XG Firewall Administrator PPT.pptx
project resource management chapter-09.pdf
Group 1 Presentation -Planning and Decision Making .pptx
A comparative study of natural language inference in Swahili using monolingua...
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Unlocking AI with Model Context Protocol (MCP)
Assigned Numbers - 2025 - Bluetooth® Document
1. Introduction to Computer Programming.pptx
Mushroom cultivation and it's methods.pdf

Hacking Highly Secured Enterprise Environments by Zoltan Balazs

  • 2. Hacking Highly Secured Enterprise Environments Zoltan Balazs Shakacon, 2015
  • 7. root@kali:~# whoami I’m NOT a CEH Member of the Anonym CTF addict’s organization Still in recovery phase Creator of the Zombie Browser Toolkit https://github.com/Z6543/ZombieBrowserPack
  • 9. How do you hack high security systems?
  • 10. How do you hack high security systems when you are not Tom Cruise?
  • 11. The mission I’m a spy (with low budget) 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
  • 12. 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
  • 13. 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 Restrictive 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
  • 14. Is this realistic? Similar environment at a client •Had no time to hack it
  • 16. Infected workstation Secure remote desktop server Target Company The Internet Attacker Firewall, port 3389 allowed only
  • 17. “In hacking, there is no such thing as impossible. Only things that are more challenging.”
  • 18. Already achieved I have remote code execution with C&C on a user’s workstation I have access to a test RDP server I know how the files on the server look like, what services are installed This is Spartaaaa post-exploitation
  • 19. Why should you care about this? Red team/pentester • New tools Blue team • New things to look for during log analysis/incident response Policy maker/business • Funny pictures
  • 20. 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
  • 21. 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
  • 22. 1. Drop malware into RDP server
  • 23. 1. Drop malware into RDP server Malware waits for the user to connect to RDP server Creates screenshot (or new animation), show in foreground 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
  • 24. 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 The AV is alive. Nope, Chuck Testa ™
  • 25. 2. What is Applocker?
  • 26. 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.”
  • 27. 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 LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long hLibrary = LoadLibrary(outputdir + "hack_service.dll")
  • 28. 3. Elevate to admin
  • 29. 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!
  • 30. Elevate to admin - Service exploit C:> accesschk.exe –l myvulnservice.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)
  • 31. Elevate to admin - Service exploit C:> accesschk.exe –l myvulnservice.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
  • 32. Quiz
  • 33. Quiz What’s the name of the company which published the first paper about packet filter firewalls in 1988?
  • 34. Quiz What’s the name of the company which published the first paper about packet filter firewalls in 1988? The company developed VAX
  • 35. Quiz What’s the name of the company which published the first paper about packet filter firewalls in 1988? Digital Equipment Corporation
  • 36. 4. Bypass hardware firewall Restrictive firewall • No Bind shell • No Reverse shell • No covert channel • DNS, ICMP, IPv6, UDP, proxy • No shell!!! In a different scenario • TCP socket reuse shell possible (not persistent) • Webshell (lame) possible • But not in this case (no exploit, no webserver)
  • 37. 4. Bypass hardware firewall First (bad) idea After malware dropped, mark every packet to be special • start with magic bytes and let a 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)
  • 38. Bypass HW firewall – second idea Use TCP source port! • E.g. port 1337 is always special Limitations • NAT from the attacker side • But who cares? 
  • 39. Bypassing hardware firewalls Linux Use code at Kernel level (with root) if ((tcp_source_port === 1337) && (tcp_dest_port === 22)) then: redirect to bind shell on port 31337 iptables -t nat -A PREROUTING -p tcp --dport 22 -- sport 1337 -j REDIRECT --to-ports 31337
  • 40. 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
  • 45. Bypassing hardware firewalls on Windows x64 Installing a kernel driver in Windows x64 is not trivial • Trusted signed driver is needed Thanks to basil for WinDivert project (and 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 ;)
  • 46. How to set TCP source port for meterpreter bind shell (or any program)? Netcat (Nmap build) to da rescue! ncat -kl 4444 -c "ncat -p 1337 RDP.SER.VER.IP 3389"
  • 47. Demo
  • 48. 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 legit network traffic
  • 49. The solution – as a whole Malware waits for the user to login to RDP with 2FA 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
  • 50. The solution Escalate privileges to admin (vulnerable service) Install hwfwbypass.exe with kernel driver Drop meterpreter Profit!
  • 52. Demo
  • 53. Demo 2 – as seen by the user
  • 54. 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 Windows server, you can bypass/fool hardware firewalls using my driver
  • 55. 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 blindly
  • 56. How to bypass NG Firewall? NCAT LUA to da rescue!
  • 59. two more things … User simulator available as Metasploit post module HW FW bypass available as Metasploit post module