SlideShare a Scribd company logo
1 of 27
Hacking Microsoft Remote Desktop Services for Fun and Profit Alisa Esage
Who am I? Reverse engineer since …  Founder, CEO, Esage Lab operating in Russia cyber incident response, software security auditing, technical training (soon) MALWAS.com Co-founder, sponsor, {neйron} Moscow’s hackerspace Ex malware analyst, major AV vendor
Why %subj? Trending: professional cyber robbery based on remote desktop access Illicit money transfers via a remote banking application An attacker wants to operate within the active user’s session, while not  intercepting with the user VNC module for Zeus Costs $$$  Based on GPL uVNC What about Microsoft Terminal Services?
Microsoft Terminal Services A powerful remote access technology  Available since NT4 Two fundamental applications: Remote Desktop Remote Assistance
Remote Desktop Allows users to log in remotely Pre-installed in almost any Windows Stable, easy, powerful, clients exists for any OS Full-featured only on Servers Restricted on Workstations  ,[object Object],[object Object]
Challenges Allow multiple user sessions Allow concurrent terminal session for the active console user Bypass logon auth Monitor/control the console session
Basic assumptions We already have code execution on the target Too many RCE exploits in the wild today to consider it a challenge We already have local admin privilege on the target Never been a problem for malware developers (says ex AV employee) Plenty of buggy system-level software to develop an EoP exploit Speaking about architecture, I am meaning Windows 7, if not stated otherwise
State of the %subj Previous research Remote Desktop functionality enhancement patches for workstation users Cw2k, RemkoWeijnenand others Limited OS support No auth bypass, no control over the console session Malware based on Remote Desktop Services Just launch the service, then login via an added user account
Key modules: Terminal Services  Termsrv.dll  service binary, RPC provider hosted by svchost.exe  Termdd.sys core device driver, network listener wrapped by icaapi.dll End-user executables msra.exe – remote assistance mstsc.exe – RDP client
Key modules: RDP protocol stack  Rdpwd.sys Tunnel remote user’s mouse and keyboard Wrapped by rdpwsx.dll Configured by rdpcfgex.dll Rdpdd.dll  Graphics redirection to the remote user Tdtcp.sys Package RDP data into TCP/IP
ChallengeS#1-2 Allow multiple user sessions; allow concurrent terminal session for the active console user
Remote Desktop connection details Termdd.sys accepts a network connection on port 3389, creates a per-connection instance of RDP protocol stack  New smss.exe and csrss.exe are spawned Per-session win32k.sys window manager Winlogon.exe to display logon prompt On successful logon, userinit.exe and explorer.exe are started (or their registry-defined substitutes)
Solution Surprise: Terminal Services module is full-featured on ALL Windows! Feature restrictions are caused by explicit version checks: Winlogon.exe: IsProfessionalTerminalServer() {  GetVersionExW()  … } Termsrv.dll XP:  gbServer, g_bPersonalTS Termsrv.dll Vista+: CSessionArbitrationHelper::IsSingleSessionPerUserEnabled()
Solution (contd.) So we fool Windows into thinking that she is a server Inline patching in real-time (no file modifications): Hook GetVersionExW() in the context of winlogon.exe to return the proper value Set global variables in termsrv.dll Some more patches in termsrv.dll
Solution (contd.) Configure the terminal server SYSTEMCurrentControlSetControlTerminal Server: fDenyTSConnections = 0, TSAppCompat = 0, TSEnabled = 1 Licensing Core: EnableConcurrentSessions = 0 WinStationsRDP-Tcp: fEnableWinStation = 1, MaxInstanceCount = 0xFFFFFFFF SOFTWAREMicrosoftWindows NTCurrentVersionWinlogon:  AllowMultipleTSSessions = 1 SYSTEMCurrentControlSetControlLsa: LimitBlankPasswordUse = 0
Solution (contd.) Add local users to “Remote Desktop Users” group GetGroupNameBySid(L"S-1-5-32-555"); NetLocalGroupAddMembers(); Allow Terminal Services through the firewall  WindowsFirewallPortAdd(...3389...); Done
Challenge #3 Bypass logon auth
Solution Msv1_0.dll (Microsoft Authentication Package) LsaApLogonUserEx2(): call MsvpPasswordValidate(x,x,x,x,x,x,x) 	test    al, al jz@@STATUS_WRONG_PASSWORD Patch it!
Challenge #4 Monitor/control console session
Solution #1 Remote Assistance (msra.exe) relies upon rdpencom.dll (RdpComApi 1.0 Type Library) API is documented! IRDPSRAPISharingSession, IRDPSRAPIViewer   m_pRdpSession = new RDPSession(); m_pRdpSession.OnAttendeeConnected += new _IRDPSessionEvents_OnAttendeeConnectedEventHandler(OnAttendeeConnected); m_pRdpSession.Open(); Available since Vista only, so we are not happy yet…
Shadow.exe Exists in all Windows since NT4! Only works for Server targets Must be launched from within a terminal session Needs target user’s permission to connect
Connection request details Shadow.exe: WinStationShadow() @winsta.dll RpcShadow() @termsrv.dll termsrv.dll: CShadowTarget::ShadowTargetWorker()CDefaultSessionArbitrationHelper::Sessions_SendRequestToSession()  CDefaultSessionArbitrationHelper::GetRequestDialogObject() …  ShadowTargetWorker(): cmp     [ebp+var_528], IDYES jz      short @@OK_DOSHADOW movesi, 0D00A002Ah jmp     @@ACCESS_DENIED
Solution #2 We’ve already tuned a workstation into a server! So shadow.exe just works Patch the dialog box that requests user’s permission: Hook MessageBoxTimeoutW() @csrss.exe: If (!wcsncmp(MsgText+ i, GetComputerNameW()…)) { // don't display the dialog box 	M_FREE(Text); 	return IDYES; }
So… 2 hooks + 3-4 inline patches  vs. xxx xxx KB of custom heavy code Seemingly complicated problems may have trivial solutions Operating systems have plenty of code and functionality which can be re-used for offensive purpose with minimum mess
PoC limitations Requires Local Administrator privilege Auth bypass trick fails on Vista SP0 only Shadow.exe trick fails on Vista Auth bypass affects local logon
THANK YOU Questions?
Hacking Microsoft Remote Desktop Services for Fun and Profit

More Related Content

What's hot

Browsing Linux Kernel Source
Browsing Linux Kernel SourceBrowsing Linux Kernel Source
Browsing Linux Kernel SourceMotaz Saad
 
XPDS16: Porting Xen on ARM to a new SOC - Julien Grall, ARM
XPDS16: Porting Xen on ARM to a new SOC - Julien Grall, ARMXPDS16: Porting Xen on ARM to a new SOC - Julien Grall, ARM
XPDS16: Porting Xen on ARM to a new SOC - Julien Grall, ARMThe Linux Foundation
 
Lcu14 306 - OP-TEE Future Enhancements
Lcu14 306 - OP-TEE Future EnhancementsLcu14 306 - OP-TEE Future Enhancements
Lcu14 306 - OP-TEE Future EnhancementsLinaro
 
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEE
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEEBKK16-110 A Gentle Introduction to Trusted Execution and OP-TEE
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEELinaro
 
LCU14-103: How to create and run Trusted Applications on OP-TEE
LCU14-103: How to create and run Trusted Applications on OP-TEELCU14-103: How to create and run Trusted Applications on OP-TEE
LCU14-103: How to create and run Trusted Applications on OP-TEELinaro
 
Linux Porting to a Custom Board
Linux Porting to a Custom BoardLinux Porting to a Custom Board
Linux Porting to a Custom BoardPatrick Bellasi
 
Linux Kernel Exploitation
Linux Kernel ExploitationLinux Kernel Exploitation
Linux Kernel ExploitationScio Security
 
Linux Kernel and Driver Development Training
Linux Kernel and Driver Development TrainingLinux Kernel and Driver Development Training
Linux Kernel and Driver Development TrainingStephan Cadene
 
Read-only rootfs: theory and practice
Read-only rootfs: theory and practiceRead-only rootfs: theory and practice
Read-only rootfs: theory and practiceChris Simmonds
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoCMacpaul Lin
 
RISC-V on Edge: Porting EVE and Alpine Linux to RISC-V
RISC-V on Edge: Porting EVE and Alpine Linux to RISC-VRISC-V on Edge: Porting EVE and Alpine Linux to RISC-V
RISC-V on Edge: Porting EVE and Alpine Linux to RISC-VScyllaDB
 
Kernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime Ripard
Kernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime RipardKernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime Ripard
Kernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime RipardAnne Nicolas
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal BootloaderSatpal Parmar
 
LCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platformLCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platformLinaro
 
Embedded Linux Quick Start Guide v1.5
Embedded Linux Quick Start Guide v1.5Embedded Linux Quick Start Guide v1.5
Embedded Linux Quick Start Guide v1.5Chris Simmonds
 

What's hot (20)

Browsing Linux Kernel Source
Browsing Linux Kernel SourceBrowsing Linux Kernel Source
Browsing Linux Kernel Source
 
Linux Internals - Part II
Linux Internals - Part IILinux Internals - Part II
Linux Internals - Part II
 
Linux Internals - Part I
Linux Internals - Part ILinux Internals - Part I
Linux Internals - Part I
 
XPDS16: Porting Xen on ARM to a new SOC - Julien Grall, ARM
XPDS16: Porting Xen on ARM to a new SOC - Julien Grall, ARMXPDS16: Porting Xen on ARM to a new SOC - Julien Grall, ARM
XPDS16: Porting Xen on ARM to a new SOC - Julien Grall, ARM
 
Lcu14 306 - OP-TEE Future Enhancements
Lcu14 306 - OP-TEE Future EnhancementsLcu14 306 - OP-TEE Future Enhancements
Lcu14 306 - OP-TEE Future Enhancements
 
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEE
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEEBKK16-110 A Gentle Introduction to Trusted Execution and OP-TEE
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEE
 
Introduction to Linux Drivers
Introduction to Linux DriversIntroduction to Linux Drivers
Introduction to Linux Drivers
 
LCU14-103: How to create and run Trusted Applications on OP-TEE
LCU14-103: How to create and run Trusted Applications on OP-TEELCU14-103: How to create and run Trusted Applications on OP-TEE
LCU14-103: How to create and run Trusted Applications on OP-TEE
 
Linux Porting to a Custom Board
Linux Porting to a Custom BoardLinux Porting to a Custom Board
Linux Porting to a Custom Board
 
Linux Kernel Exploitation
Linux Kernel ExploitationLinux Kernel Exploitation
Linux Kernel Exploitation
 
U-Boot - An universal bootloader
U-Boot - An universal bootloader U-Boot - An universal bootloader
U-Boot - An universal bootloader
 
Linux Kernel and Driver Development Training
Linux Kernel and Driver Development TrainingLinux Kernel and Driver Development Training
Linux Kernel and Driver Development Training
 
Platform Drivers
Platform DriversPlatform Drivers
Platform Drivers
 
Read-only rootfs: theory and practice
Read-only rootfs: theory and practiceRead-only rootfs: theory and practice
Read-only rootfs: theory and practice
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
 
RISC-V on Edge: Porting EVE and Alpine Linux to RISC-V
RISC-V on Edge: Porting EVE and Alpine Linux to RISC-VRISC-V on Edge: Porting EVE and Alpine Linux to RISC-V
RISC-V on Edge: Porting EVE and Alpine Linux to RISC-V
 
Kernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime Ripard
Kernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime RipardKernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime Ripard
Kernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime Ripard
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal Bootloader
 
LCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platformLCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platform
 
Embedded Linux Quick Start Guide v1.5
Embedded Linux Quick Start Guide v1.5Embedded Linux Quick Start Guide v1.5
Embedded Linux Quick Start Guide v1.5
 

Viewers also liked

On non existent 0-days, stable binary exploits and
On non existent 0-days, stable binary exploits andOn non existent 0-days, stable binary exploits and
On non existent 0-days, stable binary exploits andAlisa Esage Шевченко
 
Windows Remote Management - EN
Windows Remote Management - ENWindows Remote Management - EN
Windows Remote Management - ENKirill Nikolaev
 
TScrack: Brute Force Remote Desktop
TScrack: Brute Force Remote DesktopTScrack: Brute Force Remote Desktop
TScrack: Brute Force Remote DesktopBTshell-Fran
 
Getting the most out of RDS (Terminal Services)
Getting the most out of RDS (Terminal Services)Getting the most out of RDS (Terminal Services)
Getting the most out of RDS (Terminal Services)Amit Gatenyo
 
Chapter05 Managing File Access
Chapter05      Managing  File  AccessChapter05      Managing  File  Access
Chapter05 Managing File AccessRaja Waseem Akhtar
 
Server 2012 r2 remote desktop services
Server 2012 r2 remote desktop servicesServer 2012 r2 remote desktop services
Server 2012 r2 remote desktop servicesNihat ALTINMAKAS
 
Remote Desktop Services - Who Needs It?
Remote Desktop Services - Who Needs It?Remote Desktop Services - Who Needs It?
Remote Desktop Services - Who Needs It?Aventis Systems, Inc.
 
Lumagate Microsoft Azure RemoteApp Webinar
Lumagate Microsoft Azure RemoteApp WebinarLumagate Microsoft Azure RemoteApp Webinar
Lumagate Microsoft Azure RemoteApp WebinarMorgan Simonsen
 
Relieve submarino
Relieve submarinoRelieve submarino
Relieve submarinolitoct
 
Building Azure RemoteApp - Microsoft Campus Days 2014
Building Azure RemoteApp - Microsoft Campus Days 2014Building Azure RemoteApp - Microsoft Campus Days 2014
Building Azure RemoteApp - Microsoft Campus Days 2014Morgan Simonsen
 
Remote Desktop Services and Virtual Desktop infrastructure in Windows Server ...
Remote Desktop Services and Virtual Desktop infrastructure in Windows Server ...Remote Desktop Services and Virtual Desktop infrastructure in Windows Server ...
Remote Desktop Services and Virtual Desktop infrastructure in Windows Server ...ctc TrainCanada
 
How to hack VMware vCenter server in 60 seconds
How to hack VMware vCenter server in 60 secondsHow to hack VMware vCenter server in 60 seconds
How to hack VMware vCenter server in 60 secondsPositive Hack Days
 
Microsoft Remote Desktop Services
Microsoft Remote Desktop ServicesMicrosoft Remote Desktop Services
Microsoft Remote Desktop ServicesRonnie Isherwood
 
PowerShell for Penetration Testers
PowerShell for Penetration TestersPowerShell for Penetration Testers
PowerShell for Penetration TestersNikhil Mittal
 
Integrating your on-premises Active Directory with Azure and Office 365
Integrating your on-premises Active Directory with Azure and Office 365Integrating your on-premises Active Directory with Azure and Office 365
Integrating your on-premises Active Directory with Azure and Office 365nelmedia
 
Tablets are Transforming How Government Works
Tablets are Transforming How Government WorksTablets are Transforming How Government Works
Tablets are Transforming How Government WorksSamsung Business USA
 
1099 Problems: Self-Employment and the Future of Financial Services
1099 Problems: Self-Employment and the Future of Financial Services1099 Problems: Self-Employment and the Future of Financial Services
1099 Problems: Self-Employment and the Future of Financial ServicesCore Innovation Capital
 

Viewers also liked (20)

On non existent 0-days, stable binary exploits and
On non existent 0-days, stable binary exploits andOn non existent 0-days, stable binary exploits and
On non existent 0-days, stable binary exploits and
 
Windows Remote Management - EN
Windows Remote Management - ENWindows Remote Management - EN
Windows Remote Management - EN
 
TScrack: Brute Force Remote Desktop
TScrack: Brute Force Remote DesktopTScrack: Brute Force Remote Desktop
TScrack: Brute Force Remote Desktop
 
Getting the most out of RDS (Terminal Services)
Getting the most out of RDS (Terminal Services)Getting the most out of RDS (Terminal Services)
Getting the most out of RDS (Terminal Services)
 
Building Azure Remoteapp
Building Azure RemoteappBuilding Azure Remoteapp
Building Azure Remoteapp
 
Chapter05 Managing File Access
Chapter05      Managing  File  AccessChapter05      Managing  File  Access
Chapter05 Managing File Access
 
Server 2012 r2 remote desktop services
Server 2012 r2 remote desktop servicesServer 2012 r2 remote desktop services
Server 2012 r2 remote desktop services
 
Remote Desktop Services - Who Needs It?
Remote Desktop Services - Who Needs It?Remote Desktop Services - Who Needs It?
Remote Desktop Services - Who Needs It?
 
Lumagate Microsoft Azure RemoteApp Webinar
Lumagate Microsoft Azure RemoteApp WebinarLumagate Microsoft Azure RemoteApp Webinar
Lumagate Microsoft Azure RemoteApp Webinar
 
Relieve submarino
Relieve submarinoRelieve submarino
Relieve submarino
 
Building Azure RemoteApp - Microsoft Campus Days 2014
Building Azure RemoteApp - Microsoft Campus Days 2014Building Azure RemoteApp - Microsoft Campus Days 2014
Building Azure RemoteApp - Microsoft Campus Days 2014
 
Remote Desktop Services and Virtual Desktop infrastructure in Windows Server ...
Remote Desktop Services and Virtual Desktop infrastructure in Windows Server ...Remote Desktop Services and Virtual Desktop infrastructure in Windows Server ...
Remote Desktop Services and Virtual Desktop infrastructure in Windows Server ...
 
How to hack VMware vCenter server in 60 seconds
How to hack VMware vCenter server in 60 secondsHow to hack VMware vCenter server in 60 seconds
How to hack VMware vCenter server in 60 seconds
 
Lecture 8 permissions
Lecture 8   permissionsLecture 8   permissions
Lecture 8 permissions
 
SSAS Azure RemoteApp
SSAS Azure RemoteAppSSAS Azure RemoteApp
SSAS Azure RemoteApp
 
Microsoft Remote Desktop Services
Microsoft Remote Desktop ServicesMicrosoft Remote Desktop Services
Microsoft Remote Desktop Services
 
PowerShell for Penetration Testers
PowerShell for Penetration TestersPowerShell for Penetration Testers
PowerShell for Penetration Testers
 
Integrating your on-premises Active Directory with Azure and Office 365
Integrating your on-premises Active Directory with Azure and Office 365Integrating your on-premises Active Directory with Azure and Office 365
Integrating your on-premises Active Directory with Azure and Office 365
 
Tablets are Transforming How Government Works
Tablets are Transforming How Government WorksTablets are Transforming How Government Works
Tablets are Transforming How Government Works
 
1099 Problems: Self-Employment and the Future of Financial Services
1099 Problems: Self-Employment and the Future of Financial Services1099 Problems: Self-Employment and the Future of Financial Services
1099 Problems: Self-Employment and the Future of Financial Services
 

Similar to Hacking Microsoft Remote Desktop Services for Fun and Profit

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 AccessEC-Council
 
Workshop on BackTrack live CD
Workshop on BackTrack live CDWorkshop on BackTrack live CD
Workshop on BackTrack live CDamiable_indian
 
Kunal - Introduction to BackTrack - ClubHack2008
Kunal - Introduction to BackTrack - ClubHack2008Kunal - Introduction to BackTrack - ClubHack2008
Kunal - Introduction to BackTrack - ClubHack2008ClubHack
 
Kunal - Introduction to backtrack - ClubHack2008
Kunal - Introduction to backtrack - ClubHack2008Kunal - Introduction to backtrack - ClubHack2008
Kunal - Introduction to backtrack - ClubHack2008ClubHack
 
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 BalazsShakacon
 
