some small fixes

This commit is contained in:
Mari Wahl 2014-10-10 22:22:02 -04:00
parent 56dec30f70
commit ab70b811db
14 changed files with 196 additions and 0 deletions

View File

@ -0,0 +1,41 @@
'''
EXAMPLE FROM ASIS 2013, WITH THE CONCATENATED HASH:
7e1321b3c8423b30c1cb077a2e3ac4f0a2a551a6458a8de22446cc76d639a9e98fc42c6cddf9966db3b09e843650343578b04d5e377d298e78455efc5ca404d5f4c9385f1902f7334b00b9b4ecd164de8bf8854bebe108183caeb845c7676ae48fc42c6ddf9966db3b09e84365034357327a6c4304ad5938eaf0efb6cc3e53dc7ff9ea9a069bd793691c422fb818c07b
'''
import md5
# the entire flag
m1 = '7e1321b3c8423b30c1cb077a2e3ac4f0'
m2 = 'a2a551a6458a8de22446cc76d639a9e9'
m3 = '8fc42c6ddf9966db3b09e84365034357'
m4 = '8b04d5e3775d298e78455efc5ca404d5'
m5 = 'f4c9385f1902f7334b00b9b4ecd164de'
m6 = '8bf8854bebe108183caeb845c7676ae4'
m7 = '8fc42c6ddf9966db3b09e84365034357'
m8 = '327a6c4304ad5938eaf0efb6cc3e53dc'
m9 = '7ff9ea9a069bd793691c422fb818c07b'
all = [m1, m2, m3, m4, m5, m6, m7, m8, m9]
for m in all:
a = md5.md5(m)
print "md5 object", a
print "digest(): ", a.digest()
print "hexdigest(): ", a.hexdigest()
print
# last part
for a in "abcdef0123456789":
for b in "abcdef0123456789":
if "7ff9ea9a069bd793691c422fb818c07b" == md5.md5('ASIS_' + a + b).hexdigest():
print 'ASIS_' + a + b

View File

@ -0,0 +1,11 @@
'''
from asis 2013: The last crypto (binary numbers) was very puzzling. We couldnt decipher it. But a few minutes before the CTF ending, we noticed we could brute-force the 6 missing characters offline, because in each task, there was a client-side verification with a sha-256 hash. For this task, the hash of the flag was 6307c5441ebac07051e3b90d53c3106230dd9aa128601dcd5f63efcf824ce1ba. A quick brute-force in Python revealed us the missing chars, and therefore, the final flag to submit!
'''
import hashlib, itertools
hash = '6307c5441ebac07051e3b90d53c3106230dd9aa128601dcd5f63efcf824ce1ba'
ch = 'abcdef0123456789'
for a, b, c, d, e, f in itertools.product(ch, ch, ch, ch, ch, ch):
if hashlib.sha256('ASIS_a9%s00f497f2eaa4372a7fc21f0d' % (a + b + c + d + e + f)).hexdigest() == hash:
print 'ASIS_a9%s00f497f2eaa4372a7fc21f0d' % (a + b + c + d + e + f)

View File

@ -0,0 +1,24 @@
'''
from asis 2013
'''
from itertools import permutations
from hashlib import sha256
def test(s):
e = '9f2a579716af14400c9ba1de8682ca52c17b3ed4235ea17ac12ae78ca24876ef'
return sha256('ASIS_' + s).hexdigest() == e
m = '3c6a1c371b381c943065864b95ae5546'
s = '12456789x'
for p in permutations(s):
def f(sub, c):
if c in sub:
return sub[c]
else:
return c
sub = {c : d for c, d in zip(s, p)}
z = ''.join(f(sub, c) for c in m)
if test(z):
print z
break

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

View File

@ -0,0 +1,30 @@
#!/usr/bin/env python
from PIL import Image
import random
def get_color(x, y, r):
n = (pow(x, 3) + pow(y, 3)) ^ r
return (n ^ ((n >> 8) << 8 ))
flag_img = Image.open("flag.png")
im = flag_img.load()
r = random.randint(1, pow(2, 256))
print flag_img.size
enc_img = Image.new(flag_img.mode, flag_img.size)
enpix = enc_img.load()
for x in range(flag_img.size[0]):
for y in range(flag_img.size[1]):
t = random.randint(1, pow(2, 256)) % 250
enpix[x,y] = t
for x in range(flag_img.size[0]):
for y in range(flag_img.size[1]):
if im[x,y] < 250 :
s = get_color(x, y, r)
enpix[x,y] = s
enc_img.save('enc' + '.png')

View File

@ -0,0 +1,38 @@
#!/usr/bin/python
from PIL import Image
import random
import operator
def get_color(x, y, r):
n = (pow(x, 3) + pow(y, 3)) ^ r
return (n ^ ((n >> 8) << 8 ))
flag_img = Image.open("flag.png")
im = flag_img.load()
print flag_img.size
enc_img = Image.new(flag_img.mode, flag_img.size)
enpix = enc_img.load()
d = {}
for i in range(0, 256):
d[i] = 0
for x in range(flag_img.size[0]):
for y in range(flag_img.size[1]):
enpix[x,y] = 0
r = im[x, y] ^ ((pow(x, 3) + pow(y, 3)) % 256)
d[r] += 1
use = max(d.iteritems(), key=operator.itemgetter(1))[0]
for x in range(flag_img.size[0]):
for y in range(flag_img.size[1]):
r = im[x, y] ^ ((pow(x, 3) + pow(y, 3)) % 256)
if r == use:
enpix[x, y] = 255
print use
enc_img.save('dec' + '.png')

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

View File

@ -0,0 +1,17 @@
from PIL import Image
img = Image.open('steg100.png')
strbit1 = ''
for y in range(0, img.size[1], 19):
for x in range(0, img.size[0], 19):
r = img.getpixel((x, y))
strbit1 += str(r & 1)
strbit2 = ''
for y in range(171, 171 + 19):
for x in range(171, 171 + 19):
a = img.getpixel((x, y))
strbit2 += str(a & 1)
xored = ''.join(str(int(A) ^ int(B)) for A, B in zip(strbit1, strbit2))
print ''.join(chr(int(xored[i:i + 8], 2)) for i in range(0, len(xored), 8))

View File

@ -0,0 +1,18 @@
from PIL import Image
img = Image.open('steg100.png')
strbit1 = ''
for y in range(0, img.size[1], 19):
for x in range(0, img.size[0], 19):
print img.getpixel((x, y))
print r
strbit1 += str(r & 1)
strbit2 = ''
for y in range(171, 171 + 19):
for x in range(171, 171 + 19):
a = img.getpixel((x, y))
strbit2 += str(a & 1)
xored = ''.join(str(int(A) ^ int(B)) for A, B in zip(strbit1, strbit2))
print ''.join(chr(int(xored[i:i + 8], 2)) for i in range(0, len(xored), 8))

View File

@ -0,0 +1,17 @@
'''
.. . .. . . .. ... ... . . ..... .. . .. .. ... .
....... ....... ....... ....... ....... ....... ....... .......
.. . .. . . .. . . ..... .. .... .. .. . ..... .. ...
....... ....... ....... ....... ....... ....... ....... .......
.. .... . ..... .. ... .. . .. .... ... .. ... . ... ..
....... ....... ....... ....... ....... ....... ....... .......
'''
s="""1100001 1101001 1101110 1110100 1011111 1100001 1100110 1110010 1100001 1101001 1100100 1011111 1101111 1100110 1011111 1101110 1101111 1011111 1100111 1101000 1101111 1110011 1110100 1110011"""
a = ''.join(chr(int(i, 2)) for i in s.replace("\n"," ").split(' '))
print a