AzKay Posted November 8, 2008 Share Posted November 8, 2008 (edited) Saw some people making some, decided to try it. Heres what I came up with. The "untested" section, would be for, Autorun stuff, like, if someone were to insert a cd. It would close whatevers been "autoran". Its not finnished yet, But I doubt ill remember to work on it more. What I wanted to add in next, is to run it as service, But I doubt ill remember to. expandcollapse popup#NoTrayIcon #Include <Array.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) GUISetBkColor(0x000000) $Label1 = GUICtrlCreateLabel("@Locked", @DesktopWidth/2.3, @DesktopHeight/2.1, 144, 41) GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) GUISetCursor(16) #EndRegion ### END Koda GUI section ### $Serial = "USBSTOR\DISK&VEN_SANDISK&PROD_U3_CRUZER_MICRO&REV_4.05\0000167837743C3E&0" ;ClipPut(_GetPNPDeviceID("H:", 1)) ;<!-- Untested ;$Processes = ProcessList() ;$Set = False ;--> While 1 $oDrives = DriveGetDrive("ALL") For $i = 1 To $oDrives[0] $oSerials = _GetPNPDeviceID($oDrives[$i], 1) If $oSerials = $Serial Then GUISetState(@SW_HIDE) BlockInput(0) Do Sleep(100) Until _GetPNPDeviceID($oDrives[$i], 1) <> $Serial ;<!-- Untested ;$Processes = ProcessList() ;$Set = True ;--> EndIf Next ;<!-- Untested ;$ProcCheck = ProcessList() ;If $ProcCheck[0][0] > $Processes[0][0] And $Set = True Then ; For $x = 1 To $ProcCheck[0][0] ; $Ret = _ArraySearch($Processes, $ProcCheck[$x][0], 0, 0, 0, 1) ; If @error Then ProcessClose($ProcCheck[$x][0]) ; Next ;EndIf ;--> WinSetState($Form1, "", @SW_MAXIMIZE) ProcessClose("taskmgr.exe") BlockInput(1) WEnd 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 Run ClipPut(DriveGetSerial("USBDRIVESNUMBER")), Paste that into $Serial = "". Unplug the usbstick, run the main script. To "unlock" plug in the usb stick again, unplug to "lock". Feedback? Edited November 9, 2008 by AzKay # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
spudw2k Posted November 8, 2008 Share Posted November 8, 2008 (edited) Feedback?Simple and nice. From a recent discussion, the community here decided that a drive serial can be altered, and therefore (can be) unreliable for a locking mechanism like this. Granted, it would take some smart guys like us to change the serial, but the fact that it can occur is a risk. Perhaps the HardwareID of the device will suit your needs? Edited November 8, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF  Link to comment Share on other sites More sharing options...
AzKay Posted November 9, 2008 Author Share Posted November 9, 2008 Yeah, When I looked at it I was just looking for something which didnt need writing/reading a file from the usb stick. Only thing I found in the builtin functions was the DriveGetSerial. I didnt really research on it, but I thought it was something like hardware id. Guess not x33. Ill look into using the hardware id. # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
ironmankho Posted November 9, 2008 Share Posted November 9, 2008 i think hardware ID is best solution instead use of Serial ID ... Link to comment Share on other sites More sharing options...
AzKay Posted November 9, 2008 Author Share Posted November 9, 2008 Yeah, I used that in the updated first post. # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
ironmankho Posted November 9, 2008 Share Posted November 9, 2008 Thanks !!! it code is amazing very close to next "key" security means if you have Valid USB than you can use ............. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now