Defcon 22-zoltan-balazs-bypass-firewalls-application-whiteli
Defcon 22-zoltan-balazs-bypass-firewalls-application-whiteliDefcon 22-zoltan-balazs-bypass-firewalls-application-whiteli
Defcon 22-zoltan-balazs-bypass-firewalls-application-whiteliPriyanka Aash
 
MSMDC_CLI363
MSMDC_CLI363MSMDC_CLI363
MSMDC_CLI363mokacao
 
View PowerPoint Presentation on Pragma Systems - Stay-Linked ...
View PowerPoint Presentation on Pragma Systems - Stay-Linked ...View PowerPoint Presentation on Pragma Systems - Stay-Linked ...
View PowerPoint Presentation on Pragma Systems - Stay-Linked ...webhostingguy
 
View PowerPoint Presentation on Pragma Systems - Stay-Linked ...
View PowerPoint Presentation on Pragma Systems - Stay-Linked ...View PowerPoint Presentation on Pragma Systems - Stay-Linked ...
View PowerPoint Presentation on Pragma Systems - Stay-Linked ...webhostingguy
 
RAT - Kill or Get Killed! by Karan Bansal
RAT - Kill or Get Killed! by Karan BansalRAT - Kill or Get Killed! by Karan Bansal
RAT - Kill or Get Killed! by Karan BansalOWASP Delhi
 
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...Felipe Prado
 
Gartner Security & Risk Management Summit 2018
Gartner Security & Risk Management Summit 2018Gartner Security & Risk Management Summit 2018
Gartner Security & Risk Management Summit 2018Paula Januszkiewicz
 
Module 8 System Hacking
Module 8   System HackingModule 8   System Hacking
Module 8 System Hackingleminhvuong
 
Presentation Lfoppiano Pycon
Presentation Lfoppiano PyconPresentation Lfoppiano Pycon
Presentation Lfoppiano PyconLuca Foppiano
 
NetOp Tech GmbH Remote Control. Education. Security
NetOp Tech GmbH Remote Control. Education. SecurityNetOp Tech GmbH Remote Control. Education. Security
NetOp Tech GmbH Remote Control. Education. Securitywebhostingguy
 
NetOp Tech GmbH Remote Control. Education. Security
NetOp Tech GmbH Remote Control. Education. SecurityNetOp Tech GmbH Remote Control. Education. Security
NetOp Tech GmbH Remote Control. Education. Securitywebhostingguy
 
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...Puppet
 
Windows Malware Techniques
Windows Malware TechniquesWindows Malware Techniques
Windows Malware TechniquesLee C
 

Similar to Hacking Microsoft Remote Desktop Services for Fun and Profit (20)

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
 
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
 
Kunal - Introduction to backtrack - ClubHack2008
Kunal - Introduction to backtrack - ClubHack2008Kunal - Introduction to backtrack - ClubHack2008
Kunal - Introduction to backtrack - ClubHack2008
 
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
 
Defcon 22-zoltan-balazs-bypass-firewalls-application-whiteli
Defcon 22-zoltan-balazs-bypass-firewalls-application-whiteliDefcon 22-zoltan-balazs-bypass-firewalls-application-whiteli
Defcon 22-zoltan-balazs-bypass-firewalls-application-whiteli
 
MSMDC_CLI363
MSMDC_CLI363MSMDC_CLI363
MSMDC_CLI363
 
View PowerPoint Presentation on Pragma Systems - Stay-Linked ...
View PowerPoint Presentation on Pragma Systems - Stay-Linked ...View PowerPoint Presentation on Pragma Systems - Stay-Linked ...
View PowerPoint Presentation on Pragma Systems - Stay-Linked ...
 
View PowerPoint Presentation on Pragma Systems - Stay-Linked ...
View PowerPoint Presentation on Pragma Systems - Stay-Linked ...View PowerPoint Presentation on Pragma Systems - Stay-Linked ...
View PowerPoint Presentation on Pragma Systems - Stay-Linked ...
 
