Created
September 17, 2022 13:05
-
-
Save outlinepix/a8e08752df94b66ec59cdc9973351a21 to your computer and use it in GitHub Desktop.
EVIL ZONE Programming Challenge : fastHasher | In Python3 and Bash Script. Noobish implementation
This file contains 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
#COPY BASH SCRIPT FROM END OF FILE TO MAKE THIS PYTHON SCRIPT WORK PROPERLY. | |
# Also update cokie and session Id in Header | |
import requests | |
import subprocess | |
import re | |
import base64 | |
from bs4 import BeautifulSoup | |
url = 'https://evilzone.org/challenges/fast_hasher/' | |
headers = { | |
'Host': 'evilzone.org', | |
'session': | |
'Dwdpf2FTe7NaCjY2mvxtN9LBo5CHLZu8KT2ZwYWQXlszOVNojZmgWLpGharskmlojZhAP1cKNihkFnGJvs39WV8JM7VW1jTAk7ig', | |
'Cookie': 'PHPSESSID=q617pjmmoffhve4d413oun3im5', | |
'Origin': 'https://evilzone.org', | |
'Content-Type': 'application/x-www-form-urlencoded', | |
'Accept': | |
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', | |
'Referer': 'https://evilzone.org/challenges/fast_hasher/', | |
'Accept-Encoding': 'gzip, deflate', | |
'Accept-Language': 'en-US,en;q=0.9', | |
'Connection': 'close', | |
} | |
#Requsting page with hashes | |
r = requests.post(url, headers=headers, data={'action': 'generateHasherTask'}) | |
#filtring 100 hashes from webpage. | |
soup = BeautifulSoup(r.text, 'html.parser') | |
with open("hash.txt", 'w') as f: | |
print(soup.textarea, file=f) | |
#Invoking bash script for doing hashing and stuff/ | |
subprocess.run(["/home/user/Downloads/proc.sh"], shell=True) | |
md5 = open('tosubmit.txt', 'r') | |
hashvalue = {'hash': md5.read(), 'action': 'checkSolution'} | |
r = requests.post(url, headers=headers, data=hashvalue) | |
soup = BeautifulSoup(r.text, 'html.parser') | |
flag = (re.findall("\w{32}", str(soup.findAll("p")))) | |
print(f'flag for challange is :{flag}') | |
#COPY THE BASH SCRIPT AND NAME IT PRECISELY "proc.sh" | |
""" | |
#!/bin/bash | |
touch hash.txt | |
awk '{sub(/<textarea cols="50" rows="10">/,""); print}' hash.txt > oprated.txt | |
awk '{sub(/<\/textarea>/,""); print}' oprated.txt > final.txt | |
let hash | |
while read -r line; do | |
hash+=$(echo -n $line | md5sum | awk '{print $1}') | |
done <final.txt | |
finalhash=$(echo -n $hash | md5sum | awk '{print $1}') | |
echo -n $finalhash > tosubmit.txt | |
# echo -n $finalhash | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment