File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
trend-micro-ctf-2015/crypto/crypto-100 Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ -----BEGIN PUBLIC KEY-----
2
+ MDwwDQYJKoZIhvcNAQEBBQADKwAwKAIhALYtzp8lgWNXI9trGI8S8EacvuDLxdrL
3
+ NsNuDJa26nv8AgMBAAE=
4
+ -----END PUBLIC KEY-----
Original file line number Diff line number Diff line change
1
+ [ ] ( ctf=trend-micro-ctf-2015 )
2
+ [ ] ( type=crypto )
3
+ [ ] ( tags=rsa )
4
+ [ ] ( tools=factordb,rsatool,openssl )
5
+ [ ] ( techniques=rsa )
6
+
7
+ # crypto-100
8
+
9
+ Problem description
10
+ > You're given an RSA public key and an encrypted message which contains a flag. Get the flag.
11
+ >
12
+ > There's also a hint about "1bit" being wrong in the public key.
13
+ >
14
+ > message: kPmDFLk5b/torG53sThWwEeNm0AIpEQek0rVG3vCttc=
15
+
16
+ So lets go ahead and get the modulus (n) and exponent (e) from the given [ public key] ( ../PublicKey.pem )
17
+ ``` bash
18
+ $ openssl rsa -pubin -inform PEM -text -noout < PublicKey.pem
19
+ Public-Key: (256 bit)
20
+ Modulus:
21
+ 00:b6:2d:ce:9f:25:81:63:57:23:db:6b:18:8f:12:
22
+ f0:46:9c:be:e0:cb:c5:da:cb:36:c3:6e:0c:96:b6:
23
+ ea:7b:fc
24
+ Exponent: 65537 (0x10001)
25
+ ```
26
+ n's value in base 10 is 82401872610398250859431855480217685317486932934710222647212042489320711027708
27
+
28
+ Hmm, n is even? Question says 1 bit is wrong.. it has to be last bit!
29
+
30
+ So, n must be 82401872610398250859431855480217685317486932934710222647212042489320711027709
31
+
32
+ Lets try http://www.factordb.com/index.php?query=82401872610398250859431855480217685317486932934710222647212042489320711027709
33
+
34
+ Perfect! Got p and q.
35
+
36
+ Let's generate private key and decrypt
37
+ ``` bash
38
+ $ python2 rsatool.py -f PEM -o private.pem -p 279125332373073513017147096164124452877 -q 295214597363242917440342570226980714417
39
+ $ echo " kPmDFLk5b/torG53sThWwEeNm0AIpEQek0rVG3vCttc=" > flag.enc
40
+ $ base64 -d flag.enc | openssl rsautl -decrypt -inkey private.pem
41
+ ```
42
+
43
+ Aand we get out flag
44
+ > TMCTF{$@!zbo4+qt9=5}
You can’t perform that action at this time.
0 commit comments