Parsing network stream into http request/response

The need was to convert the network stream into clear text http request/responses while doing some decoding of the response body. For instance: request uri + queryString => response body Capture the stream – easy using tcpdump Filter the http stream – easy using wireshark with a tcp.port eq 80 filter Export http #1. using wireshark file -> export objects -> http. This works fine only for files. It does not work for POST requests....

June 22, 2016 · len

Create a database of exif data

Create a database of exif data from photos using pyexiv2 and save it in a sqlite database for futher query: <pre lang="python"> #!/usr/bin/env python import os, sys, pyexiv2, sqlite3 thumbFormats = ('JPG', 'JPEG') rawFormats = ('ARW', 'CR2') formats = thumbFormats + rawFormats tags = ['Exif.Image.LensInfo'] dbFile = 'metadata.db' conn = None cursor = None def parse(dir): cnt = 0 for root, dirs, files in os.walk(dir, topdown=False, followlinks=True): refFiles = map(str.upper, files) for file in files: fullPath = os....

January 18, 2015 · len

py-gps-tools

After spending loosing time in vain trying to convert kml files containing the gx:Track format to gpx files for my gps and finally writing my own tool for doing that I realized I have done quite a lot of small scripts for gps data manipulation and decided to push them on github. I started with 2 and as I will clean the others I will push them also. # [](https://github.com/len-ro/py-gps-tools#py-gps-tools)py-gps-tools A set of python scripts to manipulate GPS data...

May 31, 2014 · len

Let’s decrypt

AES encrypt in java and decrypt in java, flex, python, C#. Encrypt: java <pre lang="java">public static void encrypt(InputStream is, OutputStream out, String secret) throws Exception { SecretKey secretKey = new SecretKeySpec(Hex.decodeHex(secret.toCharArray()), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, secretKey); out.write(cipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV()); CipherOutputStream cipherOutputStream = new CipherOutputStream(out, cipher); int bufLength = KEY_LENGTH/8 * 100; byte buf[] = new byte[bufLength]; int bytesRead = 0; while((bytesRead = is.read(buf)) != -1 ) { cipherOutputStream.write(buf, 0, bytesRead); } cipherOutputStream....

December 20, 2013 · len

Skype logs archiving on linux

I keep migrating my Skype logs from installation to installation and they are getting pretty large. As they are binary files there is no easy way to split them properly. However I’ve found this tool which parses the logs and outputs the entries. The output however it’s not that usable. For this reason I’ve wrote a python script which organizes the output from the previous tool and generates files in the form: logs/skype-name/date....

April 14, 2012 · len

Cut, reverse and combine GPS tracks

When I plan a cycling trip I search for tracks in the target area and try to maximize the “fun factor”. Thus I often end up with a bunch of tracks from which I want to use parts. The difficult task is to cut, sometime reverse and combine the source tracks into a planned track. Most of the times this seems a too much waste of time since it involves a number of operations in qlandkarte (cutting and combining) and gpsbabel (reversing)....

August 2, 2011 · len

Migrate contacts from C510 to HTC

I order to migrate contacts from a Sony Ericsson C510 to a HTC Desire you first have to export them in an usable format. Wammu recognizes this phone and exports a .vcf file containing all contacts. However there are some major limitations to this process: entries which contains multiple phone numbers are exported separately instead of a single vcf. For an entry named “me” containing a mobile and work phone the exported file contains a: me/M and me/W contact BEGIN:VCARD VERSION:2....

November 14, 2010 · len

Searching for duplicate flex functions

After a day lost trying to find a bug caused while refactoring multiple versions of copy/paste code into a component I’ve decided to write a small application which searches for other code from my component still duplicated in other places. Naturally a basic python script has emerged. It takes as argument a file and a folder and searches for files ending with .as recursively. Both the reference file and the found files are parsed and a basic function reference is created which is compared to the other files....

October 13, 2010 · len

GPS track analysis

GPS data has become extremely available in the last time and analyzing it always yields interesting results.The purpose of this article is to show a simple example where GPS track data is compared with a set of waypoints in order to determine whether a specific tracks was followed. This scenario is custom to various competitions ranging from randonee, cycling (cross country, orientation), 4×4 and the examples can go on and on....

October 3, 2010 · len

Python xml namespace parsing with libxml2

The goal of this tinkering was simple: to parse a KML file for further interpretation and use using python and libxml2. First test <pre lang="python">#!/usr/bin/env python import libxml2, sys doc = libxml2.parseFile(sys.argv[1]) ctxt = doc.xpathNewContext() ctxt.xpathRegisterNs('kml', "http://www.opengis.net/kml/2.2") root = doc.getRootElement() res = ctxt.xpathEval("//kml:Placemark") for e in res: nodes = e.xpathEval('kml:name') if len(nodes) > 0: if nodes[0].content.strip().startswith('cp'): coord = e.xpathEval('kml:Point/kml:coordinates') if len(coord) > 0: print coord[0].content.split(',') doc.freeDoc() ctxt.xpathFreeContext() This sounded ok according to the scarce doc but resulted in the following error:...

July 9, 2010 · len