CTFs
Crackstation.net : NTLM, md4, md5 hashes match with existing hashtable from crackstation
Some useful commands:
-
cat
| head -n <line_number> | tail -1 : get n’th line_number -
strings reversing1 | egrep “^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$” | while read line ; do echo $line | base64 -d | cat -v && echo “”; done
base64 encoded text regex
-
echo “obase=16; <decimal_number>” | BC_LINE_LENGTH=0 bc | awk ‘{ print (length($0) % 2 == 0) ? $0 : 0$0; }’ : decimal number to zero padded hex
-
/bin/cat $(find / -name flag.txt): find all files with name flag.txt and paste their content
-
echo ‘<hex_string>’ | awk ‘{ print (length($0) % 2 == 0) ? $0 : 0$0; }’ | xxd -p -r > <output_file> : create binary file from hex strings
-
cat <(python -c “print((‘A’ * 76) + ‘\x08\x87\x04\x08’)”) - | ./authme : redirect into executable stdin and then keep going
-
ascii_char=\((printf “\)(printf %x <decimal_ascii_code>)” | xxd -p -r) : ascii code to characters
-
{ echo “name”; echo ‘a_reAllY_s3cuRe_p4s$word_56b977’;} | cat : echo two lines by including them in curly braces
9/ Openssl commands:
-
openssl genrsa -out <output_key_name>
: generate a rsa based private public key pair -
openssl req -in
-text -noout : view certificate signing details -
openssl x509 -in <c.cer> -inform
-text -noout: examine certificate content : formats can be pem or der -
openssl pkcs12 -export -inkey <key_file> -in <cert_file> -certfile <parent_certs> -out <output_name> : get pkcs12 file ; needs key_file, cert_file and parent certificates
-
openssl x509 -req -in <child_csr> -CA <parent_certificate> -CAkey <parent_key> -CAcreateserial -out <output_child_name> -days <validity_days> -sha256 -extfile
: sign child csr with parent -
openssl rsa -pubin -in <public_key_file> -text: examine modulus and exponent of RSA public key
-
openssl pkcs12 -info -in
: pkcs12 file details -
openssl pkcs12 -in <input_pfx_file> -clcerts -nokeys -out <output_certificate_file> : extract certificate files from pkc file
-
openssl rsa -in <private_key_file> -text : evaluate rsa private key details: modulus, exponent and so on.
-
openssl req -addext
-outform pem -out <out_csr_name> -key <input_csr_key> -new : generate csr file with extension
-
https://github.com/Ganapati/RsaCtfTool : rsa ctf tool to analyze using various public and private keys, some simple decryption tries as well. it helps uncipher files using rsa private key as well
-
echo “U2VjcmV0IG1lc3NhZ2U=” | base64 -d : simple base 64 decoding directly from command line
-
cyclic
: generate a cyclic number of string inputs of specific length; used in several cases of buffer overflow -
sudo pip install capstone; pip install ropgadget; : shellstorm script to find rop exploitation on various elf, pe , mach o binaries on various architectures.
-
shellstorm.org : so you want to have exploits to various shells, you have binaries and tools to let you exploit here.
-
radare2 : analysing any binary for reversing ; https://insinuator.net/2016/08/reverse-engineering-with-radare2-part-1/ tutorials on using radare2
-
ltrace
: gives all the library calls and system calls made by the program -
strace
: gives all the system calls made by the program to the kernel -
https://github.com/slimm609/checksec.sh : this script can give you info about different type of executables and their sections
Forensics:
-
apktool -d
: decompiles any android app -
sox <audio_file> -n spectrogram : give a spectrogram of any wav file: directly available on linux archives
Binary forensics:
-
xxd -g1 <binary_file>: g means the number of bytes to group by : this is used to print the binary file’s hex code
-
strings
-
dd skip=<start_offset> count=
if=<input_file> of=<output_file> bs=1 : get a binary file from an existing binary file using offset and count of number of bytes -
printf
| dd conv=notrunc of= bs=1 seek= : patch a binary with bytes at offset. example: printf ‘\x53\xef’ | dd conv=notrunc of=ext-super-magic.img bs=1 seek=$((1024+56)) adds the bytes at the seek position . Useful when changing and adding headers to binary files
-
file
-
https://ide.kaitai.io/ : kaitai ide to analyze any binary : has it’s specific formats at formats.kaitai.io
-
foremost
:Recover files based on their headers, footers, and internal data structures. available as linux package -
binwalk
: walk through the executable to find number of files and executable code : to extract use option -echo -
binwalk –dd=".*" <file_name> : extract any file type from binwalk; not just known files
-
pngcheck
: check the integrity of png files -
exiftool
: metadata and exif information from file -
sudo apt-get install zbar-tools; zbarimg <img_with_qr> : decodes qr code from image
-
https://blog.didierstevens.com/2008/04/09/quickpost-about-the-physical-and-logical-structure-of-pdf-files/ : learn about physical and logical structure of a pdf file
-
get pdf-parser.py from ctf-tools : pdf-parser -v
: get all malformed elements with todo prefix example: pdf-parser.py -v 1485.pdf | grep “todo”
-
Stegano with gimp: Reveal hidden text in an image.
- Open the image with GIMP.
- Mode: Grain Extract.
- Filters -> Enhance -> Unsharp Mask -> Amout: ~10.0
-
stegsolve, zsteg are easy to use as well.
Network and Web:
-
Curl : -s, –silent: -v, –verbose: , -k –insecure: any connection doesn’t check certs.
-
curl –cookie “<cookie_name>=<cookie_value>”
: give a cookie and get something from the uri -
curl
-X POST –data “ = & = ” : fetch using a post request with multiple parameters –data-binary : if you don’t want curl to work on the data
-
curl
-H ‘Content-Type: application/json; charset=UTF-8’ –data-binary ‘{" ":" "}’ : use a json request to fetch data from a server -
curl -d “
= ” –data-urlencode “ =<value2_to_be_encoded>” -X POST " : fetch using post request and a urlencoded format to send to the server -
curl -l
: gets the header only from a request.
Directory search : https://github.com/maurosoria/dirsearch : brute force a directory for files and folders
dirsearch.py -u
Dirbuster from owasp can be used to find dirs as well
nmap -p 443 –script ssl-cert
scp username@from_host:file.txt local/directory : directly get a file from ssh server to local directory
scp file.txt username@to_host:/remote/directory/ : copy to ssh server
Tshark:
tshark -r
Display all frames from a network capture which comply with filter.
Add ‘-x’ for a full hex dump of the packets.
Password file cracking:
unshadow <passwd_file> <shadow_file> : combine passwd and shadow to crack linux pwd hashes
zip2john <zip_file> > <password_file> : Encode a zip file’s password in a format John can crack.
john <password_file> : –show option to show pwd after cracking it
SQLMAP:
sqlmap -u
–dbs: Discover databases in case an SQL vulnerability is previously found.
—tables -D
–dump -T