PPC 100_1

PPC - 100 Points

We received messages with dates of creation. Our channel was unsafe and along with correct messages we received ones with wrong timestamps - you need to filter them.

A tar.gz file is given.

ls -al
# [...]
#-rw-rw-r-- 1 thezero thezero     33 nov 12 07:49 Wednesday_9_June_2158.txt
#-rw-rw-r-- 1 thezero thezero     33 nov 12 07:49 Wednesday_9_June_2185.txt
#-rw-rw-r-- 1 thezero thezero     33 nov 12 07:49 Wednesday_9_May_1981.txt
#-rw-rw-r-- 1 thezero thezero     33 nov 12 07:49 Wednesday_9_May_2083.txt
#-rw-rw-r-- 1 thezero thezero     33 nov 12 07:49 Wednesday_9_May_2152.txt
#-rw-rw-r-- 1 thezero thezero     33 nov 12 07:49 Wednesday_9_November_1979.txt
#-rw-rw-r-- 1 thezero thezero     33 nov 12 07:49 Wednesday_9_November_1990.txt
# [...]
ls -1 | wc -l
# 7937

Writeup

We started by looking inside some files too see if the content could help us

cat Wednesday_9_May_2152.txt
# 9bcf36ca6ef3c7af3137f9661c2b4b09

This is obviously an MD5 hash so we tried to do md5($filename) but returned nothing useful.

We noticed that some dates where in the future so we searched for a date in November 2016 hoping to find today (17-11-2016)

ls | grep November_2016
# Saturday_3_November_2016.txt
# Thursday_12_November_2016.txt
# Tuesday_16_November_2016.txt

No luck, but wait! Yesterday was Wednesday not Tuesday_16_November_2016.txt

Now that we knew where was the error, we made a script to count the wrong filename

python wrong_day.py
# 7936

What??? 7937-7936=1 So there is only one legit filename! Let’s find it

#!/usr/bin python

import os
from datetime import datetime

correct_days = []

for m in os.listdir("./messages"):
	day = m.split('_')[0]
	date = datetime.strptime(m, '%A_%d_%B_%Y.txt')
	realday = date.strftime('%A')
	#print realday,day,m
	if day == realday:
		correct_days.append(m)

if len(correct_days) == 1:
	with open(os.path.join("./messages",correct_days[0]), 'r') as fday:
		cont = fday.read()
		print cont
# 4eec2cd9e4bb0062d0e41c8af1bd8a0f