Update #3 on Pocket-Sized Satellite Tracker

I haven’t updated much on the satellite tracker but I figured I would make the repo public since it is just sitting there at the moment. 🙂

https://github.com/bostrt/sattrack

https://github.com/bostrt/libpredict-arduino-lib

I plan to work on this some more before upcoming DEF CON 26.

Update #2 on Pocket-Sized Satellite Tracker

Things are progressing nicely on the satellite tracker. The following is functional:

Current tasks

  • Develop a dev pcb to replace bread-board. Just something that all the breakout boards above solder onto
  • Finish display graphics
  • code-cleanup

Screenshot & Photos

Serial interface

Screenshot from 2017-10-28 11-10-24.png

All components

IMG_20171028_105906851.jpg

Polar chart that will display relative satellite position

IMG_20171028_105938349.jpg

Missing photo of the satellite position data due to being in middle of display code rewrite.

 

Update on Pocket-Sized Satellite Tracker

After some fighting with libpredict, I found that I am going to need a microcontroller with better floating-point support. The Atmega series of microcontrollers do not have an FPU which means any floating-point support is hard (either inaccurate, slow, or hacked).

I found that some of the ARM Cortex processors do indeed have an FPU and their also come in  similar form as Arduinos or other development boards:

Adafruit Feather M0 Basic Proto - ATSAMD21 Cortex M0

https://www.adafruit.com/product/2772

Or

Teensy 3.2 + header

https://www.adafruit.com/product/2756

Above is Adafruit’s Feather which I’m going to give a shot. It hosts a Cortex M0 which actually does not have an FPU but would handle floating point much better than Atmega due to 32-bit arch.

The Teensy 3.2 hosts a Cortex M4 which actually does have an FPU which might be the winner.

I’ll be experimenting with both to see which one better suits my needs.

Beginning Pocket-Sized Satellite Tracking

A couple months ago, I worked on putting a satellite tracking application on a Raspberry Pi. This worked okay but I have to use a keyboard to select the satellite I want to track before going outside to find it. I also have to lug around an external battery outside which isn’t fun. I could really use something more compact.

Hard Requirements

  • Screen + Buttons
  • Tracking multiple satellites (not hundreds, just a few)
  • Display Azimuth
  • Display Elevation
  • Display transponder frequency with Doppler shift
  • Polar plot (sky plot)
  • Button to switch between satellites
  • Ability to set the time and timezone on device (RTC required)

Soft Requirements

  • Button to toggle between screens for a single satellite (if Polar plot and transponder data cannot fit in same screen)
  • Ability to update TLE’s when plugging into computer

 

I have one of these pockeTETRIS things and love the little OLED screen. I will probably end up using the same screen. I’d like to just re-purpose my already built pockeTETRIS, but, I still need the RTC and definitely a microcontroller with more program space for largest library I will need, libpredict, which comes out to around 40k when I drop features I don’t need. The ATtiny85 in pocketTETRIS only has 8K. Pretty sure I am going with ATmega1284 a whopping 128k; plenty of room for libpredict, RTC library, OLED library, and my own code.

Flyby Satellite Tracking on Raspberry Pi

qth
Flyby is a satellite tracking application that runs in a terminal (no GUI required). I wanted to run it on my Raspberry Pi that has a display attached to it so I can carry it outside with me when tracking amateur satellites. This is much easier to move around than a laptop or even my phone where I have to keep the screen from going to sleep or touching something on the screen.Setting up Flyby on a Raspberry Pi was a bit of a challenge but it is now working fine. Here’s my setup steps:

Install Raspbian

I am using Adafruit’s 3.5” TFT display so I used their custom image with the drivers already configured. You can find that here: https://learn.adafruit.com/adafruit-pitft-3-dot-5-touch-screen-for-raspberry-pi/easy-install.

Install Dependencies

Once you have Raspbian setup, you will need to get the device networked and install some dependencies of flyby:

# apt-get install libncurses-dev cmake gcc make git

Get latest Flyby and libpredict source code

Check out the source code for both projects using git:

# git clone https://github.com/la1k/libpredict.git
# git clone https://github.com/la1k/flyby.git

At the time of writing this, I ran into a few issues with crashes while starting up flyby. A patch has been filed here: https://github.com/la1k/flyby/pull/74

Patch

If you run into problems when trying to do the initial QTH setup (that’s later on in this post), then my fix may not have been merged yet. You can checkout the patch using, rebuild, and re-try:

