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:

# ./get_hashpipe.pl
 Running Snow Leopard, version 10.6.8
 You is: zen
 Gen UID for zen = 70140C2C-0014-4759-A3CE-D7DC9EAA047C
 I got your hash pipe:
 E2DBDB9CE7C573B9CF242EE9B01AD4D4C9DDEFDDE74F9E4

 

Etcetera.  Thought about options to specify users or get all user hashes, but I don’t really use this much :)

#!/usr/bin/perl

#
# get a hash from the mysterious mac storage place
#

#
# get OS version
#
# looks like sw_vers came out in 10.3... at least that's
# what the man page uses as an example
#
# outputs something like:
#
#       ProductName:    Mac OS X
#       ProductVersion: 10.6.8
#       BuildVersion:   10K549
#
# According to wiki:
#       Public Beta: "Kodiak"
#       Version 10.0: "Cheetah"
#       Version 10.1: "Puma"
#       Version 10.2: "Jaguar"
#       Version 10.3: "Panther"
#       Version 10.4: "Tiger"
#       Version 10.5: "Leopard"
#       Version 10.6: "Snow Leopard"
#       Version 10.7: "Lion"
#
# I was running kodiak at earthlink, back in the day, who knew?
# Close enough to UNIX (but what is UNIX anymore, really?)
# Schweet cinema display, too! That machine cost over 10k....
#
%OS_NAME = (
"10.0" => "Cheetah",
"10.1" => "Puma",
"10.2" => "Jaguar",
"10.3" => "Panther",
"10.4" => "Tiger",
"10.5" => "Leopard",
"10.6" => "Snow Leopard",
"10.7" => "Lion"
);

open(OS_VER, "sw_vers |") || die "can't run sw_vers\n";
while () {
chomp;
($key, $value) = split(/:\s*/);
if (/ProductVersion/) {
($maj, $min, $rev) = split(/\./, $value);
# print "Maj: $maj, Min: $min, Rev: $rev ($maj.$min)\n";
print "Running " . $OS_NAME{"$maj.$min"} . ", version $maj.$min.$rev\n";
last;
}
}
close(OS_VER);

# who are you/me/etc?
# started with whoami... but sudo fucks with it... getlogin should do the trick
$i_is = getlogin();
print "You is: $i_is\n";

# get the Generated UID

# should work post tiger
if ($min > 3) {
open(DSCL, "dscl localhost -read /Search/Users/$i_is |") || die "can't run dscl\n";
while () {
chomp;
if (/GeneratedUID/) {
$guid = substr($_, 14);
print "Gen UID for $i_is = $guid\n";
last;
}
} close(DSCL);
}
# on Tiger you might have to run... but does anyone really care? No idea if this works
elsif ($min == 3) {
open(NIUTIL, "niutil -readprop . /users/$i_is generateduid|") || die "can't run niutil successfully\n";
}
else {
print "Min = $min\n";
die "come on loser, this was written in 2012. What does OS = $maj.$min.$min mean?\n";
}

#
# finally, pass the hash pipe (cue wheezer)
#

$shadow_file = "/var/db/shadow/hash/$guid";

die "can't read $shadow_file\n" if (! -r $shadow_file);
open(GUIDFILE, $shadow_file) || die "can't open shadow hash file $shadow_file\n";
$shadow_line = ;
chomp($shadow_line);
close(GUIDFILE);

$hash_pipe = substr($shadow_line, 168, 48);

print "I got your hash pipe:\n$hash_pipe\n";

 

get_hashpipe.pl
Title: get_hashpipe.pl (0 click)
Caption:
Filename: get_hashpipe.pl
Size: 2 kB

Sorry, the comment form is closed at this time.

   
© 2012 trouble Suffusion theme by Sayontan Sinha