So you may have looked at /proc/net/route before and thought how the heck am I suppose to read this. Well here is the low down.
This file uses endianness to store the addresses as hexadecimal, in reverse; for example 192 as hex is C0 :
In []: hex(192) Out[]: '0xc0' So lets take a look at our route file:
Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT eth0 00087F0A 00000000 0001 0 0 0 00FFFFFF 0 0 0 eth0 0000FEA9 00000000 0001 0 0 1002 0000FFFF 0 0 0 eth0 00000000 01087F0A 0003 0 0 0 00000000 0 0 0 Now the first entry has a destination of 00087F0A , lets go ahead and chunk these in to hex characters:
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.