Skip to content

Mkdocs #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin/
lib/
pyvenv.cfg
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
api/bin/pip:
@echo "$(GREEN)==> Setup Virtual Env$(RESET)"
python3 -m venv .

.PHONY: start
start:
@echo "start mkdocs server"
bin/mkdocs serve

.PHONY: install
install: api/bin/pip
@echo "setting up mkdocs server"
bin/pip install -r requirements.txt

.PHONY: clean
clean:
@echo "removing py build"
rm -rf bin lib pyvenv.cfg
2 changes: 1 addition & 1 deletion 01-setup.md → docs/01-setup.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Raspberry Pi Training - Setup and Login via SSH
# 01 - Setup and Login via SSH

## Set Up Raspberry Pi

Expand Down
10 changes: 5 additions & 5 deletions 02-brute-force-ssh.md → docs/02-brute-force-ssh.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Brute Force Attack Raspberry Pi
# 02 - Brute Force Attack

## Ideas

Expand Down Expand Up @@ -125,18 +125,18 @@ Why is the math behind this important?

Function to calculate the possible password combinations:

````
```
<CHARACTER-SET> ^ <NUMBER-OF-CHARACTERS>
````
```

Further reading: https://www.scientificamerican.com/article/the-mathematics-of-hacking-passwords/

# Lessons Learned

- Brute force attacks do not scale if the password and the used alphabet have a sufficient size
- Trying all username/password combinations will make the problem harder to solve -> this is why not exposing the information if a username is known is a good thing
- Don't try stupid things before doing the math

# Harden Raspberry Pi

## Firewall
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Simple HTTP Server
# 03 - Simple HTTP Server

Start a simple webserver on the Raspberry Pi:

Expand All @@ -8,30 +8,30 @@ python3 -m http.server

Type the IP address with the Port 8000 into your browser:

`````
```
192.168.0.1:8000
`````
```

You should see the file system of the Raspberry Pi in your webbrowser.

# Server a simple Hello World HTML page

Create a folder you want to serve:

````
```
mkdir /srv/www/
````
```

Create an HTML file "index.html" with the following content within the "srv" directory:

````
```
<h1>Hello World</h1>
````
```

Safe the file and start the Python webserver in that directory:

````
```
python3 -m http.server
````
```

Go to your browser and you will see a "Hello World" web page.
24 changes: 11 additions & 13 deletions 04-add-real-webserver.md → docs/04-add-real-webserver.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Install a real webserver (Nginx)
# 04 - Real Webserver (Nginx)

Install Nginx:

````
```
sudo apt install nginx
````
```

# Check hello world page

Expand Down Expand Up @@ -36,7 +36,6 @@ service nginx start

Add a new config file "hello-world" to /etc/nginx/sites-available with the following content:


```
server {
listen 80;
Expand All @@ -55,33 +54,32 @@ server {

Enable the config in Nginx by creating a symlink to /etc/nginx/sites-enabled:

````
```
sudo su
cd /etc/nginx/sites-enabled
ln -s ../sites-available .
`````
```

Reload Nginx Configuration:

````
```
service nginx reload
````
```

Check output and make sure there are no error traces.

If there is a problem check the Nginx error log with:

````
```
tail -f /var/log/nginx/error.log
````
```

Now we have to edit the hosts configuration file on our local machine (not the Raspberry Pi!). Add the following line to your /etc/hosts file:

````
```
192.168.178.160 helloworld.de
````
```

Type "helloworld.de" into your browser window.

You should see your hello world HTML page content.

File renamed without changes.
172 changes: 172 additions & 0 deletions docs/hd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# Hard Disk

## Connect

Connect a hard disk to the Raspberry Pi via an SATA to USB adapter.

Check if HD has been detected with "df":

```
$ df -h
Dateisystem Größe Benutzt Verf. Verw% Eingehängt auf
/dev/root 15G 5,9G 7,8G 43% /
devtmpfs 776M 0 776M 0% /dev
tmpfs 937M 0 937M 0% /dev/shm
tmpfs 375M 1,2M 374M 1% /run
tmpfs 5,0M 4,0K 5,0M 1% /run/lock
/dev/mmcblk0p1 255M 51M 205M 20% /boot
tmpfs 188M 24K 188M 1% /run/user/1000
/dev/sda2 112G 18G 95G 16% /media/leo/886
```

## Check HD

Install smartmontools:

```
sudo apt install smartmontools
```

Check smart status of HD:

```
sudo smartctl --all /dev/sda2
smartctl 7.2 2020-12-30 r5155 [armv7l-linux-5.15.76-v7l+] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor: Hitachi
Product: HTS542512K9SA00
Revision: BB2A
User Capacity: 120.034.122.240 bytes [120 GB]
Logical block size: 512 bytes
scsiModePageOffset: response length too short, resp_len=4 offset=4 bd_len=0
scsiModePageOffset: response length too short, resp_len=4 offset=4 bd_len=0
>> Terminate command early due to bad response to IEC mode page
A mandatory SMART command failed: exiting. To continue, add one or more '-T permissive' options.
```

Run Test:

```
$ sudo smartctl --test=long /dev/sda2
smartctl 7.2 2020-12-30 r5155 [armv7l-linux-5.15.76-v7l+] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

Long (extended) offline self test failed [unsupported field in scsi command]
```

Check smart status for external HD via USB:

```
sudo smartctl -A -d sat /dev/sda
smartctl 7.2 2020-12-30 r5155 [armv7l-linux-5.15.76-v7l+] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000b 100 100 062 Pre-fail Always - 0
2 Throughput_Performance 0x0005 100 100 040 Pre-fail Offline - 0
3 Spin_Up_Time 0x0007 253 253 033 Pre-fail Always - 1
4 Start_Stop_Count 0x0012 063 063 000 Old_age Always - 58487
5 Reallocated_Sector_Ct 0x0033 100 100 005 Pre-fail Always - 0
7 Seek_Error_Rate 0x000b 100 100 067 Pre-fail Always - 0
8 Seek_Time_Performance 0x0005 100 100 040 Pre-fail Offline - 0
9 Power_On_Hours 0x0012 075 075 000 Old_age Always - 11207
10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 289
191 G-Sense_Error_Rate 0x000a 100 100 000 Old_age Always - 0
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 58
193 Load_Cycle_Count 0x0012 071 071 000 Old_age Always - 292283
194 Temperature_Celsius 0x0002 229 229 000 Old_age Always - 24 (Min/Max 18/53)
195 Hardware_ECC_Recovered 0x000a 100 100 000 Old_age Always - 0
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
197 Current_Pending_Sector 0x0022 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0008 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age Always - 0
223 Load_Retry_Count 0x000a 100 100 000 Old_age Always - 0
```

Run test on USB hd:

```
sudo smartctl -A -d sat --test=long /dev/sda
smartctl 7.2 2020-12-30 r5155 [armv7l-linux-5.15.76-v7l+] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000b 100 100 062 Pre-fail Always - 0
2 Throughput_Performance 0x0005 100 100 040 Pre-fail Offline - 0
3 Spin_Up_Time 0x0007 253 253 033 Pre-fail Always - 1
4 Start_Stop_Count 0x0012 063 063 000 Old_age Always - 58488
5 Reallocated_Sector_Ct 0x0033 100 100 005 Pre-fail Always - 0
7 Seek_Error_Rate 0x000b 100 100 067 Pre-fail Always - 0
8 Seek_Time_Performance 0x0005 100 100 040 Pre-fail Offline - 0
9 Power_On_Hours 0x0012 075 075 000 Old_age Always - 11208
10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 289
191 G-Sense_Error_Rate 0x000a 100 100 000 Old_age Always - 0
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 58
193 Load_Cycle_Count 0x0012 071 071 000 Old_age Always - 292285
194 Temperature_Celsius 0x0002 229 229 000 Old_age Always - 24 (Min/Max 18/53)
195 Hardware_ECC_Recovered 0x000a 100 100 000 Old_age Always - 0
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
197 Current_Pending_Sector 0x0022 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0008 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age Always - 0
223 Load_Retry_Count 0x000a 100 100 000 Old_age Always - 0

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Extended self-test routine immediately in off-line mode".
Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 56 minutes for test to complete.
Test will complete after Sun Jan 15 10:29:39 2023 GMT
Use smartctl -X to abort test.
```

Check status again after test has ended:

```
$ sudo smartctl -A -d sat /dev/sda
smartctl 7.2 2020-12-30 r5155 [armv7l-linux-5.15.76-v7l+] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000b 100 100 062 Pre-fail Always - 0
2 Throughput_Performance 0x0005 100 100 040 Pre-fail Offline - 0
3 Spin_Up_Time 0x0007 253 253 033 Pre-fail Always - 1
4 Start_Stop_Count 0x0012 063 063 000 Old_age Always - 58491
5 Reallocated_Sector_Ct 0x0033 100 100 005 Pre-fail Always - 0
7 Seek_Error_Rate 0x000b 100 100 067 Pre-fail Always - 0
8 Seek_Time_Performance 0x0005 100 100 040 Pre-fail Offline - 0
9 Power_On_Hours 0x0012 075 075 000 Old_age Always - 11208
10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 289
191 G-Sense_Error_Rate 0x000a 100 100 000 Old_age Always - 0
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 58
193 Load_Cycle_Count 0x0012 071 071 000 Old_age Always - 292290
194 Temperature_Celsius 0x0002 220 220 000 Old_age Always - 25 (Min/Max 18/53)
195 Hardware_ECC_Recovered 0x000a 100 100 000 Old_age Always - 0
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
197 Current_Pending_Sector 0x0022 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0008 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age Always - 0
223 Load_Retry_Count 0x000a 100 100 000 Old_age Always - 0
```

## Format HD

todo?

## Mount HD

todo?
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Start

Learn the basics of Operation Systems and Networks with the Raspberry Pi.
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
site_name: Raspberry Pi Training
theme:
name: material
26 changes: 26 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
certifi==2022.12.7
charset-normalizer==3.0.1
click==8.1.3
colorama==0.4.6
ghp-import==2.1.0
idna==3.4
importlib-metadata==6.0.0
Jinja2==3.1.2
Markdown==3.3.7
MarkupSafe==2.1.2
mergedeep==1.3.4
mkdocs==1.4.2
mkdocs-material==9.0.6
mkdocs-material-extensions==1.1.1
packaging==23.0
Pygments==2.14.0
pymdown-extensions==9.9.1
python-dateutil==2.8.2
PyYAML==6.0
pyyaml_env_tag==0.1
regex==2022.10.31
requests==2.28.2
six==1.16.0
urllib3==1.26.14
watchdog==2.2.1
zipp==3.11.0