OneTeam Media Server
OneTeam Media ServerOneTeam Media Server
OneTeam Media Server
 
RAT - Kill or Get Killed! by Karan Bansal
RAT - Kill or Get Killed! by Karan BansalRAT - Kill or Get Killed! by Karan Bansal
RAT - Kill or Get Killed! by Karan Bansal
 
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...
 
Gartner Security & Risk Management Summit 2018
Gartner Security & Risk Management Summit 2018Gartner Security & Risk Management Summit 2018
Gartner Security & Risk Management Summit 2018
 
Stuxnet dc9723
Stuxnet dc9723Stuxnet dc9723
Stuxnet dc9723
 
Module 8 System Hacking
Module 8   System HackingModule 8   System Hacking
Module 8 System Hacking
 
Presentation Lfoppiano Pycon
Presentation Lfoppiano PyconPresentation Lfoppiano Pycon
Presentation Lfoppiano Pycon
 
NetOp Tech GmbH Remote Control. Education. Security
NetOp Tech GmbH Remote Control. Education. SecurityNetOp Tech GmbH Remote Control. Education. Security
NetOp Tech GmbH Remote Control. Education. Security
 
NetOp Tech GmbH Remote Control. Education. Security
NetOp Tech GmbH Remote Control. Education. SecurityNetOp Tech GmbH Remote Control. Education. Security
NetOp Tech GmbH Remote Control. Education. Security
 
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
 
Windows Malware Techniques
Windows Malware TechniquesWindows Malware Techniques
Windows Malware Techniques
 

Recently uploaded

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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 Scriptwesley chun
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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 Servicegiselly40
 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 

Hacking Microsoft Remote Desktop Services for Fun and Profit

  • 1. Hacking Microsoft Remote Desktop Services for Fun and Profit Alisa Esage
  • 2. Who am I? Reverse engineer since … Founder, CEO, Esage Lab operating in Russia cyber incident response, software security auditing, technical training (soon) MALWAS.com Co-founder, sponsor, {neйron} Moscow’s hackerspace Ex malware analyst, major AV vendor
  • 3. Why %subj? Trending: professional cyber robbery based on remote desktop access Illicit money transfers via a remote banking application An attacker wants to operate within the active user’s session, while not intercepting with the user VNC module for Zeus Costs $$$ Based on GPL uVNC What about Microsoft Terminal Services?
  • 4. Microsoft Terminal Services A powerful remote access technology Available since NT4 Two fundamental applications: Remote Desktop Remote Assistance
  • 5.
  • 6. Challenges Allow multiple user sessions Allow concurrent terminal session for the active console user Bypass logon auth Monitor/control the console session
  • 7. Basic assumptions We already have code execution on the target Too many RCE exploits in the wild today to consider it a challenge We already have local admin privilege on the target Never been a problem for malware developers (says ex AV employee) Plenty of buggy system-level software to develop an EoP exploit Speaking about architecture, I am meaning Windows 7, if not stated otherwise
  • 8. State of the %subj Previous research Remote Desktop functionality enhancement patches for workstation users Cw2k, RemkoWeijnenand others Limited OS support No auth bypass, no control over the console session Malware based on Remote Desktop Services Just launch the service, then login via an added user account
  • 9. Key modules: Terminal Services Termsrv.dll service binary, RPC provider hosted by svchost.exe Termdd.sys core device driver, network listener wrapped by icaapi.dll End-user executables msra.exe – remote assistance mstsc.exe – RDP client
  • 10. Key modules: RDP protocol stack Rdpwd.sys Tunnel remote user’s mouse and keyboard Wrapped by rdpwsx.dll Configured by rdpcfgex.dll Rdpdd.dll Graphics redirection to the remote user Tdtcp.sys Package RDP data into TCP/IP
  • 11. ChallengeS#1-2 Allow multiple user sessions; allow concurrent terminal session for the active console user
  • 12. Remote Desktop connection details Termdd.sys accepts a network connection on port 3389, creates a per-connection instance of RDP protocol stack New smss.exe and csrss.exe are spawned Per-session win32k.sys window manager Winlogon.exe to display logon prompt On successful logon, userinit.exe and explorer.exe are started (or their registry-defined substitutes)
  • 13. Solution Surprise: Terminal Services module is full-featured on ALL Windows! Feature restrictions are caused by explicit version checks: Winlogon.exe: IsProfessionalTerminalServer() { GetVersionExW() … } Termsrv.dll XP: gbServer, g_bPersonalTS Termsrv.dll Vista+: CSessionArbitrationHelper::IsSingleSessionPerUserEnabled()
  • 14. Solution (contd.) So we fool Windows into thinking that she is a server Inline patching in real-time (no file modifications): Hook GetVersionExW() in the context of winlogon.exe to return the proper value Set global variables in termsrv.dll Some more patches in termsrv.dll
  • 15. Solution (contd.) Configure the terminal server SYSTEMCurrentControlSetControlTerminal Server: fDenyTSConnections = 0, TSAppCompat = 0, TSEnabled = 1 Licensing Core: EnableConcurrentSessions = 0 WinStationsRDP-Tcp: fEnableWinStation = 1, MaxInstanceCount = 0xFFFFFFFF SOFTWAREMicrosoftWindows NTCurrentVersionWinlogon: AllowMultipleTSSessions = 1 SYSTEMCurrentControlSetControlLsa: LimitBlankPasswordUse = 0
  • 16. Solution (contd.) Add local users to “Remote Desktop Users” group GetGroupNameBySid(L"S-1-5-32-555"); NetLocalGroupAddMembers(); Allow Terminal Services through the firewall WindowsFirewallPortAdd(...3389...); Done
  • 17. Challenge #3 Bypass logon auth
  • 18. Solution Msv1_0.dll (Microsoft Authentication Package) LsaApLogonUserEx2(): call MsvpPasswordValidate(x,x,x,x,x,x,x) test al, al jz@@STATUS_WRONG_PASSWORD Patch it!
  • 19. Challenge #4 Monitor/control console session
  • 20. Solution #1 Remote Assistance (msra.exe) relies upon rdpencom.dll (RdpComApi 1.0 Type Library) API is documented! IRDPSRAPISharingSession, IRDPSRAPIViewer   m_pRdpSession = new RDPSession(); m_pRdpSession.OnAttendeeConnected += new _IRDPSessionEvents_OnAttendeeConnectedEventHandler(OnAttendeeConnected); m_pRdpSession.Open(); Available since Vista only, so we are not happy yet…
  • 21. Shadow.exe Exists in all Windows since NT4! Only works for Server targets Must be launched from within a terminal session Needs target user’s permission to connect
  • 22. Connection request details Shadow.exe: WinStationShadow() @winsta.dll RpcShadow() @termsrv.dll termsrv.dll: CShadowTarget::ShadowTargetWorker()CDefaultSessionArbitrationHelper::Sessions_SendRequestToSession() CDefaultSessionArbitrationHelper::GetRequestDialogObject() … ShadowTargetWorker(): cmp [ebp+var_528], IDYES jz short @@OK_DOSHADOW movesi, 0D00A002Ah jmp @@ACCESS_DENIED
  • 23. Solution #2 We’ve already tuned a workstation into a server! So shadow.exe just works Patch the dialog box that requests user’s permission: Hook MessageBoxTimeoutW() @csrss.exe: If (!wcsncmp(MsgText+ i, GetComputerNameW()…)) { // don't display the dialog box M_FREE(Text); return IDYES; }
  • 24. So… 2 hooks + 3-4 inline patches vs. xxx xxx KB of custom heavy code Seemingly complicated problems may have trivial solutions Operating systems have plenty of code and functionality which can be re-used for offensive purpose with minimum mess
  • 25. PoC limitations Requires Local Administrator privilege Auth bypass trick fails on Vista SP0 only Shadow.exe trick fails on Vista Auth bypass affects local logon