Skip to content

Bash Scripting

Grep cheatsheet

# with colors and recursive
grep -r "function AddAttachment" --color 2>/dev/null /usr/local/mywebapp/

Examine File structure

tree -L 3 .

Unzip Ear Files

unzip -q  application.ear -d application

Get MiliSeconds since EPOCH

# includes 3 digits of miliseconds
date +%s%3N


# Enable
sudo systemctl start apache2

# Tail the logs
sudo tail -f /var/log/apache2/access.log

Base64 Powershell payload

iconv -f ASCII -t UTF-16LE shell.ps1 | base64 | tr -d "\n"

Search for uploaded file in file system

sudo find / -name "poc.txt"

Find writable directories

sudo find /var/www/html/ -type d -perm -o+w

Find top 10000 lines in file using jq

jq '.[0:10000]' names.json 

Download all files in list file using wget

wget --no-check-certificate -i custom_js.txt

Beautify JS files

Uses Python3 jsbeautifier

  1. Install python3-jsbeautifier
    sudo pip3 install jsbeautifier
  2. for f in *.js; do js-beautify $f > pretty/"${f}"; done;