Skip to content

Instantly share code, notes, and snippets.

@konfou konfou/d34dc0d3.py
Created Mar 28, 2017

Embed
What would you like to do?
5.9.247.121
#!/usr/bin/env python
import requests
from bs4 import BeautifulSoup
from re import findall
url = 'http://5.9.247.121/d34dc0d3'
headers = { 'X-0x0ACE-Key' : 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' }
# key to be taken by previous challenge on 80.233.134.210
def solve(bgn,end):
# print all prime numbers within bgn and end seperated by comma
lst = (str(i) for i in range(bgn+1,end) if all(i%j!=0 for j in range(2,int(i**0.5)+1)))
return ','.join(lst)
with requests.session() as s:
s.headers.update(headers)
soup = BeautifulSoup(s.get(url).text,"lxml")
verify = soup.find('input',attrs={'name':'verification'}).get('value')
challenge = soup.find('span',attrs={'class':'challenge'}).text
lim = [int(i) for i in findall('\d+',challenge)]
payload = { 'verification' : verify, 'solution' : solve(lim[0],lim[1]) }
print(s.post(url,data=payload).text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.