Last active
February 6, 2019 20:49
-
-
Save REPTILEHAUS/263e6102a0e4f4abf0b3d7ac3fd03c21 to your computer and use it in GitHub Desktop.
A selection of commands to encode, decode and convert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Use PHP to Encode and Decode Hex, Binary, Base64 and Json - you can also cat the info from a file to most of these commands | |
# i.e cat file-with-data.txt | php -r "echo implode(unpack('H*', file_get_contents('php://stdin')));" | |
# Encode string to hex | |
echo -n "reptilehaus" | php -r "echo implode(unpack('H*', file_get_contents('php://stdin')));" | |
echo -n "reptilehaus" | php -r "echo bin2hex(file_get_contents('php://stdin'));" | |
# Decode hex to string | |
echo -n "72657074696c6568617573" | php -r "echo pack('H*', file_get_contents('php://stdin'));" | |
echo -n "72657074696c6568617573" | php -r "echo hex2bin(file_get_contents('php://stdin'));" | |
# base64 encode string | |
echo -n "reptilehaus"| php -r "echo base64_encode(file_get_contents('php://stdin'));" | |
# base64 decode string | |
echo -n "cmVwdGlsZWhhdXM=" | php -r "echo base64_decode(file_get_contents('php://stdin'));" | |
# json decode | |
echo -n '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":74}' | php -r "var_dump(json_decode(file_get_contents('php://stdin')));" | |
echo -n '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":74}' | php -r "print_r(json_decode(file_get_contents('php://stdin')));" | |
# JSON encode | |
php -r "echo json_encode( array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5) );" | |
# JSON encode then chain the output to json_decode via STDIN | |
php -r "echo json_encode( array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5) );" | php -r "var_dump(json_decode(file_get_contents('php://stdin')));" | |
# A string has been double encoded; first with hex, then base64; We decode base64 first then decode the hex to get the string (found in bug bounty) | |
echo -n 'NmQyNDI0NzE2YzVmNTM0MDVmNTA0MDczNzM1NzMwNzI2NDIx' | base64 -D | php -r "echo hex2bin(file_get_contents('php://stdin'));" | |
# Decode a hexadecimal to integer | |
echo -n '0x7e3' | php -r "echo hexdec(file_get_contents('php://stdin'));" | |
# Encode an integer to hexadecimal | |
echo -n '2019' | php -r "echo '0x'.dechex(file_get_contents('php://stdin'));" | |
# Decode hex to string | |
echo "0: 72657074696c6568617573" | xxd -r | |
## Get Hash of a file (if OS doesnt have native functions but does have openssl i.e OSX) | |
# Get a files SHA256 hash | |
openssl sha256 ~/Desktop/contract.pdf | awk '{print $2}'; | |
# Get a files SHA1 hash | |
openssl sha1 ~/Desktop/contract.pdf | awk '{print $2}'; | |
# Get a files MD5 hash | |
openssl md5 ~/Desktop/contract.pdf | awk '{print $2}'; | |
# Generate a local SSL Certificate | |
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout ~/Desktop/key.pem -out ~/Desktop/cert.pem | |
# Check the expiry date of an SSL Certificate | |
openssl s_client -connect example.com:443 2>/dev/null </dev/null | openssl x509 -noout -enddate | |
## Not necessarily usefull for Bug Bounty but good for Developers converting videos between formats on the fly | |
# first install ffmpeg | |
# brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with- --with-rtmpdump --with-schroedinger --with-s+ | |
# Convert an MP4 video to Og vorbis | |
ffmpeg -i input.mp4 -q:v 10 -c:v libtheora -c:a libvorbis output.ogv | |
# Convert MP4 to WebM | |
ffmpeg -i input.mp4 -q:v 10 -c:v libvpx -c:a libvorbis output.webm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment