Skip to content

Commit

Permalink
Update tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
hakavlad committed Apr 15, 2024
1 parent 7ad4fb0 commit f30d9b6
Showing 1 changed file with 177 additions and 66 deletions.
243 changes: 177 additions & 66 deletions docs/tutorial/9.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,152 +30,263 @@ After the write is completed, `fsync()` is executed.

---

#### Overwriting the entire 1 MB file contents with random bytes:
### Overwriting the entire file contents

<details>
<summary>Screenshots</summary>

![Screenshot](https://i.imgur.com/3TuhVyN.png)

![Screenshot](https://i.imgur.com/X0BGFEY.png)
</details>

<details>
<summary>Output</summary>

```
$ tird
$ sudo tird
[sudo] password for user:
MENU
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0. Exit 1. Show info
———————————————————————————————————————————
0. Exit 1. Info
2. Encrypt 3. Decrypt
4. Embed 5. Extract
6. Encrypt & embed 7. Extract & decrypt
8. Create w/ random 9. Overwrite w/ random
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
———————————————————————————————————————————
[01] Select an option [0-9]: 9
I: action #9: overwrite file contents with random bytes
[07] File to overwrite: 1MB
I: path: "1MB"; size: 1000000 B, 976.6 KiB
[08] Initial position, valid values are [0; 1000000], default=0:
[07] File to overwrite: /dev/sdc
I: path: "/dev/sdc"; size: 16357785600 B, 15.2 GiB
[08] Initial position, valid values are [0; 16357785600], default=0:
I: initial position: 0
[09] Final position, valid values are [0; 1000000], default=1000000:
I: final position: 1000000
I: data size to write: 1000000 B, 976.6 KiB
[09] Final position, valid values are [0; 16357785600], default=16357785600:
I: final position: 16357785600
I: data size to write: 16357785600 B, 15.2 GiB
W: output file will be partially overwritten with random bytes
[13] Proceed? (Y/N): y
I: writing...
I: written 1000000 B, 976.6 KiB, 100.0% in 0.0s, avg 111.6 MiB/s
I: written 1692008448 B, 1.6 GiB, 10.3% in 5.0s, avg 322.7 MiB/s
I: written 2280652800 B, 2.1 GiB, 13.9% in 10.0s, avg 217.2 MiB/s
I: written 2341994496 B, 2.2 GiB, 14.3% in 15.1s, avg 148.4 MiB/s
I: written 2364669952 B, 2.2 GiB, 14.5% in 20.1s, avg 112.3 MiB/s
I: written 2384199680 B, 2.2 GiB, 14.6% in 25.1s, avg 90.5 MiB/s
I: written 2403991552 B, 2.2 GiB, 14.7% in 30.1s, avg 76.1 MiB/s
I: written 2424700928 B, 2.3 GiB, 14.8% in 35.1s, avg 65.8 MiB/s
...
I: written 15990784000 B, 14.9 GiB, 97.8% in 1031.6s, avg 14.8 MiB/s
I: written 16059596800 B, 15.0 GiB, 98.2% in 1036.6s, avg 14.8 MiB/s
I: written 16129982464 B, 15.0 GiB, 98.6% in 1041.6s, avg 14.8 MiB/s
I: written 16199712768 B, 15.1 GiB, 99.0% in 1046.6s, avg 14.8 MiB/s
I: written 16269180928 B, 15.2 GiB, 99.5% in 1051.7s, avg 14.8 MiB/s
I: written 16339304448 B, 15.2 GiB, 99.9% in 1056.7s, avg 14.7 MiB/s
I: written 16357785600 B, 15.2 GiB, 100.0% in 1058.0s, avg 14.7 MiB/s
I: fsyncing...
I: fsynced in 0.0s
I: fsynced in 274.4s
I: action is completed
MENU
———————————————————————————————————————————
0. Exit 1. Info
2. Encrypt 3. Decrypt
4. Embed 5. Extract
6. Encrypt & embed 7. Extract & decrypt
8. Create w/ random 9. Overwrite w/ random
———————————————————————————————————————————
[01] Select an option [0-9]:
```
</details>

---
The same with debug messages enabled

<details>
<summary>Screenshots</summary>

![Screenshot](https://i.imgur.com/aOmSE8w.png)

#### Overwriting the entire 1 MB file contents with random bytes with debug messages enabled:
![Screenshot](https://i.imgur.com/LxHsina.png)
</details>

<details>
<summary>Output</summary>

```
$ tird -d
$ sudo tird -d
[sudo] password for user:
W: debug messages enabled!
MENU
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0. Exit 1. Show info
———————————————————————————————————————————
0. Exit 1. Info
2. Encrypt 3. Decrypt
4. Embed 5. Extract
6. Encrypt & embed 7. Extract & decrypt
8. Create w/ random 9. Overwrite w/ random
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
———————————————————————————————————————————
[01] Select an option [0-9]: 9
I: action #9: overwrite file contents with random bytes
[07] File to overwrite: 1MB
D: real path: "/tmpfs/1MB"
D: opening file "1MB" in mode "rb+"
D: opened file (object): <_io.BufferedRandom name='1MB'>
I: path: "1MB"; size: 1000000 B, 976.6 KiB
[08] Initial position, valid values are [0; 1000000], default=0:
[07] File to overwrite: /dev/sdc
D: real path: "/dev/sdc"
D: opening file "/dev/sdc" in mode "rb+"
D: opened file (object): <_io.BufferedRandom name='/dev/sdc'>
I: path: "/dev/sdc"; size: 16357785600 B, 15.2 GiB
[08] Initial position, valid values are [0; 16357785600], default=0:
I: initial position: 0
[09] Final position, valid values are [0; 1000000], default=1000000:
I: final position: 1000000
I: data size to write: 1000000 B, 976.6 KiB
[09] Final position, valid values are [0; 16357785600], default=16357785600:
I: final position: 16357785600
I: data size to write: 16357785600 B, 15.2 GiB
W: output file will be partially overwritten with random bytes
[13] Proceed? (Y/N): Y
[13] Proceed? (Y/N): y
D: current position: of=0
D: move to position 0 in <_io.BufferedRandom name='1MB'>
D: move to position 0 in <_io.BufferedRandom name='/dev/sdc'>
D: current position: of=0
I: writing...
D: current position: of=1000000
I: written 1000000 B, 976.6 KiB, 100.0% in 0.0s, avg 108.1 MiB/s
I: written 1451884544 B, 1.4 GiB, 8.9% in 5.0s, avg 275.1 MiB/s
I: written 1668415488 B, 1.6 GiB, 10.2% in 10.0s, avg 158.5 MiB/s
I: written 1799356416 B, 1.7 GiB, 11.0% in 15.0s, avg 114.1 MiB/s
I: written 1881276416 B, 1.8 GiB, 11.5% in 20.0s, avg 89.5 MiB/s
I: written 1963327488 B, 1.8 GiB, 12.0% in 25.1s, avg 74.7 MiB/s
I: written 2037645312 B, 1.9 GiB, 12.5% in 30.1s, avg 64.7 MiB/s
I: written 2105540608 B, 2.0 GiB, 12.9% in 35.1s, avg 57.3 MiB/s
...
I: written 15899951104 B, 14.8 GiB, 97.2% in 1026.8s, avg 14.8 MiB/s
I: written 15969288192 B, 14.9 GiB, 97.6% in 1031.8s, avg 14.8 MiB/s
I: written 16039280640 B, 14.9 GiB, 98.1% in 1036.8s, avg 14.8 MiB/s
I: written 16109273088 B, 15.0 GiB, 98.5% in 1041.8s, avg 14.7 MiB/s
I: written 16178348032 B, 15.1 GiB, 98.9% in 1046.8s, avg 14.7 MiB/s
I: written 16248340480 B, 15.1 GiB, 99.3% in 1051.8s, avg 14.7 MiB/s
I: written 16318332928 B, 15.2 GiB, 99.8% in 1056.8s, avg 14.7 MiB/s
D: current position: of=16357785600
I: written 16357785600 B, 15.2 GiB, 100.0% in 1059.3s, avg 14.7 MiB/s
I: fsyncing...
I: fsynced in 0.0s
D: closing <_io.BufferedRandom name='1MB'>
D: <_io.BufferedRandom name='1MB'> closed
I: fsynced in 241.8s
D: closing <_io.BufferedRandom name='/dev/sdc'>
D: <_io.BufferedRandom name='/dev/sdc'> closed
I: action is completed
MENU
———————————————————————————————————————————
0. Exit 1. Info
2. Encrypt 3. Decrypt
4. Embed 5. Extract
6. Encrypt & embed 7. Extract & decrypt
8. Create w/ random 9. Overwrite w/ random
———————————————————————————————————————————
[01] Select an option [0-9]:
```
</details>

---

#### Overwriting file contents with random data between positions 1000 and 3000 (writing 2000 random bytes):
### Overwriting a certain section of the file with random data

<details>
<summary>Screenshot</summary>

![Screenshot](https://i.imgur.com/En1zbDw.png)
</details>

<details>
<summary>Output</summary>

```
$ tird
MENU
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0. Exit 1. Show info
———————————————————————————————————————————
0. Exit 1. Info
2. Encrypt 3. Decrypt
4. Embed 5. Extract
6. Encrypt & embed 7. Extract & decrypt
8. Create w/ random 9. Overwrite w/ random
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
———————————————————————————————————————————
[01] Select an option [0-9]: 9
I: action #9: overwrite file contents with random bytes
[07] File to overwrite: 1MB
I: path: "1MB"; size: 1000000 B, 976.6 KiB
[08] Initial position, valid values are [0; 1000000], default=0: 1000
I: initial position: 1000
[09] Final position, valid values are [1000; 1000000], default=1000000: 3000
I: final position: 3000
I: data size to write: 2000 B, 2.0 KiB
[07] File to overwrite: file1
I: path: "file1"; size: 1000000 B, 976.6 KiB
[08] Initial position, valid values are [0; 1000000], default=0: 10000
I: initial position: 10000
[09] Final position, valid values are [10000; 1000000], default=1000000: 30000
I: final position: 30000
I: data size to write: 20000 B, 19.5 KiB
W: output file will be partially overwritten with random bytes
[13] Proceed? (Y/N): 1
[13] Proceed? (Y/N): y
I: writing...
I: written 2000 B, 2.0 KiB, 100.0% in 0.0s, avg 28.2 MiB/s
I: written 20000 B, 19.5 KiB, 100.0% in 0.0s, avg 62.5 MiB/s
I: fsyncing...
I: fsynced in 0.0s
I: action is completed
MENU
———————————————————————————————————————————
0. Exit 1. Info
2. Encrypt 3. Decrypt
4. Embed 5. Extract
6. Encrypt & embed 7. Extract & decrypt
8. Create w/ random 9. Overwrite w/ random
———————————————————————————————————————————
[01] Select an option [0-9]:
```
</details>

---
The same with debug messages enabled

#### Overwriting file contents with random data between positions 10000 and 50000 (writing 40000 random bytes) with debug messages enabled:
<details>
<summary>Screenshot</summary>

![Screenshot](https://i.imgur.com/aKkPY5U.png)
</details>

<details>
<summary>Output</summary>

```
$ tird -d
W: debug messages enabled!
MENU
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0. Exit 1. Show info
———————————————————————————————————————————
0. Exit 1. Info
2. Encrypt 3. Decrypt
4. Embed 5. Extract
6. Encrypt & embed 7. Extract & decrypt
8. Create w/ random 9. Overwrite w/ random
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
———————————————————————————————————————————
[01] Select an option [0-9]: 9
I: action #9: overwrite file contents with random bytes
[07] File to overwrite: 1MB
D: real path: "/tmpfs/1MB"
D: opening file "1MB" in mode "rb+"
D: opened file (object): <_io.BufferedRandom name='1MB'>
I: path: "1MB"; size: 1000000 B, 976.6 KiB
[07] File to overwrite: file1
D: real path: "/home/user/file1"
D: opening file "file1" in mode "rb+"
D: opened file (object): <_io.BufferedRandom name='file1'>
I: path: "file1"; size: 1000000 B, 976.6 KiB
[08] Initial position, valid values are [0; 1000000], default=0: 10000
I: initial position: 10000
[09] Final position, valid values are [10000; 1000000], default=1000000: 50000
I: final position: 50000
I: data size to write: 40000 B, 39.1 KiB
[09] Final position, valid values are [10000; 1000000], default=1000000: 30000
I: final position: 30000
I: data size to write: 20000 B, 19.5 KiB
W: output file will be partially overwritten with random bytes
[13] Proceed? (Y/N): y
D: current position: of=0
D: move to position 10000 in <_io.BufferedRandom name='1MB'>
D: move to position 10000 in <_io.BufferedRandom name='file1'>
D: current position: of=10000
I: writing...
D: current position: of=50000
I: written 40000 B, 39.1 KiB, 100.0% in 0.0s, avg 83.2 MiB/s
D: current position: of=30000
I: written 20000 B, 19.5 KiB, 100.0% in 0.0s, avg 66.2 MiB/s
I: fsyncing...
I: fsynced in 0.0s
D: closing <_io.BufferedRandom name='1MB'>
D: <_io.BufferedRandom name='1MB'> closed
D: closing <_io.BufferedRandom name='file1'>
D: <_io.BufferedRandom name='file1'> closed
I: action is completed
MENU
———————————————————————————————————————————
0. Exit 1. Info
2. Encrypt 3. Decrypt
4. Embed 5. Extract
6. Encrypt & embed 7. Extract & decrypt
8. Create w/ random 9. Overwrite w/ random
———————————————————————————————————————————
[01] Select an option [0-9]:
```
</details>

0 comments on commit f30d9b6

Please sign in to comment.