Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- echo "0x0ace solver (c)2ch.hk"
- host="80.233.134.208"
- prime_src=$'
- #include <stdio.h>\n
- #include <stdlib.h>\n
- #include <math.h>\n
- int isPrime(int n)
- {
- if (n % 1 || n < 2) return 0;
- if (n % 2==0) return (n == 2);
- if (n % 3==0) return (n == 3);
- float f = (float)sqrt(n);
- for (int i = 5;i <= (int)f; i += 6) {
- if (n % i == 0)
- return 0;
- if (n%(i+2)==0)
- return 0;
- }
- return 1;
- }
- int main(int argc, char *argv[])
- {
- int flag;
- int min = atoi(argv[1]) + 1;
- int max = atoi(argv[2]) - 1;
- for (int i = min; i < max; ++i)
- {
- if (isPrime(i) == 1)
- {
- printf("%d,", i);
- }
- }
- return 0;
- }
- '
- # build fast prime calculator
- echo "$prime_src" > prime_src.c
- g++ prime_src.c -o ./prime_all
- rm prime_src.c
- # 1
- key=`curl -s $host | grep -o '<span class="guess-what">.*</span>' | sed -e 's/^<span class="guess-what">//' -e 's/<\/.*>//'`
- url=`echo $key | base64 --decode`
- echo "First puzzle is complete"
- # 2
- data=`curl -s $host$url`
- host2=`echo "$data" | grep -o '<span class="next-loc">.*</span>' | sed -e 's/^<span class="next-loc">//' -e 's/<\/.*>//'`
- key=`echo "$data" | grep -o '.*</b></span><br /><br />' | sed -e 's/<\/.*>//'`
- echo "Second puzzle is complete for uid '$key'"
- # 3
- data=`curl -s --header "X-0x0ACE-Key: $key" $host2`
- string=`echo "$data" | grep "</span><br /><br /><br />" | sed -e 's/<\/.*>//'`
- first=`echo $string | awk '{print $1}' | cut -d'[' -f2 | cut -d',' -f1`
- second=`echo $string | awk '{print $3}' | cut -d']' -f1`
- mid_prime=`./prime_all $first $second`
- solution=${mid_prime::-1}
- verification=`echo "$data" | grep 'verification' | awk '{print $4}' | cut -d'"' -f2`
- curl -s -v -i -H "Expect:" --header "X-0x0ACE-Key: $key" $host2 --data "verification=$verification&solution=$solution"
- echo ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement