What’s new? I have received various inquiries as to whether this blog is still being maintained. Yes he still will! Currently, however, a lot has changed in my life and through various security settings of my provider I have created a few tutorials directly on GitHub. So here are 2 categories which I would like to introduce to you.
In this GitHub repository you will find instructions on how to use the small development board as a security analysis device. These instructions are simply intended to show which options the Raspberry PI offers and to provide an introduction to the topic of cyber security.
I love the Adafruit Matrix LED! With a little python you can achieve everything your heart desires super quickly and easily. To make the start a little easier for you, I’ve created a few examples with Python. You are welcome to use these or (even better) develop them further.
More???
I also started to post some pictures and videos of my work on Instagram … Yes, I have to go with time too. 😉
So if you find the time and feel like it, just drop by these platforms and let yourself be inspired for your projects.
This time I am not writing a tutorial on software. I would like to introduce you to my DIY project here. At a later point in time, however, I will focus on the newly used and partly self-developed software deeper.
Why this little project?
Over the years I have accumulated various electronic devices, cables and lots of other electrical scrap. Always storing it neatly is hell (I hate cardboard or plastic boxes). In addition, I do not live alone and should actually take all other people in the household into account. So I was looking for a better solution for my beloved girlfriend, my dog ​​(who also likes to eat things) and of course my self. In addition, everything should be tidy, ready to hand and mobile. When I then remembered my training as an electrician (especially on my toolbox), it quickly became clear to me which solution would be suitable for me. Different Suitcases made of aluminum (light and stable), where each of them have slightly different scope.
What’s in there?
Actually there are several suitcases with different contents (depending on what I have planned). I would like to show you now, two of my personal favorites here.
In addition, all cases are filled with brackets and foam so that the connecting cables are not visible (this is not shown in the pictures) and each device has a specific place.
Do you want such suitcases, too?
If you also want one (or more) suitcases and don’t have the time or inclination to build them yourself – just contact me! We can talk about it.
Note: It is important to know that each case and its contents are freely configurable (but it should fit).
Yes, this topic is very easy via VirtualBox UI and many people would not have in mind to do these actions with command line. But as I do mostly all tasks while development via terminal, I thought some other persons are interested in the solution, too. So here now a short tutorial to attach/detach USB devices on VirtualBox machines.
Learn and understand the basics for command line USB passthrough for VirtualBox.
Gather informations of USB devices
In a first step it’s important to gather all informations about possible USB devices. There are 3 important values ​​to be determined.
UUID
VendorId
ProductId
In order to better understand which devices are involved, the product name is also an advantage.
# list all usb devices
$ VBoxManage list usbhost
# list all usb devices with specific information
$ VBoxManage list usbhost | grep -i "UUID\|VendorId\|ProductId\|Product\|Current State"
The value of “Current State” can provide you the information if a USB device is in usage or captured by a VM already.
Analysis of VM’s
In the second step, it is advisable to check whether the respective USB standard is configured in the target VM (and whether USB is turned on). There are currently 3 options that VirtualBox supports.
USB 1.1: OHCI
USB 2.0: OHCI + EHCI
USB 3.0: xHCI
Note: My VM is named Debian in all examples, please change this value for your specific needs!
# show all informations for specific vm
$ VBoxManage showvminfo "Debian"
# show usb status for specific vm
$ VBoxManage showvminfo "Debian" | grep -i "ohci\|ehci\|xhci"
Add/remove USB devices
In many cases, USB 1.1 is enabled by default and deactivation leads to a misconfiguration. But there are, as almost always, exceptions.
USB 1.1: --usb on|off
USB 2.0: --usbehci on|off
USB 3.0: --usbxhci on|off
Note: For these kind of configurations the VM should be stopped (turned off).
# enable USB 2.0 for specific vm
$ VBoxManage modifyvm "Debian" --usbehci on
# disable USB 2.0 for specific vm
$ VBoxManage modifyvm "Debian" --usbehci off
# enable USB 3.0 for specific vm
$ VBoxManage modifyvm "Debian" --usbxhci on
# disable USB 3.0 for specific vm
$ VBoxManage modifyvm "Debian" --usbxhci off
If you know the UUID (see first step), you can now attach/detach the respective USB devices.
Note: You can make the following changes during the VM is running. Don’t forget to change the UUID value from my examples.
# attach specifc usb device to specifc vm
$ VBoxManage controlvm "Debian" usbattach "076866d4-436e-424d-be64-660c23248f37"
# detach specifc usb device to specifc vm
$ VBoxManage controlvm "Debian" usbdetach "076866d4-436e-424d-be64-660c23248f37"
Nothing more is needed for this very simple task. But you can save some time and automate these steps with the following section!
Usage of USB filters
VirtualBox USB filters will help you to automatically assign USB devices to your VM. With other words – As soon as the VM starts (or is started) and the USB device is recognized by VirtualBox (and it’s not in use by the host), it will be made available to the guest.
Additionally it’s important to understand that there are two kind of filters (global and machine specifc). Global filters (IHostUSBDeviceFilter) are applied before any machine specific filter (IUSBDeviceFilter).
--target <uuid|vmname>|global
--action ignore|hold (global filters only)
--active yes|no
In this tutorial I focus only on machine specific filters.
# verify for filter on specific vm
$ VBoxManage showvminfo "Debian" | awk '/^USB Device Filters:/,/^Available remote USB devices:/'
Important is the value “index” from 0 to n! If you create the first filter – the index starts with an 0, the second filter with an 1 and so on. To add a filter you must provide the VendorId and ProductId (as minimum) from first section (values inside the brackets), the name is can be chosen free.
Note: you have to adjust the following values in my examples ​​for your environment.
# show help for usb filters
$ VBoxManage usbfilter --help
# create usb filter for specifc vm
$ VBoxManage usbfilter add 0 --target "Debian" --name 'YARD Stick One' --vendorid 1d50 --productid 605b --remote no
# modify usb filter for specifc vm
$ VBoxManage usbfilter modify 0 --target "Debian" --name 'YARD Stick One' --vendorid 1d50 --productid 605b --remote no --manufacturer 'great scott gadgets'
# delete usb filter for specifc vm
$ VBoxManage usbfilter remove 0 --target "Debian"
USB filters are a very nice feature of VirtualBox, just play around and do some further research on it – I’m sure you will love it!
While my constant research for pipeline tools, I have found a fantastic security scanner for Docker images. Something you could use quickly under the topic of CI/CD and DevSecOps for your development. It’s named anchore/grype and the best it’s Open source, really fast and delivers many nice options for reports.
Short introduction in installation and usage of Grype (locally to evaluate).
Note: The later integration into your pipelines shouldn’t be a problem. I will add the Grype repository to my watchlist and for sure try it out in my pipelines.
Installation and default configuration
This first step should only take a few minutes.
# install the latest version to /usr/local/bin
$ curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin
# install the latest version to ~/Downloads
$ curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b ~/Downloads
# move binary to /usr/local/bin/grype (if you define different location)
$ mv ~/Downloads/grype /usr/local/bin/grype
# create configuration file
$ vim ~/.grype.yaml
# show help
$ grype --help
I copied the content in short form from the official GitHub repository. You can adapt this to your needs at any time.
The Anchore Feed Service provides regular updates about publicly available vulnerabilities. In this section I will guide you to derive the updates manually.
# check database status (optional)
$ grype db status
# check feed service for new updates
$ grype db check
# run database update
$ grype db update
# verify db files (optional)
$ ls -la ~/.grype/db/
Usage examples
Even as the usage of Grype is very simple, here some short examples.
# scan image with configuration settings
$ grype node
# scans for vulnerabilities on all image layer and set output format
$ grype --scope all-layers -o cyclonedx node
# stop if a severity high is found with exit code 1
$ grype --fail-on high node
# show last exit status (optional)
$ echo $?
To stop your validation/pipeline on certain severities of security risks (exit code 1), you can choose between following options: negligible, low, medium, high & critical.
Hint: To save the reports you could use the redirect, to the output stream to a file.
Clean up
Don’t forget to clean up your system!
# list all Docker images (optional)
$ docker images
# delete specific Docker image by name
$ docker rmi node
Since I’m back to develop more in Python and need to execute my Python scripts also on remote machines – I asked my self: “How can I do with PyCharm CE and without any Plugin?” The solution was very easy and this tutorial is about.
Requirements
VirtualBox VM (e.g. Linux Debian incl. user and ssh server configured)
Note: Of course you could also use any other option then a Debian vm. Just adapt the tutorial steps for your specific needs.
Objective
Use terminal and external tools of PyCharm CE to execute Python scripts on remote machines.
Introduction
For this tutorial I’m using a VirtualBox VM (Debian Linux) which do have only a NAT interface configured. So I need to enable Port-forwarding for SSH. If this is not the case for you – you can jump over to the section where I explain the important steps in PyCharm.
Analysis of stopped VM’s
As a first step I check my VM settings (just to verify).
# list all vm's (optional)
$ VBoxManage list vms
# list all vm's and grep for name & nic rules
$ VBoxManage list -l vms | grep -i "Name:\|NIC 1 Rule"
Analysis of running VM’s
I don’t know the IP – so I do start the VM and check their all settings.
# start specific vm
$ VBoxManage startvm "Debian" --type headless
# list all running vm's (optional)
$ VBoxManage list runningvms
# list all running vm's and grep for name & nic rules (optional)
$ VBoxManage list runningvms -l | grep -i "Name:\|NIC Rule"
# list specific vm Nic informations (optional)
$ VBoxManage showvminfo "Debian" | grep -i "NIC"
# get IPv4 information of specific vm
$ VBoxManage guestproperty get "Debian" "/VirtualBox/GuestInfo/Net/0/V4/IP"
Add Port-forwarding
Now I know the IP (which in my case will not change) and can enable the Port-forwarding for SSH easily.
# shutdown specific vm
$ VBoxManage controlvm "Debian" poweroff
# add port-forwarding rule to specific vm
$ VBoxManage modifyvm "Debian" --natpf1 "SSH-PW,tcp,127.0.0.1,2222,10.0.2.15,22"
# list specific vm Nic informations (optional)
$ VBoxManage showvminfo "Debian" | grep -i "NIC 1 Rule"
# start specific vm
$ VBoxManage startvm "Debian" --type headless
# test ssh connection (optional)
$ ssh -p 2222 lupin@127.0.0.1 -v -C 'whoami && exit'
Note: On my VM (Debian) the user is named “lupin” this will be different for you! Also Openssh-server is enabled and I added my public ssh key on VM (authorized_keys).
PyCharm remote execution
As I also like and use the feature “scratches” of PyCharm, I will show first the remote execution of these files.
Prepare a scratch
I prepare a simple Python script scratch, which just prints out environment variables (same code I use later inside project example).
import os
print('hello world', os.environ)
To find the absolute path for my scratch.py – I run it. On terminal the path will be visible.
After I know the path I run some simple commands in PyCharm Terminal.
# execute local script via SSH on remote system
$ ssh -p 2222 user@127.0.0.1 -C "/usr/bin/python" < "path/to/scratches/scratch.py"
# same as above but with unbuffered binary stdout and stderr
$ ssh -p 2222 user@localhost -C "/usr/bin/python" -u - < "./test_remote.py"
It works perfectly fine.
Note: Please replace the value “user” in all ssh examples!
Project files
For all other scripts in the PyCharm project I don’t want to type the terminal commands always! So I’m using the feature “External Tools”. To do so, I add a new item and use the built-in variables (Macros) of PyCharm.
You simply give a Name Run on Remote, optional a short description, for Program your shell /bin/zsh and on Arguments --login -c "ssh user@localhost -p 2222 -C /usr/bin/python -u - < "$FilePah$. If you press button “OK” the input will be saved. The value for Working Directory $ProjectFileDir$ will be set (normally) automatically.
Now you can use the context menu to execute your script over SSH on remote machine.
In my last tutorial, I showed you how to install RfCat and the ooktools on your macOS, as I promised to go into more detail on the ooktools later – I want to keep this promise now.
Requirements
RfCat installed
ooktools installed
jq installed (optional)
you own a Yard Stick One (or any rfcat compatible device)
you own a Garage Door opener (or similar device)
Objective
Learn and understand the ooktools sub command ‘signal’.
ooktools signal
The ooktools offers many great features (look at the command line help)! In this tutorial I will focus on signal search, signal record, signal plot and signal play.
# show sub command signal help
$ python2.7 -m ooktools.console signal --help
...
Usage: console.py signal [OPTIONS] COMMAND [ARGS]…
Signal Commands.
Options:
--help Show this message and exit.
Commands:
brute Bruteforce a binary range.
jam Jam a frequency by just sending noise.
play Play frames from a source file.
plot Plot frames from a recorded signal.
record Record frames to a file.
search Search for signals.
send Send signals using a RFCat dongle.
Search a signal
My garage door opener has information about the frequency (868.3 MHz) on the back, which makes my search a little easier! If this is not the case for you, search for the FCC identifier.
If you have a rough idea about the frequency (and other values), look in the signal search help and compare all standard values with your needs! You only have to overwrite the values ​​which do not match (as arguments).
# show help for signal search
$ python2.7 -m ooktools.console signal search --help
# search signal in specific range
$ python2.7 -m ooktools.console signal search -S 868200000 -E 868400000
Note: Only signal search throws sometimes an Python/USB exception on my OS (after finish the search), all other commands work perfectly. If you have the same problem, reconnect the USB device (Yard Stick One)!
Record a signal
Now run the signal record. Go the same way like you did for the signal search! First look at the sub command help, overwrite the default values and run the command.
# show help for signal record
$ python2.7 -m ooktools.console signal record --help
# start a signal record
$ python2.7 -m ooktools.console signal record -F 868300000 -f 60 -D ~/Desktop/test.json
After the signal record is finished, you can have a look on the JSON file.
# view file content and pipe output to jq (optional)
$ cat ~/Desktop/test.json | jq .
Plot the recorded signal
With signal plot you can easily create and watch frames from a recorded signal (json file). The help shows you the possible fine adjustments for the plot output. I have recorded 9 Frames, maybe that differs for you!
# show help for signal plot
$ python2.7 -m ooktools.console signal plot --help
# plot a signal record (number of frames)
$ python2.7 -m ooktools.console signal plot -c 6 -S ~/Desktop/test.json
To specify the plot you can use sub command agrument --series.
# plot a signal record (series of fields)
$ python2.7 -m ooktools.console signal plot -s 1:4 -S ~/Desktop/test.json
Play a signal
It’s time to try. For that I have to walk a long way to the parking garage gate (I usually drive this route). For signal play sub command only two arguments are needed (source & repeats).
# show help for signal play
$ python2.7 -m ooktools.console signal play --help
# play a signal record
$ python2.7 -m ooktools.console signal play -r 2 -S ~/Desktop/test.json
I did not modify the record file, just run all recorded frames for 2 times. If you are wondering if this worked for me? No – the signal is sent too quickly this way. The gate doesn’t open like this. With tools like GQRX / URH & HackRF One I was able to compare the signals. So some fine-tuning is needed (baud rate/modulation/etc.). Nevertheless, you should have got a good overview of the ooktools.
Some time ago, I wrote a tutorial about RfCat installation on Kali Linux. Many people asked me for similar tutorial on macOS (Big Sur). So I will use this time now (my first tutorial of year 2021), to show and try to explain (as best I can do). Also I will try to provide some basics for usage, as the community seems not so big and less online documentation is available like for other topics. You can reuse the knowledge for other OS, too.
First you need to download libusb tarball, unzip the downloaded archive and compile/install it (don’t worry sounds harder as it is). If you choose other sources like macports, you may run into location issues (paths to binaries/libraries).
Note: the following examples will just provide the latest version (1.0.24), while I was writing this tutorial. Please look beforehand if there is a newer libusb version already available.
# download via curl
$ curl -L -C - "https://github.com/libusb/libusb/releases/download/v1.0.24/libusb-1.0.24.tar.bz2" -o ~/Downloads/libusb-1.0.24.tar.bz2
# unzip archive
$ tar -xf ~/Downloads/libusb-1.0.24.tar.bz2 -C ~/Downloads/
# change into extraced archive directory
$ cd Downloads/libusb-1.0.24
# verify dependencies for build and install process are available
$ ./configure
# run build
$ make
# run installation
$ sudo make install
# verify installation (optional)
$ ls -la /usr/local/lib/libusb*
# delete archive and directory (optional)
$ rm -fr ~/Downloads/libusb-1.0.24*
Install required Python packages with Python Pip. Without these the RfCat compilation, installation and usage will not correctly work!
Note: As I do have different Python version installed, I specify the excat Python version (2.7.x) in the following examples. If you have only the default MacOS Python version installed – you could use pip directly (without python2.7 -m).
Clone RfCat Git repository from Github (may some older online documentations still link to Bitbucket). In the following example I choose the Downloads directory – of course you can choose any preferred destination.
# clone from GitHub
$ git clone https://github.com/atlas0fd00m/rfcat.git ~/Downloads/rfcat
# change directory
$ cd Downloads/rfcat
# run the installation
$ sudo python2.7 setup.py install
# verify the installation (optional)
$ ls -la /usr/local/bin/rfcat*
# show rfcat help (optional)
$ /usr/local/bin/rfcat -h
# delete cloned directory (optional)
$ rm -fr ~/Downloads/rfcat
If everything went well so far, you should take a look at your installed Python packages.
Now I recommend to install the ooktools packages via Python Pip. The ooktools will make your life much easier and you will have much faster results.
# install ooktools via pip
$ python2.7 -m pip install ooktools
# verify and show help (optional)
$ python2.7 -m ooktools.console --help
# verify and show specific help topic (optional)
$ python2.7 -m ooktools.console wave --help
I’ll go into the ooktools in a later tutorial, but not today.
Run RfCat
So far so good. Let’s start to connect the Yard Stick One (plug into USB) and run the first example. Always have in mind, the official operating frequencies (for the Yard Stick One):
300 – 348 MHz
391 – 464 MHz
782 – 928 MHz
Note: RfCat expact the values in “Hz”, so 315 MHz are 315000000 Hz.
Hint: don’t put any other transmitter next to the Yard Stick One while you use it (eq. Mobile, Wifi router, etc.). You could destroy it or weaken/disrupt your signals.
# start scan on specific frequency (315 MHz)
In [1]: d.specan(315000000)
You should see now the spectrum analyser.
Okay, stop the scanning process by closing the spectrum analyzer window. Now let’s start a simple record (also if you don’t have a signal nearby).
Note: there are many more settings and I cannot describe all here! It always depends to the problem you like/need to solve.
# enter the IDLE state (important after any action)
In [2]: d.setModeIDLE()
# specific frequency (315 MHz)
In [3]: d.setFreq(315000000)
# specific modulation (ASK/OOK/Manchester encoding)
In [4]: d.setMdmModulation(MOD_ASK_OOK)
# specific baudrate (4800 Hz)
In [5]: d.setMdmDRate(4800)
# turn on the amplifier
In [6]: d.setMaxPower()
# drops most blocks to pkts (CARRIER)
In [7]: d.lowball()
# start and dump data to screen
In [8]: d.RFlisten()
# stop listen (press Enter to stop)
# enter the IDLE state (or you need to unplug from USB)
In [9]: d.setModeIDLE()
# exit
In [10]: exit()
Your result should look like:
Hint: use the Tabulator key for command-line completion (also tab completion) and take use of the internal help of RfCat (eq. help(d.setMdmModulation))
The popular frequencies are mostly near by:
315 MHz (car fobs)
433 MHz (door openers, medical devices)
868 MHz (door openers in EU/swiss)
915 MHz (industrial equipment, medical devices)
Send via Python script
It would be not enough to show you only Command line and nothing about transmit. Therefore now a small Python script, which send out some example data. I think the following script is self explanatory.
from rflib import *
d = RfCat()
d.setFreq(315000000)
d.setMdmModulation(MOD_ASK_OOK)
d.setMdmDRate(4800)
print("Transmission starting")
d.RFxmit("\x2e\x2e\x2d\x2e\x2e\x2d\x2e\x00\x00\x00\x00\x00\x00"*10)
print("Transmission complete")
Hint: \x escape sequence means the next two characters are interpreted as hex digits for the character code (\x is used inside strings to represent a character), 0x is used for literal numbers in Python.
I’ve tried many times and different ways but the installation of Gqrx and GNU Radio on macOS Big Sur via MacPorts failed always. I did not give up and found a working solution for me (my HackRF One) and these two needed tools. In this tutorial I would like to show you the installation (Gqrx & GNU Radio). If you need first to install HackRF One on macOS, please have a look here.
Install XQuartz
First download and installation starts with XQuartz. Download the latest DMG, run the installation and logout/login from your system.
Install Gqrx SDR
As already mentioned, Gqrx (at least for me) cannot installed on Big Sur via MacPorts. Therefore download and install the precompiled binary from Gqrx. As soon the installation was successful, you can connect and use the HackRF One.
Install Python 3.7
The third step also requires a download and installation. Look for the version Python 3.7! Any version below will not work.
Install GNU Radio
Finally, at the last step, we can start to download and install GNU Radio. It’s a quite big application, so please be patient while processing. Also the startup of GNU Radio (inside XQuartz) takes always some few seconds.
If you consider the time (download/installation) compared to the MacPorts installation (download/build/installation), a time gain. Of course Xquartz is also needed for MacPorts. Here if you will try via MacPorts:
# install gr-osmosdr (incl hackrf + gnu radio)
$ sudo port install gr-osmosdr
# install gr-fosphor (needed by gnu radio)
$ sudo port install gr-fosphor
# install gqrx
$ sudo port install gqrx