본문 바로가기

CTFs

[MMA 2016] crypto : Twin Primes Twin Primes주어진 파일은 암호화 하는 파이썬 스크립트 하나와 각각 n 과 e 값이 적혀있는 2개의 파일과 암호화 된 파일이 주어졌다. 주어진 암호화 스크립트를 보니 일단 Twin Primes(일명 쌍둥이소수) 를 생성하고 이 값들을 이용해서 2개의 키들을 만든다.첫번 째 키에서는 각각 다른 쌍둥이 소수 p, q 가 사용되었고두번 째 키에서는 사전에 구해놓은 쌍둥이 소수인 (p+2), (q+2) 가 사용되었다.E 값은 0x10001(65537) 로 주워 졌으니 각 키에 대한 정보를 써 보면 12345678910111213- Key 1p1 = pq1 = qn1 = p*qd1 = inverse(e, (p - 1)(q - 1))e = 0x10001 - Key 2p2 = p + 2q2 = q + 2n2 .. 더보기
[MMA 2016] misc : glance glance주어진 파일은 '단!' glance.gif 파일 하나!이 파일을 열어보면 총 200개의 .png 사진들을 볼 수 있는데 그래서 이 사진들을 다 합쳐보기로 함.. 아래는 사진을 가로로 다 합치는 코드. ( PIL 라이브러리 사용 ) 12345678910111213141516171819import sysfrom PIL import Image pic = []for i in range(201): pic.append('Frame' + str(i) + '.png') images = map(Image.open, pic)widths, heights = zip(*(i.size for i in images))total_width = sum(widths)max_height = max(heights)new_im =.. 더보기
[Codegate 2016] reversing : compress compress이번 문제는 그냥 암호화된 문자열하고 인코드 하는 파이썬 코드를 던져줬네요 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263import md5 def encode(input_string): print "Input : %s" % input_string h = md5.md5(input_string[:4]).hexdigest() table = { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 0 } out = "" prev = "" stage1 =.. 더보기
[Plaid 2014] pwnable : tenement & sass These write ups don't include any exploit codes but just EIP control. tenement Given binary 'tenement' is x86 stripped elf file, too. 12zero@ubuntu:~/Desktop/ctf/plaid2014$ file tenementtenement: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, strippedcs And applied memory protections are... 12345678zero@ubuntu:~.. 더보기
[Plaid 2014] pwnable : kappa kappa This chal is also stripped x86 elf. 12zero@ubuntu:~/Desktop/ctf/plaid2014$ file kappakappa: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.26, strippedcs And applied memory protections are... 12345678zero@ubuntu:~/Desktop/ctf/plaid2014$ gdb -q ./kappaReading symbols from ./kappa...(no debugging symbols found)... 더보기