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

Domain name server
Domain name serverDomain name server
Domain name server
Mobile88
 
CompTIA Network+ Objectives
CompTIA Network+ ObjectivesCompTIA Network+ Objectives
CompTIA Network+ Objectives
sombat nirund
 
Android Forensics: Exploring Android Internals and Android Apps
Android Forensics: Exploring Android Internals and Android AppsAndroid Forensics: Exploring Android Internals and Android Apps
Android Forensics: Exploring Android Internals and Android Apps
Moe Tanabian
 
IP Multimedia Subsystems Overview - My Training on IMS
IP Multimedia Subsystems Overview - My Training on IMSIP Multimedia Subsystems Overview - My Training on IMS
IP Multimedia Subsystems Overview - My Training on IMS
Inam Khosa
 
Internet Protocol Detail Record
Internet Protocol Detail RecordInternet Protocol Detail Record
Internet Protocol Detail Record
devalnaik
 

What's hot (20)

Testing web application firewalls (waf) accuracy
Testing web application firewalls (waf) accuracyTesting web application firewalls (waf) accuracy
Testing web application firewalls (waf) accuracy
 
FreeSWITCH on Docker
FreeSWITCH on DockerFreeSWITCH on Docker
FreeSWITCH on Docker
 
WPA3 - What is it good for?
WPA3 - What is it good for?WPA3 - What is it good for?
WPA3 - What is it good for?
 
RNUG - Virtual, Faster, Better! How to deploy HCL Notes 11.0.1 FP2 for Citrix...
RNUG - Virtual, Faster, Better! How to deploy HCL Notes 11.0.1 FP2 for Citrix...RNUG - Virtual, Faster, Better! How to deploy HCL Notes 11.0.1 FP2 for Citrix...
RNUG - Virtual, Faster, Better! How to deploy HCL Notes 11.0.1 FP2 for Citrix...
 
FreeSWITCH as a Kickass SBC
FreeSWITCH as a Kickass SBCFreeSWITCH as a Kickass SBC
FreeSWITCH as a Kickass SBC
 
Domain name server
Domain name serverDomain name server
Domain name server
 
Scaling FreeSWITCH Performance
Scaling FreeSWITCH PerformanceScaling FreeSWITCH Performance
Scaling FreeSWITCH Performance
 
Log Analysis
Log AnalysisLog Analysis
Log Analysis
 
Windows Forensic 101
Windows Forensic 101Windows Forensic 101
Windows Forensic 101
 
Hacking techniques
Hacking techniquesHacking techniques
Hacking techniques
 
Wazo Platform @ Astricon19
Wazo Platform @ Astricon19Wazo Platform @ Astricon19
Wazo Platform @ Astricon19
 
CompTIA Network+ Objectives
CompTIA Network+ ObjectivesCompTIA Network+ Objectives
CompTIA Network+ Objectives
 
Why Do I Need an SBC
Why Do I Need an SBCWhy Do I Need an SBC
Why Do I Need an SBC
 
Android Forensics: Exploring Android Internals and Android Apps
Android Forensics: Exploring Android Internals and Android AppsAndroid Forensics: Exploring Android Internals and Android Apps
Android Forensics: Exploring Android Internals and Android Apps
 
Trusted platform module copy
Trusted platform module   copyTrusted platform module   copy
Trusted platform module copy
 
Dell EMC OpenManage Enterprise - Automate & Orchestrate
Dell EMC OpenManage Enterprise  - Automate & OrchestrateDell EMC OpenManage Enterprise  - Automate & Orchestrate
Dell EMC OpenManage Enterprise - Automate & Orchestrate
 
IP Multimedia Subsystems Overview - My Training on IMS
IP Multimedia Subsystems Overview - My Training on IMSIP Multimedia Subsystems Overview - My Training on IMS
IP Multimedia Subsystems Overview - My Training on IMS
 
Internet Protocol Detail Record
Internet Protocol Detail RecordInternet Protocol Detail Record
Internet Protocol Detail Record
 
DNSSEC Validation Tutorial
DNSSEC Validation TutorialDNSSEC Validation Tutorial
DNSSEC Validation Tutorial
 
F5 Networks: Introduction to Silverline WAF (web application firewall)
F5 Networks: Introduction to Silverline WAF (web application firewall)F5 Networks: Introduction to Silverline WAF (web application firewall)
F5 Networks: Introduction to Silverline WAF (web application firewall)
 

Viewers also liked

Windows Remote Management - EN
Windows Remote Management - ENWindows Remote Management - EN
Windows Remote Management - EN
Kirill Nikolaev
 
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 Access
Raja Waseem Akhtar
 
Relieve submarino
Relieve submarinoRelieve submarino
Relieve submarino
litoct
 
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
Positive Hack Days
 

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

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
 
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
 
Module 8 System Hacking
Module 8   System HackingModule 8   System Hacking
Module 8 System Hacking
leminhvuong
 
Presentation Lfoppiano Pycon
Presentation Lfoppiano PyconPresentation Lfoppiano Pycon
Presentation Lfoppiano Pycon
Luca 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. Security
webhostingguy
 
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
webhostingguy
 

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
 
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
 
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

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
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
 
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
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 

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