reading wtmp

 code, perl, security, tech  Comments Off on reading wtmp
Sep 102012

Have a wtmp file you need read? A nice perl one liner to do so: perl -we ‘@type=("Empty","Run Lvl","Boot","New Time","Old Time","Init","Login","Normal","Term","Account");$recs = ""; while (<>) {$recs .= $_};foreach (split(/(.{384})/s,$recs)) {next if length($_) == 0;my ($type,$pid,$line,$inittab,$user,$host,$t1,$t2,$t3,$t4,$t5) = $_ =~/(.{4})(.{4})(.{32})(.{4})(.{32})(.{256})(.{4})(.{4})(.{4})(.{4})(.{4})/s;if (defined $line && $line =~ /\w/) {$line =~ s/\x00+//g;$host =~ s/\x00+//g;$user =~ s/\x00+//g;printf("%s %-8s %-12s %10s %-45s\n",scalar(gmtime(unpack("I4",$t3))),$type[unpack("I4",$type)],$user,$line,$host)}}print"\n"’ < /var/log/wtmp Thanks to:

and now… custom fields

 perl, web  Comments Off on and now… custom fields
Mar 202012

Useful little things.  Beat on that old perl script and added support… a few lines of code, a lot of beating my head against the wall, but I didn’t see any other perl solutions.


After looking at about a zillion different options I ended up with Leo Charre’s WordPress CLI CPAN package for uploading posts… and after a bit of tinkering got it to work with 3.x WP.  However… it didn’t support tags, which I really needed for the project I’m working on.   This handy pointer to how to do it to java saved my bacon: it turns out that making a very […]

getting password hash on OS-X

 code, mac, security, tech  Comments Off on getting password hash on OS-X
Jan 142012

I keep having to look this up… so here’s a perl script (click to DL below). Also prints out some other stuff I keep forgetting how to get. Also does it for the user logged in, so you can sudo and have it work. Will die if you can’t read the hash file. Sample run: # ./ Running Snow Leopard, version 10.6.8 You is: zen Gen UID for zen […]

© 2012 trouble Suffusion theme by Sayontan Sinha