본문 바로가기

[Wargame Write-up]/HackThis!!

[HackThis!!] [CRYPT] LEVEL 2

Crypt 2번째 문제이다.


Caesar 암호의 냄새가 난다. 콜론 앞의 teww라는 단어, 혹시 pass는 아닐까?




Caesar 암호 문제는 여러 번 풀어봤기에, 코드를 재탕할 수 있다.


대문자까지 변환하기 위해, 전부 소문자로 통일시켰다.


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
 
import os
import string
 
ciphertext = "Aipgsqi fego, xlmw pizip mw rsx ew iewc ew xli pewx fyx wxmpp rsx xss gleppirkmrk."
ciphertext += " Ws ks elieh erh irxiv xlmw teww: wlmjxxlexpixxiv"
 
os.system("cls")
print "[*] Generate Candidate of Plaintext as \"candidate[key]: plaintext\""
 
for key in range(26):
    plaintext_candidate = ""
 
    for char in ciphertext.lower():
        tmp_char_ascii = ord(char) + key
 
        if char in list(string.lowercase):
            if tmp_char_ascii > ord('z'):
                tmp_char_ascii -= 26
 
            plaintext_candidate += chr(tmp_char_ascii)
 
        else:
            plaintext_candidate += char
            continue
 
    print "\tcandidate[%d]: %s" % (key, plaintext_candidate)
 
print "\n[*] Finish Brute Forcing"
 
 
cs



cmd에서 보면 보기 힘드니 IO Redirection을 이용해 txt로 저장하자.





결과 중 하나에 제대로 된 영어 문장이 보인다.


처음에 했던 예상도 적중했다...




'[Wargame Write-up] > HackThis!!' 카테고리의 다른 글

[HackThis!!] [CRYPT] LEVEL 4  (0) 2016.12.22
[HackThis!!] [CRYPT] LEVEL 3  (0) 2016.12.22
[HackThis!!] [CRYPT] LEVEL 1  (0) 2016.12.21
[HackThis!!] [INTERMEDIATE] LEVEL 5  (0) 2016.12.19
[HackThis!!] [INTERMEDIATE] LEVEL 4  (0) 2016.12.19