Guest User

solver

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