Linux Shell

Add string to beginning of each line (before existing strings) and output to new file - Useful for custom password lists (see also, Crunch in Security Tools List using -- "crunch -s" to achieve similar results)

sed 's/^/InsertCharsHere/' file.txt  > new-file.txt

Find all SUID files in system

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

Find all SUID binaries

find / -perm -4000 -type f -exec ls -la {} 2>/dev/null \;
find / -uid 0 -perm -4000 -type f 2>/dev/null

Search for binaries with capabilities set (similar to SUID) (1,2)

getcap -r / 2>/dev/null

Search for IPv4 address in a file

grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" filename

Find string within file(s)

grep -rnw '/path/to/somewhere/' -e 'pattern'
-r or -R is recursive,
-n is line number, and
-w stands for match the whole word.
-l (lower-case L) can be added to just give the file name of matching files.
-e is the pattern used during the search

Linux terminal control sequence commands

ctrl-c
    interrupts the running program
ctrl-d
    sends an EOF (end of file) to close the terminal
ctrl-z
    suspends the running program
ctrl-s
    freezes the screen, stopping the display
ctrl-q
    thaws out the screen and allows the screen display to continue
ctrl-h
    deletes the last character typed
ctrl-w
    deletes the last word typed
ctrl-u
    deletes the last line typed
ctrl-r
    retrieves previously run commands so you can run them again
ctrl-u
    removes text from the command line and places it in the clipboard
ctrl-y
    grabs text from the clipboard and runs it
ctrl-l
    clears the screen
ctrl-a
    moves cursor to the beginning of the line
ctrl-e
    moves cursor to the end of the line

Look at sudo activity

grep -i sudo /var/log/auth.log

Getting interactive shells after exploit

#sh
/bin/bash -i
#Bash
echo os.system('/bin/bash')

Last updated