crypto: add a few more challenges

This commit is contained in:
Oystein Kristoffer Tveit 2024-09-02 20:20:46 +02:00
parent dc6284f487
commit 92210003f6
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
15 changed files with 424 additions and 0 deletions

View File

@ -0,0 +1 @@
128 322 353 235 336 73 198 332 202 285 57 87 262 221 218 405 335 101 256 227 112 140

22
crypto/basic_mod1/solve.py Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python3
# Take each number mod 37 and map it to the following character set: 0-25 is the alphabet (uppercase), 26-35 are the decimal digits, and 36 is an underscore.
with open('message.txt') as file:
content = file.read().strip()
print("picoCTF{", end="")
for n in content.split(' '):
number = int(n)
number %= 37
if number < 26:
print(chr(number + ord('A')), end="")
elif number >= 26 and number < 36:
print(number - 26, end="")
elif number == 36:
print('_', end="")
else:
print()
print(f"Code author seems to have forgotten a number.... {number}")
exit(1)
print("}")

View File

@ -0,0 +1 @@
YidkM0JxZGtwQlRYdHFhR3g2YUhsZmF6TnFlVGwzWVROclgya3lNRFJvYTJvMmZRPT0nCg==

View File

@ -0,0 +1,6 @@
1. base64 decode
2. remove surroudning b''
3. base64 decode
4. ROT13 (value 19)
picoCTF{caesar_d3cr9pt3d_b204adc6}

View File

@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE REQUEST-----
MIICpzCCAY8CAQAwPDEmMCQGA1UEAwwdcGljb0NURntyZWFkX215Y2VydF80MWQx
Yzc0Y30xEjAQBgNVBCkMCWN0ZlBsYXllcjCCASIwDQYJKoZIhvcNAQEBBQADggEP
ADCCAQoCggEBAOdcDj2/m1LxBrXb3ch9+2BtKd3b8NFn4USXA5JORPfeGcDdIX4V
SiRkFrbxLOit6SZwoAyWQ7SmWJTtzADbr82qTbVktGJj9YebwK57jpMEL6BPT9YA
cE9AGFtVJycL+IXqtlTqAGq4DjcPtAs5THgIPDJ+aTgRDHP8YItfEFs+aywLd8kS
WSmttEjS874Tc++b9PbQ246IIrtQ701/I1NB0S/inzQvPCui+hLSHgMFkGS4leN7
7xJORGAQueRejKuYnOs6HbAlbK0oIWKR83BxkntDBee8KhOPDynHDgYoblERl8rL
JAfcVogKNSniIztMkzh408V9mbLHOfsr6eUCAwEAAaAmMCQGCSqGSIb3DQEJDjEX
MBUwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBAFEyhXpa
nZz/ofFW/31ryCF3nyvNg9pOyIniu8kcpiteSaOkNm4YREBCRwj92X3Wy1MUi/7Z
urXwR1TcRTxLdPqeVBn4nsJclAgZqMKcT0ftz5fAM/Xg5whwBHEBb1qFVN+HGhPo
1TKfhXunICyrjNWvM+2fudM2RPsGb0sBsjLAe1/6OJK82LJBoHQ0GlCPDN1tncrl
lpzHACCFPv7LMVF9BSkZDCQNglU1NYDDelXZezfXLbio/a1RC2k4rs+jorVmFese
elZFzORDsCzlgD87NvBUMZWI8J5+9fZeaWAQQfhwEiZOVn8IcjLUxUraxt4rbI/h
0EUJJuCjGyTjRpQ=
-----END CERTIFICATE REQUEST-----

4
crypto/read_my_cert/solve.sh Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash openssl
openssl req -noout -text -in 'readmycert.csr' | grep -o 'picoCTF{.*}'

View File

@ -0,0 +1 @@
xqkwKBN{z0bib1wv_l3kzgxb3l_555957n3}

2
crypto/rotation/flag.txt Normal file
View File

@ -0,0 +1,2 @@
Cyberchef ROT13 (value 18):
picoCTF{r0tat1on_d3crypt3d_555957f3}

View File

@ -0,0 +1,12 @@
OHNFUMWSVZLXEGCPTAJDYIRKQB
Suauypcg Xuwaogf oacju, rvds o waoiu ogf jdoduxq ova, ogf hacywsd eu dsu huudxu
mace o wxojj noju vg rsvns vd roj ugnxcjuf. Vd roj o huoydvmyx jnoaohouyj, ogf, od
dsod dveu, yglgcrg dc godyaoxvjdj—cm ncyaju o wauod pavbu vg o jnvugdvmvn pcvgd
cm ivur. Dsuau ruau drc acygf hxonl jpcdj guoa cgu ukdauevdq cm dsu honl, ogf o
xcgw cgu guoa dsu cdsua. Dsu jnoxuj ruau uknuufvgwxq soaf ogf wxcjjq, rvds oxx dsu
oppuoaognu cm hyagvjsuf wcxf. Dsu ruvwsd cm dsu vgjund roj iuaq aueoalohxu, ogf,
dolvgw oxx dsvgwj vgdc ncgjvfuaodvcg, V ncyxf soafxq hxoeu Zypvdua mca svj cpvgvcg
aujpundvgw vd.
Dsu mxow vj: pvncNDM{5YH5717Y710G_3I0XY710G_03055505}

107
crypto/substitution0/solve.py Executable file
View File

@ -0,0 +1,107 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python -p python3
# NOTE: the colors are used to keep track of which letters have been
# already substituted, and which are still unknown.
def green(s):
return f"\033[42m{s}\033[0m"
def red(s):
return f"\033[41m{s}\033[0m"
def substitute(cipher_text, substitution_map):
for letter in cipher_text:
if letter.lower() in substitution_map:
if letter.isupper():
x = substitution_map[letter.lower()].upper()
else:
x = substitution_map[letter]
print(green(x), end="")
else:
print(red(letter), end="")
with open('message.txt', 'r') as file:
enc = file.read()
# Here, I will be slowly substituting the letters in the ciphertext
# based on what I believe the words to be. I have commented out the
# invocations of substitute, and commented the newly found letters
# after each invocation.
# Starting off, "pvncDCM{...}" looks like "picoCTF{...}"
substitution_map = {
'0': '0',
'1': '1',
'2': '2',
'3': '3',
'4': '4',
'5': '5',
'6': '6',
'7': '7',
'8': '8',
'9': '9',
'-': '-',
'_': '_',
'\n': '\n',
' ': ' ',
',': ',',
'.': '.',
':': ':',
';': ';',
'{': '{',
'}': '}',
'p': 'p',
'v': 'i',
'n': 'c',
'c': 'o',
'd': 't',
'm': 'f',
}
# substitute(enc, substitution_map)
# 'Dsu fxow ij' -> 'The flag is'
substitution_map['d'] = 't'
substitution_map['s'] = 'h'
substitution_map['u'] = 'e'
substitution_map['x'] = 'l'
substitution_map['o'] = 'a'
substitution_map['w'] = 'g'
substitution_map['j'] = 's'
# substitute(enc, substitution_map)
# 'taligg all thiggs igto cogsifeaatiog' -> 'taking all things into consideration'
# 'rhich' -> 'which'
substitution_map['l'] = 'k'
substitution_map['g'] = 'n'
substitution_map['f'] = 'd'
substitution_map['a'] = 'r'
substitution_map['r'] = 'w'
# substitute(enc, substitution_map)
# 'roynd hlack spots' -> 'round black spots'
# 'ekceedinglq' -> 'exceedingly'
substitution_map['y'] = 'u'
substitution_map['h'] = 'b'
substitution_map['q'] = 'y'
substitution_map['k'] = 'x'
# substitute(enc, substitution_map)
# 'iery reearkable' -> 'very remarkable'
# 'pribe' -> 'pride'
# 'Zupiter' -> 'Jupiter'
substitution_map['i'] = 'v'
substitution_map['e'] = 'm'
substitution_map['b'] = 'd'
substitution_map['z'] = 'j'
substitute(enc, substitution_map)

View File

@ -0,0 +1 @@
ZWDg (gejfw djf zacwpfx wex dqar) afx a wscx jd zjicpwxf gxzpfbws zjicxwbwbjv. Zjvwxgwavwg afx cfxgxvwxm hbwe a gxw jd zeaqqxvrxg hebze wxgw wexbf zfxawbybws, wxzevbzaq (avm rjjrqbvr) gnbqqg, avm cfjtqxi-gjqybvr atbqbws. Zeaqqxvrxg pgpaqqs zjyxf a vpitxf jd zawxrjfbxg, avm hexv gjqyxm, xaze sbxqmg a gwfbvr (zaqqxm a dqar) hebze bg gptibwwxm wj av jvqbvx gzjfbvr gxfybzx. ZWDg afx a rfxaw has wj qxafv a hbmx affas jd zjicpwxf gxzpfbws gnbqqg bv a gadx, qxraq xvybfjvixvw, avm afx ejgwxm avm cqasxm ts iavs gxzpfbws rfjpcg afjpvm wex hjfqm djf dpv avm cfazwbzx. Djf webg cfjtqxi, wex dqar bg: cbzjZWD{DF3LP3VZS_4774ZN5_4F3_Z001_4871X6DT}

