crypto: add already solved challenges

This commit is contained in:
Oystein Kristoffer Tveit 2024-09-01 21:50:34 +02:00
parent 210f69341b
commit a02ad89612
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
9 changed files with 161 additions and 0 deletions

3
crypto/13/solve.sh Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
echo "cvpbPGS{abg_gbb_onq_bs_n_ceboyrz}" | tr 'A-Za-z' 'N-ZA-Mn-za-m'

1
crypto/caesar/ciphertext Normal file
View File

@ -0,0 +1 @@
picoCTF{dspttjohuifsvcjdpoabrkttds}

16
crypto/caesar/solve.py Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3
def decrypt(ciphertext: str, key: int):
for letter in ciphertext:
shifted = chr(((ord(letter) - ord('a') + key + 26) % 26) + ord('a'))
print(shifted, end='')
print()
if __name__ == "__main__":
with open('ciphertext') as file:
enc = file.read().strip()[len('picoCTF{'):-len('}')]
# Note: seems to be the last one, "crossing the rubicon"
for shift in range(26):
decrypt(enc, shift)

41
crypto/easy1/solve.py Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3
# Character mapping table:
#
# A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
# +----------------------------------------------------
# A | A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
# B | B C D E F G H I J K L M N O P Q R S T U V W X Y Z A
# C | C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
# D | D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
# E | E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
# F | F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
# G | G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
# H | H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
# I | I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
# J | J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
# K | K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
# L | L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
# M | M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
# N | N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
# O | O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
# P | P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
# Q | Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
# R | R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
# S | S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
# T | T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
# U | U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
# V | V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
# W | W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
# X | X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
# Y | Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
# Z | Z A B C D E F G H I J K L M N O P Q R S T U V W X Y
enc = "UFJKXQZQUNB"
key = "SOLVECRYPTO"
if __name__ == "__main__":
for (x, y) in zip(enc, key):
decrypted = chr(((((ord(x) - ord('A')) - (ord(y) - ord('A'))) + 26) % 26) + ord('A'))
print(decrypted, end="")

1
crypto/mod_26/solve.sh Executable file
View File

@ -0,0 +1 @@
echo "cvpbPGS{arkg_gvzr_V'yy_gel_2_ebhaqf_bs_ebg13_Ncualgvd}" | tr 'A-Za-z' 'N-ZA-Mn-za-m'

View File

@ -0,0 +1,10 @@
16 9 3 15 3 20 6 { 20 8 5 14 21 13 2 5 18 19 13 1 19 15 14 }
This is probably a number to letter mapping, in the form of
1->A, 2->B, 3->C, 4->D, ...
Translation:
p i c o c t f { t h e n u m b e r s m a s o n }
Flag:
picoCTF{thenumbersmason}

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

View File

@ -0,0 +1,4 @@
-------------------------------------------------------------------------------
pexmdiah csds bh reod kzim - kdsgosxpr_bh_p_efsd_ziyqni_emkyioxdik
-------------------------------------------------------------------------------
cifbxm cin heys abys ia yr nbhtehiz wcsx bx zexnex, b cin fbhbasn acs qdbabhc yohsoy, ixn yins hsidpc iyexm acs qeelh ixn yith bx acs zbqdidr dsmidnbxm adixhrzfixbi; ba cin hadopl ys acia heys kedslxewzsnms ek acs peoxadr peozn cidnzr kibz ae cifs heys bytedaixps bx nsizbxm wbac i xeqzsyix ek acia peoxadr. b kbxn acia acs nbhadbpa cs xiysn bh bx acs svadsys siha ek acs peoxadr, joha ex acs qednsdh ek acdss haiash, adixhrzfixbi, yeznifbi ixn qolefbxi, bx acs ybnha ek acs pidtiacbix yeoxaibxh; exs ek acs wbznsha ixn zsiha lxewx tedabexh ek sodets. b wih xea iqzs ae zbmca ex ixr yit ed wedl mbfbxm acs svipa zepizbar ek acs pihazs ndipozi, ih acsds ids xe yith ek acbh peoxadr ih rsa ae peytids wbac eod ewx ednxixps hodfsr yith; qoa b keoxn acia qbhadbau, acs teha aewx xiysn qr peoxa ndipozi, bh i kibdzr wszz-lxewx tzips. b hcizz sxasd csds heys ek yr xeash, ih acsr yir dskdshc yr ysyedr wcsx b aizl efsd yr adifszh wbac ybxi.

View File

@ -0,0 +1,85 @@
#!/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 in substitution_map:
print(green(substitution_map[letter]), end="")
else:
print(red(letter), end="")
with open('ciphertext', '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, "csds bh reod kzim" looks like "here is your flag"
substitution_map = {
'-': '-',
'_': '_',
'\n': '\n',
' ': ' ',
',': ',',
'.': '.',
';': ';',
'c': 'h',
's': 'e',
'd': 'r',
'b': 'i',
'h': 's',
'r': 'y',
'e': 'o',
'o': 'u',
'k': 'f',
'z': 'l',
'i': 'a',
'm': 'g',
}
# substitute(enc, substitution_map)
# found: euro't'e, ligh'a', o'f'er, 'q'ri'a'ish
# suspect: euro p e, ligh t, o v er, b ri t ish
substitution_map['t'] = 'p'
substitution_map['a'] = 't'
substitution_map['f'] = 'v'
substitution_map['q'] = 'b'
# substitute(enc, substitution_map)
# found: visite'n', british 'y'useu'y', sear'p'h, havi'x'g
# suspect: visite d , british m useu m , sear c h, havi'n'g
substitution_map['n'] = 'd'
substitution_map['y'] = 'm'
substitution_map['p'] = 'c'
substitution_map['x'] = 'n'
# substitute(enc, substitution_map)
# found: fre'g'uency, 'l'no'w'n, 'j'ust, e'v'act
# suspect: fre q uency, k no w n, j ust, e'x'act
substitution_map['g'] = 'q'
substitution_map['l'] = 'k'
substitution_map['w'] = 'w'
substitution_map['j'] = 'j'
substitution_map['v'] = 'x'
substitute(enc, substitution_map)
# still not sure about 'u'? But flag is found