File tree 9 files changed +23
-29
lines changed
9 files changed +23
-29
lines changed Original file line number Diff line number Diff line change @@ -9,17 +9,17 @@ head -c 21 /dev/zero | ./encrypt.py "Super secret key" > cipher2
9
9
```
10
10
./encryptimage.py alexei.png smile.png
11
11
```
12
- Then open in GIMP and layer difference
12
+ Then open the resulting images in Krita and XOR layers (In GIMP, you can use layer difference but it's not quite the same)
13
13
14
+ You can also use a coomand line tool:
14
15
` sudo apt install gmic `
15
16
16
17
https://stackoverflow.com/a/40049271
17
18
```
18
- gmic alexei-encrypted .png smile-encrypted .png -blend xor -o xor1.png
19
- gmic alexei-encrypted .png smile-encrypted .png smile.png -blend xor -o xor2.png
19
+ gmic alexei-enc .png smile-enc .png -blend xor -o xor1.png
20
+ gmic alexei-enc .png smile-enc .png smile.png -blend xor -o xor2.png
20
21
```
21
22
22
-
23
23
Images:
24
24
25
25
- https://www.publicdomainpictures.net/en/view-image.php?image=128827&picture=clip-art-smiley-face
Original file line number Diff line number Diff line change @@ -21,13 +21,12 @@ pip install pycryptodome
21
21
22
22
Run the application
23
23
```
24
- export FLASK_APP=server.py
25
- flask run
24
+ FLASK_RUN_PORT=5004 FLASK_APP=server.py flask run
26
25
```
27
26
28
27
## Use the application
29
28
30
- Navigate to http://localhost:5000 , start browser developer tools, and examine the session cookie
29
+ Navigate to http://localhost:5004 , start browser developer tools, and examine the session cookie
31
30
32
31
33
32
## Break the session cookie encryption key
Original file line number Diff line number Diff line change @@ -21,22 +21,21 @@ pip install pycryptodome
21
21
22
22
Run the application
23
23
```
24
- export FLASK_APP=server.py
25
- flask run
24
+ FLASK_RUN_PORT=5005 FLASK_APP=server.py flask run
26
25
```
27
26
28
27
## Use the application
29
28
30
- Navigate to http://localhost:5000 and see what's going on
29
+ Navigate to http://localhost:5005 and see what's going on
31
30
32
31
33
32
## Padding oracle attack
34
33
35
34
See what the app tells you. Then try to go the URL with a valid message and with an invalid one, e.g.
36
35
37
- http://localhost:5000 /send?msg=deadbeef
36
+ http://localhost:5005 /send?msg=deadbeef
38
37
39
- http://localhost:5000 /send?msg=296729c7564ad3198f686f24850a16647d2a269a96d21148c1be75f45768a809396db14ddb0dc6ae1f6ee9ebe49eb49e
38
+ http://localhost:5005 /send?msg=296729c7564ad3198f686f24850a16647d2a269a96d21148c1be75f45768a809396db14ddb0dc6ae1f6ee9ebe49eb49e
40
39
41
40
(your ciphertext will be different!)
42
41
@@ -45,5 +44,5 @@ Notice the app returns different code depending on the validity.
45
44
Now run the exploit (your ciphertext will be different)
46
45
47
46
```
48
- $ ./exploit.py http://localhost:5000 /send?msg=36289eda81e4895db64c84bae1468eb21b122cebcaf1b0d81232a496d77a3238df444a038398693869ac3c598b434c59
47
+ $ ./exploit.py http://localhost:5005 /send?msg=36289eda81e4895db64c84bae1468eb21b122cebcaf1b0d81232a496d77a3238df444a038398693869ac3c598b434c59
49
48
```
Original file line number Diff line number Diff line change 1
1
< html >
2
2
< head > < title > Padding oracle</ title > </ head >
3
3
< body >
4
+ < p > Hello human!</ p >
4
5
< p > Send me an encrypted message using < a href ="send?msg= "> http://{{host}}/send?msg=</ a > </ p >
5
- < p > for example:< br />
6
- < a href ="send?msg={{msg}} "> http://{{host}}/send?msg={{msg}}</ a > < br />
7
- (you can't decrypt since you don't have the key, loser)</ p >
6
+ < p > for example: < a href ="send?msg={{msg}} "> http://{{host}}/send?msg={{msg}}</ a > </ p >
7
+ < p > < em > Note: only I can decrypt the message (you don't have the key!)</ em > </ p >
8
8
</ body >
9
9
</ html >
Original file line number Diff line number Diff line change 1
1
< html >
2
2
< head > < title > Thank you</ title > </ head >
3
3
< body >
4
- < p > Thank you for your message! We 'll get back to you soon.</ p >
4
+ < p > Thank you for your message! I 'll get back to you soon.</ p >
5
5
</ body >
6
6
</ html >
Original file line number Diff line number Diff line change @@ -21,13 +21,12 @@ pip install pycryptodome
21
21
22
22
Run the application
23
23
```
24
- export FLASK_APP=server.py
25
- flask run
24
+ FLASK_RUN_PORT=5006 FLASK_APP=server.py flask run
26
25
```
27
26
28
27
## Use the application
29
28
30
- Navigate to http://localhost:5000 , start browser developer tools, and examine the session cookie
29
+ Navigate to http://localhost:5006 , start browser developer tools, and examine the session cookie
31
30
32
31
33
32
## Bit flipping attack
@@ -56,9 +55,9 @@ Putting everything together:
56
55
57
56
58
57
```
59
- $ ./flip.py 'j/3zPw9KCchD8ofdX/EaH8BNQuPhWG0x/IG3mZa67rA17FAMygLR' '{"user": "guest", "date": "2020-01-29"}' '{"user": "admin"}'
58
+ $ ./flip.py '9G/ySV3Ry9E=. j/3zPw9KCchD8ofdX/EaH8BNQuPhWG0x/IG3mZa67rA17FAMygLR' '{"user": "guest", "date": "2020-01-29"}' '{"user": "admin"}'
60
59
61
- j/3zPw9KCchD8oHMV+sAH5E=
60
+ 9G/ySV3Ry9E=. j/3zPw9KCchD8oHMV+sAH5E=
62
61
```
63
62
64
63
Now, replace the encrypted part with the new value in the session cookie, refresh the page and behold the admin session!
Original file line number Diff line number Diff line change @@ -21,13 +21,12 @@ pip install pycryptodome
21
21
22
22
Run the application
23
23
```
24
- export FLASK_APP=server.py
25
- flask run
24
+ FLASK_RUN_PORT=5007 FLASK_APP=server.py flask run
26
25
```
27
26
28
27
## Use the application
29
28
30
- Navigate to http://localhost:5000 , start browser developer tools, and examine the session cookie
29
+ Navigate to http://localhost:5007 , start browser developer tools, and examine the session cookie
31
30
32
31
33
32
## Bit flipping attack
Original file line number Diff line number Diff line change 1
1
# Offensive Help: Crypto Mistakes ON demand! (OH C'MON!)
2
2
3
- These examples are written in Python 3 and require a couple of modules to be installed:
4
-
5
- ` pip3 install pycryptodome numpy `
3
+ These examples are written in Python 3 and may require additional modules to be installed.
6
4
7
5
See the readmes in each directory for guidance.
8
6
Original file line number Diff line number Diff line change @@ -4,4 +4,4 @@ python3 -m venv venv
4
4
source venv/bin/activate
5
5
pip install Flask
6
6
pip install pycryptodome
7
- FLASK_APP=server.py flask run --port $1
7
+ FLASK_RUN_PORT= $1 FLASK_APP=server.py flask run
You can’t perform that action at this time.
0 commit comments