SlideShare a Scribd company logo
1 of 51
Download to read offline
InSecure Remote Operations
What Sucks, Rocks & a Super-CLI
Yossi Sassi
WhoAmI
• InfoSec Researcher; H@‫כ‬k3r (1nTh35h311)
• Red mind, Blue heart
• Co-Founder @
• Consulting in 4 continents (Banks/gov/F100)
• 30+ years of keyboard access – Code, IT Sec, Net Comms.
• The HAcktive Directory guy; Ex-Javelin Networks (Acquired by Symantec)
• Ex-Technology Group Manager @ Microsoft (Coded Windows Server Tools)
• Volunteer (Youth at risk); Oriental Rock Bouzoukitarist; Aviator
ChatGPT was Not used in the making of this
presentation, code & content
• Remoting ‘Mindset’ – LoTL examples
• PSRemoting / WinRM
• Credentials exposure during Remote Operations
• Preventing Lateral movement without products
• Tips & open-source toolZ
What we’ll talk about
Living off the land…
Remote Management or Lateral Movement?
• Multiple LoLBins…
• RPC: WMI, DCOM
• ‘API heaven’ – e.g. IPC (MailSlots, NamedPipes..)
• RDP
• WinRM / PSRemoting
etc.
Remote Procedure Call (RPC)
•System service that is an inter-process communication (IPC)
mechanism, enabling data exchange and invocation of
functionality that is located in a different process.
•The different process can be on the same computer, on the
LAN, or in a remote location
•The RPC service serves as the RPC Endpoint Mapper and
Component Object Model (COM) Service Control Manager
(Remotely – DCOM)
•Many services depend on the RPC service to start
successfully
https://docs.microsoft.com/en-US/troubleshoot/windows-server/networking/service-overview-and-network-port-requirements
The RpcSs System service
https://docs.microsoft.com/en-US/troubleshoot/windows-server/networking/service-overview-and-network-port-requirements
Application Protocol Protocol Ports
RPC TCP 135
RPC over HTTPS TCP 593
NetBIOS datagram service UDP 138
NetBIOS Name Resolution UDP 137
NetBIOS Session Service TCP 139
SMB TCP 445
Dynamic port range TCP & UDP 1025 - 5000*,
49152 – 65535
Protocol / Port AD DS Usage Type of traffic
TCP 25 Replication SMTP
TCP 42 If using WINS in a domain trust scenario offering NetBIOS resolution WINS
TCP 135 Replication RPC, EPM
TCP 137 NetBIOS Name resolution NetBIOS Name resolution
TCP 139 User and Computer Authentication, Replication
DFSN, NetBIOS Session Service,
NetLogon
TCP and UDP 389 Directory, Replication, User and Computer Authentication, Group Policy, Trusts LDAP
TCP 636 Directory, Replication, User and Computer Authentication, Group Policy, Trusts LDAP SSL
TCP 3268 Directory, Replication, User and Computer Authentication, Group Policy, Trusts LDAP GC
TCP 3269 Directory, Replication, User and Computer Authentication, Group Policy, Trusts LDAP GC SSL
TCP and UDP 88 User and Computer Authentication, Forest Level Trusts Kerberos
TCP and UDP 53 User and Computer Authentication, Name Resolution, Trusts DNS
TCP and UDP 445 Replication, User and Computer Authentication, Group Policy, Trusts
SMBv1/2/3, CIFS, DFSN, LSARPC,
NbtSS, NetLogonR, SamR, SrvSvc
TCP 9389 AD DS Web Services SOAP
TCP 5722 File Replication RPC, DFSR (SYSVOL)
TCP and UDP 464 Replication, User and Computer Authentication, Trusts Kerberos change/set password
UDP 123 Windows Time, Trusts Windows Time
UDP 137 User and Computer Authentication
NetLogon, NetBIOS Name
Resolution
UDP 138 DFS, Group Policy, NetBIOS Netlogon, Browsing
DFSN, NetLogon, NetBIOS
Datagram Service
UDP 67 and UDP 2535
DHCP (Note: DHCP is not a core AD DS service, but these ports may be
necessary for other functions besides DHCP, such as WDS)
DHCP, MADCAP, PXE
TCP & UDP 1024-5000;
49152-65535
Ongoing (RPC etc’) RPC / DCOM / WMI...
TCP 593 DCOM/Messaging/Exchange RPC over HTTP
What ports/protocols does tool XX use?
(AND – why understanding pre-AuthN matters)
‘Netstat loop’ – Ports Monitor
• Pass strings/objects/execute code between
processes, local or remote – using Named Pipes
• Communicate between local or remote powershell
runspaces over one/two-way, encrypted pipe
• Pass info between processes on same machine
easily through IPC$
Inter-Process Communications (IPC)
• Can also use it for C2, without opening FW port,
without local admin privileges
– No need to Bind() server local port, just “rides” 445 ☺
Named-Pipe/SMB One-liner
(Exfil data/C2 with No socket bind)
IPC C’n’C
RPC Not Available / Kerberos Clock Skew
•e.g. ‘RPC not available’ errors (host is online, yet no Kerberos)
•Determine if clock skew exists
• Net time computer (does Not require special permissions)
• $varDate = Get-Date; Invoke-Command -ComputerName <IP>
-ScriptBlock {set-date $using:varDate} -Authentication Negotiate
• Cannot run winrm, or even ping(!) the host, because clock Diff,
and no KRB? try WMI process create w/IP (NTLM)
Invoke-WmiMethod -ComputerName <IP> -Class win32_process
-Name Create -ArgumentList "w32tm /resync"
TIP: Fixing Clock Skew issues Remotely
Fix Clock Skew Remotely
RDP – Windows admins’ favorite feature
RDP Attacks & adversary tools
• Brute force
• Change default user, default port…
• Seth.sh
• pyRdp
.. and more
RDP MiTM
•Get netNTLM, at minimum
•Can also get clear text password, if NLA is Not used
•Downgrades session, fakes certificate, attempts CredSSP
•Can also get clipboard/typed text directly to attacker
•Victim is totally unaware (RDP session functions normal,
just a bit slower initial connection time)
RDP MiTM
Getting Clear-Text password from any RDP Server
•With proper permissions – can disable NLA remotely –
either by modifying the Regkey directly, or via Powershell:
(Get-WmiObject -class Win32_TSGeneralSetting
-Namespace rootcimv2terminalservices
-ComputerName SRV1 -Filter "TerminalName='RDP-
tcp'").SetUserAuthenticationRequired(0)
• More silent, efficient & quicker than mimikatz etc. ;-)
• Can use inveigh/responder to relay the Registry
command, and/or ‘net localgroup administrators /add user’
• Remote Desktop Protocol (RDP)
• Remote WMI access over RPC/DCOM
• Remote event log management | service management
• SMB file share access
• PsExec
• Other…
• Yet “overlook” PSRemoting, always encrypted,
single port 5985 or 5986, does all of the above,
and much more??!?
Soooo… You perform Remote Management using:
PSRemoting Architecture
Remote Computer
Local Computer
PowerShell
Wsmprovhost
Endpoint
WinRM
Listener (HTTP)
WS-MAN
Traffic
PSRemoting w/Jobs
Copying to/from remote session
•Copy-item –ToSession $pssession c:myConfig.txt
c:folder-on-remote-srv
•Local Variables cast to remote session with $using
•Local functions cast to remote session with
${function:My-Function}
Copy files without SMB
For the Blue Team -
Just Enough Access –
Secure constrained remote access
• Utilizes PS Session Configurations
–WSMan config (per nic/IP, http/s, limit bandwidth and more)
–All the Logging you can ask for
–Transcriptions
–ConstrainedLanguage
–Virtual Account (virtual SID)
–Whitelist scripts, apps, commands, parameters – anything!
PSSession Configurations
Mapping / Hunting for WSMan sessions
• EDR/Sysmon etc. (wsmprovhost.exe)
• WinRM / PowerShell-operational logs
• Try Get-RemotePSSession ps1
Query PSRemoting Sessions
Remote Operations: Credentials Exposure
Action/Tool Logon Type Creds on Target Notes
Console login 2 Yes* * Except when Credential Guard is
enabled
RunAs 2 Yes* * Except when Credential Guard is
enabled
RDP 10 Yes* * Except when Remote Credential
Guard enabled
Net Use 3 No Inc. /u: parameter
PS Remoting 3 No -u <username> -p <pass>
PsExec w/Creds 3+2 Yes
PsExec no Creds 3 No
Remote SchedTask 4 Yes Password saved in LSA (on disk)
Run as a Service 5 Yes Password saved in LSA (w/account)
Remote Registry 3 No
Let’s get advice from Microsoft… ☺
Get TGT without ANY lsass secrets
Process token -> TGT
“Mitigation” – Virtual accounts
Using Virtual Accounts
But… the adversary can edit the Role Capabilities file ☺
But… Defenders can monitor for file/config changes, hash change etc’
(e.g. sign config file)
“Small step for IT, Giant step against Lateral Movement”
• No EDR
• No segmentation
• No firwewalls config
• No MFA
• All the misconfigurations you can think of …
• No proper auditing/SIEM/SOC
… and yet ☺
LogonWorkstations
Preventing DAs from logging to EndPoints
Living off the land
• Before setting LogonWorkstations, 1st reduce/”cleanup” priv users
• Ensure DA(s) not running on other targets to prevent services
& applications interruption (e.g. IIS AppPools, SchedTasks, Svc)
• Add at least one PAW/”Jump host” together with the Target(s)
– Protect/Harden PAW (.. & consider a Shielded VM)
• Monitor changes of LogonWorkstations attribute (see github)
• Other configuration options exist (e.g. Restrictive GPOs)
github.com/YossiSassi
Key Takeaways
• Embrace ‘Living off the land’ mindset (Red & Blue)
• Note Credentials exposure during Remote Operations
• A single configuration can do more than few products
(e.g. lateral movement prevention)
• PSRemoting Rocks! And JEA is effective. But ….
• Almost no security features are enabled by default. proper
configuration is needed. And can be bypassed (e.g. Invisi-Shell)
• Logging and continuous monitoring can be effective (and tools)
• Check out github.com/YossiSassi for code & scripts
Everything is a set of nested ‘if’ statements
D@nk3!
Yossi_Sassi
yossis@protonmail.com

