n = 10283681839193276126097189449431804469761940095295471888398234447479454966284763902940257262270896218602885591849219329295416054197234326881779747263501982465102957508563705432633950651360492963151374387619070656704554971992649022858286686244477458518219811343940208016922937570643216329114427596008380607613093481777894261584227765149699743645734317383348201997748556656749211035951710759363655486663011079526697122026161182876988679088458171192764980121987583057238040415225285169219391637708267493561674900564748140379192079752942242600521017002960185256025253900075152690586476143729320416895984549165574371936823
c = 0x5c93ba85692a8b3981a5d47be0e80d129b8a2f6cf4dc134547aa7e1620f6691513b1dc1d69e085c39e261c2b49026436bb243dba70a86f7fcd1a3a7e6b0f0ecfac015becad0a76e9cf208d5d31e2b4865
e = 3

 

해당 문제는 낮은 지수 공격으로 e 값은 작고 n 값은 매우 경우이다.

 

[Exploit]

from gmpy2 import *



c = 0x5c93ba85692a8b3981a5d47be0e80d129b8a2f6cf4dc134547aa7e1620f6691513b1dc1d69e085c39e261c2b49026436bb243dba70a86f7fcd1a3a7e6b0f0ecfac015becad0a76e9cf208d5d31e2b4865



with local_context() as ctx:

    ctx.precision = 3000

    m = cbrt(c)

    #m = iroot(c, 3)[0]

   

    print ('%x' % int(m)).decode("hex")

'CTF > HackCTF' 카테고리의 다른 글

[Cryptography] RSA3  (0) 2020.01.11
[Cryptography] RSA2  (0) 2020.01.11
[Cryptography] DNA  (0) 2020.01.11
[Cryptography] Classic Cipher -4  (0) 2020.01.11
[Cryptography] Classic Cipher -3  (0) 2020.01.11
[Cryptography] Classic Cipher -2  (0) 2020.01.11

 

 

n = 675517326695494061190287679557796696358902817969424171685361

c = 0xe3712876ea77c308083ef596a32c5ce2d7edf22abbc58657e

 

도움 : https://www.alpertron.com.ar/ECM.HTM

 

p = 804811499343607200702893651293

q = 839348502408870119614692320677

phi = 21 666250 324845 688377 538645 829331 393191 999621 542715 910095 508724

 

<flag code>

from Crypto.Util.number import *

n = 675517326695494061190287679557796696358902817969424171685361
c = 0xe3712876ea77c308083ef596a32c5ce2d7edf22abbc58657e
p = 804811499343607200702893651293
q = 839348502408870119614692320677
e = 65537
phi = (p - 1) * (q - 1)
d = inverse(e, phi)
flag = long_to_bytes(pow(c, d, n))

print flag

 

 

