#!/usr/bin/env python
#===================================================================================
#
# FILE: HTS-Realistic-06.py
#
# USAGE: HTS-Realistic-06.py
#
# DESCRIPTION: This script is for level 6 challenge in HackThisSite
# realistic missions.
# _____ _ _ _____ _ _____ _____
# | __||_| _____ ___ | | ___ | _ || | ___ ___ ___ | __| | _ |
# |__ || || || . || || -_| | __|| || .'|| | |___| |__ | _ | __|_
# |_____||_||_|_|_|| _||_||___| |__| |_||__,||_|_| |_____||_||__| |_|
# |_|
#
#===================================================================================
# read the ciphertext
f = open('/root/HTS/ciphertext.txt', 'r')
data = f.read().split('.')
f.close()
statistic=[]
message=""
index=1
# statistic all encryption code
while index < len (data) - 1 :
statistic.append(int(data[index]) + int(data[index+1]) + \
int(data[index+2]))
index += 3
# find the encryption password
password = max(set(statistic), key=statistic.count) - 32
# convert ASCII to character
for i in range(len(statistic)) :
message += chr(int(statistic[i]) - int(password))
# print the original message
print message