More Related Content

Similar to Secure Remote Ops: PSRemoting, Credentials, Lateral Movement

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
 
TTL Alfresco Product Security and Best Practices 2017
TTL Alfresco Product Security and Best Practices 2017TTL Alfresco Product Security and Best Practices 2017
TTL Alfresco Product Security and Best Practices 2017Toni de la Fuente
 
OSSEC @ ISSA Jan 21st 2010
OSSEC @ ISSA Jan 21st 2010OSSEC @ ISSA Jan 21st 2010
OSSEC @ ISSA Jan 21st 2010wremes
 
DEF CON 23 - Sean - metcalf - red vs blue ad attack and defense
DEF CON 23 - Sean - metcalf - red vs blue ad attack and defenseDEF CON 23 - Sean - metcalf - red vs blue ad attack and defense
DEF CON 23 - Sean - metcalf - red vs blue ad attack and defenseFelipe Prado
 
Elk its big log season
Elk its big log seasonElk its big log season
Elk its big log seasonEric Luellen
 
Securing the Helix Platform at Citrix
Securing the Helix Platform at CitrixSecuring the Helix Platform at Citrix
Securing the Helix Platform at CitrixPerforce
 
Being HAPI! Reverse Proxying on Purpose
Being HAPI! Reverse Proxying on PurposeBeing HAPI! Reverse Proxying on Purpose
Being HAPI! Reverse Proxying on PurposeAman Kohli
 
DCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep diveDCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep diveMadhu Venugopal
 
Low Hanging Fruit, Making Your Basic MongoDB Installation More Secure
Low Hanging Fruit, Making Your Basic MongoDB Installation More SecureLow Hanging Fruit, Making Your Basic MongoDB Installation More Secure
Low Hanging Fruit, Making Your Basic MongoDB Installation More SecureMongoDB
 
Understanding Active Directory Enumeration
Understanding Active Directory EnumerationUnderstanding Active Directory Enumeration
Understanding Active Directory EnumerationDaniel López Jiménez
 
Unmasking Careto through Memory Forensics (video in description)
Unmasking Careto through Memory Forensics (video in description)Unmasking Careto through Memory Forensics (video in description)
Unmasking Careto through Memory Forensics (video in description)Andrew Case
 
OSMC 2021 | ITSM by Asterix and friends
OSMC 2021 | ITSM by Asterix and friendsOSMC 2021 | ITSM by Asterix and friends
OSMC 2021 | ITSM by Asterix and friendsNETWAYS
 
Privilege Escalation with Metasploit
Privilege Escalation with MetasploitPrivilege Escalation with Metasploit
Privilege Escalation with Metasploitegypt
 
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2Chris Gates
 
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...ScyllaDB
 
DFIR Austin Training (Feb 2020): Remote Access & Deploying Agents
DFIR Austin Training (Feb 2020): Remote Access & Deploying AgentsDFIR Austin Training (Feb 2020): Remote Access & Deploying Agents
DFIR Austin Training (Feb 2020): Remote Access & Deploying AgentsChristopher Gerritz
 
hacking and crecjing
hacking and crecjinghacking and crecjing
hacking and crecjingparth jasani
 
DataPower Security Hardening
DataPower Security HardeningDataPower Security Hardening
DataPower Security HardeningShiu-Fun Poon
 
Exploiting Active Directory Administrator Insecurities
Exploiting Active Directory Administrator InsecuritiesExploiting Active Directory Administrator Insecurities
Exploiting Active Directory Administrator InsecuritiesPriyanka Aash
 

Similar to Secure Remote Ops: PSRemoting, Credentials, Lateral Movement (20)

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 -...
 
TTL Alfresco Product Security and Best Practices 2017
TTL Alfresco Product Security and Best Practices 2017TTL Alfresco Product Security and Best Practices 2017
TTL Alfresco Product Security and Best Practices 2017
 
OSSEC @ ISSA Jan 21st 2010
OSSEC @ ISSA Jan 21st 2010OSSEC @ ISSA Jan 21st 2010
OSSEC @ ISSA Jan 21st 2010
 
DEF CON 23 - Sean - metcalf - red vs blue ad attack and defense
DEF CON 23 - Sean - metcalf - red vs blue ad attack and defenseDEF CON 23 - Sean - metcalf - red vs blue ad attack and defense
DEF CON 23 - Sean - metcalf - red vs blue ad attack and defense
 
Elk its big log season
Elk its big log seasonElk its big log season
Elk its big log season
 
Securing the Helix Platform at Citrix
Securing the Helix Platform at CitrixSecuring the Helix Platform at Citrix
Securing the Helix Platform at Citrix
 
Being HAPI! Reverse Proxying on Purpose
Being HAPI! Reverse Proxying on PurposeBeing HAPI! Reverse Proxying on Purpose
Being HAPI! Reverse Proxying on Purpose
 
DCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep diveDCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep dive
 
Low Hanging Fruit, Making Your Basic MongoDB Installation More Secure
Low Hanging Fruit, Making Your Basic MongoDB Installation More SecureLow Hanging Fruit, Making Your Basic MongoDB Installation More Secure
Low Hanging Fruit, Making Your Basic MongoDB Installation More Secure
 
Understanding Active Directory Enumeration
Understanding Active Directory EnumerationUnderstanding Active Directory Enumeration
Understanding Active Directory Enumeration
 
Unmasking Careto through Memory Forensics (video in description)
Unmasking Careto through Memory Forensics (video in description)Unmasking Careto through Memory Forensics (video in description)
Unmasking Careto through Memory Forensics (video in description)
 
OSMC 2021 | ITSM by Asterix and friends
OSMC 2021 | ITSM by Asterix and friendsOSMC 2021 | ITSM by Asterix and friends
OSMC 2021 | ITSM by Asterix and friends
 
Privilege Escalation with Metasploit
Privilege Escalation with MetasploitPrivilege Escalation with Metasploit
Privilege Escalation with Metasploit
 
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
 
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
 
DFIR Austin Training (Feb 2020): Remote Access & Deploying Agents
DFIR Austin Training (Feb 2020): Remote Access & Deploying AgentsDFIR Austin Training (Feb 2020): Remote Access & Deploying Agents
DFIR Austin Training (Feb 2020): Remote Access & Deploying Agents
 
hacking and crecjing
hacking and crecjinghacking and crecjing
hacking and crecjing
 
DataPower Security Hardening
DataPower Security HardeningDataPower Security Hardening
DataPower Security Hardening
 
Rails Security
Rails SecurityRails Security
Rails Security
 
Exploiting Active Directory Administrator Insecurities
Exploiting Active Directory Administrator InsecuritiesExploiting Active Directory Administrator Insecurities
Exploiting Active Directory Administrator Insecurities
 

Recently uploaded

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Recently uploaded (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

Secure Remote Ops: PSRemoting, Credentials, Lateral Movement

  • 1. InSecure Remote Operations What Sucks, Rocks & a Super-CLI Yossi Sassi
  • 2. WhoAmI • InfoSec Researcher; H@‫כ‬k3r (1nTh35h311) • Red mind, Blue heart • Co-Founder @ • Consulting in 4 continents (Banks/gov/F100) • 30+ years of keyboard access – Code, IT Sec, Net Comms. • The HAcktive Directory guy; Ex-Javelin Networks (Acquired by Symantec) • Ex-Technology Group Manager @ Microsoft (Coded Windows Server Tools) • Volunteer (Youth at risk); Oriental Rock Bouzoukitarist; Aviator
  • 3. ChatGPT was Not used in the making of this presentation, code & content
  • 4. • Remoting ‘Mindset’ – LoTL examples • PSRemoting / WinRM • Credentials exposure during Remote Operations • Preventing Lateral movement without products • Tips & open-source toolZ What we’ll talk about
  • 5. Living off the land… Remote Management or Lateral Movement? • Multiple LoLBins… • RPC: WMI, DCOM • ‘API heaven’ – e.g. IPC (MailSlots, NamedPipes..) • RDP • WinRM / PSRemoting etc.
  • 6. Remote Procedure Call (RPC) •System service that is an inter-process communication (IPC) mechanism, enabling data exchange and invocation of functionality that is located in a different process. •The different process can be on the same computer, on the LAN, or in a remote location •The RPC service serves as the RPC Endpoint Mapper and Component Object Model (COM) Service Control Manager (Remotely – DCOM) •Many services depend on the RPC service to start successfully https://docs.microsoft.com/en-US/troubleshoot/windows-server/networking/service-overview-and-network-port-requirements
  • 7. The RpcSs System service https://docs.microsoft.com/en-US/troubleshoot/windows-server/networking/service-overview-and-network-port-requirements Application Protocol Protocol Ports RPC TCP 135 RPC over HTTPS TCP 593 NetBIOS datagram service UDP 138 NetBIOS Name Resolution UDP 137 NetBIOS Session Service TCP 139 SMB TCP 445 Dynamic port range TCP & UDP 1025 - 5000*, 49152 – 65535
  • 8. Protocol / Port AD DS Usage Type of traffic TCP 25 Replication SMTP TCP 42 If using WINS in a domain trust scenario offering NetBIOS resolution WINS TCP 135 Replication RPC, EPM TCP 137 NetBIOS Name resolution NetBIOS Name resolution TCP 139 User and Computer Authentication, Replication DFSN, NetBIOS Session Service, NetLogon TCP and UDP 389 Directory, Replication, User and Computer Authentication, Group Policy, Trusts LDAP TCP 636 Directory, Replication, User and Computer Authentication, Group Policy, Trusts LDAP SSL TCP 3268 Directory, Replication, User and Computer Authentication, Group Policy, Trusts LDAP GC TCP 3269 Directory, Replication, User and Computer Authentication, Group Policy, Trusts LDAP GC SSL TCP and UDP 88 User and Computer Authentication, Forest Level Trusts Kerberos TCP and UDP 53 User and Computer Authentication, Name Resolution, Trusts DNS TCP and UDP 445 Replication, User and Computer Authentication, Group Policy, Trusts SMBv1/2/3, CIFS, DFSN, LSARPC, NbtSS, NetLogonR, SamR, SrvSvc TCP 9389 AD DS Web Services SOAP TCP 5722 File Replication RPC, DFSR (SYSVOL) TCP and UDP 464 Replication, User and Computer Authentication, Trusts Kerberos change/set password UDP 123 Windows Time, Trusts Windows Time UDP 137 User and Computer Authentication NetLogon, NetBIOS Name Resolution UDP 138 DFS, Group Policy, NetBIOS Netlogon, Browsing DFSN, NetLogon, NetBIOS Datagram Service UDP 67 and UDP 2535 DHCP (Note: DHCP is not a core AD DS service, but these ports may be necessary for other functions besides DHCP, such as WDS) DHCP, MADCAP, PXE TCP & UDP 1024-5000; 49152-65535 Ongoing (RPC etc’) RPC / DCOM / WMI... TCP 593 DCOM/Messaging/Exchange RPC over HTTP
  • 9. What ports/protocols does tool XX use? (AND – why understanding pre-AuthN matters)
  • 10. ‘Netstat loop’ – Ports Monitor
  • 11. • Pass strings/objects/execute code between processes, local or remote – using Named Pipes • Communicate between local or remote powershell runspaces over one/two-way, encrypted pipe • Pass info between processes on same machine easily through IPC$ Inter-Process Communications (IPC)
  • 12. • Can also use it for C2, without opening FW port, without local admin privileges – No need to Bind() server local port, just “rides” 445 ☺
  • 15. RPC Not Available / Kerberos Clock Skew
  • 16. •e.g. ‘RPC not available’ errors (host is online, yet no Kerberos) •Determine if clock skew exists • Net time computer (does Not require special permissions) • $varDate = Get-Date; Invoke-Command -ComputerName <IP> -ScriptBlock {set-date $using:varDate} -Authentication Negotiate • Cannot run winrm, or even ping(!) the host, because clock Diff, and no KRB? try WMI process create w/IP (NTLM) Invoke-WmiMethod -ComputerName <IP> -Class win32_process -Name Create -ArgumentList "w32tm /resync" TIP: Fixing Clock Skew issues Remotely
  • 17. Fix Clock Skew Remotely
  • 18. RDP – Windows admins’ favorite feature
  • 19. RDP Attacks & adversary tools • Brute force • Change default user, default port… • Seth.sh • pyRdp .. and more
  • 20. RDP MiTM •Get netNTLM, at minimum •Can also get clear text password, if NLA is Not used •Downgrades session, fakes certificate, attempts CredSSP •Can also get clipboard/typed text directly to attacker •Victim is totally unaware (RDP session functions normal, just a bit slower initial connection time)
  • 22. Getting Clear-Text password from any RDP Server •With proper permissions – can disable NLA remotely – either by modifying the Regkey directly, or via Powershell: (Get-WmiObject -class Win32_TSGeneralSetting -Namespace rootcimv2terminalservices -ComputerName SRV1 -Filter "TerminalName='RDP- tcp'").SetUserAuthenticationRequired(0) • More silent, efficient & quicker than mimikatz etc. ;-) • Can use inveigh/responder to relay the Registry command, and/or ‘net localgroup administrators /add user’
  • 23.
  • 24. • Remote Desktop Protocol (RDP) • Remote WMI access over RPC/DCOM • Remote event log management | service management • SMB file share access • PsExec • Other… • Yet “overlook” PSRemoting, always encrypted, single port 5985 or 5986, does all of the above, and much more??!? Soooo… You perform Remote Management using:
  • 25. PSRemoting Architecture Remote Computer Local Computer PowerShell Wsmprovhost Endpoint WinRM Listener (HTTP) WS-MAN Traffic
  • 27. Copying to/from remote session •Copy-item –ToSession $pssession c:myConfig.txt c:folder-on-remote-srv •Local Variables cast to remote session with $using •Local functions cast to remote session with ${function:My-Function}
  • 29. For the Blue Team - Just Enough Access – Secure constrained remote access • Utilizes PS Session Configurations –WSMan config (per nic/IP, http/s, limit bandwidth and more) –All the Logging you can ask for –Transcriptions –ConstrainedLanguage –Virtual Account (virtual SID) –Whitelist scripts, apps, commands, parameters – anything!
  • 31. Mapping / Hunting for WSMan sessions • EDR/Sysmon etc. (wsmprovhost.exe) • WinRM / PowerShell-operational logs • Try Get-RemotePSSession ps1
  • 33. Remote Operations: Credentials Exposure Action/Tool Logon Type Creds on Target Notes Console login 2 Yes* * Except when Credential Guard is enabled RunAs 2 Yes* * Except when Credential Guard is enabled RDP 10 Yes* * Except when Remote Credential Guard enabled Net Use 3 No Inc. /u: parameter PS Remoting 3 No -u <username> -p <pass> PsExec w/Creds 3+2 Yes PsExec no Creds 3 No Remote SchedTask 4 Yes Password saved in LSA (on disk) Run as a Service 5 Yes Password saved in LSA (w/account) Remote Registry 3 No
  • 34. Let’s get advice from Microsoft… ☺
  • 35.
  • 36. Get TGT without ANY lsass secrets
  • 40. But… the adversary can edit the Role Capabilities file ☺
  • 41. But… Defenders can monitor for file/config changes, hash change etc’ (e.g. sign config file)
  • 42.
  • 43.
  • 44.
  • 45. “Small step for IT, Giant step against Lateral Movement” • No EDR • No segmentation • No firwewalls config • No MFA • All the misconfigurations you can think of … • No proper auditing/SIEM/SOC … and yet ☺
  • 47. Preventing DAs from logging to EndPoints Living off the land • Before setting LogonWorkstations, 1st reduce/”cleanup” priv users • Ensure DA(s) not running on other targets to prevent services & applications interruption (e.g. IIS AppPools, SchedTasks, Svc) • Add at least one PAW/”Jump host” together with the Target(s) – Protect/Harden PAW (.. & consider a Shielded VM) • Monitor changes of LogonWorkstations attribute (see github) • Other configuration options exist (e.g. Restrictive GPOs)
  • 49. Key Takeaways • Embrace ‘Living off the land’ mindset (Red & Blue) • Note Credentials exposure during Remote Operations • A single configuration can do more than few products (e.g. lateral movement prevention) • PSRemoting Rocks! And JEA is effective. But …. • Almost no security features are enabled by default. proper configuration is needed. And can be bypassed (e.g. Invisi-Shell) • Logging and continuous monitoring can be effective (and tools) • Check out github.com/YossiSassi for code & scripts
  • 50. Everything is a set of nested ‘if’ statements