Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function unarchive_all() {
- for f in *.zip
- do
- unzip $f -d "$(echo $f | cut -d . -f 1)"
- rm $f
- done
- for f in *.rar
- do
- mkdir "$(echo $f | cut -d . -f 1)"
- unrar e $f "$(echo $f | cut -d . -f 1)"
- rm $f
- done
- }
- function check_solutions() {
- for dir in *
- do
- echo "----------------------------------------------------------------------"
- echo "------------------------- $dir ---------------------------------------"
- key2=$(find $dir -type f -name "key2.bin.enc")
- message=$(find $dir -type f -name "message_2.enc")
- public=$(find $dir -type f -name "public.pem")
- sign=$(find $dir -type f -name "message_2.sign.sha256")
- instruction=$(find $dir -type f -name "instruction.txt")
- instructions=$(find $dir -type f -name "instructions.txt")
- echo "********"
- echo $key2
- echo $message
- echo $public
- echo $sign
- echo $instruction $instructions
- echo "********"
- openssl rsautl -decrypt -inkey ../alice.pem -in "$key2" -out "$key2.dec"
- openssl des-ecb -d -in "$message" -out "$message.dec" -pass "file:$key2.dec"
- openssl dgst -sha256 -verify "$public" -signature "$sign" "$message.dec" > "$sign.check"
- echo "......................................................................"
- echo "## KEY:"
- cat "$key2.dec"
- echo
- echo "## MESSAGE:"
- cat "$message.dec"
- echo
- echo "## SIGNATURE:"
- cat "$sign.check"
- echo
- echo "## PUBLIC KEY:"
- cat "$instruction" | grep "pkcs12"
- cat "$instructions" | grep "pkcs12"
- echo
- done
- }
- openssl rsa -in alice_private.pem -out alice.pem
- pushd $1
- unarchive_all
- check_solutions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement