Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Getting USB unique ID ?


  • Please log in to reply
23 replies to this topic

#1 ironmankho

ironmankho

    Wayfarer

  • Active Members
  • Pip
  • 63 posts

Posted 05 November 2008 - 07:53 PM

Getting USB unique ID

i know very well in auto it a function named get serial # is also available ........my question is it is unique or not .e.g when i format it will change ?

how it is possible to get this type of info via autoit .................

Posted Image

OR another possible method to getting unique # info . i have Kingston data traveler 4 GB DTI


Thanks for reading waiting for answer







#2 dbzfanatic

dbzfanatic

    functional psychopath!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,090 posts

Posted 05 November 2008 - 08:00 PM

Serial numbers usually are unique,at least per machine. Why do you need this information? Perhaps someone here can think of a better method to do what you want, or a simpler one if not better.

#3 ironmankho

ironmankho

    Wayfarer

  • Active Members
  • Pip
  • 63 posts

Posted 05 November 2008 - 08:16 PM

thanks for kind reply .... actually i want develop dongle type application .... it only run from Authorized USB ...what is your Idea ?

Edited by ironmankho, 05 November 2008 - 08:16 PM.


#4 dbzfanatic

dbzfanatic

    functional psychopath!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,090 posts

Posted 05 November 2008 - 08:25 PM

Well a few ideas would be to setup a database and check the data from the drive against that or have a registration file inside the drive. Those can't be reproduced because they're unique for each computer/drive.

CODE
;==========================================================================================

=========
====================================================================================================


=================================================================================================

#include <date.au3>
#include <string.au3>
#include <array.au3>

Global $Debugit = 1
Local $securityCodeEncryptionKey = "somepassword";this must match the key generator
Global $mac = StringUpper (StringReplace (_GetMAC(),":","") & StringRight ( Hex(@mon),1)); this makes the mac address only valid during this month or registration, so if they discover the fake dll and delete it, the code only registers during this month of cousre they could figure on putting it back to the original registration month
Global $Generate = StringRight ($mac,5)
Global $restore = StringUpper (_StringEncrypt (1, $Generate, $securityCodeEncryptionKey , 1 ))
Global $myFakeDll = @Windowsdir & "\CBfu11.dll"; I suggest using a prefix of T for Trial software in the dllname and be sure it's not a dll name that is going to already exist you could hide it in the windows directory or anywhere else really
Global $trialPeriod = -1;days (use -1 if not trial software just regkey licenced)
Global $applicationName = "Choas Bot"
Global $dllEncKey = "O59yuey93";you can change this to whatever you like it is the ini encryption if made too long and it takes longer to read and write
Global $dlliniSection = Encrypt("iniSectionName");you can change this too if you really want to

If NOT FileExists ($myFakeDll) then
EnterNewCode()
EndIf

$validation = CheckValidation()

;============================================Main app Starts here============================================

If $validation <> -1 then
Msgbox(0,"","This is the main application start point" & @crlf & "If you can see this then you have a successfully registered application" & @crlf & "You have " & $validation & " Days left to evaluate this software")
Else
Msgbox(0,"","This is the main application start point" & @crlf & "If you can see this then you have a successfully registered application")
EndIf















Func EnterNewCode()
ClipPut ($mac & "F")
$entered = InPutBox ("Register", "This software is not freeware. Please email" & @crlf & "chaosbotncp@hotmail.com to obtain a registration code." & @crlf & "Please quote the following Code: " & @crlf & @crlf & $mac & "F" & @crlf & @crlf & "It has been placed on the clipboard for easy usage." & @CRLF & @CRlf & "Enter the unlock code below:","","",-1,250)

If @error = 1 then Exit;CANCEL WAS PRESSED

If $entered = $restore then
MsgBox (262144,$applicationName,"Successfully Registered")

IniWrite ($myFakeDll,$dlliniSection,Encrypt ("DecodeKey"),Encrypt ($restore))
IniWrite ($myFakeDll,$dlliniSection,Encrypt ("GeneratedMac"),Encrypt ($Mac))

If $trialPeriod <> -1 then
IniWrite ($myFakeDll,$dlliniSection,Encrypt ("RegDate"),Encrypt (_NowCalcDate()))
$sysprep = _DateAdd ( "D", $trialPeriod, _NowCalcDate() )
IniWrite ($myFakeDll,$dlliniSection,Encrypt ("FinalDate"),Encrypt ($sysprep))
IniWrite ($myFakeDll,$dlliniSection,Encrypt ("LastRunDate"),Encrypt (_NowCalcDate()))
IniWrite ($myFakeDll,$dlliniSection,Encrypt ("Count"),Encrypt (0))
endif

Else
MsgBox (262144,"Error","Registration code is incorrect")
Exit

EndIf
EndFunc;==> EnterNewRegCode()




Func CheckValidation()


$RecordedMacCheck = StringLeft (StringRight (Decrypt (IniRead ($myFakeDll,$dlliniSection,Encrypt ("GeneratedMac"),"Eric")),5),4)
$MacCheck = StringLeft (StringRight ($mac,5),4)
If $RecordedMacCheck <> $MacCheck then
Debug ("Recorded Mac = " & $RecordedMacCheck)
Debug ("Macaddress = " & $MacCheck )
Debug ("The Mac code didn't match")
If FileExists ($myFakeDll) then FileDelete($myFakeDll)
EnterNewCode()
Return -1
EndIf

If $trialPeriod = -1 then return -1

Splashtexton ($applicationName,@crlf & "This is evaluation software",250,60)

$finalDateCheck = Decrypt ( IniRead ($myFakeDll,$dlliniSection, Encrypt("FinalDate"),""))
$RegDateCheck = Decrypt ( IniRead ($myFakeDll,$dlliniSection, Encrypt("RegDate"),""))
$LastRunDateCheck = Decrypt ( IniRead ($myFakeDll,$dlliniSection, Encrypt("LastRunDate"),""))
$CountCheck = Number( Decrypt ( IniRead ($myFakeDll,$dlliniSection, Encrypt("Count"),"")) )

If _DateDiff ("D", _NowCalcDate(),$finalDateCheck) < 0 Then
;the date is 14 days past the registration date
Debug ("passed the " & $trialPeriod & " days Expired " & _DateDiff ("D",$finalDateCheck, _NowCalcDate() ) )
SplashOff()
Msgbox (262144,$applicationName,"Evaluation Expired")
IniWrite ($myFakeDll,$dlliniSection,Encrypt ("Count"),Encrypt ($trialPeriod + 1))
Exit
EndIf


If _DateDiff ("D",$LastRunDateCheck,_NowCalcDate()) < 0 Then
;they have changed the clock bacwards so expire
Debug ("Clock date is set before last run date")
SplashOff()
Msgbox (262144,$applicationName,"Date tampering detected Evaluation Expired")
IniWrite ($myFakeDll,$dlliniSection,Encrypt ("Count"),Encrypt ($trialPeriod + 1))
Exit
EndIf

If $CountCheck >= $trialPeriod then;second method for checking days used
;trialPeriod days are up so expire
Debug ("Count is greater than " & $trialPeriod)
SplashOff()
Msgbox (262144,$applicationName,"Evaluation Expired")
Exit
EndIf

If _NowCalcDate() <> $LastRunDateCheck Then;if the date is different to the last ran date then increase the days used by 1
$CountCheck += 1
Debug ("Increase the used count; Count is now " & $CountCheck)
IniWrite ($myFakeDll,$dlliniSection,Encrypt ("Count"),Encrypt ($CountCheck))
IniWrite ($myFakeDll,$dlliniSection,Encrypt ("LastRunDate"),Encrypt (_NowCalcDate()));log the new last run date
EndIf

Sleep (2000)
SplashOff()

Return ($trialPeriod - $CountCheck)
EndFunc;==> CheckValidation()

Func Encrypt ($string)

Return _StringEncrypt (1, $String, $dllEncKey , 1 )

EndFunc;==> Encrypt()


Func Decrypt ($String)

Return _StringEncrypt (0, $String, $dllEncKey , 1 )

EndFunc;==> Decrypt()

Func Debug ($var)

If $Debugit then ConsoleWrite ($var & @crlf)

EndFunc;==> Debug to Scite()

Func _GetMAC($getmacindex = 1)
$ipHandle = Run(@ComSpec & ' /c ipconfig /all', '', @SW_HIDE, 2)
$read = ""
Do
$read &= StdoutRead($ipHandle)
Until @error

$read = StringStripWS($read,7)

$macdashed = StringRegExp( $read , '([0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2})', 3)
If Not IsArray($macdashed) Then Return 0
If $getmacindex < 1 Then Return 0
If $getmacindex > UBound($macdashed) Or $getmacindex = -1 Then $getmacindex = UBound($macdashed)
$macnosemicolon = StringReplace($macdashed[$getmacindex - 1], '-', ':', 0)
Return $macnosemicolon
EndFunc;==>_GetMAC
keygenerator: (not really needed if incorporated but helpful to keep separate to ensure only authorized devices run)
Plain Text         
#Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=chaos.ico #AutoIt3Wrapper_outfile=Chaos Bot Keygen.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Allow_Decompile=n #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** ; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.2.4.9 ; Author:        Chris Lambert ; ; Script Function: KeyGen for trial/licensed software ;   Template AutoIt script. ; ; ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include<string.au3> Local $securityCodeEncryptionKey = "somepassword";this must match the applications key $str = InputBox ("ISS Drive Check Registration","Input code") $str = StringTrimRight( $str, 1) If @error = 1 then exit     $Generate = StringUpper (StringRight ($str,5)) $restore = StringUpper(_StringEncrypt (1, $Generate, $securityCodeEncryptionKey , 1 )) ClipPut ($restore) Msgbox (0,"ISS Drive Check","The registration code is: " & $restore & @crlf & @crlf & "The code has been placed on the clipboard")


