Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 3ba0ff31 authored by Keanu Lee's avatar Keanu Lee 💬
Browse files

Merge branch 'patch-2' into 'master'

Adding second crypto challenge.

See merge request wolvsec/umichctf-hwf2020!4
parents dc2eb566 321612e3
746F6A676D45534E723B4F686B615E63675975715D614E707271766A5E765E1D1C5F
\ No newline at end of file
umichCTF{1DdfoQsvKfeHwYhkkmvChA==}
\ No newline at end of file
# Make challenge
# Encrypte a file with a simple XOR, with the key being integers starting at 1.
#
flag="umichCTF{"$(openssl rand -base64 16)"}"
echo -n $flag > flag.txt
filesize=$(wc -c < flag.txt)
# Make the key file - just hex numbers increasing from 1, one per line.
jot -w "%x" $filesize 1 $filesize > key.txt
# Make file to create xor printf lines to execute in bash. Use "#" in paste for ease of replacement in sed.
xxd -p -c1 flag.txt > flag-lines-hex.txt
paste -d "#" flag-lines-hex.txt key.txt > xors.txt
cat xors.txt | sed -e "s/^/printf '\%X' \$\(\(0x/" | sed -e "s/#/\^0x/" | sed -e "s/$/\)\)/" | bash > challenge.txt
rm flag-lines-hex.txt xors.txt
# Check the encryption/decryption
xxd -r -p challenge.txt | xxd -p -c1 > crypto-lines.txt
paste -d "#" crypto-lines.txt key.txt > xors2.txt
cat xors2.txt | sed -e "s/^/printf '\%X' \$\(\(0x/" | sed -e "s/#/\^0x/" | sed -e "s/$/\)\)/" | bash > unxored.txt
xxd -r -p unxored.txt > decrypted.txt
if ! cmp -s "flag.txt" "decrypted.txt"; then
echo "Something went wrong - the flag file and solution do not match!"
fi
# Cleanup
rm crypto-lines.txt xors2.txt unxored.txt decrypted.txt key.txt
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment