Example #1
0
def recoverAllCombinations(addresses,currentAddress,data):

	# obtains all 2^n combinations and check if the the file is recovered. As anticipated 
	# this function won't be able to brute-force the solution under the time limit which is
	# 10 minutes
	#

	global processedBranches;
	
	if (currentAddress >= len(addresses)):
		processedBranches += 1;

		
		try:
  			dec = bz2.decompress(binascii.unhexlify(data));
  			print('\nrecovered @ recover.png\n');
  			pngRecFile = open('recover.png','wb');
  			pngRecFile.write(dec);
  			solution = raw_input("password: "******"sending solution")
			payload = {'solution' : solution, 'submitbutton' : 'submit'};
			HTS.postPage("https://www.hackthissite.org/missions/prog/5/index.php",payload);

  			sys.exit(0);

		except IOError:
			return;

  	else:
  		constructTreeRecursive(addresses,currentAddress+1,data); #unchanged
  		#update the addresses
  		newData = data[0:addresses[currentAddress]]+data[addresses[currentAddress]+2:len(data)];
  		addresses = updateAddresses(addresses,addresses[currentAddress]);
  		constructTreeRecursive(addresses,currentAddress+1,newData); #changed
Example #2
0
def recoverGrouped(addresses,data):
	#change the given addresses -> 0d0a to 0a
	newData = "";
	lastIndex=0
	for index in xrange(0,len(addresses)):

		newData = newData + data[lastIndex:addresses[index]]+data[addresses[index]+2:addresses[index]+4];
		lastIndex = addresses[index]+4;


	newData = newData + data[lastIndex:len(data)];

	# bz2.decompress does the cyclic redundancy check first and throws an exception if the file 
	# doesn't pass the check. If it does pass the check then we have recovered the file
	try:
		dec = bz2.decompress(binascii.unhexlify(newData));
		print('\nRecovered the file. Check recovered.png and enter the password\n');
		pngRecFile = open('recovered.png','wb');
		pngRecFile.write(dec);
		pngRecFile.close();
		solution = raw_input("password: "******"sending solution")
		payload = {'solution' : solution, 'submitbutton' : 'submit'};
		HTS.postPage("https://www.hackthissite.org/missions/prog/5/index.php",payload);

		sys.exit(0);

	except IOError:
		return;
def downloadData():
	#login
	HTS.loginUserInput();
	#start mission and get the page
	response = HTS.getPage("https://www.hackthissite.org/missions/prog/11/");

	#parse content and get the data
	# we have to mine the code starting with Generated String and Shift;
	javascriptCode = response.content;
	mineStartIndex = javascriptCode.find("Generated String: ");

	#find the first non-numeric character which is used as the delimiter
	delimiter = "";
	mineEndIndex = javascriptCode.find("<",mineStartIndex);
	encodedData = javascriptCode[mineStartIndex + 18:mineEndIndex];

	encodedData = encodedData[0:len(encodedData)-1];
	for chars in encodedData:
		if (chars.isdigit() is False):
			delimiter = chars;
			break;

	mineStartIndex = javascriptCode.find("Shift: ");
	mineEndIndex = javascriptCode.find("<",mineStartIndex);
	shift = javascriptCode[mineStartIndex + 6:mineEndIndex];

	return [encodedData, delimiter, shift];
def downloadData():
    #login
    HTS.loginUserInput()
    #start mission and get the page
    response = HTS.getPage("https://www.hackthissite.org/missions/prog/11/")

    #parse content and get the data
    # we have to mine the code starting with Generated String and Shift;
    javascriptCode = response.content
    mineStartIndex = javascriptCode.find("Generated String: ")

    #find the first non-numeric character which is used as the delimiter
    delimiter = ""
    mineEndIndex = javascriptCode.find("<", mineStartIndex)
    encodedData = javascriptCode[mineStartIndex + 18:mineEndIndex]

    encodedData = encodedData[0:len(encodedData) - 1]
    for chars in encodedData:
        if (chars.isdigit() is False):
            delimiter = chars
            break

    mineStartIndex = javascriptCode.find("Shift: ")
    mineEndIndex = javascriptCode.find("<", mineStartIndex)
    shift = javascriptCode[mineStartIndex + 6:mineEndIndex]

    return [encodedData, delimiter, shift]
Example #5
0
def downloadFile():
	#login to the site
	HTS.loginUserInput();
	#start the mission
	HTS.getPage("https://www.hackthissite.org/missions/prog/5/");
	#get the compressed file
	print("downloading file...");
	response = HTS.getPage("https://www.hackthissite.org/missions/prog/5/corrupted.png.bz2");
	print("file downloaded..");
	return response;
