From 6b190ffa6217cd09ecd9a0efb63dd15e80f51837 Mon Sep 17 00:00:00 2001 From: neptunia Date: Fri, 10 Mar 2017 19:23:22 -0500 Subject: [PATCH] now it works --- rsa1/description.md | 6 +- rsa1/description.md.BACKUP.129.md | 8 --- rsa1/description.md.BACKUP.137.md | 8 --- rsa1/description.md.BACKUP.20.md | 8 --- rsa1/description.md.BASE.129.md | 1 - rsa1/description.md.BASE.137.md | 1 - rsa1/description.md.BASE.20.md | 1 - rsa1/description.md.LOCAL.129.md | 5 -- rsa1/description.md.LOCAL.137.md | 5 -- rsa1/description.md.LOCAL.20.md | 5 -- rsa1/description.md.REMOTE.129.md | 0 rsa1/description.md.REMOTE.137.md | 0 rsa1/description.md.REMOTE.20.md | 0 rsa1/grader.py | 105 ++++++++++++++---------------- rsa1/problem.yml | 22 ++----- rsa1/rsa3 | 2 - 16 files changed, 55 insertions(+), 122 deletions(-) delete mode 100644 rsa1/description.md.BACKUP.129.md delete mode 100644 rsa1/description.md.BACKUP.137.md delete mode 100644 rsa1/description.md.BACKUP.20.md delete mode 100644 rsa1/description.md.BASE.129.md delete mode 100644 rsa1/description.md.BASE.137.md delete mode 100644 rsa1/description.md.BASE.20.md delete mode 100644 rsa1/description.md.LOCAL.129.md delete mode 100644 rsa1/description.md.LOCAL.137.md delete mode 100644 rsa1/description.md.LOCAL.20.md delete mode 100644 rsa1/description.md.REMOTE.129.md delete mode 100644 rsa1/description.md.REMOTE.137.md delete mode 100644 rsa1/description.md.REMOTE.20.md delete mode 100644 rsa1/rsa3 diff --git a/rsa1/description.md b/rsa1/description.md index c61c847..d44c07b 100644 --- a/rsa1/description.md +++ b/rsa1/description.md @@ -1,5 +1 @@ -<<<<<<< HEAD -I found somebody's notes on their private RSA! Help me crack [this](${ciphertext_txt}). -======= -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 +I found somebody's notes on their private RSA! Help me crack [this](${ciphertext_txt}). \ No newline at end of file diff --git a/rsa1/description.md.BACKUP.129.md b/rsa1/description.md.BACKUP.129.md deleted file mode 100644 index 68f5e9f..0000000 --- a/rsa1/description.md.BACKUP.129.md +++ /dev/null @@ -1,8 +0,0 @@ -<<<<<<< HEAD -<<<<<<< HEAD -I found somebody's notes on their private RSA! Help me crack [this](${ciphertext_txt}). -======= -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 -======= ->>>>>>> f9a58afef003d40f3ada9c1645eda26363521cf3 diff --git a/rsa1/description.md.BACKUP.137.md b/rsa1/description.md.BACKUP.137.md deleted file mode 100644 index 68f5e9f..0000000 --- a/rsa1/description.md.BACKUP.137.md +++ /dev/null @@ -1,8 +0,0 @@ -<<<<<<< HEAD -<<<<<<< HEAD -I found somebody's notes on their private RSA! Help me crack [this](${ciphertext_txt}). -======= -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 -======= ->>>>>>> f9a58afef003d40f3ada9c1645eda26363521cf3 diff --git a/rsa1/description.md.BACKUP.20.md b/rsa1/description.md.BACKUP.20.md deleted file mode 100644 index 68f5e9f..0000000 --- a/rsa1/description.md.BACKUP.20.md +++ /dev/null @@ -1,8 +0,0 @@ -<<<<<<< HEAD -<<<<<<< HEAD -I found somebody's notes on their private RSA! Help me crack [this](${ciphertext_txt}). -======= -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 -======= ->>>>>>> f9a58afef003d40f3ada9c1645eda26363521cf3 diff --git a/rsa1/description.md.BASE.129.md b/rsa1/description.md.BASE.129.md deleted file mode 100644 index 6f6a960..0000000 --- a/rsa1/description.md.BASE.129.md +++ /dev/null @@ -1 +0,0 @@ -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. \ No newline at end of file diff --git a/rsa1/description.md.BASE.137.md b/rsa1/description.md.BASE.137.md deleted file mode 100644 index 6f6a960..0000000 --- a/rsa1/description.md.BASE.137.md +++ /dev/null @@ -1 +0,0 @@ -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. \ No newline at end of file diff --git a/rsa1/description.md.BASE.20.md b/rsa1/description.md.BASE.20.md deleted file mode 100644 index 6f6a960..0000000 --- a/rsa1/description.md.BASE.20.md +++ /dev/null @@ -1 +0,0 @@ -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. \ No newline at end of file diff --git a/rsa1/description.md.LOCAL.129.md b/rsa1/description.md.LOCAL.129.md deleted file mode 100644 index c61c847..0000000 --- a/rsa1/description.md.LOCAL.129.md +++ /dev/null @@ -1,5 +0,0 @@ -<<<<<<< HEAD -I found somebody's notes on their private RSA! Help me crack [this](${ciphertext_txt}). -======= -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 diff --git a/rsa1/description.md.LOCAL.137.md b/rsa1/description.md.LOCAL.137.md deleted file mode 100644 index c61c847..0000000 --- a/rsa1/description.md.LOCAL.137.md +++ /dev/null @@ -1,5 +0,0 @@ -<<<<<<< HEAD -I found somebody's notes on their private RSA! Help me crack [this](${ciphertext_txt}). -======= -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 diff --git a/rsa1/description.md.LOCAL.20.md b/rsa1/description.md.LOCAL.20.md deleted file mode 100644 index c61c847..0000000 --- a/rsa1/description.md.LOCAL.20.md +++ /dev/null @@ -1,5 +0,0 @@ -<<<<<<< HEAD -I found somebody's notes on their private RSA! Help me crack [this](${ciphertext_txt}). -======= -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 diff --git a/rsa1/description.md.REMOTE.129.md b/rsa1/description.md.REMOTE.129.md deleted file mode 100644 index e69de29..0000000 diff --git a/rsa1/description.md.REMOTE.137.md b/rsa1/description.md.REMOTE.137.md deleted file mode 100644 index e69de29..0000000 diff --git a/rsa1/description.md.REMOTE.20.md b/rsa1/description.md.REMOTE.20.md deleted file mode 100644 index e69de29..0000000 diff --git a/rsa1/grader.py b/rsa1/grader.py index 4f6a800..4f42f65 100644 --- a/rsa1/grader.py +++ b/rsa1/grader.py @@ -1,56 +1,49 @@ -<<<<<<< HEAD -from cStringIO import StringIO - -flag = "wh3n_y0u_h4ve_p&q_RSA_iz_ez" - -def modx(base,exp,mod): - r = 1; - while (exp > 0): - if (exp % 2 == 1): - r = (r * base) % mod - base = (base * base) % mod - exp = exp/2 - return r - -def probprime(s): - if s%2==0: - s += 1 - smolprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] - while len(set([modx(i,s-1,s) for i in smolprimes])) != 1 or modx(2,s-1,s) != 1: - s+=2 - return(s) - -def get_problem(random): - # add Probable Prime function later - p = probprime(random.randint(3*10**79,4*10**79)) - q = probprime(random.randint(3*10**79,4*10**79)) - e = 3 - salt = "".join([random.choice("0123456789abcdef") for i in range(8)]) - return (p, q, e, salt) - -def generate_ciphertext(random): - p, q, e, salt = get_problem(random) - encoded = int(("easyctf{%s_%s}" % (flag, salt)).encode('hex'),16) - ciphertext = 'p: '+str(p)+'\n' - ciphertext += 'q: '+str(q)+'\n' - ciphertext += 'e: '+str(e)+'\n' - ciphertext += 'c: '+str(pow(encoded, e, p*q))+'\n' - - return StringIO(ciphertext) - -def generate(random): - return dict(files={ - "ciphertext_rsa1.txt": generate_ciphertext - }) - -def grade(random, key): - n, salt = get_problem(random) - if key.find("%s_%s" % (flag, salt)) >= 0: - return True, "Correct!" - return False, "Nope." -======= -def grade(autogen, key): - if key.find("tw0_v3ry_merrry_tw1n_pr1m35!!_417c0d") != -1: - return True, "Really Superb! Applause!" - return False, "RIP" ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 +from cStringIO import StringIO + +flag = "wh3n_y0u_h4ve_p&q_RSA_iz_ez" + +def modx(base,exp,mod): + r = 1; + while (exp > 0): + if (exp % 2 == 1): + r = (r * base) % mod + base = (base * base) % mod + exp = exp/2 + return r + +def probprime(s): + if s%2==0: + s += 1 + smolprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] + while len(set([modx(i,s-1,s) for i in smolprimes])) != 1 or modx(2,s-1,s) != 1: + s+=2 + return(s) + +def get_problem(random): + # add Probable Prime function later + p = probprime(random.randint(3*10**79,4*10**79)) + q = probprime(random.randint(3*10**79,4*10**79)) + e = 3 + salt = "".join([random.choice("0123456789abcdef") for i in range(8)]) + return (p, q, e, salt) + +def generate_ciphertext(random): + p, q, e, salt = get_problem(random) + encoded = int(("easyctf{%s_%s}" % (flag, salt)).encode('hex'),16) + ciphertext = 'p: '+str(p)+'\n' + ciphertext += 'q: '+str(q)+'\n' + ciphertext += 'e: '+str(e)+'\n' + ciphertext += 'c: '+str(pow(encoded, e, p*q))+'\n' + + return StringIO(ciphertext) + +def generate(random): + return dict(files={ + "ciphertext_rsa1.txt": generate_ciphertext + }) + +def grade(random, key): + n, salt = get_problem(random) + if key.find("%s_%s" % (flag, salt)) >= 0: + return True, "Correct!" + return False, "Nope." diff --git a/rsa1/problem.yml b/rsa1/problem.yml index 8ff5a4d..d2e137c 100644 --- a/rsa1/problem.yml +++ b/rsa1/problem.yml @@ -1,19 +1,7 @@ -<<<<<<< HEAD -title: RSA 1 -author: neptunia -hint: Go google RSA if you're stuck. -category: Cryptography -autogen: true -programming: false -value: 25 -======= -author: blockingthesky -title: RSA 3 -hint: You might want to read up on how RSA works. +title: RSA 1 +author: neptunia +hint: Go google RSA if you're stuck. category: Cryptography -autogen: false +autogen: true programming: false -value: 70 -files: - - rsa3 ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 +value: 25 \ No newline at end of file diff --git a/rsa1/rsa3 b/rsa1/rsa3 deleted file mode 100644 index bda7c13..0000000 --- a/rsa1/rsa3 +++ /dev/null @@ -1,2 +0,0 @@ -{N : e : c} -{0x27335d21ca51432fa000ddf9e81f630314a0ef2e35d81a839584c5a7356b94934630ebfc2ef9c55b111e8c373f2db66ca3be0c0818b1d4eda7d53c1bd0067f66a12897099b5e322d85a8da45b72b828813af23L : 0x10001 : 0x9b9c138e0d473b6e6cf44acfa3becb358b91d0ba9bfb37bf11effcebf9e0fe4a86439e8217819c273ea5c1c5acfd70147533aa550aa70f2e07cc98be1a1b0ea36c0738d1c994c50b1bd633e3873fc0cb377e7L} \ No newline at end of file