Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSA 2 writeup. #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [Heaps of Knowledge \[420 points\]](/binary-exploitation/heaps-of-knowledge-420-points.md)
* [Cryptography](cryptography.md)
* [RSA 1 \[50 points\]](/cryptography/rsa-1-50-points.md)
* [RSA 2 \[80 points\]](/cryptography/rsa-2-80-points.md)
* [Hash on Hash \[100 points\]](/cryptography/hash-on-hash-100-points.md)
* [Security Through Obscurity \[150 points\]](/cryptography/security-through-obscurity-150-points.md)
* [RSA 4 \[200 points\]](/cryptography/rsa-4-200-points.md)
Expand Down
2 changes: 1 addition & 1 deletion cryptography.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This category focuses on using advanced mathematical topics to encrypt data to p
* Flip My Letters \[20 points\]
* [RSA 1 \[50 points\]](/cryptography/rsa-1-50-points.md)
* Let Me Be Frank \[75 points\]
* RSA 2 \[80 points\]
* [RSA 2 \[80 points\]](/cryptography/rsa-2-80-points.md)
* Decode Me \[100 points\]
* [Hash on Hash \[100 points\]](/cryptography/hash-on-hash-100-points.md)
* RSA 3 \[135 points\]
Expand Down
46 changes: 46 additions & 0 deletions cryptography/rsa-2-80-points.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# RSA 2 - 80 points

Some more RSA! This time, there's no P and Q... [this](https://github.com/EasyCTF/easyctf-2017-problems/blob/master/rsa2/ciphertext2.txt).

```
n: 360863815763347129786223223753677186553479
e: 65537
c: 212985665370717183529999720499957413167571
```

### Solution

RSA 2 is like [RSA 1](rsa-1-50-points.md), with the difference that this time we don't have the factorization of *N*.
*N* is small enough, though, that it's easy to factor.
For example, https://www.wolframalpha.com/input/?i=prime+factorization+of+360863815763347129786223223753677186553479
gives us:

* *p* = 595630980471473199937
* *q* = 605851320019829172167

Now we can just reuse any decryption code from [RSA 1](rsa-1-50-points.md)
to find the private key *d*:

* *d* = *e*<sup>−1</sup> mod (*p*−1)(*q*−1) = 300201340241660215082768288814375000466433

Using *d*, we decrypt the ciphertext as

* *M* = *c*<sup>*d*</sup> mod *N* = 136143999223212922673501593241914978429

In hexadecimal,

* *M* = 0x666c61677b6c30775f6e5f616438307d

Interpreting each pair of hexadecimal digits as an ASCII character
(`66`→'f', `6c`→'l', etc.) reveals the flag:

```
flag{l0w_n_ad80}
```

After the competition, the
[grader.py script](https://github.com/EasyCTF/easyctf-2017-problems/blob/master/rsa2/grader.py)
showed that flags were perhaps randomly generated
as `l0w_n_` followed by a four-character random string.

### External Writeups