101
crypto/substitution1/solve.py Executable file
View File

@ -0,0 +1,101 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python -p python3
# NOTE: the colors are used to keep track of which letters have been
# already substituted, and which are still unknown.
def green(s):
return f"\033[42m{s}\033[0m"
def red(s):
return f"\033[41m{s}\033[0m"
def substitute(cipher_text, substitution_map):
for letter in cipher_text:
if letter.lower() in substitution_map:
if letter.isupper():
x = substitution_map[letter.lower()].upper()
else:
x = substitution_map[letter]
print(green(x), end="")
else:
print(red(letter), end="")
with open('message.txt', 'r') as file:
enc = file.read()
# Here, I will be slowly substituting the letters in the ciphertext
# based on what I believe the words to be. I have commented out the
# invocations of substitute, and commented the newly found letters
# after each invocation.
# Starting off, "wex dqar bg: cbzjZWD{...}" looks like "the flag is: picoCTF{...}"
substitution_map = {
'0': '0',
'1': '1',
'2': '2',
'3': '3',
'4': '4',
'5': '5',
'6': '6',
'7': '7',
'8': '8',
'9': '9',
'-': '-',
'_': '_',
'\n': '\n',
' ': ' ',
',': ',',
'.': '.',
':': ':',
';': ';',
'{': '{',
'}': '}',
'(': '(',
')': ')',
'w': 't',
'e': 'h',
'x': 'e',
'd': 'f',
'q': 'l',
'a': 'a',
'r': 'g',
'b': 'i',
'g': 's',
'c': 'p',
'z': 'c',
'j': 'o',
}
# substitute(enc, substitution_map)
# '(shoft fof captpfe the flag) afe a tspe' -> '(short for capture the flag) are a type'
# 'coipetitiov' -> 'competition'
substitution_map['f'] = 'r'
substitution_map['p'] = 'u'
substitution_map['s'] = 'y'
substitution_map['i'] = 'm'
substitution_map['v'] = 'n'
# substitute(enc, substitution_map)
# 'presentem hith' -> 'presented with'
# 'numter' -> 'number'
# 'security snills' -> 'security skills'
substitution_map['m'] = 'd'
substitution_map['h'] = 'w'
substitution_map['t'] = 'b'
substitution_map['n'] = 'k'
# substitute(enc, substitution_map)
# 'seryice' -> 'service'
# 'FR3LU3NCY' -> 'FR3QU3NCY'
substitution_map['y'] = 'v'
substitution_map['l'] = 'q'
substitute(enc, substitution_map)

View File

@ -0,0 +1 @@
nafyffoxenefufytpqnafymfppfentkpxeafbaxraezaqqpzqgswnfyefzwyxnhzqgsfnxnxqlexlzpwbxlrzhkfystnyxqntlbwezhkfyzatppflrfnafefzqgsfnxnxqlevqzwesyxgtyxphqlehenfgetbgxlxenytnxqlvwlbtgflntpemaxzatyfufyhwefvwptlbgtycfntkpfecxppeaqmfufymfkfpxfufnafsyqsfyswysqefqvtaxraezaqqpzqgswnfyefzwyxnhzqgsfnxnxqlxelqnqlphnqnftzautpwtkpfecxppekwntpeqnqrfnenwbflnexlnfyfenfbxltlbfozxnfbtkqwnzqgswnfyezxflzfbfvflexufzqgsfnxnxqletyfqvnflptkqyxqwetvvtxyetlbzqgfbqmlnqywllxlrzafzcpxenetlbfofzwnxlrzqlvxrezyxsneqvvflefqlnafqnafyatlbxeaftuxphvqzwefbqlfospqytnxqltlbxgsyquxetnxqltlbqvnflatefpfgflneqvspthmfkfpxfuftzqgsfnxnxqlnqwzaxlrqlnafqvvflexuffpfgflneqvzqgswnfyefzwyxnhxenafyfvqyftkfnnfyufaxzpfvqynfzafutlrfpxegnqenwbflnexltgfyxztlaxraezaqqpevwynafymfkfpxfufnatntlwlbfyentlbxlrqvqvvflexufnfzalxiwfexefeeflnxtpvqygqwlnxlrtlfvvfznxufbfvfleftlbnatnnafnqqpetlbzqlvxrwytnxqlvqzweflzqwlnfyfbxlbfvflexufzqgsfnxnxqlebqfelqnpftbenwbflnenqclqmnafxyflfghtefvvfznxufphtenftzaxlrnafgnqtznxufphnaxlcpxcftltnntzcfysxzqznvxetlqvvflexufphqyxflnfbaxraezaqqpzqgswnfyefzwyxnhzqgsfnxnxqlnatneffcenqrflfytnfxlnfyfenxlzqgswnfyezxflzftgqlraxraezaqqpfyenftzaxlrnafgflqwratkqwnzqgswnfyefzwyxnhnqsxiwfnafxyzwyxqexnhgqnxutnxlrnafgnqfospqyfqlnafxyqmltlbfltkpxlrnafgnqkfnnfybfvflbnafxygtzaxlfenafvptrxesxzqZNV{L6Y4G_4L41H515_15_73B10W5_8F1KV808}

144
crypto/substitution2/solve.py Executable file
View File

@ -0,0 +1,144 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python -p python3
# NOTE: the colors are used to keep track of which letters have been
# already substituted, and which are still unknown.
def green(s):
return f"\033[42m{s}\033[0m"
def red(s):
return f"\033[41m{s}\033[0m"
def substitute(cipher_text, substitution_map):
for letter in cipher_text:
if letter.lower() in substitution_map:
if letter.isupper():
x = substitution_map[letter.lower()].upper()
else:
x = substitution_map[letter]
print(green(x), end="")
else:
print(red(letter), end="")
with open('message.txt', 'r') as file:
enc = file.read()
# Here, I will be slowly substituting the letters in the ciphertext
# based on what I believe the words to be. I have commented out the
# invocations of substitute, and commented the newly found letters
# after each invocation.
# Starting off, "sxzqZNV{...}" looks like "picoCTF{...}"
substitution_map = {
'0': '0',
'1': '1',
'2': '2',
'3': '3',
'4': '4',
'5': '5',
'6': '6',
'7': '7',
'8': '8',
'9': '9',
'_': '_',
'{': '{',
'}': '}',
's': 'p',
'x': 'i',
'z': 'c',
'q': 'o',
'n': 't',
'v': 'f',
}
# substitute(enc, substitution_map)
# Using frequency analysis (https://www.dcode.fr/frequency-analysis), we find that:
# F 175× 13.87%
# N 125× 9.9%
# X 103× 8.16%
# Q 102× 8.08%
# L 98× 7.77%
# E 83× 6.58%
# T 68× 5.39%
# Z 63× 4.99%
# Y 61× 4.83%
# A 56× 4.44%
# P 46× 3.65%
# W 42× 3.33%
# V 39× 3.09%
# G 35× 2.77%
# B 34× 2.69%
# S 28× 2.22%
# R 24× 1.9%
# U 20× 1.58%
# H 19× 1.51%
# K 16× 1.27%
# M 9× 0.71%
# C 9× 0.71%
# O 5× 0.4%
# I 2× 0.16%
# Based on this, and the frequency of letters in the english alphabet, we can guess for 'e'
substitution_map['f'] = 'e' # 13.87% ~= 12.7%
# 'petitiol' -> 'petition'
substitution_map['l'] = 'n'
# 'incpwbinr' -> 'including'
# 'effectiue' -> 'effective'
substitution_map['p'] = 'l'
substitution_map['w'] = 'u'
substitution_map['b'] = 'd'
substitution_map['r'] = 'g'
# 'encountey' -> 'encounter'
substitution_map['y'] = 'r'
# 'eecurith' -> 'security'
substitution_map['e'] = 's'
substitution_map['h'] = 'y'
# 'effectiuely' -> 'effectively'
substitution_map['u'] = 'v'
# 'cogputer' -> 'computer'
substitution_map['g'] = 'm'
# 'catllenge' -> 'challenge'
substitution_map['a'] = 'h'
substitution_map['t'] = 'a'
# 'thinc' -> 'think'
substitution_map['c'] = 'k'
# 'valuakle' -> 'valuable'
substitution_map['k'] = 'b'
# 'thereeoists' -> 'there exists'
substitution_map['o'] = 'x'
# 'homever' -> 'however'
substitution_map['m'] = 'w'
# 'techniiue' -b 'technique'
substitution_map['i'] = 'q'
substitute(enc, substitution_map)

4
crypto/vigenere/flag.txt Normal file
View File

@ -0,0 +1,4 @@
rgnoDVD{O0NU_WQ3_G1G3O3T3_A1AH3S_cc82272b}
From cyberchef:
picoCTF{D0NT_US3_V1G3N3R3_C1PH3R_ae82272q}