Linux Snippets

Get capabilities

/sbin/getcap -r / 2>/dev/null

Get suid binaries

find / -perm -u=s -type f 2>/dev/null

Check sudo configuration

sudo -l
cat /etc/sudoers

Check open files on linux

fuser <filename>
lsof <filename>

Check for unmounted disks on linux

ls /dev

Bash port scan

for p in {1..65535}; do echo hi > /dev/tcp/<ip>/$p && echo port $p is open > scan 2>/dev/null; done

Using gateway finder to detect rogue gateways

arp-scan -l | tee <name>.txt
python gateway-finder.py -f arp.txt -i <public ip>

Mount vmdk file

modprobe nbd
qemu-nbd -r -c /dev/nbd2 <name>.vmdk
mount /dev/nbd1p1 /mnt

Find files by date

find / -newermt "<start-date>" ! -newermt '<end-date>' 2>/dev/null

Get proper tty on shell

# stty method
python -c "import pty; pty.spawn('/bin/bash')"
ctrl+z
stty raw -echo
fg
<enter>
<enter>
# rlwrap method
rlwrap <command>

Get Apt History

gunzip -dc history.log.1.gz | less #from /var/log/apt

Last updated