FLAG : HackCTF{That's_4_Pr1m3!}

'CTF > HackCTF' 카테고리의 다른 글

[Cryptography] RSA3  (0) 2020.01.11
[Cryptography] RSA2  (0) 2020.01.11
[Cryptography] DNA  (0) 2020.01.11
[Cryptography] Classic Cipher -4  (0) 2020.01.11
[Cryptography] Classic Cipher -3  (0) 2020.01.11
[Cryptography] Classic Cipher -2  (0) 2020.01.11

 

<DNA CODE>

 

 

 

표를 참고해서 대칭일테니 앞부분 GTCATAATGCCGGGACTTGGT 이건 HackCTF이고 뒷부분은 적당히 찾아 플래그를 얻으면 된다

 

라고 생각했는데 아니더라 ㅎㅎ;

 

추출 : TmowOFR{e0_saap_PZ4}

 

도움 : https://www.dcode.fr/affine-cipher

 

추출한 문자 사이트로 돌리면 뚝딱나옴.

 

 

FLAG : HackCTF{s0_good_DN4}

'CTF > HackCTF' 카테고리의 다른 글

[Cryptography] RSA3  (0) 2020.01.11
[Cryptography] RSA2  (0) 2020.01.11
[Cryptography] DNA  (0) 2020.01.11
[Cryptography] Classic Cipher -4  (0) 2020.01.11
[Cryptography] Classic Cipher -3  (0) 2020.01.11
[Cryptography] Classic Cipher -2  (0) 2020.01.11

 

 

특수문자 종류를 보면 알파벳 종류와 같기 때문에 아무 특수문자 하나를 알파벳으로 교체한 뒤,

 

도움 : https://quipqiup.com/

 

사이트를 통해 플래그를 얻으면 된다.

 

<평문>

in cryptography, a substitution cipher is a method of encrypting by which units of plaintext are replaced with ciphertext, according to a fixed system; the "units" may be single letters (the most common), pairs of letters, triplets of letters, mixtures of the above, and so forth. the receiver deciphers the text by performing the inverse substitution. substitution ciphers can be compared with transposition ciphers. in a transposition cipher, the units of the plaintext are rearranged in a different and usually quite complex order, but the units themselves are left unchanged. by contrast, in a substitution cipher, the units of the plaintext are retained in the same sequence in the ciphertext, but the units themselves are altered. there are a number of different types of substitution cipher. if the cipher operates on single letters, it is termed a simple substitution cipher; a cipher that operates on larger groups of letters is termed polygraphic. a monoalphabetic cipher uses fixed substitution over the entire message, whereas a polyalphabetic cipher uses a number of substitutions at different positions in the message, where a unit from the plaintext is mapped to one of several possibilities in the ciphertext and vice versa. although the traditional keyword method for creating a mixed substitution alphabet is simple, a serious disadvantage is that the last letters of the alphabet (which are mostly low frequency) tend to stay at the end. a stronger way of constructing a mixed alphabet is to perform a columnar transposition on the ordinary alphabet using the keyword, but this is not often done. although the number of possible keys is very large, this cipher is not very strong, and is easily broken. provided the message is of reasonable length (see below), the cryptanalyst can deduce the probable meaning of the most common symbols by analyzing the frequency distribution of the ciphertext. this allows formation of partial words, which can be tentatively filled in, progressively expanding the (partial) solution (see frequency analysis for a demonstration of this). in some cases, underlying words can also be determined from the pattern of their letters; for example, attract, osseous, and words with those two as the root are the only common english words with the pattern abbcadb. many people solve such ciphers for recreation, as with cryptogram puzzles in the newspaper. according to the unicity distance of english, 27.6 letters of ciphertext are required to crack a mixed alphabet simple substitution. in practice, typically about 50 letters are needed, although some messages can be broken with fewer if unusual patterns are found. in other cases, the plaintext can be contrived to have a nearly flat frequency distribution, and much longer plaintexts will then be required by the cryptanalyst. the flag is ##############################

'CTF > HackCTF' 카테고리의 다른 글

[Cryptography] RSA2  (0) 2020.01.11
[Cryptography] DNA  (0) 2020.01.11
[Cryptography] Classic Cipher -4  (0) 2020.01.11
[Cryptography] Classic Cipher -3  (0) 2020.01.11
[Cryptography] Classic Cipher -2  (0) 2020.01.11
[Forensics] Magic PNG  (0) 2020.01.11

 

도움 : https://www.dcode.fr/affine-cipher

 

사이트에서 암호문과 키를 넣고 돌리면 플래그 나옴.

 

 

FLAG : HackCTF{Cl4ss1c_C1pher_1s_very_e4sy_1f91qaf14f}

'CTF > HackCTF' 카테고리의 다른 글

[Cryptography] DNA  (0) 2020.01.11
[Cryptography] Classic Cipher -4  (0) 2020.01.11
[Cryptography] Classic Cipher -3  (0) 2020.01.11
[Cryptography] Classic Cipher -2  (0) 2020.01.11
[Forensics] Magic PNG  (0) 2020.01.11
[Forensics] 잔상  (0) 2020.01.11

+ Recent posts