Skip to content

Instantly share code, notes, and snippets.

@YasserGersy
Last active March 3, 2018 20:19
Show Gist options
  • Save YasserGersy/fb5c5a5e09a891ecf956496d0926ae22 to your computer and use it in GitHub Desktop.
Save YasserGersy/fb5c5a5e09a891ecf956496d0926ae22 to your computer and use it in GitHub Desktop.
Cyber-talent secretbox solution secret-box
#CTF https://cybertalents.com/competitions/quals-uae-egy-national-cyber-security-ctf-2018/secret-box
#https://s3-eu-west-1.amazonaws.com/hubchallenges/Reverse/secretbox.zip
#
#
#The code takes the message
#reveres it
# msg bitwised with the length of image file name
#Each char at i postioton in the MSG is stored in the image at postition [0,i][3]
#
#python secretbox-sol.py secret.png
#
#
import sys
from PIL import Image
def prob(s_img):
im = Image.open(s_img).convert("RGBA")
p = im.load()
c = 0
lines=''
for i in range(0, 100):
dx=str(p[c, 0][3])
c += 1
if dx != '255':
asc=int(dx)^len(s_img)
ec=chr(asc)
lines=str(ec)+lines
print lines
open('sol.txt','w').write(lines)
prob(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment