mirror of https://github.com/dirtbags/moth.git
Merge branch 'master' of cfl.lanl.gov:/var/projects/gctf
This commit is contained in:
commit
4238aa8636
|
@ -10,17 +10,6 @@ bob = bob.replace(b' ', b'_').lower()
|
|||
map = [6, 3, 0, 5, 2, 7, 4, 1]
|
||||
imap = [2, 7, 4, 1, 6, 3, 0, 5]
|
||||
|
||||
def transform(text, map):
|
||||
assert len(text) % 8 == 0, 'Text must be multiple of 8 in length. '\
|
||||
'%d more chars needed.' % (8 - len(text) % 8)
|
||||
|
||||
out = bytearray()
|
||||
i = 0
|
||||
while i < len(text):
|
||||
for j in range(8):
|
||||
out.append( text[i + map[j]] )
|
||||
i = i+8
|
||||
return bytes(out)
|
||||
|
||||
encode = lambda t : transform(t, map)
|
||||
decode = lambda t : transform(t, imap)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
the squirrels crow at noon
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
import cbc, crypto
|
||||
|
||||
alice = b"""Do you think they've figured out that this was encrypted using cipher block chaining with a cipher of C(key, text) = text? If they somehow stumbled across the solution with knowing what it was, the next three will be hard. """
|
||||
bob = b"""Well, either way, we might as well let them know that the next three puzzles all uses CBC, but with progressively more difficult cipher functions. the squirrels crow at noon """
|
||||
|
||||
def C(text, key):
|
||||
return text
|
||||
|
||||
IV = b'ahiru'
|
||||
key = None
|
||||
|
||||
encode = lambda t : cbc.cipherBlockChainingE(key, IV, C, t)
|
||||
decode = lambda t : cbc.cipherBlockChainingD(key, IV, C, t)
|
||||
|
||||
crypto.mkIndex(encode, decode, alice, bob, crypto.hexFormat)
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
The Colour Out of Space
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
import cbc, crypto
|
||||
|
||||
alice = b"""I'd say this was easy, but we didn't give them the key, did we? I'm adding some text to give them something to work with: Commencing his descent of the dark stairs, Ammi heard a thud below him. He even thought a scream had been suddenly choked off, and recalled nervously the clammy vapour which had brushed by him in that frightful room above. What presence had his cry and entry started up? Halted by some vague fear, he heard still further sounds below. Indubitably there was a sort of heavy dragging, and a most detestably sticky noise as of some fiendish and unclean species of suction. With an associative sense goaded to feverish heights, he thought unaccountably of what he had seen upstairs. Good God! What eldritch dream-world was this into which he had blundered? He dared move neither backward nor forward, but stood there trembling at the black curve of the boxed-in staircase. Every trifle of the scene burned itself into his brain. The sounds, the sense of dread expectancy, the darkness, the steepness of the narrow steps-and merciful heaven! . . . the faint but unmistakable luminosity of all the woodwork in sight; steps, sides, exposed laths, and beams alike! """
|
||||
bob = b"""No, and they\'ll have to figure out the key for the next one too. Here\'s some Lovecraft: "Nothin\' . . . nothin\' . . . the colour . . . it burns . . . cold an\' wet . . . but it burns . . . it lived in the well . . . I seen it . . . a kind o\' smoke . . . jest like the flowers last spring . . . the well shone at night . . . Thad an\' Mernie an\' Zenas . . . everything alive . . . suckin\' the life out of everything . . . in that stone . . . it must a\' come in that stone . . . pizened the whole place . . . dun\'t know what it wants . . . that round thing them men from the college dug outen the stone . . . they smashed it . . . it was that same colour . . . jest the same, like the flowers an\' plants . . . must a\' ben more of \'em . . . seeds . . . seeds . . . they growed . . . I seen it the fust time this week . . . must a\' got strong on Zenas . . . he was a big boy, full o\' life . . . it beats down your mind an\' then gits ye . . . burns ye up . . . in the well water . . . you was right about that . . . evil water . . . Zenas never come back from the well . . . can\'t git away . . . draws ye . . . ye know summ\'at\'s comin\', but \'tain\'t no use . . . I seen it time an\' agin senct Zenas was took . . . whar\'s Nabby, Ammi? . . . my head\'s no good . . . dun\'t know how long senct I fed her . . . it\'ll git her ef we ain\'t keerful . . . jest a colour . . . her face is gettin\' to hev that colour sometimes towards night . . . an\' it burns an\' sucks . . . it come from some place whar things ain\'t as they is here . . . one o\' them professors said so . . . he was right . . . look out, Ammi, it\'ll do suthin\' more . . . sucks the life out. . . ." The Colour Out of Space"""
|
||||
|
||||
def C(text, key):
|
||||
out = bytearray()
|
||||
for i in range(len(text)):
|
||||
out.append( text[i] ^ key[i] )
|
||||
|
||||
return bytes(out)
|
||||
|
||||
IV = b'ahiru'
|
||||
key = b'color'
|
||||
|
||||
encode = lambda t : cbc.cipherBlockChainingE(key, IV, C, t)
|
||||
decode = lambda t : cbc.cipherBlockChainingD(key, IV, C, t)
|
||||
|
||||
crypto.mkIndex(encode, decode, alice, bob, crypto.hexFormat)
|
|
@ -0,0 +1,2 @@
|
|||
<dl><dt>Alice<dd> 1c 1e 38 7 52 4f 72 72 71 2b 18 58 6 52 4 74 65 6c 78 37 16 53 18 c 1d <BR>6c 6e 36 3a 2b 5f 4f 4c 5 54 2a 27 7f 20 25 18 43 47 52 0 67 73 77 31 27 <BR>18 45 47 7 11 33 7d 7d 65 66 13 46 58 14 2 37 76 72 24 61 1d 41 17 1e 53 <BR>64 73 78 20 67 58 e b 1 44 62 31 3e 68 62 1e a e 45 1c 6b 6c 7b 79 65 <BR>1 0 1e 16 15 7f 70 72 20 64 17 13 5f 7 0 2d 20 72 34 62 19 c 40 41 5d <BR>34 38 7e 2c 29 c 5d 59 18 4d 2b 39 64 38 38 a 4b 43 58 18 35 76 65 27 31 <BR>11 54 52 56 4f 72 18 7c 7a 76 a 56 17 3f 1f 7e 7b 7e 24 5a 1b 36 5e 9 45 <BR>7e 24 77 4f 61 57 e c 40 3b 6d 5e 77 63 2b 1f 46 4d 2a 6 22 72 3f 35 a <BR>4b 73 4a 13 15 6a 7a 24 6 77 50 1f 4 5d 26 61 52 31 69 7d 57 11 e 72 6 <BR>79 75 3b 7e 52 5e 21 16 18 5e 75 38 2e 44 71 e 19 1c 5b 30 7d 10 7c 7c 3f <BR>5c 50 12 76 10 71 64 3b 39 56 5c 22 1e 44 5c 71 28 7c 56 64 5c b 19 4d 35 <BR>7c 41 2e 79 2e 40 59 5c 20 a 67 73 25 2b 0 5 75 8 6 41 28 20 76 1 6e <BR>56 1 5e 45 75 2b f 76 71 3f 56 4a 47 6a 1e 33 7b 22 6a 2 47 6a 13 16 9 <BR>7a 64 26 4 65 48 a 5a d 72 3f 5c 24 7c 69
|
||||
<dt>Bob<dd> c 1b 35 0 52 41 31 69 63 20 19 4f 33 48 17 46 74 39 29 26 56 6 32 1d 47 <BR>12 28 3f 75 6e 4b 7 7f 4d 1d 5f 74 25 60 3e 49 12 32 4 5 47 25 69 70 70 <BR>1e 50 29 40 5e 4c 3b 3e 18 32 56 44 60 1b 79 13 14 33 64 74 5e 6 76 34 b <BR>3a 7d 3b 26 5b 49 3d 5f 1e 47 3e 26 3d 1d 79 7 38 57 48 3d 3e 4e 6a 55 68 <BR>1d c 56 2b 30 3e 5d 3d 78 4e 55 6e 1e 29 1d 7d 3d 37 f 42 58 62 19 52 7d <BR>7d 9 39 c 72 19 13 15 6c 7c 35 c 6d 7b 19 5 76 15 78 9 7d 7d 70 11 58 <BR>50 31 15 18 77 71 57 35 5d 6b 15 3 5 38 29 71 47 70 23 5d 13 38 5c 26 51 <BR>3d 25 33 48 55 56 75 48 57 66 2d 46 2 1d 2e 6e 4b 5a 27 76 3b 12 a 6b 49 <BR>7e 24 1b 61 1e 7e 3e 1c 48 5 3c 6b 1f 4d 21 3f 53 1c a 29 71 9 5a 32 26 <BR>3e 42 10 67 12 30 7d 57 26 9 33 7b 44 5d 47 28 28 56 5b 32 34 51 43 8 3a <BR>37 56 5f 71 61 2b 4 5b 76 19 2c 6b 52 24 13 34 61 49 4b 45 3e 3c 14 0 2a <BR>7a 5e 1e 53 20 3e 49 12 3b 3b 32 49 59 21 5c 37 72 5d 3c 45 35 3c 17 26 59 <BR>72 3c 15 4b 54 79 30 52 5b 2a 34 5e 59 5f 7b 79 1a 5c 3b 2f 70 49 d 72 1b <BR>2d 73 1f 3b 6 3f 69 48 a 58 2c 36 4a 5 2a 6a 4b 43 42 6d 63 2 1c 2e 25 <BR>3c 4d d 67 5a 6b 35 59 6d 15 79 74 5 41 1a 25 63 0 58 23 68 57 5 17 39 <BR>60 55 48 20 7b 1 5b 4e 75 54 3d 36 76 3a 55 56 3b 5c 52 5f 3b 7f 39 4e 3a <BR>4a 53 4b 1e 3d 6b 55 24 34 6a 43 5 e 75 58 60 78 34 6c 12 46 32 2 19 2 <BR>66 71 27 5c 39 43 15 e 14 2f 60 f 63 74 70 c 15 14 67 7 7c 69 2c 66 e <BR>4b 61 15 7 46 7d 34 39 2 66 4d 3 19 14 70 39 19 28 70 63 8 b 4d 71 4 <BR>3f 63 6d 62 51 1f 34 51 2 e 71 67 7b 18 64 1f 17 14 9 71 77 1f 77 37 66 <BR>2 15 3 70 45 61 31 39 35 5 51 6b 41 45 54 29 35 3a 4b 20 54 54 5f 50 6b <BR>7f 19 3c 31 32 5f 57 1e 77 59 7a 3d 2c 77 1e 44 77 5a 49 12 2d 60 36 57 26 <BR>16 51 5e 14 23 2a 4d 7f 22 7d 17 1a 4d 6d 4b 38 65 7f 3a 1d 17 3d 18 31 5f <BR>77 7f 7a 52 5f 14 7f 0 1a 26 64 54 61 11 7f e 1a 44 27 7c 21 5 2e 6c 55 <BR>42 36 1 67 d 62 62 29 16 b 5a 6a 17 6 36 63 53 29 4a 6e 4a 1 1a 73 38 <BR>7f 18 39 72 17 5c 65 b 70 52 7f 31 29 16 19 5b 7d 5f 53 7f 7f 9 3c 18 3c <BR>1c 54 1a 7b 5b 77 35 7d 24 1a 5d 68 50 46 66 3b 46 32 7 6a 56 3 5a 28 27 <BR>2d 54 22 23 49 4e 27 d 36 4a 6a 25 2a 7 44 44 64 1a 4c 60 75 40 22 16 21 <BR>47 44 1 28 64 6e 10 67 30 8 47 78 6 75 5f 26 3a 22 16 18 4d 6b 47 5e 61 <BR>28 4 63 4b 2e e 4f 46 24 2e 31 e 6a 20 57 </dl>
|
|
@ -0,0 +1 @@
|
|||
open meadows
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
import cbc, crypto
|
||||
from transform import transform
|
||||
|
||||
alice = b"""You know, I just realized it's kind of smug for us to be talking about how easy or difficult these puzzles are we we're making them rather than solving them. We've tried really hard to make them so that you don't have to follow some specific thread of logic to get to the correct answer; you just have to puzzle out the mechanism involved."""
|
||||
bob = b"""The next crypto function is something simple, but new. Here, have some more Lovecraft again: Ammi shewed them the back door and the path up through the fields to the ten-acre pasture. They walked and stumbled as in a dream, and did not dare look back till they were far away on the high ground. They were glad of the path, for they could not have gone the front way, by that well. It was bad enough passing the glowing barn and sheds, and those shining orchard trees with their gnarled, fiendish contours; but thank heaven the branches did their worst twisting high up. The moon went under some very black clouds as they crossed the rustic bridge over Chapman's Brook, and it was blind groping from there to the open meadows. open meadows """
|
||||
|
||||
IV = b'ahiru'
|
||||
keyE = [2, 4, 0, 1, 3]
|
||||
keyD = [2, 3, 0, 4, 1]
|
||||
|
||||
encode = lambda t : cbc.cipherBlockChainingE(keyE, IV, transform, t)
|
||||
decode = lambda t : cbc.cipherBlockChainingD(keyD, IV, transform, t)
|
||||
|
||||
crypto.mkIndex(encode, decode, alice, bob, crypto.hexFormat)
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
quavering tendrils
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
import cbc, crypto
|
||||
import diffie
|
||||
|
||||
alice = """Lets do a diffie hellman key exchange, Bob. The next puzzle will be encrypted using CBC and sha512(<name>.<key>) ^ text as the cipher function,
|
||||
and an IV of 0xaa 64 times. The prime is: %d, mod: %d, and I chose %d. Also, have some more Lovecraft: Too awed even to hint theories, the seven shaking men trudged back toward Arkham by the north road. Ammi was worse than his fellows, and begged them to see him inside his own kitchen, instead of keeping straight on to town. He did not wish to cross the nighted, wind-whipped woods alone to his home on the main road. For he had had an added shock that the others were spared, and was crushed forever with a brooding fear he dared not even mention for many years to come. As the rest of the watchers on that tempestuous hill had stolidly set their faces toward the road, Ammi had looked back an instant at the shadowed valley of desolation so lately sheltering his ill-starred friend. And from that stricken, far-away spot he had seen something feebly rise, only to sink down again upon the place from which the great shapeless horror had shot into the sky. It was just a colour—but not any colour of our earth or heavens. And because Ammi recognised that colour, and knew that this last faint remnant must still lurk down there in the well, he has never been quite right since. """ % \
|
||||
(diffie.prime, diffie.mod, diffie.a)
|
||||
bob = """Umm, ok. You'll need this: %d. The key this time is 'quavering tendrils'. Some more text to decode: West of Arkham the hills rise wild, and there are valleys with deep woods that no axe has ever cut. There are dark narrow glens where the trees slope fantastically, and where thin brooklets trickle without ever having caught the glint of sunlight. On the gentler slopes there are farms, ancient and rocky, with squat, moss-coated cottages brooding eternally over old New England secrets in the lee of great ledges; but these are all vacant now, the wide chimneys crumbling and the shingled sides bulging perilously beneath low gambrel roofs.
|
||||
The old folk have gone away, and foreigners do not like to live there. French-Canadians have tried it, Italians have tried it, and the Poles have come and departed. It is not because of anything that can be seen or heard or handled, but because of something that is imagined. The place is not good for the imagination, and does not bring restful dreams at night. It must be this which keeps the foreigners away, for old Ammi Pierce has never told them of anything he recalls from the strange days. Ammi, whose head has been a little queer for years, is the only one who still remains, or who ever talks of the strange days; and he dares to do this because his house is so near the open fields and the travelled roads around Arkham.
|
||||
There was once a road over the hills and through the valleys, that ran straight where the blasted heath is now; but people ceased to use it and a new road was laid curving far toward the south. Traces of the old one can still be found amidst the weeds of a returning wilderness, and some of them will doubtless linger even when half the hollows are flooded for the new reservoir. Then the dark woods will be cut down and the blasted heath will slumber far below blue waters whose surface will mirror the sky and ripple in the sun. And the secrets of the strange days will be one with the deep’s secrets; one with the hidden lore of old ocean, and all the mystery of primal earth.
|
||||
When I went into the hills and vales to survey for the new reservoir they told me the place was evil. They told me this in Arkham, and because that is a very old town full of witch legends I thought the evil must be something which grandams had whispered to children through centuries. The name “blasted heath” seemed to me very odd and theatrical, and I wondered how it had come into the folklore of a Puritan people. Then I saw that dark westward tangle of glens and slopes for myself, and ceased to wonder at anything besides its own elder mystery. It was morning when I saw it, but shadow lurked always there. The trees grew too thickly, and their trunks were too big for any healthy New England wood. There was too much silence in the dim alleys between them, and the floor was too soft with the dank moss and mattings of infinite years of decay. """ % \
|
||||
(diffie.B,)
|
||||
|
||||
alice = crypto.strip(alice)
|
||||
bob = crypto.strip(bob)
|
||||
|
||||
def Ce(text, key):
|
||||
out = bytearray()
|
||||
for i in range(len(text)):
|
||||
out.append( ( (text[i] + key[i]) % 256) ^ key[i] )
|
||||
|
||||
return bytes(out)
|
||||
|
||||
def Cd(text, key):
|
||||
out = bytearray()
|
||||
for i in range(len(text)):
|
||||
out.append( ( (text[i] ^ key[i]) - key[i]) % 256 )
|
||||
|
||||
return bytes(out)
|
||||
|
||||
IV = b'ahiru'
|
||||
key = b'space'
|
||||
|
||||
encode = lambda t : cbc.cipherBlockChainingE(key, IV, Ce, t)
|
||||
decode = lambda t : cbc.cipherBlockChainingD(key, IV, Cd, t)
|
||||
|
||||
if __name__ == '__main__':
|
||||
crypto.mkIndex(encode, decode, alice, bob, crypto.hexFormat)
|
|
@ -0,0 +1,2 @@
|
|||
<dl><dt>Alice<dd> e3 75 ff 47 8e 96 a3 b 46 47 76 af a9 4 d6 13 99 65 79 d7 bd 3f 3a 5e f1 <BR>c4 29 f5 c 45 74 77 b6 84 4c dd 9 38 9c f6 bf a6 d6 ef 11 b5 22 b7 f7 b7 <BR>2 65 6b 84 7 3e 76 68 e3 d6 9b 3e 8a 95 92 a1 e6 a6 f9 a0 e4 ae aa a8 ab <BR>bd ef fe b3 b2 b5 f0 b6 ae ee f0 e5 c3 ed ab e1 ef ee de b6 a0 f3 ec a2 a2 <BR>aa a9 a0 ae aa f8 fe a8 b7 aa aa ab bb f8 bb e2 b1 b0 ed b2 e7 ee f9 b7 ac <BR>a0 bc a4
|
||||
<dt>Bob<dd> bb 29 86 18 a7 e0 a6 33 ec bc df 73 3e b5 dc 76 66 6d 74 68 30 81 9b 42 a1 <BR>41 ac 3b ee ab 3d ae d4 ae d0 33 d9 11 1 e4 57 3f 61 14 9b e2 85 f5 89 e0 <BR>cf 94 d8 56 71 a ec 99 7a 5d 4 7e 68 93 </dl>
|
|
@ -0,0 +1 @@
|
|||
in the same vein
|
|
@ -0,0 +1,25 @@
|
|||
import crypto
|
||||
import cbc
|
||||
import diffie
|
||||
import hashlib
|
||||
|
||||
IV = [0xaa]*64
|
||||
aliceKey = hashlib.sha512(bytes('alice.%d' % diffie.key, 'utf-8')).digest()
|
||||
bobKey = hashlib.sha512(bytes('bob.%d' % diffie.key, 'utf-8')).digest()
|
||||
|
||||
alice = b"""Only one more puzzle to go. They'll never get it though, since we use a one time pad. I need to add more text here to pad this."""
|
||||
bob = b"""I wouldn't be so sure of that. The key is: in the same vein """
|
||||
|
||||
def C(text, key):
|
||||
out = bytearray()
|
||||
for i in range( len( text ) ):
|
||||
out.append(key[i] ^ text[i])
|
||||
|
||||
return bytes(out)
|
||||
|
||||
c = cbc.cipherBlockChainingE(aliceKey, IV, C, alice)
|
||||
print('<dl><dt>Alice<dd>', crypto.hexFormat(c))
|
||||
assert cbc.cipherBlockChainingD(aliceKey, IV, C, c) == alice
|
||||
c = cbc.cipherBlockChainingE(bobKey, IV, C, bob)
|
||||
assert cbc.cipherBlockChainingD(bobKey, IV, C, c) == bob
|
||||
print('<dt>Bob<dd>', crypto.hexFormat(c), '</dl>')
|
|
@ -0,0 +1,2 @@
|
|||
<dl><dt>Alice<dd> f4 c9 40 41 ac 4b 9c 3f 32 58 2f 70 1c 49 fb bf a8 56 72 72 2 88 2c 87 cc <BR>d 13 6c 25 d5 da 30 64 dd dd b8 ba 58 c1 a3 17 26 6d ff 64 62 cb 69 b3 e2 <BR>ae 2d dd 11 2f a1 5d 79 b6 63 cb 51 5b de 9c 57 20 45 72 7b f2 35 15 40 60 <BR>8c 45 c9 a6 38 e0 79 7 a4 cc 18 e9 7e eb 4b 38 e2 ed 6b 17 a1 ee fd 69 2a <BR>24 b5 21 be 96 92 d4 f6 5b 40 59 1d b f6 8a cb dd 6 43 16 6 f ab c8 4 <BR>fc b2 f3 c3 64 11 40 db 9e d6 7 f9 40 17 bd 2 1e cc b2 14 81 6a c1 6b b9 <BR>2c 6c ab 5f 7f
|
||||
<dt>Bob<dd> e9 d5 6 46 ac 52 92 38 32 5d 32 37 59 10 e3 af a8 46 72 6b 18 89 68 c2 c0 <BR>15 13 2f 3d 94 d0 2b 31 9e db ae ea 5f c1 ef 11 36 37 e4 66 7e 9e 21 99 e3 <BR>a7 6a ce 13 2f a1 50 74 ae 73 84 5b 41 96 da 1e a 10 76 60 a2 39 5b 19 6e <BR>d9 1 da ba 75 ac 71 1b b5 89 1e a1 7e f3 b 36 ab a3 6b 43 e9 ab fd 23 75 <BR>68 f6 68 b3 c8 dc 81 ae b 18 44 4f 50 eb aa cb d5 6 4f 16 a 49 b0 d2 41 <BR>df bb 93 cd 7d d 42 c6 cc 8d 1a b0 f 43 f6 46 52 8d bf 5d c5 21 8a 22 fa <BR>79 20 ff 6 71 </dl>
|
|
@ -0,0 +1 @@
|
|||
--------========Thanks for Pl@y|ng========--------
|
|
@ -0,0 +1,23 @@
|
|||
import crypto
|
||||
import random
|
||||
|
||||
def mkPad(length):
|
||||
pad = bytearray()
|
||||
for i in range(length):
|
||||
pad.append( random.randint(0,255) )
|
||||
return bytes(pad)
|
||||
|
||||
alice = b'That was it, you solved the last crypto puzzle! Congratulations. I hope you realize that, in the grand scheme of things, these were of trivial difficulty.'
|
||||
bob = b"It's not like we could expect you to solve anything actually difficult in a day, after all. --------========Thanks for Pl@y|ng========-------- "
|
||||
|
||||
assert len(alice) == len(bob)
|
||||
key = mkPad(len(alice))
|
||||
|
||||
def encode(text):
|
||||
out = bytearray()
|
||||
for i in range(len(text)):
|
||||
out.append(key[i] ^ text[i])
|
||||
return bytes(out)
|
||||
|
||||
crypto.mkIndex(encode, encode, alice, bob, crypto.hexFormat)
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
def cipherBlockChainingE(key, IV, C, text):
|
||||
"""Cypher block chaining encryption. Works in blocks the size of IV.
|
||||
@param key: the key for the Cipher.
|
||||
@param IV: initialization vector (bytes object).
|
||||
@param C: the cypher function C(text, key).
|
||||
@param text: A bytes object of the text. The length of the text
|
||||
must be a multiple of the length of the IV.
|
||||
"""
|
||||
mod = len(text) % len(IV)
|
||||
assert mod == 0, 'The text length needs to be a multiple of the key '\
|
||||
'length. %d of %d' % (mod, len(IV))
|
||||
|
||||
feedback = IV
|
||||
block = len(IV)
|
||||
out = bytearray()
|
||||
while text:
|
||||
p, text = text[:block], text[block:]
|
||||
|
||||
c = bytearray(block)
|
||||
for i in range(block):
|
||||
c[i] = p[i] ^ feedback[i]
|
||||
|
||||
c2 = C(c, key)
|
||||
out.extend(c2)
|
||||
feedback = c2
|
||||
|
||||
return bytes(out)
|
||||
|
||||
def cipherBlockChainingD(key, IV, C, text):
|
||||
"""Cipher block chaining decryption. Arguments are the same as for the
|
||||
encrypting function."""
|
||||
mod = len(text) % len(IV)
|
||||
assert mod == 0, 'The text length needs to be a multiple of the IV '\
|
||||
'length. %d of %d' % (mod, len(IV))
|
||||
|
||||
feedback = IV
|
||||
block = len(IV)
|
||||
out = bytearray()
|
||||
while text:
|
||||
c, text = text[:block], text[block:]
|
||||
|
||||
p = C(c, key)
|
||||
p = bytearray(p)
|
||||
for i in range(block):
|
||||
p[i] = p[i] ^ feedback[i]
|
||||
|
||||
out.extend(p)
|
||||
feedback = c
|
||||
|
||||
return bytes(out)
|
||||
|
|
@ -32,3 +32,15 @@ def groups(text, perLine=5, format='{0:c}'):
|
|||
|
||||
return ''.join(out)
|
||||
|
||||
def strip(text):
|
||||
"""Strip any unicode from the given text, and return it as a bytes
|
||||
object."""
|
||||
|
||||
b = bytearray()
|
||||
for t in text:
|
||||
if ord(t) > 255:
|
||||
t = ' '
|
||||
|
||||
b.append(ord(t))
|
||||
|
||||
return bytes(b)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
prime = 51237129793
|
||||
mod = 321454621
|
||||
a = 341
|
||||
A = prime ** a % mod
|
||||
b = 573
|
||||
B = prime ** b % mod
|
||||
key = A**b % mod
|
||||
assert B**a % mod == key, 'Bad diffie math.'
|
|
@ -0,0 +1,13 @@
|
|||
def transform(text, map):
|
||||
size = len(map)
|
||||
div = len(text) % size
|
||||
assert div == 0, 'Text must be a multiple of the key size in length. '\
|
||||
'At %d out of %d' % (div, size)
|
||||
|
||||
out = bytearray()
|
||||
i = 0
|
||||
while i < len(text):
|
||||
for j in range(size):
|
||||
out.append( text[i + map[j]] )
|
||||
i = i+size
|
||||
return bytes(out)
|
|
@ -0,0 +1,13 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Forensic 100</TITLE>
|
||||
</HEAD>
|
||||
<BODY>The FBI has asked for your team's assistance in conducting a forensic analysis of a seized hacker's drive.
|
||||
The FBI tells you that the suspect is a known terrorist and may be using encryption on his disk.
|
||||
They have put their best agent on the job, but he has been unsuccessful in mounting and analyzing the drive on
|
||||
their forensic tool. Where do you tell Special Agent Dumas to begin looking to determine what type of filesystem
|
||||
is being used and whether disk encryption may be employed?
|
||||
<p>
|
||||
Enter the key in all lower case letters
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -0,0 +1 @@
|
|||
master boot record
|
|
@ -0,0 +1,11 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Forensic 150</TITLE>
|
||||
</HEAD>
|
||||
<BODY>Special Agent Dumas has looked for the structure you told him but can't find it. He thinks the
|
||||
subject has taken evasive measures to hide the data on his drive. What signature should he look for to
|
||||
identify the structure?
|
||||
<p>
|
||||
Enter the key as a set of hex characters. (E.g. 0xde 0xad 0xbe 0xef)
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -0,0 +1 @@
|
|||
0x55 0xaa
|
Binary file not shown.
|
@ -0,0 +1,13 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Forensic 200</TITLE>
|
||||
</HEAD>
|
||||
<BODY>Special Agent Dumas is still stumped. He has looked where you told him but is unable to decipher
|
||||
what filesystem is on the disk. He has extracted the portion of the disk you pointed him to and has
|
||||
<BR>
|
||||
<P>
|
||||
<a href="eff21d462a07b09b0cb34f9255baa768">eff21d462a07b09b0cb34f9255baa768</a>
|
||||
<p>
|
||||
Provide the answer in all capital letters
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -0,0 +1 @@
|
|||
NTFS
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Forensic 300</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
Special Agent Dumas really appreciates your team's assistance. If you can just tell him the cylinder:head:sector
|
||||
of the partition you identified for him, he thinks he can get started in analyzing this disk.
|
||||
<P>
|
||||
<a href="eff21d462a07b09b0cb34f9255baa768">eff21d462a07b09b0cb34f9255baa768</a>
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -0,0 +1 @@
|
|||
0:32:33
|
Binary file not shown.
|
@ -0,0 +1,12 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Forensic 350</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
Special Agent Dumas is really grateful you were able to provide him the Cylinder:Head:Sector of the partition
|
||||
but he just realized that his forensic tool requires a LBA instead of C:H:S. Please give SA Dumas the
|
||||
information he needs.
|
||||
<P>
|
||||
<a href="eff21d462a07b09b0cb34f9255baa768">eff21d462a07b09b0cb34f9255baa768</a>
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -0,0 +1 @@
|
|||
2048
|
Loading…
Reference in New Issue