Skip to content

Instantly share code, notes, and snippets.

@konfou
Created March 28, 2017 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konfou/bb60b3f29347e26ae39df7fe689b204f to your computer and use it in GitHub Desktop.
Save konfou/bb60b3f29347e26ae39df7fe689b204f to your computer and use it in GitHub Desktop.
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