def getImage():

    #login to the site
    HTS.loginUserInput()
    #start the mission
    HTS.getPage("https://www.hackthissite.org/missions/prog/2/")
    #get the image
    response = HTS.getPage("https://www.hackthissite.org/missions/prog/2/PNG")
    im = Image.open(StringIO(response.content))
    print("image downloaded \n")
    return im
def getImage():

	#login to the site
	HTS.loginUserInput();
	#start the mission
	HTS.getPage("https://www.hackthissite.org/missions/prog/2/");
	#get the image
	response = HTS.getPage("https://www.hackthissite.org/missions/prog/2/PNG");
	im = Image.open(StringIO(response.content));
	print("image downloaded \n")
	return im;
Example #8
0
def downloadXML():
	#login to the site
	HTS.loginUserInput();
	#start the mission
	HTS.getPage("https://www.hackthissite.org/missions/prog/4/");
	#get the xml 
	response = HTS.getPage("https://www.hackthissite.org/missions/prog/4/XML");
	#uncompress downloaded content
	xmlContent = bz2.decompress(response.content);

	return xmlContent;
Example #9
0
def downloadXML():
    #login to the site
    HTS.loginUserInput()
    #start the mission
    HTS.getPage("https://www.hackthissite.org/missions/prog/4/")
    #get the xml
    response = HTS.getPage("https://www.hackthissite.org/missions/prog/4/XML")
    #uncompress downloaded content
    xmlContent = bz2.decompress(response.content)

    return xmlContent
Example #10
0
def downloadData():
	#login
	HTS.loginUserInput();
	#start mission
	HTS.getPage("https://www.hackthissite.org/missions/prog/6/");
	#get url 
	print("downloading data");
	response = HTS.getPage("https://www.hackthissite.org/missions/prog/6/image");
	#parse content and get the data
	# we have to mine the code starting with new Array(...);
	javascriptCode = response.content;
	mineStartIndex = javascriptCode.find("new Array(");
	mineEndIndex = javascriptCode.find(");",mineStartIndex);
	data = javascriptCode[mineStartIndex + 10:mineEndIndex]
	return data;
Example #11
0
def downloadData():
    #login
    HTS.loginUserInput()
    #start mission
    HTS.getPage("https://www.hackthissite.org/missions/prog/6/")
    #get url
    print("downloading data")
    response = HTS.getPage(
        "https://www.hackthissite.org/missions/prog/6/image")
    #parse content and get the data
    # we have to mine the code starting with new Array(...);
    javascriptCode = response.content
    mineStartIndex = javascriptCode.find("new Array(")
    mineEndIndex = javascriptCode.find(");", mineStartIndex)
    data = javascriptCode[mineStartIndex + 10:mineEndIndex]
    return data
def sendSolution(solution):
	print("sending solution");
	payload = {'solution' : solution, 'submitbutton' : 'submit'};
	response = HTS.postPage("https://www.hackthissite.org/missions/prog/11/index.php",payload);
	print("solution response: \n");
	print(response.content);
	return;
def sendResponse(decodedText):
	#send back the decoded text

	print(decodedText);
	print("sending solution")
	payload = {'solution' : decodedText, 'submitbutton' : 'submit'};
	return HTS.postPage("https://www.hackthissite.org/missions/prog/2/index.php",payload);
Example #14
0
def sendResponse(solution):
    print("sending solution")
    payload = {
        'solution': solution,
        'submitbutton': 'submit'
    }
    return HTS.postPage(
        "https://www.hackthissite.org/missions/prog/4/index.php", payload)
Example #15
0
def sendSolution(solution):
    print("sending solution")
    payload = {
        'solution': solution,
        'submitbutton': 'submit'
    }
    response = HTS.postPage(
        "https://www.hackthissite.org/missions/prog/6/index.php", payload)
    print("solution response: \n")
    print(response.content)
def sendResponse(decodedText):
    #send back the decoded text

    print(decodedText)
    print("sending solution")
    payload = {
        'solution': decodedText,
        'submitbutton': 'submit'
    }
    return HTS.postPage(
        "https://www.hackthissite.org/missions/prog/2/index.php", payload)
Example #17
0
def sendResponse(solution):
	print("sending solution")
	payload = {'solution' : solution, 'submitbutton' : 'submit'};
	return HTS.postPage("https://www.hackthissite.org/missions/prog/4/index.php",payload);