Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. echo "0x0ace solver (c)2ch.hk"
  4.  
  5. host="80.233.134.208"
  6.  
  7. prime_src=$'
  8. #include <stdio.h>\n
  9. #include <stdlib.h>\n
  10. #include <math.h>\n
  11. int isPrime(int n)
  12. {
  13. if (n % 1 || n < 2) return 0;
  14. if (n % 2==0) return (n == 2);
  15. if (n % 3==0) return (n == 3);
  16.  
  17. float f = (float)sqrt(n);
  18. for (int i = 5;i <= (int)f; i += 6) {
  19. if (n % i == 0)
  20. return 0;
  21.  
  22. if (n%(i+2)==0)
  23. return 0;
  24. }
  25.  
  26. return 1;
  27. }
  28. int main(int argc, char *argv[])
  29. {
  30. int flag;
  31.  
  32. int min = atoi(argv[1]) + 1;
  33. int max = atoi(argv[2]) - 1;
  34.  
  35. for (int i = min; i < max; ++i)
  36. {
  37. if (isPrime(i) == 1)
  38. {
  39. printf("%d,", i);
  40. }
  41. }
  42.  
  43. return 0;
  44. }
  45. '
  46.  
  47. # build fast prime calculator
  48. echo "$prime_src" > prime_src.c
  49. g++ prime_src.c -o ./prime_all
  50. rm prime_src.c
  51.  
  52. # 1
  53. key=`curl -s $host | grep -o '<span class="guess-what">.*</span>' | sed -e 's/^<span class="guess-what">//' -e 's/<\/.*>//'`
  54. url=`echo $key | base64 --decode`
  55. echo "First puzzle is complete"
  56.  
  57. # 2
  58. data=`curl -s $host$url`
  59. host2=`echo "$data" | grep -o '<span class="next-loc">.*</span>' | sed -e 's/^<span class="next-loc">//' -e 's/<\/.*>//'`
  60. key=`echo "$data" | grep -o '.*</b></span><br /><br />' | sed -e 's/<\/.*>//'`
  61. echo "Second puzzle is complete for uid '$key'"
  62.  
  63. # 3
  64. data=`curl -s --header "X-0x0ACE-Key: $key" $host2`
  65. string=`echo "$data" | grep "</span><br /><br /><br />" | sed -e 's/<\/.*>//'`
  66. first=`echo $string | awk '{print $1}' | cut -d'[' -f2 | cut -d',' -f1`
  67. second=`echo $string | awk '{print $3}' | cut -d']' -f1`
  68. mid_prime=`./prime_all $first $second`
  69. solution=${mid_prime::-1}
  70. verification=`echo "$data" | grep 'verification' | awk '{print $4}' | cut -d'"' -f2`
  71. curl -s -v -i -H "Expect:" --header "X-0x0ACE-Key: $key" $host2 --data "verification=$verification&solution=$solution"
  72. echo ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement