Sign in to follow this  
Followers 0
spanga

Getting a computer unique string

59 posts in this topic

#21 ·  Posted

No, I have no problem with your solution -- that's the thing.

What I meant by my remark was that no solution will guarantee unique results from every computer in the world, but your solution seems to come closer to that than the others.

Share this post


Link to post
Share on other sites



#22 ·  Posted

Oh, I see. I misunderstood your reply ;-)

Regards.

Buffo

Share this post


Link to post
Share on other sites

#23 ·  Posted

All the responses look great - especially the processor ID. However, it's relatively easy to change the processor, and where I work we frequently get machines back from repair with no serial number, model name, manufacturer in the Bios (where WMI gets the info).

However, I rarely see machines with invalid (typically all F's or zeros) UUID's - and haven't seen a blank one yet.

Here's a small script that uses the function _ComputerUUID() to get the computer's UUID:

; Generated by AutoIt Scriptomatic
MsgBox ( 0, @ScriptName, _ComputerUUID() )

Func _ComputerUUID( $strComputer="localhost" )
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $sRetUUID=""
    $objWMIService = ObjGet ( "winmgmts:\\" & $strComputer & "\root\CIMV2" )
    $colItems = $objWMIService.ExecQuery ( "SELECT * FROM Win32_ComputerSystemProduct", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly )
    If IsObj ( $colItems ) then
       For $objItem In $colItems
          $sRetUUID = $objItem.UUID
       Next
    Else
       SetError ( 1 )
       Return $sRetUUID
    Endif
    Return $sRetUUID
EndFunc

Share this post


Link to post
Share on other sites

#24 ·  Posted

All the responses look great - especially the processor ID. However, it's relatively easy to change the processor, and where I work we frequently get machines back from repair with no serial number, model name, manufacturer in the Bios (where WMI gets the info).

However, I rarely see machines with invalid (typically all F's or zeros) UUID's - and haven't seen a blank one yet.

Here's a small script that uses the function _ComputerUUID() to get the computer's UUID:

; Generated by AutoIt Scriptomatic
MsgBox ( 0, @ScriptName, _ComputerUUID() )

Func _ComputerUUID( $strComputer="localhost" )
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $sRetUUID=""
    $objWMIService = ObjGet ( "winmgmts:\\" & $strComputer & "\root\CIMV2" )
    $colItems = $objWMIService.ExecQuery ( "SELECT * FROM Win32_ComputerSystemProduct", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly )
    If IsObj ( $colItems ) then
       For $objItem In $colItems
          $sRetUUID = $objItem.UUID
       Next
    Else
       SetError ( 1 )
       Return $sRetUUID
    Endif
    Return $sRetUUID
EndFunc
Mine returns all F's


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#25 ·  Posted (edited)

@JerryD: Mine returns all F's too.

@Buffo: Your workaround could be great and I really like it. However consider that in machines that are "ghosted" this workaround will have no effect at all. In this way you must have done a clean installation on each machine to get a unique ID from these files you mentioned.

In any case what I would propose is to combine several things in one string such as:

The HD's serial

The processor's ID

The MAC address (if a NIC is present)

...and the length of other non-numerical strings like:

Processor's name

System name

Processor's manufacturer name

Processor's description

...etc etc.

By adding only numbers of ready serials or of the length of alphanumerical strings (that are always unique) will have our unique serial number that can be MD5 hashed afterwards.

Edit: Ah, you may also consider adding the date numbers that Buffo mentioned as well. I think you got the point, the more the better.

Better?

Edited by erebus

Share this post


Link to post
Share on other sites

#26 ·  Posted (edited)

In my situation the uniq id must be data that easily a person(or customer) can give.Another thing.All pcs are ghosted (obviously Operating ids and date files are the same).And then like spanga said this id must not depends an an computer part.(If this part damaged and replaced we have problem) I think ip and public ip for a lan is the best thing to look. So i choose to Look ip for Authentication and send data to my computer after a while(if prog succefully runned) with the public ip.Just to know who is using my prog.Question: Should i look also Gateway for athentication? Gateway is always uniq for a Lan such as Internet caffe? (TO avoid illigan use of my program) This must be depending of the way someone has built the lan .A lan on a store can probably have the same ips with another store.But gateway must be different.am I right?

Edited by Amen

Share this post


Link to post
Share on other sites

#27 ·  Posted

No, you are not.

It is very usual in several LANs (and in internet cafes too) to use the private ip of a common router as a gateway (like 192.168.1.1 for Zyxel, 10.0.0.138 for Alcatel/Thomson, 192.168.0.1 for some others, etc.).

We rarely change the default router's IP and the only case to find public IPs set in Windows network settings is the case to use these IPs outside your router settings and widely set in your LAN (meaning that instead of routing with your router to route from each Windows box).

Share this post


Link to post
Share on other sites

#28 ·  Posted

You could use the computer serialnumber

; Get the serial number and asset tag of a computer
; 25 November 2005 by Geert (NL)
; Translated VBScript source code: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_tasks__computer_hardware.asp
; AutoIt 3.1.x Beta needed

$strComputer = "."
$objWMIService = ObjGet("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & $strComputer & "\root\cimv2")
$colSMBIOS = $objWMIService.ExecQuery _
    ("Select * from Win32_SystemEnclosure")
For $objSMBIOS in $colSMBIOS
    MsgBox(0,"","Part Number: " & $objSMBIOS.PartNumber)
    MsgBox(0,"","Serial Number: " & $objSMBIOS.SerialNumber)
    MsgBox(0,"","Asset Tag: " & $objSMBIOS.SMBIOSAssetTag)
Next
i was going to say home drive serial...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#29 ·  Posted

System UUID on replacement motherboards and quite a number of AMD-based boards have either all F's or all 0's.

Also Part#, Serial#, and Tag # may be all 0's or 1234567890 on replacement boards.

I think a combination of data joined together should do the trick...Consider ComputerName + MAC + Time that OS had been installed should be somewhat unique.

Share this post


Link to post
Share on other sites

#30 ·  Posted

Computer name and MAC can be spoofed. I am using a FileGetTime of Creation method for 2 required none editable system files.

Share this post


Link to post
Share on other sites

#31 ·  Posted

Basic point.

There isnt going to be something that is totally unique. You will have to probably take many of the above suggestions and combine them. To make a semi-unique string. You could then convert that string to a numerical form run a formula to shorten the string, and then convert back to a new string. Make that the unique value.

There isnt going to be a fool proof way just like bullet proof glass can still be broken. Just its harder.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

#32 ·  Posted

Point made :P

Well done JS, if you would like to post my ClientAuthID UniqueID funcs on your behalf you can :lmao: After all I got ideas from your quotes.

Share this post


Link to post
Share on other sites

#33 ·  Posted

Another way is to get the computer SID, which will not be unique if the PC's are cloned and are not joined to a domain. The SID on cloned PCs can be changed with ease.

NB system files on cloned PC's will have the same creation and modification date.

Will this provide an absolute unique ID? NO, but nothing will. Even NIC's can have a duplicate MAC address, despite manufacturer having to request MAC ranges from an international association.

If the idea is to ensure unique ID on your network only, this will work.

Read SID, www.sysinternal.com

Change SID, www.sysinternal.com


CheersNobby

Share this post


Link to post
Share on other sites

#34 ·  Posted

Point made :P

Well done JS, if you would like to post my ClientAuthID UniqueID funcs on your behalf you can :lmao: After all I got ideas from your quotes.

Do I detect a bit of sarcasim? :(

If you think it would possibly help then yes please post it.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

#35 ·  Posted

Adding (most) of what you all said together allows me to produce these two UDFs:

;===============================================================================
;
; _UniqueWoodID( $com, $no )
; Description:      Used to generate a nearly "unique" ID for a computer
; Parameter(s):     [optional] $com : name of computer to generate ID for (default=localhost)
;                   [optional] $no : shortening value used to shorten id(default: 5)
; Requirement:      AutoIt
; Return Value(s):  The ID for the computer
; Author(s):        Alexander "TechDude" Wood
; Note(s):          Use the SAME shortening value every time you call this function.
;                  I feel that _UniqueWoodID2() is more unique than this
;
;===============================================================================
#Include <String.au3>
Func _UniqueWoodID( $com = "localhost", $no = 5 )
;$time = TimerInit()
    $colItems = ""
    $objWMIService = ObjGet ("winmgmts:\\" & $com & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor", "WQL", 0x10 + 0x20)
    If IsObj ($colItems) Then
        For $objItem In $colItems
            $Out1 = _StringEncrypt(1, $objItem.AddressWidth & $objItem.Architecture & $objItem.Caption, _
                    $objItem.ConfigManagerErrorCode & $objItem.ConfigManagerUserConfig & $objItem.DataWidth)
            $Out2 = _StringEncrypt(1, $objItem.Description & $objItem.DeviceID & $objItem.ExtClock, _
                    $objItem.Family & $objItem.InstallDate & $objItem.L2CacheSize)
            $Out3 = _StringEncrypt(1, $objItem.L2CacheSpeed & $objItem.Level & $objItem.Manufacturer, _
                    $objItem.MaxClockSpeed & $objItem.Name & $objItem.OtherFamilyDescription)
            $Out4 = _StringEncrypt(1, $objItem.PNPDeviceID & $objItem.ProcessorId & $objItem.ProcessorType, _
                    $objItem.Revision & $objItem.Role & $objItem.SocketDesignation)
            $Out5 = _StringEncrypt(1, $objItem.SystemCreationClassName & $objItem.SystemName & $objItem.UniqueId, _
                    $objItem.UpgradeMethod & $objItem.Version & $objItem.VoltageCaps)
            $Output = $Out1 & $Out2 & $Out3 & $Out4 & $Out5 & _WoodIDhelper2()
            $Output = _WoodIDhelper( $Output, $no )
        ;MsgBox(0, "Unique Wood's ID", $Output)
        ;MsgBox(0, "Timer", TimerDiff( $time ))
            Return $Output
            ExitLoop;;Only want first match (will have more matches for multipule processor/multithreaded systems)
        Next
    Else
        MsgBox(0, "Unique Wood's ID - ERROR", "No WMI Objects Found for class: " & "Win32_Processor")
        Exit -1
        Return
    EndIf
EndFunc  ;==>_UniqueWoodID
;===============================================================================
;
; _UniqueWoodID2( $com, $no )
; Description:      Used to generate a nearly "unique" ID for a computer
; Parameter(s):     [optional] $com : name of computer to generate ID for (default=localhost)
;                   [optional] $no : shortening value (default: 2 )
; Requirement:      AutoIt
; Return Value(s):  The Wood's ID for the computer
; Author(s):        Alexander "TechDude" Wood
; Note(s):          Use the SAME shortening value every time you call this function.
;
;===============================================================================
Func _UniqueWoodID2( $com = "localhost", $no = 2 )
;$time = TimerInit()
    $colItems = ""
    $objWMIService = ObjGet ("winmgmts:\\" & $com & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor", "WQL", 0x10 + 0x20)
    If IsObj ($colItems) Then
        For $objItem In $colItems
            $Out1 = $objItem.AddressWidth & $objItem.Architecture & $objItem.Caption & _
                    $objItem.ConfigManagerErrorCode & $objItem.ConfigManagerUserConfig & $objItem.DataWidth
            $Out2 = $objItem.Description & $objItem.DeviceID & $objItem.ExtClock & _
                    $objItem.Family & $objItem.InstallDate & $objItem.L2CacheSize
            $Out3 = $objItem.L2CacheSpeed & $objItem.Level & $objItem.Manufacturer & _
                    $objItem.MaxClockSpeed & $objItem.Name & $objItem.OtherFamilyDescription
            $Out4 = $objItem.PNPDeviceID & $objItem.ProcessorId & $objItem.ProcessorType & _
                    $objItem.Revision & $objItem.Role & $objItem.SocketDesignation
            $Out5 = $objItem.SystemCreationClassName & $objItem.SystemName & $objItem.UniqueId & _
                    $objItem.UpgradeMethod & $objItem.Version & $objItem.VoltageCaps
            $Output = $Out1 & $Out2 & $Out3 & $Out4 & $Out5 & _WoodIDhelper2()
            $Output = _WoodIDhelper3( _WoodIDhelper( $Output, $no ) )
        ;MsgBox(0, "Unique Wood's ID", $Output)
        ;MsgBox(0, "Timer", TimerDiff( $time ))
            Return $Output
            ExitLoop;;Only want first match (will have more matches for multipule processor/multithreaded systems)
        Next
    Else
        MsgBox(0, "Unique Wood's ID - ERROR", "No WMI Objects Found for class: " & "Win32_Processor")
        Exit -1
        Return
    EndIf
EndFunc  ;==>_UniqueWoodID2
Func _WoodIDhelper( $str, $no=1 );;Used to shorten the string
    If ($no < 1) Or ($no == 1) then Return $str
    $str = StringSplit( $str, "" )
    Local $ret = ""
    For $i = 1 to $str[0] Step $no
        $ret &= $str[$i]
    Next
    Return $ret
EndFunc
Func _WoodIDhelper2()
    Return FileGetTime( @HomeDrive & "\io.sys", 1, 1 ) & FileGetTime( @HomeDrive & "\recycler", 1, 1 ) & FileGetTime( @HomeDrive & "\LocalService\ntuser.ini", 1, 1 )
EndFunc
Func _WoodIDhelper3($str)
    $str = StringSplit( $str, @TAB & " ,_()"& @CR & @LF )
    Local $ret = ""
    For $i = 1 to $str[0]
        $ret &= $str[$i]
    Next
    Return StringUpper( $ret )
EndFunc

Note that the smaller the $no value, the longer the string, but the greater the uniqueness.

Samples:

MsgBox(0, "Version 2 of Wood's Unique ID - $no of 1", _UniqueWoodID2("localhost", 1))
MsgBox(0, "Version 2 of Wood's Unique ID - $no of 2(default)", _UniqueWoodID2())
MsgBox(0, "Version 1 of Wood's Unique ID - $no of 1", _UniqueWoodID("localhost", 1))
MsgBox(0, "Version 1 of Wood's Unique ID - $no of 5(default)", _UniqueWoodID2())

According the the Timing provided by TimerInit() and TimerDiff(), it takes slightly less than 2100 milliseconds of it to calculate the Unique computer ID.

Share this post


Link to post
Share on other sites

#36 ·  Posted (edited)

sorry to bring up the old topic... maybe i should have researched this, but if the systems you're using have the system restore tool then you can read this: C:\WINDOWS\system32\Restore\MachineGuid.txt

is all i know is that my system has that (windows xp home edition), and im pretty sure someone mentioned a Guid being nearly if not impossible to reproduce

i see you have some udf's working for you, but i came accross this and remebered this thread :P

Edited by layer

FootbaG

Share this post


Link to post
Share on other sites

#37 ·  Posted (edited)

sorry to bring up the old topic... maybe i should have researched this, but if the systems you're using have the system restore tool then you can read this: C:\WINDOWS\system32\Restore\MachineGuid.txt

is all i know is that my system has that (windows xp home edition), and im pretty sure someone mentioned a Guid being nearly if not impossible to reproduce

i see you have some udf's working for you, but i came accross this and remebered this thread :lmao:

I was surfing around, and came across a very easy way to generate a GUID.

;===============================================================================
;
; Function Name:    _GenGUID()
; Description:    Generates a GUID (globally unique identifier)
; Parameter(s):  None
; Requirement(s):   AutiIt 3.1.1 Beta (tested with version 101)
; Return Value(s):  On Success - Returns a string with the GUID
;                  On Failure - ''  and sets @ERROR = 1
; Author(s):        JerryD
; Reference:        http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb05/hey0221.mspx
;
;===============================================================================
Func _GenGUID()
    Local $sRetGUID
    $TypeLib = ObjCreate ( 'Scriptlet.TypeLib' )
    If IsObj( $TypeLib ) Then
        $sRetGUID = $TypeLib.Guid
        $TypeLib = ''
        Return $sRetGUID
    Else
        $TypeLib = ''
        SetError(1)
        Return ''
    EndIf
EndFunc  ;==>_GenGUID

BTW - I'm running System Resotre, and don't find MachineGuid.txt anywhere. Maybe it's only generated when you actually perform a restore which I've never done, plus I'm running XP Pro.

Jerry

Modified to release object after reading SvenP's comments in How to release an object reference

Edited by JerryD

Share this post


Link to post
Share on other sites

#38 ·  Posted

You could use the computer serialnumber

; Get the serial number and asset tag of a computer
; 25 November 2005 by Geert (NL)
; Translated VBScript source code: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_tasks__computer_hardware.asp
; AutoIt 3.1.x Beta needed

$strComputer = "."
$objWMIService = ObjGet("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & $strComputer & "\root\cimv2")
$colSMBIOS = $objWMIService.ExecQuery _
    ("Select * from Win32_SystemEnclosure")
For $objSMBIOS in $colSMBIOS
    MsgBox(0,"","Part Number: " & $objSMBIOS.PartNumber)
    MsgBox(0,"","Serial Number: " & $objSMBIOS.SerialNumber)
    MsgBox(0,"","Asset Tag: " & $objSMBIOS.SMBIOSAssetTag)
Next
Whooo ! Great to be back :lmao:

Ok well, this didn't work on my computer - I got generic values for everything.

Mind you one thing that might be arguably be better as a reference is ....

well without saying it, one could "hitch a ride" with Microsoft...

hint --> what's the same on each install, is different for each user and can be found within the registry?

hint --> FCKGW RHQQ2 ...


I am endeavoring, ma'am, to construct a mnemonic circuit using stone knives and bearskins.SpockMy UDFs:Deleted - they were old and I'm lazy ... :)My utilities:Comment stripperPolicy lister 1.07AutoIT Speed Tester (new!)

Share this post


Link to post
Share on other sites

#39 ·  Posted

beats me ;)

Matt :lmao:


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

#40 ·  Posted

i not sure....but isn't the windows product id unique?

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ProductId


Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0