December 30, 2015

Closures and Decorators in Python

Closures basically mean that an inner function defined in an outer function remembers what its enclosing name space (or name spaces) looked like at definition time. The variables defined in this name space can later be accessed by the inner function: def closure(): x = 1 def inner(y): return y - x return inner print(closure()(5)) 4 Closures also work, when an variable is passed to the outer function: def otherClosure(x): def inner(y): return y - x return inner print(otherClosure(1)(5)) 4 Read more

May 15, 2015

Messing With DNS Using NFQUEUE and Scapy

Some days ago I taught myself a little about NFQUEUE and Python. Meanwhile I dug a little more into the matter and looked into building new network packets. In this special case I wanted to create DNS packets. The idea was to intercept DNS requests with Netfilter and return a fake IP address in a faked DNS response. Messing with packets in Python is quite easy to do when you use the Python bindings for Scapy, a quite powerful packet manipulation tool. Read more

May 8, 2015

Messing With VoIP Calls Using NFQUEUE

For the project of one of my students we need to intercept and modify SIP messages. Our first idea was to configure a proxy in the SIP user agent (soft phone) and to modify an existing SIP proxy to our liking. Unfortunately this approach did not work reliably as the soft phone seemed to be faulty: some SIP messages were sent via the proxy we configured, other were sent directly to the server. Read more

March 3, 2015

Visiting Cards With Latex

I created a simple Latex template for a standard 85x55mm visiting card and some add-ons. The template features the standard elements of a visiting card plus a PGP/GPG fingerprint and some space for an (optional) portrait, logo or QR Code. As I wanted to use a specific font not available in MacTeX, I used XeLaTeX. XeLaTeX gives access to fonts installed on the Mac, such as Times New Roman, Arial, Helvetica, etc. Read more

January 24, 2015

Markdown Mass Converter

I hacked a little python script that converts a directory tree full of markdown files to PDF using pandoc. The script remembers the hash sum of each markdown file and thus only converts new or updated files. The script is available via my Github. The tex template is used by pandoc. It is very basic but tweaks the output of pandoc to my liking.

January 3, 2015

Convert GPX Tracks to a HTML File With Info About Nearby Places

I have the habit to log my route when I’m traveling, hiking or sometimes even shopping in town. The GPX track is useful for geotagging photos or simply for understanding where I have been. Yesterday I had the idea to convert a GPX track to something that gives me an overview about interesting places nearby my track. So I fiddled a little with Python and wrote a script that extracts the lat/lon coordinates from a GPX file sends these coordinates to the Geonames database extracts text from the Geonames reply creates a very basic HTML page with some describing text about the interesting places nearby and a link to Wikipedia. Read more

© ho1ger 2015 - 2022