Manual Exploitaion

Windows Structure

  • Named drives i.e. A, B, C, D

  • \Program Files and \Program Files (x86)

    • all programs are in these two directories

    • x86 is for 32-bit and 16-bit programs

  • \Users

    • User profile folders which contain files for that specific user

    • Desktop, Downloads, Documents, Picture, Music

  • \Windows

    • Have both \system and \system32 folders

    • Contain exe and dll files

  • \Inetpub Default directory for IIS (web server)

Operating System

What is the OS and architecture? Is it missing any patches? (!)

systeminfo

wmic qfe

systeminfo | findstr /B /C:"OS Name" /C:"OS Version"

Users

Who are you? (!)

All users

What users are on the system? Any old user profiles that weren’t cleaned up? We list the other user accounts on the box and view our own user's information in a bit more detail.

Add User

Adding user that is part of the Administrator group

Groups

What groups are on the system?

Autologon

Anything in the Registry for User Autologon?

if we got any auto log on enabled , we can use the winexe command to spawn a shell using these credentials:

Programs, Processes, and Services

Softwares

What software is installed?

Services

What are the running processes/services on the system? Is there an inside service not exposed? If so, can we open it?

This one liner returns the process owner without admin rights, if something is blank under owner it’s probably running as SYSTEM, NETWORK SERVICE, or LOCAL SERVICE.

scheduled tasks

What scheduled tasks are there? Anything custom implemented?

Networking

NICs

What NICs are connected? Are there multiple networks?

Routes

What routes do we have?

ARP

Anything in the ARP cache?

Connections

Are there connections to other hosts?

Host File

Firewall

Is the firewall turned on? If so what’s configured?

Enable RDP

SNMP configurations

Weak Files and Folder permissions

Listing files

Icacls

Are there any weak folder or file permissions? Full Permissions for Everyone or Users on Program Folders?

Modify Permissions for Everyone or Users on Program Folders?

Sensitive Information

Yes, passwords.

Even administrators re-use their passwords, or leave their passwords on systems in readable locations.

Windows can be especially vulnerable to this, as several features of Windows store passwords insecurely.

Registry

Searching registry for password

If we got any credentials we can use winexe to login into box

Autologon

Anything in the Registry for User Autologon?

if we got any auto log on enabled , we can use the winexe command to spawn a shell using these credentials:

Saved Creds

Windows has a runas command which allows users to run commands with the privileges of other users.

This usually requires the knowledge of the other user’s password.

However, Windows also allows users to save their credentials to the system, and these saved credentials can be used to bypass this requirement.

We can use the saved credential to run any command as the admin user. Start a listener on Kali and run the reverse shell executable:

Configuration Files

Some administrators will leave configurations files on the system with passwords in them.

The Unattend.xml file is an example of this.

It allows for the largely automated setup of Windows systems.

Is XAMPP, Apache, or PHP installed? Any there any XAMPP, Apache, or PHP configuration files?

Once again we can simply use winexe to spawn a shell as the admin user.

Unattend and sysprep

IIS

If the server is an IIS webserver, what’s in inetpub? Any hidden directories? web.config files?

What’s in the IIS Logs?

Unquoted Service Path

The Unquoted Service Paths vulnerability is a vulnerability that arises out of the way Windows interprets a file path for a service binary (executable). File paths that contain spaces, should be enclosed in double-quotes. If not, there’s a potential Unquoted Service Path vulnerability.

For example, the following path would be vulnerable:

Not vulnerable

We could place our payload with any of the following paths:

Required Things -

  1. A service with an "unquoted" binary path containing one or more spaces in the path.

  2. Write permission for any of the folder containing spaces.

  3. A way to reboot the service or system in order to execute a payload.

Finding unquoted services

Checking writable permission

Creating malicious program

Managing Services

once we transferred our payload to particular directory , we can restart the service to execute it

AlwaysInstallElevated

AlwaysInstallElevated is a Windows setting that allows non-privileged users to install Microsoft Windows Installer Package Files (MSI) with elevated system permissions. This means that we can use this feature to execute a malicious MSI installer package with administrator permissions. To achieve this, two registry entries have to be set to the value 1 to be enabled.

Check the value of these registry keys

Generating Payload

Executing msi file

Unattended Installs

Unattended Installs allow Windows to be deployed with little or no active involvement from an administrator. If administrators fail to clean up after such a process, an EXtensible Markup Language (XML) file called Unattend is left on the local system. This file contains all the configuration settings that were set during the installation process, some of which can involve the configuration of local accounts including Administrator accounts!

Unattend credentials are stored in base64 and can be decoded manually with base64.

$PATH Interception

Requirements:

  • PATH contains a writeable folder with low privileges.

  • The writeable folder is before the folder that contains the legitimate binary.

List contents of the PATH environment variables

Checking writable permission

Placing malicious binary

Kernel Exploitation

Finding kernel exploit

Finding and using kernel exploits is usually a simple process:

  1. Enumerate Windows version / patch level (systeminfo).

  2. Find matching exploits (Google, ExploitDB, GitHub).

  3. Compile and run.

Known Exploits

List of exploits kernel : https://github.com/SecWiki/windows-kernel-exploitsarrow-up-right

#Security Bulletin #KB #Description #Operating System

Important Tools

Windows Exploit Suggester: https://github.com/bitsadmin/wesngarrow-up-right

Precompiled Kernel Exploits: https://github.com/SecWiki/windows-kernel-exploitsarrow-up-right

Watson: https://github.com/rasta-mouse/Watsonarrow-up-right

Hot Potatoes

Service Accounts -

Service accounts can be given special privileges in order for them to run their services, and cannot be logged into directly.

Unfortunately, multiple problems have been found with service accounts, making them easier to escalate privileges with.

"SeImpersonatePrivilege" is enabled so we can impersonate other users

If the machine is >= Windows 10 1809 & Windows Server 2019 - Try Rogue Potato If the machine is < Windows 10 1809 < Windows Server 2019 - Try Juicy Potato

Juicy Potato

Vulnerable Win versions

1. Create paylaod

2. Transfer shell.bat and jp.exe to target box

3. Run JuicyPotato

Along with community string if default is failed

CLSID List -

Rogue Potato

Insecure Service PermissionsEach service has an ACL which defines certain service-specific permissions.

Some permissions are innocuous (e.g. SERVICE_QUERY_CONFIG, SERVICE_QUERY_STATUS).

Some may be useful (e.g. SERVICE_STOP, SERVICE_START).

Some are dangerous (e.g. SERVICE_CHANGE_CONFIG, SERVICE_ALL_ACCESS)

If our user has permission to change the configuration of a service which runs with SYSTEM privileges, we can change the executable the service uses to one of our own.

Potential Rabit Hole: If you can change a service configuration but cannot stop/start the service, you may not be able to escalate privileges!

Identifying Service

The following commands will print the affected services:

Check the current configuration and status of the service

Putting our malicious payload

Starting service

start listener on your kali and start the service on target box

Weak Registry Permissions

The Windows registry stores entries for each service. Since registry entries can have ACLs, if the ACL is misconfigured, it may be possible to modify a service’s configuration even if we cannot modify the service directly.

Identifying weak registry

Overwriting registry key to add reverse shell

Starting service

start listener on your kali and start the service on target box

Last updated