-
-
Save spnow/26f3b77d60315f1f4b5ffee751dd68c9 to your computer and use it in GitHub Desktop.
Nuit du hack 2017 Quals - Slumdog Millionaire (web 100)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import random | |
def send_combination(combination): | |
URL = "http://slumdogmillionaire.quals.nuitduhack.com/" | |
data = {"numbers": "%s" %(combination)} | |
r = requests.post(URL, data=data) | |
winning_combination = r.content[r.content.find("Winning combination was: ")+25:r.content.find("Winning combination was: ")+54] | |
return winning_combination | |
def set_seed(seed): | |
random.seed(seed) | |
def generate_combination(): | |
numbers = "" | |
for _ in range(10): | |
rand_num = random.randint(0, 99) | |
if rand_num < 10: | |
numbers += "0" | |
numbers += str(rand_num) | |
if _ != 9: | |
numbers += "-" | |
return numbers | |
def main(): | |
target_combination = "35-32-57-14-22-88-66-41-96-31" # you get this from the first request | |
for i in xrange(2**32/2): # pid_t | |
set_seed(i) | |
if target_combination == generate_combination(): | |
break | |
print "FOUND seed %d" %(i) | |
for i in xrange(10): | |
print generate_combination() | |
print "DONE" | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment