Hello! I wanted to post a quick write up of a solution to a recent ctf challenge! This was one of the first real crypto challenges I’ve helped solve with the b01lers ctf team! I got very close, and my teammate helped me with the last step.

Here is the original file: submit_the_flag_that_is_here

In the file are alot of strange series of texts, they’re actually hashes (md5sum (32 chars) and sha512 (64 chars)). Using python we can group them into a dictionary and see how often they occur! That was my first thought, but this lead nowhere.

The next step was to see if they were hashed from a common character, this website was helpful. This gave me a list of keys->values I could map in a dictionary. Printing that out gave me a string of text that looked like this:

I thought the hashtags might be significant so I went on a long journey, digging through the file and removing words. Along the way, I actually found parts of the real flag, which I thought were clues left to help me find the final flag. Eventually I ended with this snippet and output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
with open("xargs", "r+") as f:
    lines =  f.read().split(' ')

out = []

for l in lines:
    check = True
    for x in lines:
        if l in x and l != x:
            check = False
    if check:
        out.append(l)


p = re.compile("[.]|[,]")
print [ i for i in out if not p.search(i) ]

Of course the I could see that the real flag was in here, with Sh0256} and {Y3a! but I wasn’t sure how to put it together. My teammate also came up with the solution at about the same time. The flag was between the { } in the original .txt file!

So here is my final python script:

  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
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import base64
import re

#converted hashes: https://md5decrypt.net/en/Sha256/
# https://md5decrypt.net/en/

d = {
"cbb184dd8e05c9709e5dcaedaa0495cf" : "}",
"021fb596db81e6d02bf3d2586ee3981fe519f275c0ac9ca76bbcf2ebb4097d96": "{"
}

dd = {"1679091c5a880faf6fb5e6087eb1b2dc" :"6",
"c81e728d9d4c2f636f067f89cc14862c" : "2",
"57cec4137b614c87cb4e24a3d003a3e0" : "Y",
"b9ece18c950afbfa6b0fdbfa4ff731d3" : "T",
"f1290186a5d0b1ceab27f4e77c0c5d68" : "w",
"8ce4b16b22b58894aa86c421e8759df3" : "k",
"e4da3b7fbbce2345d7772b0674a318d5" : "5",
"9eecb7db59d16c80417c72d1e1f4fbf1" : ";",
"f186217753c37b9b9f958d906208506e" : "O",
"d20caec3b48a1eef164cb4ca81ba2587" : "L",
"f09564c9ca56850d4cd6b3319e541aee" : "Q",
"3a3ea00cfc35332cedf6e5e9a32e94da" : "E",
"800618943025315f869e4e1f09471012" : "F",
"4c614360da93c0a041b22e537de151eb" : "U",
"363b122c528f54df4a0446b6bab05515" : "j",
"7fc56270e7a70fa81a5935b72eacbe29" : "A",
"5206560a306a2e085a437fd258eb57ce" : "V",
"0d61f8370cad1d412f80b84d143e1257" : "C",
"f623e75af30e62bbd73d6df5b50bb7b5" : "D",
"9dd4e461268c8034f5c8564e155c67a6" : "x",
"dd7536794b63bf90eccfd37f9b147d7f" : "I",
"5dbc98dcc983a70728bd082d1a47546e" : "S",
"69691c7bdcc3ce6d5d8a1361f22d04ac" : "M",
"8d9c307cb7f3c4a32822a51922d1ceaa" : "N",
"44c29edb103a2872f519ad0c9a0fdaaa" : "P",
"01abfc750a0c942167651c40d088531d" : "#",
"8fa14cdd754f91cc6554c9e71929cce7" : "f",
"7694f4a66316e53c8cdd9d9954bd611d" : "q",
"b2f5ff47436671b6e533d8dc3614845d" : "g",
"92eb5ffee6ae2fec3ad71c777531578f" : "b",
"9e3669d19b675bd57058fd4664205d2a" : "v",
"c0cb5f0fcf239ab3d9c1fcd31fff1efc" : ",",
"83878c91171338902e0fe0fb97a8c47a" : "p",
"5058f1af8388633f609cadb75a75dc9d" : ".",
"8277e0910d750195b448797616e091ad" : "d",
"4a8a08f09d37b73795649038408b5f33" : "c",
"d95679752134a2d9eb61dbd7b91c4bcc" : "o",
"6f8f57715090da2632453988d9a1501b" : "m",
"7b8b965ad4bca0e41ab51de7b31363a1" : "n",
"2db95e8e1a9267b7a1188556b2013b33" : "l",
"4b43b0aee35624cd95b910189b3dc231" : "r",
"0cc175b9c0f1b6a831c399e269772661" : "a",
"e358efa489f58062f10dd7316b65649e" : "t",
"03c7c0ace395d80182db07ae2c30f034" : "s",
"7b774effe4a349c6dd82ad4f4f21d34c" : "u",
"865c0c0b4ab0e063e5caa3387c1a8741" : "i",
"e1671797c52e15f763380b45e841ec32" : "e",
"b14a7b8059d9c055954c92674ce60032" : "_",
"18f5384d58bcb1bba0bcd9e6a6781d1a6ac2cc280c330ecbab6cb7931b721552": "Y",
"ef2d127de37b942baad06145e54b0c619a1f22327b2ebbcfbec78f5564afe39d": "5",
"4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce": "3",
"aaa9402664f1a41f40ebbc52c9993eb66aeb366602958fdfaa283b71e64db123": "h",
"44bd7ae60f478fae1061e11a7739f4b94d1daf917982d33b6fc8a01a63f89c21": "!",
"bb7208bc9b5d7c04f1236a82a0093a5e33f40423d5ba8d4266f7092c3ba43b62": "4",
"4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a": "0",
"5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9": ";",
"41b805ea7ac014e23556e98bb374702a08344268f92489a02f0880849394a1e4": "",
"c4694f2e93d5c4e7d51f9c5deb75e6cc8be5e1114178c6a45b6fc2c566a0aa8c" : "O",
"72dfcfb0c470ac255cde83fb8fe38de8a128188e03ea5ba5b2a93adbea1062fa" : "L",
"a25513c7e0f6eaa80a3337ee18081b9e2ed09e00af8531c8f7bb2542764027e7" : "U",
"a9f51566bd6705f7ea6ad54bb9deb449f795582d6529a0e22207b8981233ec58" : "E",
"4ae81572f06e1b88fd5ced7a1a000945432e83e1551e6f721ee9c00b8cc33260" : "Q",
"f67ab10ad4e4c53121b6a5fe4da9c10ddee905b978d3788d2723d7bfacbe28a9" : "F",
"189f40034be7a199f1fa9891668ee3ab6049f82d38c68be70f596eab2e1857b7" : "j",
"de5a6f78116eca62d7fc5ce159d23ae6b889b365a1739ad2cf36f925a140d0cc" : "V",
"6b23c0d5f35d1b11f9b683f0b0a617355deb11277d91ae091d399c655b87940d" : "C",
"a83dd0ccbffe39d071cc317ddf6e97f5c6b1c87af91919271f9fa140b0508c6c" : "I",
"559aead08264d5795d3909718cdd05abd49572e84fe55590eef31a88a08fdffd" : "A",
"3f39d5c348e5b79d06e842c114e6cc571583bbf44e4b0ebfda1a01ec05745d43" : "D",
"2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881" : "x",
"8de0b3c47f112c59745f717a626932264c422a7563954872e237b223af4ad643" : "S",
"08f271887ce94707da822d5263bae19d5519cb3614e0daedc4c7ce5dab7473f1" : "M",
"8ce86a6ae65d3692e7305e2c58ac62eebd97d3d943e093f577da25c36988246b" : "N",
"5c62e091b8c0565f1bafad0dad5934276143ae2ccef7a5381e8ada5b1a8d26d2" : "P",
"334359b90efed75da5f0ada1d5e6b256f4a6bd0aee7eb39c0f90182a021ffc8b" : "#",
"252f10c83610ebca1a059c0bae8255eba2f95be4d1d7bcfa89d7248a82d9f111" : "f",
"3e23e8160039594a33894f6564e1b1348bbd7a0088d42c4acb73eeaed59c009d" : "b",
"cd0aa9856147b6c5b4ff2b7dfee5da20aa38253099ef1b4a64aced233c9afe29" : "g",
"8e35c2cd3bf6641bdb0e2050b76932cbb2e6034a0ddacc1d9bea82a6ba57f7cf" : "q",
"4c94485e0c21ae6c41ce1dfe7b6bfaceea5ab68e40a2476f50208e526f506080" : "v",
"d03502c43d74a30b936740a9517dc4ea2b2ad7168caa0a774cefe793ce0b33e7" : ",",
"148de9c5a7a44d19e56cd9ae1a554bf67847afb0c58f6e12fa29ac7ddfca9940" : "p",
"cdb4ee2aea69cc6a83331bbe96dc2caa9a299d21329efb0336fc02a82e1839a8" : ".",
"18ac3e7343f016890c510e93f935261169d9e3f565436429830faf0934f4f8e4" : "d",
"2e7d2c03a9507ae265ecf5b5356885a53393a2029d241394997265a1a25aefc6" : "c",
"65c74c15a686187bb6bbf9958f494fc6b80068034a659a9ad44991b08c58f2d2" : "o",
"62c66a7a5dd70c3146618063c344e531e6d4b59e379808443ce962b3abd63c5a" : "m",
"454349e422f05297191ead13e21d3db520e5abef52055e4964b82fb213f593a1" : "r",
"1b16b1df538ba12dc3f97edbb85caa7050d46c148134290feba80f8236c83db9" : "n",
"acac86c0e609ca906f632b0e2dacccb2b77d22b0621f20ebece1a4835b93f6f0" : "l",
"ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb" : "a",
"043a718774c572bd8a25adbeb1bfcd5c0256ae11cecf9f9c3f925d0e52beaf89" : "s",
"e3b98a4da31a127d4bde6e43033f66ba274cab0eb7eb1c70ec41402bf6273dd8" : "t",
"0bfe935e70c321c7ca3afc75ce0d0ca2f98b5422e008bb31c00c6d7f1f1c0ad6" : "u",
"de7d1b721a1e0632b7cf04edf5032c8ecffa9f9a08492152b926f1a5a7e765d7" : "i",
"3f79bb7b435b05321651daefd374cdc681dc06faa65e374e38337b88ca046dea" : "e",
"d2e2adf7177b7a8afddbc12d1634cf23ea1a71020f6a1308070a16400fb68fde" : "_"}

with open("submit_the_flag_that_is_here.txt", "r+") as f:
  lines =  f.read().split(' ')

check = False
out = ""
for l in lines:
    if l in d:
        #flip check
        if check:
            check = False
        else:
            check = True
        continue
    if check:
       out = out + dd[l]
print "F#{" + out +"}"

The final flag: F#{Y3a!_Y;u_kN;w_mD5_0Nd_Sh0256}