Skip to content

Instantly share code, notes, and snippets.

@AnasAboreeda
Last active November 5, 2017 16:15
Show Gist options
  • Save AnasAboreeda/a55bf0c44e2a535847a89d2452334c58 to your computer and use it in GitHub Desktop.
Save AnasAboreeda/a55bf0c44e2a535847a89d2452334c58 to your computer and use it in GitHub Desktop.
Different usefull bash scripts #bash_script #shell_script

Useful Shell scripts

Print all files content in a directory

find . -print0 | while read -d $'\0' file; do cat $file; done

Pick all strings from a binary file

strings <file_name> | grep <searched text>

Count unique lines in file

sort ips.txt | uniq -c | sort -bgr

ROT13 file content

cat <file_name> | tr '[A-Za-z]' '[N-ZA-Mn-za-m]'

Extracting a password from a hex dump file

# reverse hexdump
$ xxd -r data.txt foobar.bin

$ zcat foobar.bin | file -
bzip2 compressed data, block size = 900k

$ zcat foobar.bin | bzcat | file -
gzip compressed data, was "data4.bin", from Unix, last modified: Thu Sep 28 14:04:06 2017, max compression

$ zcat foobar.bin | bzcat | zcat | file -
POSIX tar archive (GNU)

$ zcat foobar.bin | bzcat | zcat | tar xO | file -
POSIX tar archive (GNU)

$ zcat foobar.bin | bzcat | zcat | tar xO | tar xO | file -
bzip2 compressed data, block size = 900k

$ zcat foobar.bin | bzcat | zcat | tar xO | tar xO | bzcat | file -
POSIX tar archive (GNU)

$ zcat foobar.bin | bzcat | zcat | tar xO | tar xO | bzcat | tar xO | file -
gzip compressed data, was "data9.bin", from Unix, last modified: Thu Sep 28 14:04:06 2017, max compression

$ zcat foobar.bin | bzcat | zcat | tar xO | tar xO | bzcat | tar xO | zcat | file -
ASCII text

$ zcat foobar.bin | bzcat | zcat | tar xO | tar xO | bzcat | tar xO | zcat | cat -
The password is 8ZjyCRiBWFYkneahHwxCv3wb2a1ORpYL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment