Skip to content
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
25 changes: 19 additions & 6 deletions timisoaractf/Back_in_Time/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
I always hated history class. I thought history would never come in handy.
# Back in Time

It contained two files:
encrypt.py
ciphertext.txt
> I always hated history class. I thought history would never come in handy.

> [encrypt.py](encrypt.py)
> [ciphertext.txt](ciphertext.txt)

------
On reading the python code we can easily know that;

Lowercase chars have been substituted by other Lowercase char.

All other are where they are suppose to be.

<br>

We even know flag has timctf in start.
So by simple reverse subsitution we get the flag as:
timctf{Ps3udO_R4NdoM_1S_Not_RAnD0M}

So, start by simple reverse subsitution;

and making the words sensible in english;

we get the flag

------
flag = timctf{Ps3udO_R4NdoM_1S_Not_RAnD0M}
59 changes: 38 additions & 21 deletions timisoaractf/Those_Are_Rookie_Numbers/README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,50 @@
You've overheard a discussion between two classmates arguing whether the size really matters.
What does this have to do with RSA?
# Not your average RSA

Within this challenge there is single file given with RSA parameters n, e, c.
We know, by RSA algorithm.
> You've overheard a discussion between two classmates arguing whether the size really matters.
> What does this have to do with RSA?

> [params.txt](params.txt)
------
Within this challenge there is single file given with RSA parameters n, e, c

We know, by RSA algorithm
```
m = c^d mod(n)
c = m^e mod(n)
We need to find m here.
```
We need to find m here

So, we need to find d.
For d we need phi(n).
So, we need to find d

For d we need *phi(n)*
```
phi(n) = (p-1)(q-1)
where,

p and q are prime numbers.
p and q are prime numbers
And, n = pq

So, we go check factorizedb if we can factors.
http://www.factordb.com/index.php?query=58900433780152059829684181006276669633073820320761216330291745734792546625247
we get;
p = 176773485669509339371361332756951225661
q = 333197218785800427026869958933009188427

So, now we get phi(n) = 58900433780152059829684181006276669632563849616305906563893514443102586211160

```
So, we go check [factordb](http://www.factordb.com/index.php?query=58900433780152059829684181006276669633073820320761216330291745734792546625247) if factors are available

we get
```python
>>> p = 176773485669509339371361332756951225661
>>> q = 333197218785800427026869958933009188427
>>> phi_n = p * q
>>> print(phi_n)
58900433780152059829684181006276669632563849616305906563893514443102586211160
```
Now, we need to find d, which multiplicative inverse of e mod(phi(n)).
Thus, we go on using a python code saved as d_find.py
we get, d = 13699426463079754153895905688064380048051799131808763503874587494945034432713

Now, for final c decode we use our c_decode.py
Thus, we go on using [d_find.py](d_find.py)
```Shell
$ python d_find.py 58900433780152059829684181006276669632563849616305906563893514443102586211160 65537
13699426463079754153895905688064380048051799131808763503874587494945034432713
```
Now, finally for flag [c_decode.py](c_decode.py)
```Shell
$ python c_decode.py 56191946659070299323432594589209132754159316947267240359739328886944131258862 13699426463079754153895905688064380048051799131808763503874587494945034432713 58900433780152059829684181006276669633073820320761216330291745734792546625247
timctf{th0sE_rOoKIe_numB3rz}
```

And, voila the flag is:
timctf{th0sE_rOoKIe_numB3rz}
11 changes: 8 additions & 3 deletions timisoaractf/Those_Are_Rookie_Numbers/c_decode.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
c = 56191946659070299323432594589209132754159316947267240359739328886944131258862
d = 13699426463079754153895905688064380048051799131808763503874587494945034432713
n = 58900433780152059829684181006276669633073820320761216330291745734792546625247
import sys

# c = 56191946659070299323432594589209132754159316947267240359739328886944131258862
c = int(sys.argv[1])
# d = 13699426463079754153895905688064380048051799131808763503874587494945034432713
d = int(sys.arv[2])
# n = 58900433780152059829684181006276669633073820320761216330291745734792546625247
n = int(sys.argv[3])

p = pow(c,d,n)
size = len("{:02x}".format(n)) // 2
Expand Down
9 changes: 5 additions & 4 deletions timisoaractf/Those_Are_Rookie_Numbers/d_find.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

def egcd(a, b):
if a == 0:
return (b, 0, 1)
Expand All @@ -12,7 +14,6 @@ def modinv(a, m):
else:
return x % m

a = 65537
m = 58900433780152059829684181006276669632563849616305906563893514443102586211160

print(modinv(a,m))
print(modinv(int(sys.argv[2]),int(sys.argv[1])))
# print(modinv(65537, 58900433780152059829684181006276669632563849616305906563893514443102586211160)
# 58900433780152059829684181006276669632563849616305906563893514443102586211160