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

January 29, 2015

Python on iOS

Yesterday I stumbled upon something quite amazing: in the Apple App Store there is an App called Pythonista that runs/interprets Python 2.7 scripts, offers an Python IDE, offers some modules which give your Python apps access to iOS functions, e.g., location, camera, … My first impression of the app was quite spoiled because the App does not provide any import function for your Python scripts. For instance, you put your Python script in your Dropbox, select the file and press “open in”. 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

© holger 2015 - 2020 |