반응형
Shifter
Misc
What a strange challenge...
It'll be no problem for you, of course!
Solve 50 of these epic problems in a row to prove you are a master crypto man like Aplet123!
You'll be given a number n and also a plaintext p.
Caesar shift `p` with the nth Fibonacci number.
n < 50, p is completely uppercase and alphabetic, len(p) < 50
You have 60 seconds!
--------------------
Shift XECK by n=1
주어진 문자열을 n번째 피보나치 수열 만큼 shift 한 값을 보내면 된다.
EX
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | from pwn import * def fibo(n): t = [0, 1] if n in (0, 1): f = n else: for i in range(2, n+1): f = sum(t) t = [t[1], f] return f alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" p = remote("misc.2020.chall.actf.co", 20300) for a in range(0,50): p.recvuntil("Shift ") taskstr = list((p.recvuntil(" ")).strip()) p.recvuntil("=") n = fibo(int(p.recvline())) for i in range(len(taskstr)): taskstr[i] = alpha[(ord(taskstr[i]) - 65 + n) % 26] ans = ''.join(taskstr) print ans p.sendline(ans) p.interactive() | cs |
flag : actf{h0p3_y0u_us3d_th3_f0rmu14-1985098}
Reasonably Strong Algorithm
Crypto
n = 126390312099294739294606157407778835887
e = 65537
c = 13612260682947644362892911986815626931
https://www.alpertron.com.ar/ECM.HTM
여기에서 n을 인수분해 해준다.
126 390312 099294 739294 606157 407778 835887 (39 digits) = 9 336949 138571 181619 × 13 536574 980062 068373
$ python rsatool.py -p 9336949138571181619 -q 13536574980062068373
Using (p, q) to initialise RSA instance
n = 126390312099294739294606157407778835887 (0x5f15e3803896f7b78f17d685eb590daf)
e = 65537 (0x10001)
d = 122116681453826726664714315157880092841 (0x5bded13dfcef588dae9e87c5c23eb8a9)
p = 9336949138571181619 (0x819381c5b26cbe33)
q = 13536574980062068373 (0xbbdb93397a0a3e95)
rsatool.py를 이용해서 d값을 구해준다.
c^d mod N
복호화
flag : actf{10minutes}
Wacko Images
Crypto
How to make hiding stuff a e s t h e t i c? And can you make it normal again? enc.png image-encryption.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
from numpy import *
from PIL import Image
flag = Image.open(r"flag.png")
img = array(flag)
key = [41, 37, 23]
a, b, c = img.shape
for x in range (0, a):
for y in range (0, b):
pixel = img[x, y]
for i in range(0,3):
pixel[i] = pixel[i] * key[i] % 251
img[x][y] = pixel
enc = Image.fromarray(img)
enc.save('enc.png')
|
cs |
각 픽셀의 rgb 값에 각각 41, 37, 23을 곱하고 251로 나눈 나머지 값을 저장하여 enc.png 이미지를 만든다.
역연산을 해주면 되는데 251로 나눈 몫을 모르기 때문에 t로 두고 브포를 때렸다.
ex.py :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
from numpy import *
from PIL import Image
flag = Image.open(r"enc.png")
img = array(flag)
key = [41, 37, 23]
a, b, c = img.shape
for x in range (0, a):
for y in range (0, b):
pixel = img[x, y]
for i in range(0,3):
for t in range(0,41):
if (251 * t + pixel[i]) % key[i] == 0:
pixel[i] = (251 * t + pixel[i]) / 23
img[x][y] = pixel
enc = Image.fromarray(img)
enc.save('flag.png')
|
cs |
반응형
'CTF Write Up' 카테고리의 다른 글
FIESTA 2020 Write up (2) | 2020.09.07 |
---|---|
2020 Defenit CTF Write Up (2) | 2020.06.06 |
UTCTF 2020 Write up (0) | 2020.03.07 |
RiceTeaCatPanda CTF 2020 Write up (0) | 2020.01.22 |
Christmas CTF 2019 Write-up 문제 풀이 (2) | 2019.12.30 |