# cd flyby
# git fetch origin pull/74/head:qth-setup-segfault
# git checkout qth-setup-segfault

Update: patch above has been accepted.

Build

After you have checked out the sources, run the build process for libpredict:

# cd ~/libpredict
# mkdir build; cd build
# cmake ..
# make
# sudo make install
# sudo ldconfig

Then, build flyby:

# cd ~/flyby
# mkdir build; cd build
# cmake ..
# make
# sudo make install

A few final tweaks before running

The default font in Raspbian is too big to render flyby properly. Change the terminal by doing this:

# sudo dpkg-reconfigure console-setup

Choose the following options in each prompt:

  1. UTF-8
  2. “Guess optimal character set”
  3. Terminus
  4. 6×12 (framebuffer only)

The screen may hang for a moment while the settings are applied. After it completes, you will be sent back to a shell with your new font visible.

Run it!

Finally, start up flyby simply by executing:

# flyby

Your screen should look something like below. Fill in your details and you are good to go 🙂

qth

Remeber, if you are not able to save your settings above and experience a Segmentation Fault, then follow the steps in the Patch section earlier in this post.Finally, proceed with the normal setup steps provided in flyby’s Wiki: https://github.com/la1k/flyby/blob/master/docs/usage_guide.md#obtaining-and-updating-tles
Update (again): patch above has been accepted.

Introducing mod_serverheader

mod_serverheader project siteIn my work, I have seen people performing security scans, going through audits, and stumbling upon information they wish they could hide about their webservers.

One of the simplest questions that comes up over-and-over is regarding the Server header in Apache HTTPD responses; the thing with the arrows are pointing to below:

# curl -I http://localhost/
HTTP/1.1 200 OK
Date: Tue, 28 Feb 2017 20:56:24 EST
Server: Apache/2.4.25 (Fedora) OpenSSL/1.0.2k-fips  ◀◀◀◀◀◀◀◀
Content-Type: text/html; charset=UTF-8

There are a couple ways to reduce what is disclosed in the Server header.

  1. Configure your ServerTokens directive to be ProductOnly.
  2. Use ModSecurity’s SecServerSignature directive to overwrite the Server header with custom contents.

Each of the options are backed by opposing opinions. The Apache HTTPD documentation claims there is no advantage to hiding/altering the contents of the Server header because a malicious user could just throw all their attacks at a webserver, no matter what the webserver product actual is.

Setting ServerTokens to less than minimal is not recommended because it makes it more difficult to debug interoperational problems. Also note that disabling the Server: header does nothing at all to make your server more secure. The idea of “security through obscurity” is a myth and leads to a false sense of safety. 1

And, as far as I know, the motivation behind ModSecurity’s SecServerSignaturedirective is the because of a not in the HTTP/1.1 RFC 2068:

Revealing the specific software version of the server may allow the server machine to become more vulnerable to attacks against software that is known to contain security holes. Implementers SHOULD make the Server header field a configurable option. 2

I’m not going to take sides in the matter, becaues I think both points have merits. However, I think our battles must be chosen carefully. Should time be spent deciding whether or not to obfuscate your Server header or should time be spent on more significant security matters? Why not satisfy this simple concern to satisfy the request of security professionals or security auditors?

ModSecurity has solved this issue with the SecServerSignature directive. However, I’ve seen people use ModSecurity only for this header. I think the module is completely overkill to use just for this one directive. So, I worked up a simple module who’s only purpose is to overwrite the Server header: https://github.com/bostrt/mod_serverheader

ModSecurity 2.9.x in 5 minutes

There are just a few fundamental pieces to learn in order to get started with ModSecurity.

  • Phases
  • Actions and Rules
  • Collections

Phases

There are 5 phases of request processing in ModSecurity 1. You can hook into any one these phases using the phase keyword when writing ModSecurity Actions and Rules. The 5 phases occur in this order:

  1. Request Headers Phase
  2. Request Body Phase
  3. Response Headers Phase
  4. Response Body Phase
  5. Logging Phase

As you pass through the phases, you can still access the information from the previous phases. So, if you are not sure where to begin, start with Logging Phase 5.

Actions and Rules

ModSecurity configurations are built around Actions (SecAction) and Rules (SecRule). We’ll start with SecAction since it is the same as a SecRule, just without a conditional. In other words, SecAction will always execute a list of actions, while a SecRule will only execute a list of actions if a certain condition is met.

