Category Archives: Uncategorized

Windows Product Key Kernel Module

For fun, I created a simple kernel module for linux to extract the windows product key from the acpi table msdm (acpidump is your friend) and create a sysfs object to read it.

Usage:

cat /sys/devices/platform/windows_product_key/key

> XXXX-XXXX-XXXX-XXXX

 

 

Code: https://github.com/btwotch/windows_product_key

colorful pastebin for use in terminals

Some months ago I played a bit with the highlight C++ library (https://www.gnu.org/software/src-highlite/) and libhttpserver (https://github.com/etr/libhttpserver) to build a simple embedded pastebin server that server the source code highlighted via ansi control sequences.

Check it out: https://github.com/btwotch/pastebin

Have a lot of fun!

Backup: GReader2Sqlite

Backup your google reader into a sqlite database; moreover all used xml files (received via the API) are also stored. You should use this script in an empty directory!

#!/usr/bin/perl -w

#--------Enter your credentials here-----------------
my $user= 'sjobs@gmail.com';
my $pwd = 'iPassword';



#----------------------------------------------------
use strict;
use LWP;
use XML::Simple;
use LWP::UserAgent;
use Data::Dumper;
use DBI;

my $dbh; 
my $xml;
my $st; 
my $count = 0;
my $ua = LWP::UserAgent->new;;
$ua->agent("GReader Export ");

my $req = HTTP::Request->new(GET => 'https://www.google.com/accounts/ClientLogin?service=reader&Email='.$user.'&Passwd='.$pwd);
my $res = $ua->request($req);

die $res->status_line, "\n" if (not $res->is_success);
$res->content =~ m/Auth=(\S*)/;
my $auth = $1;


$req = HTTP::Request->new(GET => 'http://www.google.com/reader/api/0/subscription/list?output=xml');
$req->header(Authorization => 'GoogleLogin auth='.$auth);
$res = $ua->request($req);
die $res->status_line, "\n" if (not $res->is_success);


open (FILEHANDLE, ">subscriptions.xml");
print FILEHANDLE $res->content;
close FILEHANDLE;

$dbh = DBI->connect("dbi:SQLite:dbname=greader.db",{AutoCommit => 0});
$dbh->do('CREATE TABLE IF NOT EXISTS subscriptions (id VARCHAR PRIMARY KEY, title VARCHAR, htmlUrl VARCHAR, file VARCHAR)');
$dbh->do('CREATE TABLE IF NOT EXISTS feeds (id VARCHAR REFERENCES subscriptions(id), title VARCHAR, link VARCHAR, label VARCHAR, content VARCHAR)');
$st = $dbh->prepare("INSERT OR REPLACE INTO subscriptions (id, title, htmlUrl, file) VALUES (?, ?, ?, ?)");

my $xs = XML::Simple->new;
$xml = $xs->XMLin($res->content, KeyAttr => {});

my $id;
my $title;
my $htmlurl;
my $label;
my $content;
my $link;
my $file;
foreach my $object (values $xml->{list}->{object}) {
	foreach my $string (values $object->{string}) {
		$id = $string->{content} if ($string->{name} eq 'id');
		$title = $string->{content} if ($string->{name} eq 'title');
		$htmlurl = $string->{content} if ($string->{name} eq 'htmlUrl');
	}
	$file = substr($htmlurl, 0, 30);
	$file =~ s/[^0-9a-z_-]+/_/gi;
	$file = $file."-".$count.".xml";
	$st->execute($id, $title, $htmlurl, $file);
	$count++;
}


$st = $dbh->prepare("SELECT id, file FROM subscriptions");
my $st_insert = $dbh->prepare("INSERT OR REPLACE INTO feeds (id, title, link, label, content) VALUES (?, ?, ?, ?, ?)");
$st->execute();
while ((my $row = $st->fetchrow_hashref())) {
	print $count--." ".$row->{id}."\n";
	$req = HTTP::Request->new(GET => 'http://www.google.com/reader/atom/'.$row->{id});
	$req->header(Authorization => 'GoogleLogin auth='.$auth);
	$res = $ua->request($req);
	next if (not $res->is_success);

	open (FILEHANDLE, ">".$row->{file});
	print FILEHANDLE $res->content;
	close FILEHANDLE;

	$xml = $xs->XMLin($res->content, KeyAttr => {});
	foreach my $entry (values $xml->{entry}) {

		open (FILEHANDLE, ">".$row->{file}.".dump");
		print FILEHANDLE Dumper($xml);
		close FILEHANDLE;

		$title = ""; $link = ""; $label = ""; $content = "";
		if (not ref($entry) eq 'HASH') {
			next;
		}
		if (ref($entry->{title}) eq 'HASH') {
			$title = $entry->{title}->{content} if (defined $entry->{title}->{content});
		} else {
			$title = $entry->{title} if (defined $entry->{title});
		}
		if(ref($entry->{link}) eq 'ARRAY'){
			$link = $entry->{link}[0]->{href} if (defined $entry->{link}[0]->{href});
		} else {
			$link = $entry->{link}->{href} if (defined $entry->{link}->{href});
		}
		if (defined $entry->{category}) {
			foreach my $l (values $entry->{category}) {
				$label = $label.$l->{label}." " if (ref($l) eq 'HASH' and defined $l->{label});
				chomp $label;
			}
		}
		if (ref($entry->{content}) eq 'HASH') {
			$content = $entry->{content}->{content} if (defined $entry->{content}->{content});
		} else {
			$content = $entry->{content} if (defined $entry->{content});
		}
		chomp $title; chomp $link; chomp $label; chomp $content;
		$st_insert->execute($row->{id}, $title, $link, $label, $content);
	}
}

How I unbricked my 19 days old thinkpad

and switched away from my macbook again …

Last monday the on-site technician exchanged the motherboard (only the motherboard, i.e. he removed the cpu from the old board and put it on the new one!). Afterwards it didn’t work anyway.

On the 6th day lenovo support called me and asked me if they could send me a new RAM. Half an hour later a technician called me, if it is okay to come in an hour to fix my computer.
Meanwhile I’ve removed one RAM bar and now it works :) (I never tried that before, because the telephon support said that I should see something on the display if I remove the main memory completely). An hour later the technician called again, that he doesn’t come, because no hardware (i.e. ram) arrived.

As the technician on monday couldn’t boot my laptop he wasn’t able set any serial numbers, so I had to do that myself: http://down-circle.blogspot.com/2012/07/ibm-lenovo-thinkpad-maintenance-disk.html

this is an update to: https://btwotch.wordpress.com/2013/02/28/how-i-bricked-my-13-days-old-thinkpad/