All you need to do is change "somepassword" to whatever you want your password to be (make sure it's the saem in the keygen and program) and then your program won't work withouth authorization. Also change my registration email to whatever you want yours to be. This is much easier to read in SciTE so it will make more sense there.

Edited by dbzfanatic, 05 November 2008 - 08:26 PM.


#5 torels

torels

    I Hacked 127.0.0.1! :D

  • Active Members
  • PipPipPipPipPipPip
  • 676 posts

Posted 05 November 2008 - 08:34 PM

Easyer:
File streams
or File Contents
or File Presence
or Drive's Serial maybe combined with drive's total space and label

Maybe not the safest thing in the world but it's very simple
Some Projects:indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

#6 ironmankho

ironmankho

    Wayfarer

  • Active Members
  • Pip
  • 63 posts

Posted 05 November 2008 - 08:37 PM

above code really help full and more in detail .but i am sorry to say it not fulfill my work ..................i want only get Uinque ID of USB than it pass to multimedia builder http://mmb.mediachance.com/index.html.....

#7 Kip

Kip

    Into the JavaScript

  • Active Members
  • PipPipPipPipPipPip
  • 1,690 posts

Posted 05 November 2008 - 08:39 PM

Cool, you're from mmb too? :mellow:
Haven't used in years, but thats how I got here.

#8 ironmankho

ironmankho

    Wayfarer

  • Active Members
  • Pip
  • 63 posts

Posted 05 November 2008 - 08:50 PM

creating a GUI apllication in MMB is very easy as comparare to Autoit .........but it is almost true Autoit is more powerful

#9 torels

torels

    I Hacked 127.0.0.1! :D

  • Active Members
  • PipPipPipPipPipPip
  • 676 posts

Posted 05 November 2008 - 09:00 PM

chrome says the link you posted is infected and not safe :mellow:
Some Projects:indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

#10 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 10,298 posts

Posted 05 November 2008 - 09:12 PM

Have you tried DriveGetSerial?

#11 ironmankho

ironmankho

    Wayfarer

  • Active Members
  • Pip
  • 63 posts

Posted 05 November 2008 - 09:28 PM

Have you tried DriveGetSerial?


dbzfanatic
Serial numbers usually are unique,at least per machine



#12 dbzfanatic

dbzfanatic

    functional psychopath!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,090 posts

Posted 05 November 2008 - 10:57 PM

I haven't really needed to check serials between machines so they may not be,but afaik they are, so that honestly should work.

#13 spudw2k

spudw2k

    passionately misinformed

  • Active Members
  • PipPipPipPipPipPip
  • 1,283 posts

Posted 06 November 2008 - 12:58 AM

How about the PNPDeviceID? *The example below only works with Fixed or Removable drives. CDrom and Network drives fail because of WMI calls.
AutoIt         
$drive = StringLeft(FileSelectFolder("Pick a Drive",""),2) $id = _GetPNPDeviceID($drive) msgbox(0,$id,"") Func _GetPNPDeviceID($drive,$fullid=0)     $objWMIService = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\\.\root\cimv2")     If Not IsObj($objWMIService) Then Return -1 ;Failed to Connect to WMI on Local Machine         $colDevice = $objWMIService.ExecQuery("SELECT * from Win32_LogicalDiskToPartition")     $var=""     For $objItem in $colDevice         If StringInStr($objItem.Dependent,$drive) Then             $var=StringTrimLeft($objItem.Antecedent,stringInstr($objItem.Antecedent,"="))         EndIf     Next     If Not $var Then Return -2 ;Failed to Find Drive Letter         $colDevice = $objWMIService.ExecQuery("SELECT * from Win32_DiskDriveToDiskPartition")     $diskpartition = $var     $var=""     For $objItem in $colDevice         If StringInStr($objItem.Dependent,$diskpartition) Then             $var=StringTrimLeft($objItem.Antecedent,stringInstr($objItem.Antecedent,"="))         EndIf     Next     If Not $var Then Return -3 ;Failed to Find Physical Drive #     $colDevice = $objWMIService.ExecQuery("SELECT * from Win32_DiskDrive")     $physicaldrive = StringReplace(StringReplace($var,"\\","\"),'"',"")     $var=""     For $objItem in $colDevice         If $objItem.DeviceID = $physicaldrive Then             $var=$objItem.PNPDeviceID         EndIf     Next     If Not $var Then Return -4 ;Failed to Find PNPDeviceID         If Not $fullid Then $var = StringTrimLeft($var,StringInstr($var,"\",0,-1)) ;Return Ugly Full PNPDeviceID     Return $var EndFunc

Edited by spudw2k, 06 November 2008 - 04:32 PM.


#14 ironmankho

ironmankho

    Wayfarer

  • Active Members
  • Pip
  • 63 posts

Posted 06 November 2008 - 08:07 AM

Thanks ..... i get value from this "5B721B8A98A4&0" ....BTW it is unique means it is depended on my USB flash drive or OS

#15 spudw2k

spudw2k

    passionately misinformed

  • Active Members
  • PipPipPipPipPipPip
  • 1,283 posts

Posted 06 November 2008 - 03:51 PM

It is dependent of the device, yes. I tested this on many PCs and got the same ID. :mellow: Updated example.

Edited by spudw2k, 06 November 2008 - 04:25 PM.


#16 ironmankho

ironmankho

    Wayfarer

  • Active Members
  • Pip
  • 63 posts

Posted 06 November 2008 - 04:16 PM

Just waiting for your kind reply :mellow:

#17 spudw2k

spudw2k

    passionately misinformed

  • Active Members
  • PipPipPipPipPipPip
  • 1,283 posts

Posted 06 November 2008 - 04:19 PM

Just waiting for your kind reply :mellow:

Who me? see last post on first page.

#18 ironmankho

ironmankho

    Wayfarer

  • Active Members
  • Pip
  • 63 posts

Posted 06 November 2008 - 04:37 PM

Yes !!! you ............ first i read "updating" now i read "updated" .......

my result "5B721B8A98A4&0" on 1st PC

my result "5B721B8A98A4&0" on 2nd PC

working good !!! Thanks for help :mellow:

Edited by ironmankho, 06 November 2008 - 04:51 PM.


#19 spudw2k

spudw2k

    passionately misinformed

  • Active Members
  • PipPipPipPipPipPip
  • 1,283 posts

Posted 06 November 2008 - 04:55 PM

No prob. Now, you may get the same ID if two of the same USB drives are used. I haven't tested that as I do not have two of the same type of thumb drives.

I was able to test this using two GeekSquad 1GB sticks that were purchased from the same store within a week apart from each other.
USBSTOR\DISK&VEN_BEST_BUY&PROD_GEEK_SQUAD_U3&REV_6.50\0C11096090E2199F&0
USBSTOR\DISK&VEN_BEST_BUY&PROD_GEEK_SQUAD_U3&REV_6.50\0CD1096091420B8B&0

ID's appears to be unique for each device as well. :mellow:

edit:
tested with two more similar drives. Unique. I assume they have to be, otherwise, how would the pc know how to identify each one accurately.

Edited by spudw2k, 10 November 2008 - 03:52 PM.


#20 ironmankho

ironmankho

    Wayfarer

  • Active Members
  • Pip
  • 63 posts

Posted 06 November 2008 - 06:15 PM

ok !!! next day i will post more result ......hope magic will work :mellow:

988000000000000045B46330-&0 - kingston DT100 1GB
5B871B-000031-&0 - kingston DTi-1014GB
5B721B-8A98A4-&0 kingston DTI 4 GB
200809010000000000000027&0 -kingston 8 GB DTI
5B841E0044C3&0 - kingston 1 GB DTI

Edited by ironmankho, 09 December 2008 - 02:09 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users