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

Man in the middle attack .pptx
Man in the middle attack .pptxMan in the middle attack .pptx
Man in the middle attack .pptxPradeepKumar728006
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Barrel Software
 
Understanding the Windows Server Administration Fundamentals (Part-1)
Understanding the Windows Server Administration Fundamentals (Part-1)Understanding the Windows Server Administration Fundamentals (Part-1)
Understanding the Windows Server Administration Fundamentals (Part-1)Tuan Yang
 
Windows Server 2012 Managing Active Directory Domain
Windows Server 2012 Managing  Active Directory DomainWindows Server 2012 Managing  Active Directory Domain
Windows Server 2012 Managing Active Directory DomainNapoleon NV
 
Operating System 2
Operating System 2Operating System 2
Operating System 2tech2click
 
Operating system security
Operating system securityOperating system security
Operating system securityRachel Jeewa
 
Introduction to Web Server Security
Introduction to Web Server SecurityIntroduction to Web Server Security
Introduction to Web Server SecurityJITENDRA KUMAR PATEL
 
Network security and protocols
Network security and protocolsNetwork security and protocols
Network security and protocolsOnline
 
Windows Server 2016 First Look (Part 1)
Windows Server 2016 First Look (Part 1)Windows Server 2016 First Look (Part 1)
Windows Server 2016 First Look (Part 1)Tuan Yang
 
HP WebInspect
HP WebInspectHP WebInspect
HP WebInspectrohit_ta
 
Types of Threat Actors and Attack Vectors
Types of Threat Actors and Attack VectorsTypes of Threat Actors and Attack Vectors
Types of Threat Actors and Attack VectorsLearningwithRayYT
 
MALWARE AND ITS TYPES
MALWARE AND ITS TYPES MALWARE AND ITS TYPES
MALWARE AND ITS TYPES Sagilasagi1
 
Web App Security Presentation by Ryan Holland - 05-31-2017
Web App Security Presentation by Ryan Holland - 05-31-2017Web App Security Presentation by Ryan Holland - 05-31-2017
Web App Security Presentation by Ryan Holland - 05-31-2017TriNimbus
 
2 secure systems design
2   secure systems design2   secure systems design
2 secure systems designdrewz lin
 
17 roles of window server 2008 r2
17 roles of window server 2008 r217 roles of window server 2008 r2
17 roles of window server 2008 r2IGZ Software house
 

What's hot (20)

Man in the middle attack .pptx
Man in the middle attack .pptxMan in the middle attack .pptx
Man in the middle attack .pptx
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
 
Understanding the Windows Server Administration Fundamentals (Part-1)
Understanding the Windows Server Administration Fundamentals (Part-1)Understanding the Windows Server Administration Fundamentals (Part-1)
Understanding the Windows Server Administration Fundamentals (Part-1)
 
Windows Server 2012 Managing Active Directory Domain
Windows Server 2012 Managing  Active Directory DomainWindows Server 2012 Managing  Active Directory Domain
Windows Server 2012 Managing Active Directory Domain
 
Network security and viruses
Network security and virusesNetwork security and viruses
Network security and viruses
 
Operating System 2
Operating System 2Operating System 2
Operating System 2
 
Operating system security
Operating system securityOperating system security
Operating system security
 
Introduction to Web Server Security
Introduction to Web Server SecurityIntroduction to Web Server Security
Introduction to Web Server Security
 
Network security and protocols
Network security and protocolsNetwork security and protocols
Network security and protocols
 
Windows Server 2016 First Look (Part 1)
Windows Server 2016 First Look (Part 1)Windows Server 2016 First Look (Part 1)
Windows Server 2016 First Look (Part 1)
 
Windows Kernel-
Windows Kernel-Windows Kernel-
Windows Kernel-
 
HP WebInspect
HP WebInspectHP WebInspect
HP WebInspect
 
Types of Threat Actors and Attack Vectors
Types of Threat Actors and Attack VectorsTypes of Threat Actors and Attack Vectors
Types of Threat Actors and Attack Vectors
 
Dns server
Dns serverDns server
Dns server
 
MALWARE AND ITS TYPES
MALWARE AND ITS TYPES MALWARE AND ITS TYPES
MALWARE AND ITS TYPES
 
File system
File systemFile system
File system
 
Web App Security Presentation by Ryan Holland - 05-31-2017
Web App Security Presentation by Ryan Holland - 05-31-2017Web App Security Presentation by Ryan Holland - 05-31-2017
Web App Security Presentation by Ryan Holland - 05-31-2017
 
2 secure systems design
2   secure systems design2   secure systems design
2 secure systems design
 
17 roles of window server 2008 r2
17 roles of window server 2008 r217 roles of window server 2008 r2
17 roles of window server 2008 r2
 
Army Social Media Presentation
Army Social Media PresentationArmy Social Media Presentation
Army Social Media Presentation
 

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

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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.pdfsudhanshuwaghmare1
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
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
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
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
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
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 FresherRemote DBA Services
 
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 challengesrafiqahmad00786416
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 

Recently uploaded (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
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
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 

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