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

Six Degrees of Domain Admin - BloodHound at DEF CON 24
Six Degrees of Domain Admin - BloodHound at DEF CON 24Six Degrees of Domain Admin - BloodHound at DEF CON 24
Six Degrees of Domain Admin - BloodHound at DEF CON 24Andy Robbins
 
HMAC - HASH FUNCTION AND DIGITAL SIGNATURES
HMAC  - HASH FUNCTION AND DIGITAL SIGNATURESHMAC  - HASH FUNCTION AND DIGITAL SIGNATURES
HMAC - HASH FUNCTION AND DIGITAL SIGNATURESPACHIYAPPAN PACHIYAPPAS
 
Kali linux useful tools
Kali linux useful toolsKali linux useful tools
Kali linux useful toolsmilad mahdavi
 
Recon with Nmap
Recon with Nmap Recon with Nmap
Recon with Nmap OWASP Delhi
 
SquirrelMail for webmail
SquirrelMail for webmailSquirrelMail for webmail
SquirrelMail for webmailAryman Gautam
 
Ripe71 FastNetMon open source DoS / DDoS mitigation
Ripe71 FastNetMon open source DoS / DDoS mitigationRipe71 FastNetMon open source DoS / DDoS mitigation
Ripe71 FastNetMon open source DoS / DDoS mitigationPavel Odintsov
 
aclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundaclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundDirkjanMollema
 
INITIATION A LA SÉCURITÉ INFORMATIQUE.pptx
INITIATION A LA SÉCURITÉ INFORMATIQUE.pptxINITIATION A LA SÉCURITÉ INFORMATIQUE.pptx
INITIATION A LA SÉCURITÉ INFORMATIQUE.pptxLeandre Cof's Yeboue
 
Cloud penetration testing
Cloud penetration testingCloud penetration testing
Cloud penetration testingvericlouds11
 
Hot potato Privilege Escalation
Hot potato Privilege EscalationHot potato Privilege Escalation
Hot potato Privilege EscalationSunny Neo
 
Network analysis Using Wireshark Lesson 11: TCP and UDP Analysis
Network analysis Using Wireshark Lesson 11: TCP and UDP AnalysisNetwork analysis Using Wireshark Lesson 11: TCP and UDP Analysis
Network analysis Using Wireshark Lesson 11: TCP and UDP AnalysisYoram Orzach
 
Wireshark, Tcpdump and Network Performance tools
Wireshark, Tcpdump and Network Performance toolsWireshark, Tcpdump and Network Performance tools
Wireshark, Tcpdump and Network Performance toolsSachidananda Sahu
 
Exploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelExploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelVitaly Nikolenko
 
Reconnaissance & Scanning
Reconnaissance & ScanningReconnaissance & Scanning
Reconnaissance & Scanningamiable_indian
 
The Travelling Pentester: Diaries of the Shortest Path to Compromise
The Travelling Pentester: Diaries of the Shortest Path to CompromiseThe Travelling Pentester: Diaries of the Shortest Path to Compromise
The Travelling Pentester: Diaries of the Shortest Path to CompromiseWill Schroeder
 
Arbor Presentation
Arbor Presentation Arbor Presentation
Arbor Presentation J Hartig
 
WannaCry Ransomware Attack: What to Do Now
WannaCry Ransomware Attack: What to Do NowWannaCry Ransomware Attack: What to Do Now
WannaCry Ransomware Attack: What to Do NowIBM Security
 
User Management and Privileges - pfSense Hangout February 2015
User Management and Privileges - pfSense Hangout February 2015User Management and Privileges - pfSense Hangout February 2015
User Management and Privileges - pfSense Hangout February 2015Netgate
 

What's hot (20)

Six Degrees of Domain Admin - BloodHound at DEF CON 24
Six Degrees of Domain Admin - BloodHound at DEF CON 24Six Degrees of Domain Admin - BloodHound at DEF CON 24
Six Degrees of Domain Admin - BloodHound at DEF CON 24
 
HMAC - HASH FUNCTION AND DIGITAL SIGNATURES
HMAC  - HASH FUNCTION AND DIGITAL SIGNATURESHMAC  - HASH FUNCTION AND DIGITAL SIGNATURES
HMAC - HASH FUNCTION AND DIGITAL SIGNATURES
 
Kali linux useful tools
Kali linux useful toolsKali linux useful tools
Kali linux useful tools
 
Recon with Nmap
Recon with Nmap Recon with Nmap
Recon with Nmap
 
SquirrelMail for webmail
SquirrelMail for webmailSquirrelMail for webmail
SquirrelMail for webmail
 
Ripe71 FastNetMon open source DoS / DDoS mitigation
Ripe71 FastNetMon open source DoS / DDoS mitigationRipe71 FastNetMon open source DoS / DDoS mitigation
Ripe71 FastNetMon open source DoS / DDoS mitigation
 
aclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundaclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHound
 
INITIATION A LA SÉCURITÉ INFORMATIQUE.pptx
INITIATION A LA SÉCURITÉ INFORMATIQUE.pptxINITIATION A LA SÉCURITÉ INFORMATIQUE.pptx
INITIATION A LA SÉCURITÉ INFORMATIQUE.pptx
 
Cloud penetration testing
Cloud penetration testingCloud penetration testing
Cloud penetration testing
 
IPSec VPN tunnel
IPSec VPN tunnelIPSec VPN tunnel
IPSec VPN tunnel
 
Hot potato Privilege Escalation
Hot potato Privilege EscalationHot potato Privilege Escalation
Hot potato Privilege Escalation
 
Network analysis Using Wireshark Lesson 11: TCP and UDP Analysis
Network analysis Using Wireshark Lesson 11: TCP and UDP AnalysisNetwork analysis Using Wireshark Lesson 11: TCP and UDP Analysis
Network analysis Using Wireshark Lesson 11: TCP and UDP Analysis
 
Wireshark, Tcpdump and Network Performance tools
Wireshark, Tcpdump and Network Performance toolsWireshark, Tcpdump and Network Performance tools
Wireshark, Tcpdump and Network Performance tools
 
Exploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelExploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernel
 
Reconnaissance & Scanning
Reconnaissance & ScanningReconnaissance & Scanning
Reconnaissance & Scanning
 
Wireless hacking
Wireless hackingWireless hacking
Wireless hacking
 
The Travelling Pentester: Diaries of the Shortest Path to Compromise
The Travelling Pentester: Diaries of the Shortest Path to CompromiseThe Travelling Pentester: Diaries of the Shortest Path to Compromise
The Travelling Pentester: Diaries of the Shortest Path to Compromise
 
Arbor Presentation
Arbor Presentation Arbor Presentation
Arbor Presentation
 
WannaCry Ransomware Attack: What to Do Now
WannaCry Ransomware Attack: What to Do NowWannaCry Ransomware Attack: What to Do Now
WannaCry Ransomware Attack: What to Do Now
 
User Management and Privileges - pfSense Hangout February 2015
User Management and Privileges - pfSense Hangout February 2015User Management and Privileges - pfSense Hangout February 2015
User Management and Privileges - pfSense Hangout February 2015
 

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
 
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
 
Workshop on BackTrack live CD
Workshop on BackTrack live CDWorkshop on BackTrack live CD
Workshop on BackTrack live CDamiable_indian
 
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
 
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
 
Workshop on BackTrack live CD
Workshop on BackTrack live CDWorkshop on BackTrack live CD
Workshop on BackTrack live CD
 
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

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 

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