Cheatography
https://cheatography.com
Basic but useful commands to perform pentesting taks related to Gather information from processes, network, accounts, sensitive locations, files or to perform changes, build things, etc.
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Processes
|
lists processes in a tree-like format |
|
lists services running |
systemctl status<service>
|
Get status of aprocess |
systemctl list-units --type=service --state=active
|
list all running services in systemd |
Network
|
Get IP address for all net interfaces |
|
Get connections info |
|
show listening ports |
|
Look for “LISTENING” and “ESTABLISHED” |
|
List and read open connections by processes |
|
ports/process in LISTEN state |
|
Get GW and routing table |
|
Get arp table |
|
Get IP address for all net interfaces |
|
Get connections info |
|
ports/process in LISTEN state |
|
use this multicast address for all link-local IPv6 nodes |
|
use this multicast address for all link-local IPv6 routers |
|
Get arp table / host in same BRD domain |
|
Get GW and routing table |
Users and Groups
|
Get local user info |
|
Get user hashes |
|
Get all local groups |
|
See who is currentlylogged in |
|
See what they are doing |
cat /etc/nsswitch.conf
|
get config about auth mechanisms |
|
Get user accounts, regardless of back-end auth mechanism |
|
Get groups, regardless of back-end auth mechanism |
|
If SSSD or PAM is configured, get hashes for all users, regardless of back-end auth mechanism |
Remote information Gathering
|
|
See who is currentlylogged in |
|
If NIS is in use, get users |
|
If NIS is in use, get ugroups and memberships |
|
runs id and hostname on the dest host |
scp root@x.x.x.x:/root/.ssh/id_rsa .
(with point at the end)) |
copy remote file to current location |
wget |
|
No directories, puts all files in one directory |
|
Recursive Download / web spider function |
|
Prefix output fule locations with [directory] |
|
Restrict or alow file types or patterns |
Example1: wget -nd -r -R htm,html,php,asp ,aspx,cgi -P /home /560 /CourseFiles/ 560metadata_ex [tgt_domain]
|
Exclude html, php, asp and cgi extensions |
Example1: wget -nd -r -A pdf, doc, docx,xls,xlsx -P /home /560 CourseFiles/ 560metadata_ex [tgt_domain]
|
included only PDF, Word, and Excel extensions |
smbclient --list=IP --no-pass
|
List shared folders hosted on IP anonymously |
smbclient //IP/sharedF -U "DOMAIN\user"
|
Map sharedFolder with creds |
smbclient //IP/sharedF -U 'NULL' -N
|
Map sharedFolder with anonymous creds |
sudo mount //IP/sharedF /mount/point -o rw,guest
|
Map sharedFolder to a mount point |
Sensitive Locations
|
user account info |
|
user password info |
|
user’s history file |
|
SSH keys |
|
Firefox profile |
|
SystemV runlevels services to run at startup |
/etc/systemd/system/<x>.target.wants
|
Systemd target directory |
|
determine which authentication back-end a Linux system is configured to use |
|
sudoers file |
|
get files with "passw" in them |
Read & execute
|
get content from a file |
|
get first 20 lines of [filename] |
|
get last 2 lines of [filename] |
|
view large content moving in pages |
|
putting command output as input to less |
|
see Where your commands are run from |
|
run a program located in the current directory |
PATH=$PATH /[another_dir]
|
Temporary (Session's life) add directories to your path |
Miscelaneous
|
find files in the current directory that contain theword root |
|
show detailed usage information for other commands |
|
Get a hint about What a program does |
|
search for topics |
|
look up something by keyword, |
|
Disable command history/logging |
|
monitor when a file will appear |
|
Listing environment variables |
|
View your path env variable |
|
WordCount | -l count the number of lines |
Working with programs/jobs
|
run command in background as a job |
|
if a program/command is running, it'll pause the job letting the process in the brackground paused |
|
list background/pauses jobs |
|
resume program in background |
|
resume program in foreground, back to actual screen |
|
|
Port Forwarding
ssh -L 8888:victimIP:victimPORT usr@PIVOT-PC |
LOCAL - forward traffic from local port 8888 to DSThostIP:80 |
|
REMOTE - forwarding traffic through the SSH connection, but your SSH connection this time will be “outbound.” |
ssh usr@PIVOT-PC -D 9050 |
Dynamic Port forwarding OR SOCKS proxy |
Building tools
|
untar Tape Archive Image file |
tar xvfz [archive.tar.gz or archive.tgz]
|
uncompress and untar .tar.gz or tgz file |
" ./configure make make install"
|
compile and install |
Setup Services
python -m SimpleHTTPServer
|
Serves current dir as webcontent |
|
Serves current dir as webcontent |
impacket-smbserver -comment "Temp Dir" TMP /tmp -username tempuser -p temppass -smb2support
|
Simple SMB Service |
Change configuration
gedit /etc/network/interfaces
|
set up static or dynamic network interfaces |
service networking restart
|
pretty much that |
export PATH=/usr/sbin:$PATH
|
To add/usr/sbin to your PATH variable |
Filesystems
|
get location for a file |
find [directory to search] [search criteria]
|
|
exhaustively looks for stuff |
|
|
create a locate database |
shred --remove /tmp/sam.txt
|
Shred overwrites the file with alternating zeros and ones three times so that they cannot be recovered. |
Accounts
useradd -d [home dir] [username]
|
create a user login |
|
change actual user password |
|
change other user's password |
|
becomes root |
|
shows which account you are using |
|
get more ditauls about your user and privis |
|
Delete user |
Firewall / IPTables
|
Delete INPUT rule ID 2 |
iptables -I INPUT 2 -s x.x.x.x -j DROP
|
fw INPUT rule ID 2, action DROP traffic from X.X.X.X |
iptables -I INPUT 1 -s x.x.x.x -p tcp --dport 4444 -j ACCEPT
|
allow inbound port 4444 |
firewall-cmd --direct --add-rule ipv4 filter INPUT 1 -m tcp -p tcp --dport 8443 -j ACCEPT
|
add fw rule to allow incoming traffic |
firewall-cmd --direct --remove-rule ipv4 filter INPUT 1 -m tcp -p tcp --dport 8443 -j ACCEPT
|
remove fw rule to allow incoming traffic |
Authentication
ssh-keygen -t rsa -b 2048 |
generate a new identity file |
Priv elevation
%admins ALL=(root) NOPASSWD: /bin/bar
|
Let admins Group run command as root |
|