Crypto

UUT CTF writeup Break the RSA

Break the RSA

50

Flag is the decryption of the following:

PublicKey= (114869651319530967114595389434126892905129957446815070167640244711056341561089,113)

CipherText=102692755691755898230412269602025019920938225158332080093559205660414585058354


PublicKeyをfactordbで素因数分解します。素因数分解できますので次のPythonプログラムで復号できます。
def exgcd(m, n):
  if n>0:
    y,x,d = exgcd(n, m%n)
    return x, y-m/n*x, d
  else:
    return 1, 0, m

n = 114869651319530967114595389434126892905129957446815070167640244711056341561089
e = 113
c = 102692755691755898230412269602025019920938225158332080093559205660414585058354

p = 338924256021210389725168429375903627261
q = 338924256021210389725168429375903627349
d = exgcd(e, (p-1)*(q-1))[0] % ((p-1)*(q-1))
s = pow(c, d, n)
h = format(s, 'x')
f = ''
for i in range(0, len(h), 2):
f += chr(int(h[i:i+2], 16))
print(f)
フラグは、
UUTCTF{easy sH0Rt RSA!!!}

UUT CTF writeup Solve the Crypto

Solve the Crypto

25

Solve this Crypto and find the flag.

RsaCtfToolを使います。
$ python RsaCtfTool.py --publickey pub.key --private > priv.key
opensslコマンドで復号します。
$ openssl rsautl -decrypt -in enc.message -inkey priv.key
SGllcl9pc3RfZGVpbmVfRmxhZ2dl
Base64でデコードします。
$ openssl rsautl -decrypt -in enc.message -inkey priv.key | base64 -d
Hier_ist_deine_Flagge
フラグは、
UUTCTF{Hier_ist_deine_Flagge}
です。



ångstromCTF 2019 writeup Classy Cipher

Classy Cipher

Crypto
20
678

Every CTF starts off with a Caesar cipher, but we're more classy.

復号するPythonプログラムを書きます。
def decrypt(d, s):
e = ''
for c in d:
e += chr((ord(c) + 0xff - s) % 0xff)
return e
print(decrypt(':<M?TLH8<A:KFBG@V', ord(':') + 0xff - ord('a')))
フラグは、
actf{so_charming}
です。



ångstromCTF 2019 writeup Really Secure Algorithm

Really Secure Algorithm

Crypto
30
523

I found this flag somewhere when I was taking a walk, but it seems to have been encrypted with this Really Secure Algorithm!

復号するPythonプログラムを書きます。
def exgcd(m, n):
  if n>0:
    y,x,d = exgcd(n, m%n)
    return x, y-m/n*x, d
  else:
    return 1, 0, m

p = 8337989838551614633430029371803892077156162494012474856684174381868510024755832450406936717727195184311114937042673575494843631977970586746618123352329889
q = 7755060911995462151580541927524289685569492828780752345560845093073545403776129013139174889414744570087561926915046519199304042166351530778365529171009493
e = 65537
c = 7022848098469230958320047471938217952907600532361296142412318653611729265921488278588086423574875352145477376594391159805651080223698576708934993951618464460109422377329972737876060167903857613763294932326619266281725900497427458047861973153012506595691389361443123047595975834017549312356282859235890330349

n = p * q
d = exgcd(e, (p-1)*(q-1))[0] % ((p-1)*(q-1))
s = pow(c, d, n)
h = format(s, 'x')
f = ''
for i in range(0, len(h), 2):
f += chr(int(h[i:i+2], 16))
print(f)
フラグは、
actf{really_securent_algorithm}
です。



ASIS CTF Quals 2019 writeup A delicious sup

解凍すると、暗号文flag.encと暗号プログラムsimple_and_delicious.pyができます。encord関数の繰り返しの中でencrypt関数を呼び出していますが、何度もencrypt関数を呼び出すと元の平文に戻ることがあります。したがって、flag.encファイルの暗号文を元にして、ループ変数lの値を大きくしてencord関数を呼び出すと、perm配列が一致した場合に元の平文に戻ることになります。
以上を行うPythonプログラムを書きます。
#!/usr/bin/env python
#-*- coding:utf-8 -*-

import random
#from flag import flag

flag = '11d.3ilVk_d3CpIO_4nlS.ncnz3e_0S}M_kn5scpm345n3nSe_u_S{iy__4EYLP_aAAall'

def encrypt(msg, perm):
W = len(perm)
while len(msg) % (2*W):
msg += "."
msg = msg[1:] + msg[:1]
msg = msg[0::2] + msg[1::2]
msg = msg[1:] + msg[:1]
res = ""
for j in xrange(0, len(msg), W):
for k in xrange(W):
res += msg[j:j+W][perm[k]]
msg = res
return msg

def encord(msg, perm, l):
for _ in xrange(l):
msg = encrypt(msg, perm)
if 'ASIS{' in msg:
print(msg + '\t' + str(_))
if msg.startswith(flag):
break
return msg

W, l = 7, random.randint(0, 1337)
l = 10000000
perm = range(W)
while True:
random.shuffle(perm)
print(perm)
enc = encord(flag, perm, l)
実行すると次のようになります。perm = [1, 0, 5, 4, 2, 6, 3]のときに元の平文に戻ります。
(略)
[1, 0, 5, 4, 2, 6, 3]
ASIS{1n54n3ly_Simpl3_And_d3lic1Ous_5n4ckS_eVEn_l4zY_Pe0pL3_Can_Mak3}.. 1218
フラグは、
ASIS{1n54n3ly_Simpl3_And_d3lic1Ous_5n4ckS_eVEn_l4zY_Pe0pL3_Can_Mak3}
です。



TG:Hack writeup Exclusive Magic Club

Exclusive Magic Club

Author: Einar Antonsen - Chabz/Chabaluz

Someone sent the Exclusive Magic Club all these 1's and 0's and told us mother_knows_best.

00111001 00101000 01000101 01010001 00011110 00010000 00110000 00011100
00110001 00001011 00011000 00000100 00110001 00111101 00010001 00011100
00101011 00011001 00000111 00010001 00110111 00100100 00111011 00000000
00000100 00011000 00001010 00000101 00011111 00110000 00010000 00000001
00000000 00001001
2進数のASCIIコードと与えられた文字列"mother_knows_best"とを順番にXORを取ります。
s = '''
00111001 00101000 01000101 01010001 00011110 00010000 00110000 00011100
00110001 00001011 00011000 00000100 00110001 00111101 00010001 00011100
00101011 00011001 00000111 00010001 00110111 00100100 00111011 00000000
00000100 00011000 00001010 00000101 00011111 00110000 00010000 00000001
00000000 00001001
'''
key = 'mother_knows_best'
flag = ''
i = 0
for c in s.replace('\n', ' ').strip().split(' '):
flag += chr(int(c, 2) ^ ord(key[i % len(key)]))
i += 1
print(flag)
フラグは、
TG19{bow_down_to_the_AI_overlords}
です。

文系プログラマーのためのPythonで学び直す高校数学
谷尻かおり(メディックエンジニアリング)
日経BP社
2019-03-14


TG:Hack writeup American Standard Code for Information Interchange

American Standard Code for Information Interchange

Author: Einar Antonsen - Chabz/Chabaluz

I got some mystical numbers here, but I don't know what it means. Can you help me?

84 71 49 57 123 65 83 67 73 73 95 97 110 100 95 121 111 117 95 115 104 97 108 108 95 114 101 99 101 105 118 101 125
ASCIIコードを文字列にして出力します。
s = '84 71 49 57 123 65 83 67 73 73 95 97 110 100 95 121 111 117 95 115 104 97 108 108 95 114 101 99 101 105 118 101 125'
flag = ''
for c in s.split(' '):
flag += chr(int(c))
print(flag)
フラグは、
TG19{ASCII_and_you_shall_receive}

TG:Hack writeup Rotarius

Rotarius

Author: Einar Antonsen - Chabz/Chabaluz

This looks like a flag, but something is not quite right... or was it left?

OB19{ocz_hjno_wvndx_otkz_ja_zixmtkodji}
アルファベットを5つずらします。
フラグは、
TG19{the_most_basic_type_of_encryption}
です。



TG:Hack writeup Land of Encoding

Land of Encoding

Author: Einar Antonsen - Chabz/Chabaluz

Handle this flag with care. It is from the 64 wizards and witches based in the Land of Encoding.

VEcxOXtiZV9jYXJlZnVsX3doZW5fZHJvcHBpbmdfdGhlX2Jhc2V9
Base64でデコードします。
フラグは、
TG19{be_careful_when_dropping_the_base}
です。



RADARCTF writeup Chars

  • Chars
  • Points: 100
  • Type: Crypto
  • Solves: 175
  • Download

Can you find then flag inside this matrix ?
ダウンロードしたファイルを解凍するとflag.txtができます。次のようなテキストデータです。
cRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RmRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRFRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRkRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRYRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRXRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRJRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRR7RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRYRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRR2RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRhRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRhRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR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RRRRRRRRRRRRRRRRRRRRRRRRfRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRZRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRmRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRxRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRhRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRZRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR3R
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR0
左上から斜め方向に文字を抽出すると次のような文字列になります。
cmFkYXJ7Y2hhcl9hZnRlcl9jaGFyX2dpdmVfZmxhZ30
これをBASE64でデコードするとフラグになります。
フラグは、
radar{char_after_char_give_flag}
記事検索
ギャラリー
  • TetCTF 2023 NewYearBot
  • UUT CTF writeup Find The Password
  • UUT CTF writeup The Puzzle
  • Hack Zone Tunisia 2019 writeup Microscope
  • Hack Zone Tunisia 2019 writeup Welcome
  • SwampCTF 2019 writeup Brokerboard
  • SwampCTF 2019 writeup Leap of Faith
  • SwampCTF 2019 writeup Last Transmission
  • CBM CTF 2019 writeup Long road
カテゴリー