update readme
This commit is contained in:
@@ -24,7 +24,7 @@ HTB{4ff1n3_c1ph3r_15_51mpl3_m47h5}
|
|||||||
- So it's possible to attack the encryption by iterating and trying to create a pair (a, b) that matches the entire encrypted pdf header.
|
- So it's possible to attack the encryption by iterating and trying to create a pair (a, b) that matches the entire encrypted pdf header.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def get_factors(ct, n=256):
|
def get_factors(ct:bytes, n:int=256) -> (int, int):
|
||||||
''' find a and b for n and ct '''
|
''' find a and b for n and ct '''
|
||||||
# first generate a list of all numbers without common divisor with 256
|
# first generate a list of all numbers without common divisor with 256
|
||||||
nogcds = [ x for x in range(1, n) if gcd(x, n) == 1 ]
|
nogcds = [ x for x in range(1, n) if gcd(x, n) == 1 ]
|
||||||
@@ -43,7 +43,7 @@ def get_factors(ct, n=256):
|
|||||||
- When the factors are found, simply create a lookup table of all values and substitute each byte in the ciphertext.
|
- When the factors are found, simply create a lookup table of all values and substitute each byte in the ciphertext.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def decrypt(ct):
|
def decrypt(ct:bytes) -> bytes:
|
||||||
''' decrypt the file using the lookup table '''
|
''' decrypt the file using the lookup table '''
|
||||||
res = b''
|
res = b''
|
||||||
for byte in ct:
|
for byte in ct:
|
||||||
|
|||||||
Reference in New Issue
Block a user