1 // Hardware ID
 2 // © Oscar Kohler
 3 
 4 use strict;
 5 
 6 use Win32::OLE qw(in with);
 7 use Digest::MD5;
 8 
 9 my $oWmi;
10 my @aoClass = ();
11 my $sHWID = '';
12 
13 $oWmi = Win32::OLE->GetObject("WinMgmts://./root/cimv2");
14 if ($oWmi) { 
15     
16    #-> Bios ID
17    @aoClass = Win32::OLE::Enum->All(
18       $oWmi->InstancesOf ('Win32_BIOS'));
19    if ($aoClass[0]) {
20       $sHWID .= $aoClass[0]->{'SerialNumber'};
21    }
22    
23    #-> Cpu ID (Unique innerhalb einer CPU Familie)
24    @aoClass = Win32::OLE::Enum->All(
25       $oWmi->InstancesOf ('Win32_Processor'));
26    if ($aoClass[0]) {
27       $sHWID .= $aoClass[0]->{'UniqueId'};
28    }
29    
30    #-> Volume-ID c: (Wird mit der Neuinstallation gešndert.)
31    @aoClass = $oWmi->Get('Win32_LogicalDisk.DeviceID="c:"');
32    if ($aoClass[0]) {
33       $sHWID .= $aoClass[0]->{'VolumeSerialNumber'};
34    }
35    
36    #-> Windows system (Seriennummer, Installationsdatum)
37    #   ( Vorsicht: Installationsdatum šndert sich mit der Zeitzone ! )
38    @aoClass = Win32::OLE::Enum->All(
39       $oWmi->InstancesOf ('Win32_OperatingSystem'));
40    if ($aoClass[0]) {
41       $sHWID .= $aoClass[0]->{'SerialNumber'};
42       $sHWID .= $aoClass[0]->{'InstallDate'};
43    }
44    
45    undef $oWmi;
46    
47    print "Raw:  ".$sHWID."\n";
48    print "Hash: ".Digest::MD5::md5_hex($sHWID)."\n";
49 }
50 else {
51    print "Can't open WMI !\n";
52 }
53 
54 exit 0;