Fluffy Bunnies Or decrypted with XGEKOCMGYLKEA is Cryptography
Fluffy Bunnies Or… decrypted with XGEKOCMGYLKEA is…
Cryptography
Start With Something that is Not Encryption
Encoding • Encoding is different than encryption because the idea is to transform data so that it can be read properly • As opposed to transforming data to keep it secret • Encoding transforms data into another format that is publicly available so that it can be easily reversed
Encryption
Encryption • This is where we transform data/information with the intent to keep it secret. • Rather than focusing on usability, the goal is to ensure the data can only be consumed by targeted recipients • Only these targeted recipients should be able to reverse the transformation (or decrypt) the information • Uses a key, plaintext, and an algorithm to transform the data. • The key, ciphertext, and algorithm are required in order to decrypt the information
Hashing
Hashing • The purpose of hashing is to ensure data integrity (to make sure the information has not been changed). • Has the following properties: – – The same input creates the same output Multiple different inputs should not create the same output Should not be possible to go from output to input Any modification to the input should dramatically change the hash
Hashing • Integrity is checked by: – – – taking a given input encrypting it with a given key hashing it and then encrypting the key with the recipient’s public key and signing the hash with the sender’s private key. • When the recipient opens the message, they can then decrypt the key: – With their private key, which allows them to decrypt the message. – They then hash the message themselves and compare it to the hash that was signed by the sender. • If they match it is an unmodified message, sent by the correct person.
Obfuscation
Obfuscation: • The purpose of obfuscation is to make something harder to understand, – Typically to make it more difficult to attack or to copy. • One common use is the obfuscation of source code so that it’s harder to replicate a given product if it is reverse engineered. • It’s important to note that obfuscation is not a strong control (like properly employed encryption) but rather an obstacle. • Like encoding, can often be reversed by using the same technique that obfuscated it. Other times it is simply a manual process that takes time to work through. • Another key thing to realize about obfuscation is that there is a limitation to how obscure the code can become, depending on the content being obscured. • If you are obscuring computer code, for example, the limitation is that the result must still be consumable by the computer or else the application will cease to function.
Krypton
Krypton • You’ll need access to SSH • You can get Putty from here: • http: //www. chiark. greenend. org. uk/~sgtatham/putty/download. h tml • Or if you’re not cool with downloading from an unfamiliar site, you can get Secure. CRT from the school website: • http: //eng. auburn. edu/admin/ens/helpdesk/off-campus/licensedsoftware. html
Krypton Setup • For Secure. CRT: – – – Start it up Click “New Session” Protocol SSH 2 Hostname: krypton. labs. overthewire. org Username: krypton 1 (Give a brief optional description? ) • For Putty: – – Start up putty Set Hostname as: krypton. labs. overthewire. org Hit “connect” Login as: krypton 1
Krypton Login • Over. The. Wire says that the password for logging into krypton is encrypted with Base 64 encoding. – It’s encoding. Not encryption – Base 64 allows for representing binary data using only printable (text) characters.
Wikipedia’s Example • Quote from Thomas Hobbe’s Leviathan: – Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure. • Represented as 8 -bit padded ASCII encoded in MIME’s scheme – TWFu. IGlz. IGRpc 3 Rpbmd 1 a. XNo. ZWQs. IG 5 vd. CBvbmx 5 IGJ 5 IGhpcy. By. ZWFzb 24 s. IGJ 1 d. CBie. SB 0 a. Glz. IHNpbmd 1 b. GFy. IHBhc 3 Npb 24 g. Zn. Jvb. SBvd. Ghlci. Bhbmlt. Y Wxz. LCB 3 a. Glja. CBpcy. Bh. IGx 1 c 3 Qgb 2 Ygd. Ghl. IG 1 pbm. Qs. IHRo. YXQg. Ynkg. YSBw ZXJz. ZXZlcm. Fu. Y 2 Ugb 2 Yg. ZGVsa. Wdod. CBpbi. B 0 a. GUg. Y 29 ud. Glud. WVk. IGFu. ZC Bpbm. Rl. Zm. F 0 a. Wdh. Ymxl. IGdlbm. Vy. YXRpb 24 gb 2 Yga 25 vd 2 xl. ZGdl. LCBle. GNl. Z WRz. IHRo. ZSBza. G 9 yd. CB 2 ZWhlb. WVu. Y 2 Ugb 2 Yg. YW 55 IGNhcm 5 hb. CBwb. GVh c 3 Vy. ZS 4=
Wikipedia Example: • The first word “Man “ in the quote is represented as TWFu • Each letter is as follows in ASCII: – 77, 97, 110 • Each value as 8 -bit binary values: – 0100 1101 – 0110 0001 – 0110 1110 • Concatenated together: – 0100 1101 0110 0001 0110 1110 • Grouped into 6 -bits and converted to integers – 0100 1101 0110 0001 0110 1110 – 19 22 5 46 • Converted to Base 64 (by looking at Index table): – TWFu
Krypton Level 1 • Login to SSH with password: KRYPTONISGREAT
Krypton Level 1 • We’re told that the password is stored in the file krypton 2 and: – Non-standard ciphertext – Group letters into 5 -letter clusters – File has kept plaintext word boundaries • The README file gives us some extra information: – krypton 2 is encrypted using ROT 13
Rotational (Shift) Ciphers • Rotational (shift) ciphers are a type of Substitution cipher • Substitution Cipher: – Each letter is replaced by some other letter in the alphabet – This can be chosen arbitrarily
Krypton Level 1 • If you haven’t guessed already… • We’ll just be rotating each character by 13 characters in the alphabet – A becomes N, and so on. • Use the translate command in linux to obtain password for level 3: – tr ‘A-Za-z’ ‘N-ZA-Mn-za-m’
Krypton Level 2 • Login to Level 2 with password: ROTTEN • In the README we’re given some information about this level: – It’s a substitution cipher (Caesar) – We aren’t given a key like last time (key was 13 last time)
Caesar Cipher Example: • Today’s E-mail: Good afternoon everyone! We'll be holding a meeting tonight in Shelby Center (room 3129) at 6: 00 PM CST. Ezytrse hp'ww mp elwvtyr lmzfe Ncjaelylwjdtd (zc Ncjaezrclasj). Hp'ww mp otdnfddtyr esp otqqpcpynpd mpehppy Pynzotyr, Pyncjaetzy, Sldstyr lyo Zmqfdnletzy. Hp'ww lwdz delce awljtyr Vcjaezy zy Zgpcesphtcp. zcr, dz jzf'ww yppo lnnpdd ez DDS. Lwdz, tq jzf'gp opncjaepo estd dfnnpddqfwwj, Nzyrcled! Jzf'cp zyp depa lsplo zq ezytrse'd xppetyr. Slaaj Slnvtyr! (Hail Caesar)
Caesar Cipher Example • Encrypted Using Rotation of 1337 Good afternoon everyone! We'll be holding a meeting tonight in Shelby Center (room 3129) at 6: 00 PM CST. Tonight we'll be talking about Cryptanalysis (or Cryptography). We'll be discussing the differences between Encoding, Encryption, Hashing and Obfuscation. We'll also start playing Krypton on Overthewire. org, so you'll need access to SSH. Also, if you've decrypted this successfully, Congrats! You're one step ahead of tonight's meeting. Happy Hacking! (Hail Caesar) • Can be decrypted using rotation of 15
Krypton Level 2 • Brute-force the password with Caesar shifts (there are only 26 options). • How we’re supposed to do it: – – – – Create temp directory using: mktemp –d Go there: cd /tmp. yourcodehere Create symlink to keyfile. dat file: ln –s /krypton 2/keyfile. dat Give it top permissions: chmod 777 keyfile. dat Give keyfile. dat the entire alphabet: vi alphabet Encode it: /krypton 2/encrypt alphabet Read ciphertext and find rotation (should be 12) Read krypton 3 file, and use translate to rotate everything back: cat krypton 3 | tr ‘M-ZA-Lm-za-l’ ‘A-Za-z’
Krypton Level 2 • How I did it: • Use online tool: http: //quipqiup. com/index. php
Krypton Level 3 • Login to Krypton 3 with password: CAESARISEASY • The README gives us some information: – – – – Caesar Cipher’s weakness is repeated use of a single key We’re not given the key this time We’re lucky to have intercepted a few messages It’s all in plaintext Messages were produced from the same key Some letters are more prevalent than others “Frequency Analysis” is our friend here
Krypton 3
Frequency Analysis • Studying how frequently each letter of the alphabet appears within a particular language. • ‘e’ is the most common letter in the English language • By finding ‘e’ we can find the majority of the ciphertext. • This is not always easy.
Krypton Level 3 • Here’s a neat little tool to help us out: http: //www. cryptoclub. org/tools/cracksub_topframe. php • Shows the percentage of letters within our ciphertext versus the percentage of letters in the English language. • Also shows decrypted letters above the ciphertext • Now all we need to do is look at word lengths and guess at the ciphertext messages.
Krypton Level 3 • Cracked: – – – A=B B=O C=I D= H E= G F= K G=N H=Q I= V J= T K= W L=Y M=U N=R O=X P=Z Q=A R=J S=E T=M U=S V=L W=D X=F Y=P Z=C
Krypton Level 4 • Login to Krypton 4 with password: BRUTE • The README gives us some information: – Substitution Cipher – Vigenere Cipher – Key length is 6
Vigenere Cipher • How it works: • P (plaintext) => PROCEED TO MEETING AS AGREED • K (key) => GOLD
Vigenere Cipher • Replicate K across P • P: P R O C E E D T O ME E T I N G A S A G R E E D • K: G O L D G O L D
Vigenere Cipher • Take each ASCII value in P and add it to K to get C • P: 15 17 14 2 4 4 3 12 4 4 19 • K: 6 14 11 3 6 14 11 • C: 21 5 25 5 10 18 4 11 19 20 11 • Each value = one letter in C, if it goes above C, wrap around to beginning: • (P+K) % C
Vigenere Cipher • We get ASCII values in return in C, as our Ciphertext • P: P R O C E E D T O M E • K: G O L D G O L • C: V F Z F K S O P K S E
Krypton Level 4 • How to crack this: – Do frequency analysis again – But this time, check the ciphertext at keylength positions (e. g: 1, 6, 12…) • It appears our favorite tool won’t quite work with this one, so let’s use a different one to help illustrate: • http: //www. simonsingh. net/The_Black_Chamber/vigenere_crackin g_tool. html
Krypton Level 4 • Copy one of the found texts into the web tool – – Hit “find repeated sequences” We know the keylength is 6, so click “ 6” on the keylength bar Click “L 1” on the buttons at the bottom of the page Do a frequency analysis on each of the L# buttons, and use the scrollbar at the bottom to move the chart. – The key will eventually show up. – Use this key to decrypt krypton 5
Krypton Level 5 • Login to Krypton 5 with password: CLEARTEXT • The README gives us some useful information: – The key is unknown now. • Basically, we just need to do the same thing as last time. – Use the web tool to perform a frequency analysis • Afterwards, find that the key for found 1 is KEYLENGTH – I facepalmed.
Krypton Level 6 • Login to Krypton 6 with password: RANDOM • The README gives us some useful information: – This is a One-Time Pad • I haven’t solved this one yet. Answer coming soon : D
- Slides: 40