Skip to content

Commit

Permalink
Added docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
Matheus-Garbelini committed May 7, 2020
1 parent f7df0db commit 8243710
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
*.pyc

CC2540_connection_req_crash.pcap

release/
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cmake.configureOnOpen": false
}
2 changes: 1 addition & 1 deletion CC_connection_req_crash.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def scan_timeout():

# Yes, we're sending raw link layer messages in Python. Don't tell anyone as this is forbidden!!!
send(conn_request)
wrpcap('CC2540_connection_req_crash.pcap', conn_request)
wrpcap('logs/CC2540_connection_req_crash.pcap', conn_request)
print(Fore.YELLOW + 'Malformed connection request was sent')

# Start the timeout to detect crashes
Expand Down
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:2.7.17-slim-buster
# Default script to execute
ENV test dhcheck_skip.py
ENV port /dev/ttyACM0
ENV addr ""
WORKDIR /
# Add main python scripts and folders
ADD *.py /
ADD drivers /drivers/
ADD libs /libs/
ADD extras /extras/
ADD captures /captures/
# Add helper files
ADD nRF52_driver_firmware.zip requirements.txt install_sweyntooth.sh flash_nRF52_driver_firmware.sh /

RUN mkdir -p /logs && apt update && chmod +x install_sweyntooth.sh && ./install_sweyntooth.sh && apt-get autoremove && apt-get clean
CMD [ "sh", "-c", "python ${test} ${port} ${addr} && find ./ -maxdepth 1 -name '*.pcap' -exec cp {} logs \\; && find ./extras -maxdepth 1 -name '*.pcap' -exec cp '{}' logs \\;" ]
2 changes: 1 addition & 1 deletion Microchip_invalid_lcap_fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def scan_timeout():


# Open serial port of NRF52 Dongle
driver = NRF52Dongle(serial_port, '115200', logs_pcap=True, pcap_filename='Microchip_invalid_lcap_fragment.pcap')
driver = NRF52Dongle(serial_port, '115200', logs_pcap=True, pcap_filename='logs/Microchip_invalid_lcap_fragment.pcap')
# Send scan request
scan_req = BTLE() / BTLE_ADV(RxAdd=slave_addr_type) / BTLE_SCAN_REQ(
ScanA=master_address,
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ nrfutil dfu usb-serial -p COM_PORT -pkg nRF52_driver_firmware.zip

The scripts work on Linux or Windows. You just need to change the `COM_PORT` parameter to match the nRF52840 port name.

##### (Optional nRF52 driver flashing method)
##### (Alternative nRF52 driver flashing method)

You can alternatively flash the firmware by using the [nRF Connect App for Desktop](https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Connect-for-desktop), which gives a nice interface to flash the hex firmware (**nRF52_driver_firmware.hex**).

Expand All @@ -51,6 +51,22 @@ Taking as example the Key Size Overflow vulnerability, the following output is



### Docker image for Linux (optional)

If you wish to use SweynTooth via a docker image to avoid install Python dependencies, you can use the `docker.sh` helper script to build and run the docker instance or download the prebuild docker image ([link](https://github.com/Matheus-Garbelini/sweyntooth_bluetooth_low_energy_attacks/releases)) available on releases page. The usage of `docker.sh` is described below.

```
--------- HELP -------------
sudo ./docker run <script_name> <serial_port> <ble_target_address> - Start any sweyntooth script by its name (<script_name>)
sudo ./docker build - Build docker container
sudo ./docker build release - Build docker container and create compressed image for release
sudo ./docker shell - Start docker container shell
---------- EXAMPLE ----------
./docker.sh run extras/Microchip_and_others_non_compliant_connection.py /dev/ttyACM0 f0:f8:f2:da:09:63
```



#### Available BLE exploits

Each exploit script corresponds to one flaw. The following summary table captures the correspondence between the vulnerability and a script to exploit the vulnerability on the affected SoCs.
Expand Down Expand Up @@ -121,7 +137,7 @@ The folder **captures** contains some sample captures of each vulnerability. We

### Extras

The [extras folder](extras/) contains some additional scripts related to non-compliances and some SweynTooth variants. Check the table of extras scripts on [extras/README.m](extras/README.m)d for more information.
The [extras folder](extras/) contains some additional scripts related to non-compliances and some SweynTooth variants. Check the table of extras scripts on [extras/README.md](extras/README.m) for more information.



Expand Down
Empty file modified Telink_zero_ltk_installation.py
100644 → 100755
Empty file.
36 changes: 36 additions & 0 deletions docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

if [ "$1" == "build" ]
then
docker build -t sweyntooth:latest .
if [ "$2" == "release" ]
then
mkdir -p release
docker image save sweyntooth | gzip -9 -c > release/sweyntooth.tar.gz
chmod a+rw release/sweyntooth.tar.gz
echo "Image release/sweyntooth.tar.gz created!"
fi

elif [ "$1" == "run" ]
then
if [ -z $2 ]
then
echo "Insert python script name to start"
exit
fi

docker run --privileged --rm -e test="$2" -e port=$3 -e addr=$4 -ti --mount type=bind,source="$(pwd)"/logs,target=/logs sweyntooth # Start sweyntooth container

elif [ "$1" == "shell" ]
then
docker run --rm --entrypoint bash --mount type=bind,source="$(pwd)"/logs,target=/logs -ti sweyntooth # Start container with bash and mount files

else
echo "--------- HELP -------------"
echo "sudo ./docker run <script_name> <serial_port> <ble_target_address> - Start any sweyntooth script by its name (<script_name>)"
echo "sudo ./docker build - Build docker container"
echo "sudo ./docker build release - Build docker container and create compressed image for release"
echo "sudo ./docker shell - Start docker container shell"
echo "---------- EXAMPLE ----------"
echo "./docker.sh run extras/Microchip_and_others_non_compliant_connection.py /dev/ttyACM0 f0:f8:f2:da:09:63"
fi
Empty file modified extras/anomaly_unexpected_encryption_start.py
100644 → 100755
Empty file.
Empty file modified extras/non_compliance_data_during_encryption_setup.py
100644 → 100755
Empty file.
Empty file modified extras/non_compliance_dhcheck_skip.py
100644 → 100755
Empty file.
Empty file modified extras/non_compliance_nonzero_ediv_rand.py
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions install_smp_server.sh → install_sweyntooth.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
sudo apt install python-dev gcc g++ make -y
apt install python-dev gcc g++ make -y
python -m pip install -r requirements.txt
cd ./libs/smp_server/
make build
sudo make install
cd ../
make install
cd ../../

0 comments on commit 8243710

Please sign in to comment.