Example

SecRuleEngine On
SecAction id:100,phase:1,deny

SecRuleEngine enables the ModSecurity engine. If you do not enable it, none of your actions/rules will apply.

The SecAction above is about as simple as it gets. It always denies a request, sending a 403 status to client.

The id:100,phase:1,deny is known as the action list. Let’s work through it now. Every action must include an id and it must be unique amongst all your SecAction and SecRule2. After the id is the phase:1 which means this rule will run in the Request Headers phase. Finally, the deny is the part that actually says this SecAction will send a 403 status.

Modified Example

If you want to send something besides the default deny status of 403, you can change it by using the status action like this:

SecAction id:100,phase:1,deny,status:451

The action above would deny the client access and send a “451 Unavailable For Legal Reasons” status.

Action List Order

The ordering of items in an action list is not always important. If you are using things like Transformation Functions 3 (e.g. base64Encode, hexEncode, trim, etc) you need to pay attention to order, especially when you use multiple Transformation Functions in a single action or rule. Transformation Functions will change the input for the following functions and actions.

The example from the previous section does not have any actions that are sensitive to ordering. For instance, the following would execute in exact same manner as in previous section:

SecAction status:451,deny,phase:1,id:100

More Useful Example

In the previous sections we used an example that simply denies every request. This isn’t very useful so we will add a condition to the action, making it a SecRule. The condition will be this: if someone requests the page and is from the IP address 192.168.100.200, then we want to deny them with the 451 status:

SecRule REMOTE_ADDR "192\.168\.100\.200" id:100,phase:1,deny,status:451

The REMOTE_ADDR 4 is the value we are testing and the “192.168.100.200” is value that needs to match. If the test passes then the action list is executed.

Collections

Collections (a.k.a. Persistent Storage) are an important feature of ModSecurity because they give you the ability to store information over multiple requests. There are a few different types of collections5 but we will focus on GLOBAL and SESSION collections in this guide. A GLOBAL collection is not associated with any single request, session, or anything really; it is just a general collection that can be accessed from anywhere. A SESSION collection is different in that it is associated with a specific session and initialized differently than a GLOBAL collection.

Let’s take a look at some example configuration.

Global Collection Example

SecDataDir /var/cache/mod_security/
SecAction id:150,phase:1,initcol:reindeer=rudolph
SecAction id:152,phase:1,setvar:reindeer.antlers=+2
SecAction id:153,phase:1,setvar:reindeer.hoofs=+4

SecDataDir is the directory where the persistent database files will be kept. Make sure this is writable by your Apache HTTPD user.

The first SecAction initializes the collection (initcol stands for initialize collection). The last two SecActions are setting the variables inside of the collection. So, in the example above, the collection is called rudolph and and it has two attributes: antlers and hoofs. The antlers are incremented by 2 for each request and the hoofs are incremented by 4 for each request.

The collection has a structure like this:

File name: reindeer
rudolph => {
    antlers: 2,
    hoofs: 4
}

Something imporatnt to note is that you can only call initcol once in your configuration since it is a GLOBAL collection. However, you can use SecRule in combination with initcol in the event you need to conditionally initialize a GLOBAL collection to use throughout a request’s lifecycle. For example, you can do:

SecRule REQUEST_URI rudolph id:150,phase:1,initcol:reindeer=rudolph
SecRule REQUEST_URI dancer id:151,phase:1,initcol:reindeer=dancer
SecAction id:152,phase:1,setvar:reindeer.antlers=+2

Session Collection Example

Instead of tracking things globally, you may want to associate a counter or variable with a specific session or request cookie. Let’s track how many people send requests from a specific session ID.

SecAction id:154,phase:1,setsid:%{REQUEST_COOKIES.SESSIONID}
SecAction id:155,phase:1,setvar:SESSION.requests=+1

In the configuration above, a counter called requests will be incremented for each request from the user with a specific session ID.

The collection will have a structure like this:

File name: default_SESSION
e0d47ef20 => {
  requests: 100
},
a303b3cc7 => {
  requests: 93
},
146f5a98e => {
  requests: 174
}

e0d47ef20, a303b3cc7, and 146f5a98e are just example session ID’s which are the “keys” for each collection.

After reading this article, you will be ready to get started with writing your own rules and actions for ModSecurity. Maybe even dive into the complex set of prebuilt rules in the OWASP ModSecurity Core Rule Set 6.

References: