# Description
I recently got this cryptic message in the mail:
`9429 263 6992 2243 715 6992 4650 7924 237 5486 6204 6239 6204 237 494 6239 1794 7167 715 5149 6239 3801 3750 6239 1242 13481 7774 3401`
Along with these clues:
1. Nooo! This great tennis player recently retired, and was accused of doping. His first name sounds cool.
2. And I heard this person received a large grant of land in California, something named "Rancho San Antonio"? His last name sounds cool.
3. I've heard wikipedia is a great resource. How can I research them more?
4. hmm... this is interesting. his birth day and birth year are both pRime! what Should i do with thAt?
Sounds like gibberish to me. Hopefully you can figure it out though!
Plain Text
볡μ¬
# λΆμ
μ μμ 문ꡬλ₯Ό ν΄μν΄μ 보면 λκ° μνΈλ¬Έμ λ°μκ³ μλμ λ©μμ§κ° ννΈλΌλ κ² μ΄λ€.
1. μλ! μ΄ νλ₯ν ν
λμ€ μ μλ μΌλ§ μ μν΄νκ³ λν νμλ₯Ό λ°μμ΅λλ€. κ·Έμ μ΄λ¦μ λ©μ§ κ² κ°μ΅λλ€.
2. κ·Έλ¦¬κ³ μ΄ μ¬λμ΄ μΊλ¦¬ν¬λμμμ "λμ΄ μ μν λμ€(RSA)"λΌλ μ΄λ¦μ λ
μ λ§μ΄ λ°μλ€κ³ λ€μμ΅λλ€. κ·Έμ μ±μ λ©μ§ κ² κ°μ΅λλ€.
3. μν€νΌλμκ° μ’μ μλ£λΌκ³ λ€μμ΅λλ€. μ΄λ»κ² λ μ‘°μ¬ν μ μμκΉμ?
4. μ... ν₯λ―Έλ‘λ€μ. κ·Έμ μμΌκ³Ό μΆμ μ°λκ° λͺ¨λ μ΅κ³ (pRime)μ
λλ€! μ΄λ»κ² ν΄μΌ ν κΉμ?
Plain Text
볡μ¬
μΌλ¨ λ©μμ§μμ pRimeκ³Ό βRancho San Antonioβμμ μ κΈμλ§ RSAλ‘ λλ¬Έμλ‘ νμνκΈ° λλ¬Έμ μμ κ΄λ ¨ RSA μ·볡νΈν κ΄λ ¨ λ¬Έμ λ‘ μκ°ν μ μλ€.
μ¬κΈ°μ μ μμ μΈ νμ΄λ μν€νΌλμμμ κ²μμ ν΄μ μν΄νκ³ λν νμλ₯Ό λ°μ ν
λμ€ μ μμ μ±μ μ°Ύκ³
"Rancho San Antonio"μ λ
μ λ°μ μ¬λμ μ΄λ¦μ μ°Ύμ
μ΄λ¦κ³Ό μ±μ ν©μ³ μ΄μ±μ λ§λ€μ΄ ν΄λΉ μ¬λμ μΆμ μ°λλ₯Ό λ½μ RSA볡νΈν ν€μ μ¬μ©νλ©΄ λλ€κ³ μμν μ μλλ° μ΄κ² μ μμ μΈ νμ΄μ§λ§ λ¬Έλ λ μκ°μ΄ μμλ€.
1.
μν€ νΌλμμ μ¬λΌμ¬ μ λλ©΄ κΈ°μν μ¬λμ΄λ€.
2.
1000λ
μ΄νμ μ¬λμΌ κ²μ΄λ€.
3.
2000λ
μ΄μ μ μ¬λμΌ κ²μ΄λ€.
4.
μλ
μμΌμ΄ μμλΌλ©΄ 0~2000λ
λμ 1~12μ 1~31μΌκΉμ§μ κ²½μ°μμκ° λμ€λλ° μ΄λ κ·Έλ κ² λ§μ κ²½μ°μ μκ° μλλ€
5.
3λ²μ κ²½μ°μ μμμ μμκ° λμ€λ κ²½μ°μ μλ₯Ό κ³μ°νλ©΄ μ΄ μμ λ§€μ° μ νμ μ΄λ€.
1~5λ²κΉμ§μ μκ°μ ν΅ν΄μ κ·Έλ₯ μμλ₯Ό μμλλ‘ λ£μ΄λ³΄λ©΄μ ν΄λΉ λ©μμ§λ₯Ό 볡νΈννλ€λ©΄ 볡ꡬλμ§ μμκΉλΌκ³ μκ°νλ€.
κ·Έλ₯ μ΄κ±΄ μ겨μ 보λ€κ° μ겨μγ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
# get_prime Code
def solution(n):
is_prime = [True for x in range(n+1)]
p = 2
while (p * p < n):
if is_prime[p]:
for i in range(p * p, n + 1, p):
is_prime[i] = False
p += 1
prime_numbers = [p for p in range(2, n + 1) if is_prime[p]]
return prime_numbers
primes = solution(2000)
with open('year_primes.txt','w')as f:
for i in primes:
f.write(str(i)+"\n")
primes = solution(31)
with open('day_primes.txt','w')as f:
for i in primes:
f.write(str(i)+"\n")
Python
볡μ¬
μΌλ¨ μ μ½λλ‘ μμλ₯Ό λ¨Όμ ꡬν΄μ€¬λ€
# Payload
def extended_gcd(a, b):
"""νμ₯ μ ν΄λ¦¬λ μκ³ λ¦¬μ¦μ μ¬μ©νμ¬ gcd(a, b)μ λ² μ£Ό νλ±μμ κ³μλ₯Ό μ°Ύμ΅λλ€."""
if a == 0:
return b, 0, 1
else:
gcd, x1, y1 = extended_gcd(b % a, a)
x = y1 - (b // a) * x1
y = x1
return gcd, x, y
def find_d(e, phi_n):
"""νμ₯ μ ν΄λ¦¬λ μκ³ λ¦¬μ¦μ μ¬μ©νμ¬ κ°μΈν€ μ§μ dλ₯Ό κ³μ°ν©λλ€. dλ eμ λͺ¨λλ¬ Ο(n)μ λν μμμ
λλ€."""
gcd, x, y = extended_gcd(e, phi_n)
if x < 0:
x += phi_n # λͺ¨λλ¬ μμμ΄ μμμΌ κ²½μ° μμλ‘ λ³ν
return x
with open('day_primes.txt','r')as f:
day_keys = [int(i.strip()) for i in f.readlines()]
with open('year_primes.txt','r')as f:
year_keys = [int(i.strip()) for i in f.readlines()]
for e in range(1000):
for year in year_keys:
# RSA 볡νΈνμ νμν κ°λ€
for day in day_keys:
p = year # μμ μμ p
q = day # μμ μμ q
ciphertext = [
9429, 263, 6992, 2243, 715, 6992, 4650, 7924, 237, 5486,
6204, 6239, 6204, 237, 494, 6239, 1794, 7167, 715, 5149,
6239, 3801, 3750, 6239, 1242, 13481, 7774, 3401
]
# # RSA λͺ¨λλ¬μ€ Nκ³Ό μ€μΌλ¬ νΌ ν¨μ phi κ³μ°
N = p * q
phi = (p - 1) * (q - 1)
# # κ°μΈν€ d κ³μ° (eμ phiμ λͺ¨λλ‘ κ³±μ
μμ)
d = find_d(e, phi)
# # RSA 볡νΈν: νλ¬Έ m = ciphertext^d mod N
plaintext = list()
for i in range(len(ciphertext)):
plaintext.append(pow(ciphertext[i], d, N))
if plaintext[0] != ord('b'):
continue
try:
_ = ''.join([chr(i) for i in plaintext])
print("볡νΈνλ λ©μμ§({}, {}, {}): ".format(p,q,e), _)
except:
print("볡νΈνλ λ©μμ§({}, {}, {}): ".format(p,q,e), "Non Printable")
Python
볡μ¬
RSAμμ p, qλ λμΆ© λ§μΆ μ μμ§λ§ eλ₯Ό μμλΌ μ μκΈ° λλ¬Έμ eλ 0~1000κΉμ§ λ²μλ‘ μ‘κ³ python3 main.py > 1.txtλ‘ μ½λλ₯Ό μ€ννλ€.
vscodeλ‘ Ctrl + Fλ₯Ό λλ¬ κ²μ κΈ°λ₯μ μ΄μ©ν΄ Flagλ₯Ό μ°Ύμμ€λ€.
# Flag
bronco{wh4t_th3_f0ck_1s_RSA}
Plain Text
볡μ¬





