Advertisement
Guest User

Untitled

a guest
May 20th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. function unarchive_all() {
  4. for f in *.zip
  5. do
  6. unzip $f -d "$(echo $f | cut -d . -f 1)"
  7. rm $f
  8. done
  9.  
  10. for f in *.rar
  11. do
  12. mkdir "$(echo $f | cut -d . -f 1)"
  13. unrar e $f "$(echo $f | cut -d . -f 1)"
  14. rm $f
  15. done
  16. }
  17.  
  18. function check_solutions() {
  19. for dir in *
  20. do
  21. echo "----------------------------------------------------------------------"
  22. echo "------------------------- $dir ---------------------------------------"
  23. key2=$(find $dir -type f -name "key2.bin.enc")
  24. message=$(find $dir -type f -name "message_2.enc")
  25. public=$(find $dir -type f -name "public.pem")
  26. sign=$(find $dir -type f -name "message_2.sign.sha256")
  27. instruction=$(find $dir -type f -name "instruction.txt")
  28. instructions=$(find $dir -type f -name "instructions.txt")
  29.  
  30. echo "********"
  31. echo $key2
  32. echo $message
  33. echo $public
  34. echo $sign
  35. echo $instruction $instructions
  36. echo "********"
  37.  
  38. openssl rsautl -decrypt -inkey ../alice.pem -in "$key2" -out "$key2.dec"
  39. openssl des-ecb -d -in "$message" -out "$message.dec" -pass "file:$key2.dec"
  40. openssl dgst -sha256 -verify "$public" -signature "$sign" "$message.dec" > "$sign.check"
  41.  
  42. echo "......................................................................"
  43. echo "## KEY:"
  44. cat "$key2.dec"
  45. echo
  46.  
  47. echo "## MESSAGE:"
  48. cat "$message.dec"
  49. echo
  50.  
  51. echo "## SIGNATURE:"
  52. cat "$sign.check"
  53. echo
  54.  
  55. echo "## PUBLIC KEY:"
  56. cat "$instruction" | grep "pkcs12"
  57. cat "$instructions" | grep "pkcs12"
  58.  
  59. echo
  60.  
  61. done
  62. }
  63.  
  64. openssl rsa -in alice_private.pem -out alice.pem
  65. pushd $1
  66. unarchive_all
  67. check_solutions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement