Reading Yum Repository Data

I’ve spent a lot of time working with RPM in the last couple years, and have had the pleasure of maintaining the IUS Community . I wanted to share a small utility we use quite often called repodataParser , repodataParser is a Python class for working with RPM repositories, and used in a few of our Django applications . The idea is all RPM repositories contain a XML file containing details about the package it contains.

Random Board Game Selection using Board Game Geek

Using Board Game Geek’s API I wanted to create a simple Python tool for randomly picking a game to play. Below is some quick Python code to achieve my goal: from urllib2 import urlopen from lxml import etree from random import choice def get_xml(): req = urlopen('http://www.boardgamegeek.com/xmlapi/collection/flip387') return req def get_items(): xml = etree.parse(get_xml()) return xml.xpath('//item') def get_thumbnail(item): t = item.xpath('thumbnail') if len(t) == 1: return t[0].text def get_name(item): t = item.

Boardgame Geek API

Today I learned Boardgamegeek.com provides a XML API which appears to be pretty well documented. For example if I wanted to list all the Board Games I own I could do something like this in python: In [1]: from urllib2 import urlopen In [2]: from lxml import etree In [3]: req = urlopen('http://www.boardgamegeek.com/xmlapi/collection/flip387') In [4]: xml = etree.parse(req) In [5]: sorted([ i.text for i in xml.xpath('//name') ]) Out[5]: ['Arkham Horror', 'Bears!

Predictable Random Numbers

Well that title is odd, right? What I’m wanting to do here is demonstrate one way to generate random numbers using a seed . The requirement here is we need to test a number at any given time, this will be useful if we intend to use the process as a token of sort, think RSA SecureID . Anyways I wanted to make a implementation that used Python and didn’t cost me hundreds of dollars.

Python chroot and exit chroot

I know this has been written a few time online, but the last time I needed to read up on it, it took a little long to find the answer. What I wanted to do was to chroot in to a new root, then exit that chroot via python . Below we have my current working directory that is /root , take a look at what we have in the directory:

Using Tor with Python

Using tor with python’s urllib2 is pretty easy, you just need to setup a few things before hand. First off what is tor? Tor stands for " The Onion Router " and allows you to anonymously browse the internet by bouncing your request through multiple tor nodes. I’m going to be using a Fedora 17 machine to demonstrate, and show output. First lets install two packages from our package manager:

Pathfinder Equipment in JSON Form

While reading through the Pathfinder Core Rule book I notice there is a specific way to randomly generate magic items for town shops. I thought about possibly creating some code to generate magic items. However, to start I needed the basic data found in the rule book for equipment. Below I give you a JSON file I created of the SRD 3.5 equipment: https://nessy.info/equipment.json In [1]: from urllib2 import urlopen In [2]: from json import loads In [3]: data = urlopen('https://nessy.

MagTek USB Card Reader Hacking 2

So back at it, now with some code to decode the common financial card: Let start out by showing the end results of scanning my Freebirds card: # ./main.py Please swipe your card now: Raw String: %B???????????^FANATIC/FREEBIRDS^4211?;????????????=???????????? Card Holder: FANATIC/FREEBIRDS Card Number: ????-????-????-???? Expiration Date: 11/42 As you can see we still have our raw string, this is being decoded from the code I used last time. However now I have the Card Holder’s name, Card Number, and Expiration date, this format was all outlined quite well on Wikipedia .

MagTek USB Card Reader Hacking

So just the other day I received my MagTek MSR100 in the mail, this unit only cost me about $20 and I have to say I’m very satisfied with it. After opening the box it was delivered in I quickly noticed no documentation was provided. No worries I figured, this will make hacking at it that much more fun. I started out by connecting the USB device to my Gentoo Linux laptop and swiped a card, I noticed on my console prompt the card data was spewed out.

Python Device Hacking (Keyboard)

After spending a bit of time hacking at the gamepad I decided to take a deeper look in to how /dev devices worked in Python, the easiest device I could get my hands on of course was a keyboard. First things first I needed to discover which device name represented my keyboard, to do this I used the virtual /proc filesystem at /proc/bus/input/devices : I: Bus=0011 Vendor=0001 Product=0001 Version=ab41 N: Name="AT Translated Set 2 keyboard" P: Phys=isa0060/serio0/input0 S: Sysfs=/devices/platform/i8042/serio0/input/input3 U: Uniq= H: Handlers=sysrq kbd event2 B: PROP=0 B: EV=120013 B: KEY=4 2000000 3803078 f800d001 feffffdf ffefffff ffffffff fffffffe B: MSC=10 B: LED=7 From the above output I can see my device is event2 within Handlers, which I know is the block device /dev/input/event2 .