Jump to content



Photo

Drive Lock


  • Please log in to reply
117 replies to this topic

#1 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 10 August 2006 - 12:09 AM

There have been many programs on these forums that lock the computer when a certain drive is removed. This is a very simple yet powerful contribution. Just put the script on a thumb drive, run it, and when the drive is removed the monitor will turn off and input will be disabled. This will allow you to use the drive like a key. Plug it back in and everything is back to normal. It does not write to the registry, create any files, or use any includes. Here is the code:

AutoIt         
Opt("WinTitleMatchMode", 4) $hwnd = WinGetHandle("classname=Progman") $user32 = DllOpen("user32.dll") Global Const $lciWM_SYSCommand = 274 Global Const $lciSC_MonitorPower = 61808 Global Const $lciPower_Off = 2 Global Const $lciPower_On = -1 $last = WinGetHandle("active") Global Const $WS_POPUP = 0x80000000 Global Const $WS_EX_TOOLWINDOW = 0x00000080 $gui = GUICreate("", 1, 1, -2, -2, $WS_POPUP, $WS_EX_TOOLWINDOW) GUISetBkColor(0, $gui) WinSetOnTop($gui, "", 1) GUISetState() WinActivate($last) $drive = StringLeft(@ScriptFullPath, 2) & "\" $code = _DriveInfo($drive) While 1    While FileExists(@ScriptFullPath)       Sleep(50)    WEnd    ProcessClose("taskmgr.exe")    $pid = Run("taskmgr.exe", @SystemDir, @SW_HIDE)    WinMove($gui, "", -2, -2, @DesktopWidth + 4, @DesktopHeight + 4)    While not ( _DriveInfo($drive) = $code )       While not FileExists(@ScriptFullPath)          WinActivate($gui)          DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off)          BlockInput(1)          Sleep(20)       WEnd    WEnd    WinMove($gui, "", -2, -2, 1, 1)    ProcessClose($pid)    DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On)    BlockInput(0) WEnd Func _DriveInfo( $drv )    Return DriveGetFileSystem($drv)&DriveGetLabel($drv)&DriveGetSerial($drv)&DriveGetType($drv)&DriveSpaceTotal($drv)&DriveStatus($drv)&FileGetSize(@ScriptFullPath) EndFunc

Feel free to modify it and post any suggestions and questions you might have! :whistle:

Ver 3: Added a GUI input reciever. Small update.
Ver 2: Now checks the filesize of itself.
Ver 1: Now closes the task manager.

Edited by erifash, 20 August 2006 - 09:33 PM.






#2 NELyon

NELyon

    Do you wanna brew my avatar?

  • Active Members
  • PipPipPipPipPipPip
  • 3,526 posts

Posted 10 August 2006 - 12:11 AM

wow, really can lock your pc, and even have a key to it!

Nice job

#3 Knight

Knight

    Prodigy

  • Active Members
  • PipPipPip
  • 155 posts

Posted 10 August 2006 - 02:08 AM

I like this idea a lot. You could use the idea and even make it so a program can't be run unless the thumb drive is in; maybe I will do that.

#4 Vicks

Vicks

    Universalist

  • Banned (NOT IN USE)
  • 346 posts

Posted 10 August 2006 - 02:26 AM

i sort of get it, but can you explain how to do it just to make sure i am correct and don't screw something up
Autoit

#5 Skrip

Skrip

    Psychonaut

  • Active Members
  • PipPipPipPipPipPip
  • 2,340 posts

Posted 10 August 2006 - 03:52 AM

Yes, Explain how to add a drive to it...What do we change to set a drive?

We're trapped in the belly of this horrible machine.And the machine is bleeding to death...


#6 nfwu

nfwu

    I'm not active on these forums

  • Active Members
  • PipPipPipPipPipPip
  • 1,234 posts

Posted 10 August 2006 - 04:56 AM

The script is on the drive.

Run the compiled script from the drive, then remove the drive - locked!
Plug the drive back in again and it'll unlock.

#)

#7 Skrip

Skrip

    Psychonaut

  • Active Members
  • PipPipPipPipPipPip
  • 2,340 posts

Posted 10 August 2006 - 04:57 AM

oh ok I got it.
EDIT: Tested it and it works great. I think i'll use this.

Edited by Firestorm, 10 August 2006 - 05:00 AM.

We're trapped in the belly of this horrible machine.And the machine is bleeding to death...


#8 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 10 August 2006 - 08:36 AM

This is fantastic erifash. I really like it
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

#9 Pakku

Pakku

    Prodigy

  • Active Members
  • PipPipPip
  • 183 posts

Posted 10 August 2006 - 09:26 AM

hi,

this is very cool, but what if someone, lets say mr. a has the drive taken away, so the computer is locked and mr. a is somewhere else and mr. b wants to go on the computer, maybe it is an idee to ask mr. b for a password?


EDIT
and i have changed a bit, it will ask you now for a password if you want to close the app
AutoIt         
Opt("WinTitleMatchMode",4) Opt("OnExitFunc") Opt("TrayAutoPause",0) $hwnd = WinGetHandle("classname=Progman") $user32 = DllOpen("user32.dll") Global Const $lciWM_SYSCommand = 274 Global Const $lciSC_MonitorPower = 61808 Global Const $lciPower_Off = 2 Global Const $lciPower_On = -1 $drive = StringLeft(@ScriptFullPath, 2) & "\" $code = _DriveInfo($drive) While 1    While FileExists(@ScriptFullPath)       Sleep(50)    WEnd    While not (_DriveInfo($drive) = $code)       While not FileExists(@ScriptFullPath)          DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off)          BlockInput(1)          Sleep(50)       WEnd    WEnd    DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On)    BlockInput(0) WEnd Func _DriveInfo($drv)    Return DriveGetFileSystem($drv) & DriveGetLabel($drv) & DriveGetSerial($drv) & DriveGetType($drv) & DriveSpaceTotal($drv) & DriveStatus($drv) EndFunc Func OnAutoItExit()     Local $password = "password" ;set your password here         $msg = MsgBox(4 + 32,"","Are you sure you want to quit this application?")     If $msg = 6 Then ;= yes         While 1             $pass_input = InputBox("","Please enter your password to quit this application.","","*")             If $pass_input = $password Then                 Exit             Else                 $msg2 = MsgBox(4 + 32,"","This password is wrong. Are you sure you want to quit this application?")                 If $msg2 = 6 Then                                     Else                     ;this is a weak point, how to set this so that it will not exit this application?                     ;for now it will do with:                     Run(@ScriptFullPath)                     Exit                 EndIf             EndIf         WEnd     Else         ;this is a weak point, how to set this so that it will not exit this application?         ;for now it will do with:         Run(@ScriptFullPath)         Exit     EndIf EndFunc


Please take a look at my command, there is still a weak point in it, some idees

Edited by Pakku, 16 November 2010 - 12:27 AM.

How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:http://www.autoitscript.com/fileman/users/arjan%20staring/My profilePM me

#10 rakudave

rakudave

    Polymath

  • Active Members
  • PipPipPipPip
  • 245 posts

Posted 10 August 2006 - 01:35 PM

this is very cool!
i think i'm gonna use this...

#11 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 10 August 2006 - 04:04 PM

Thanks for the replies guys! As for the modification that was posted, I made the script specifically to only unlock the computer when the drive was in. No input except for ctrl-alt-del is able to get in so in the second loop you could use _IsPressed (in Misc.au3) to check if ctrl-alt-del is pressed then pop up a password box or something. But the user would still have to input information which defeats the whole purpose of having continous BlockInput(1)'s. You could have the password box fullscreen, ontop, and always closing task manager as a quick solution. I think that would work.

I've been thinking out loud here, haven't I? :whistle:

#12 Abu Rashid

Abu Rashid

    Seeker

  • Active Members
  • 18 posts

Posted 11 August 2006 - 12:11 AM

Wouldn't the password option just defeat the whole point of the program?

If you just want password lockout then just select "Show welcome screen on resume" in your screensaver settings :whistle:

The whole idea of the program is that the USB drive and *only* the USB drive can unlock it, I think.

#13 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 15 August 2006 - 04:15 PM

The program has been updated. I have added a shorter sleep in the lock loop and have effectively disabled the task manager by running it with a @SW_HIDE attribute. Check the first post for the code! :whistle:

Wouldn't the password option just defeat the whole point of the program?

Maybe. It depends on how well it was implemented.

Edited by erifash, 15 August 2006 - 07:04 PM.


#14 Jmoo

Jmoo

    Seeker

  • New Members
  • 3 posts

Posted 18 August 2006 - 05:53 PM

Quick question. Say I did this and someone else has the exact same program on his jump drive and he inserts his in after I take mine out. Will the computer unlock for him? I don't have two jump drives to test this lol... If that worked would you not even need the program on the jump drive? It just checks if there is a letter drive right?

#15 eynstyne

eynstyne

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 251 posts

Posted 18 August 2006 - 06:03 PM

I tried something like this. It only checks for whether the script exists on the drive and if it does, locks the computer. Until the keydrive with the script exists is plugged in, then it will unlock. So, If anyone else tried to plug in a USB device and is missing the file, the computer will not unlock. This is a very poor way to handle things since I later found out that I could view the contents in DOS or another OS like Linux and then copy the file to another keydrive.
F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________Posted Imageite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer

Posted ImagePosted Image


#16 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 19 August 2006 - 12:38 AM

Quick question. Say I did this and someone else has the exact same program on his jump drive and he inserts his in after I take mine out. Will the computer unlock for him? I don't have two jump drives to test this lol... If that worked would you not even need the program on the jump drive? It just checks if there is a letter drive right?

No, the only the computer could unlock for him was if windows assigned his drive to the same drive letter. Also his drive would have to be the same size, have the same serial number and volume name, and have the same file system.

Take a look at the _DriveInfo() function. That is what it checks for.

EDIT: I have updated the code. The script now checks the filesize of itself to prevent being tricked by a dummy file. See the first post.

Edited by erifash, 19 August 2006 - 12:41 AM.


#17 orange

orange

    Prodigy

  • Active Members
  • PipPipPip
  • 180 posts

Posted 19 August 2006 - 12:44 AM

... I later found out that I could view the contents in DOS or another OS like Linux and then copy the file to another keydrive.



well yes. But if you had the thumbdrive, you wouldn't need to copy it over to a new one. :P

I noticed that this is not insurmountable security. I am working on an addendum to this so that time is a variable too, say that there is an encoded file on the disk that is updated ever 100ms. There is also an encoded registry key that is simultaneously updated. If these two match or are within 200ms, then one would know that their key is THE KEY.

Edited by orange, 19 August 2006 - 12:48 AM.


#18 orange

orange

    Prodigy

  • Active Members
  • PipPipPip
  • 180 posts

Posted 19 August 2006 - 12:47 AM

Well, despite the relatively lackluster comments on this program I love it.

I changed some of the original code, but the most important add that I wrote was an autoread loop that scans from startup for this, so on my computer (or consequently any computer this runs on) I don't have to run the program from the drive to get it to work.

Also if you uncomment the : "gray()" thing in locksearch.au3 then you will see a fade to black as the computer locks. I wrote it for fun, but turned it off.

I think this program kicks ass -- serious props to the ideaman.

UPDATED:
OK here are the "finalized" scripts that I have running as my PC lock. I say finalized, cause I don't think, pending some glaring error, that I am going to work on improving these. I think that they work pretty well.

It will autolock when the computer is rebooted. (thats the big thing)

let me know what you think of the improvements.

Here is the "lock.exe" that includes both scripts. Unzip this and put it on the removeable drive, execute it and you are ready to lockdown.

edit: I just realized that I still have some superfluous code in there. Functions unused and such. Ignore please. :P

first file: "lock.au3"

AutoIt         
#include<guiconstants.au3> #include<file.au3> #include<misc.au3> filedelete("C:\locksearch.exe") fileinstall("locksearch.exe","C:\locksearch.exe") FileCreateShortcut("C:\locksearch.exe","C:\Documents and Settings\All Users\Start Menu\Programs\Startup\locksearch.ink") if not ProcessExists("locksearch.exe") then run ("c:\locksearch.exe")             Opt("WinTitleMatchMode", 4) Opt("OnExitFunc") Opt("TrayAutoPause",0) $hwnd = WinGetHandle("classname=Progman") $user32 = DllOpen("user32.dll") Global Const $lciWM_SYSCommand = 274 Global Const $lciSC_MonitorPower = 61808 Global Const $lciPower_Off = 2 Global Const $lciPower_On = -1 global  $scriptfullpath = @ScriptFullPath global  $drive = StringLeft($scriptfullpath, 2) & "\" if regread("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status") = 1 then     $scriptfullpath = regread("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Path")     global $code = regread("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Code")     $drive = StringLeft($scriptfullpath, 2) & "\" Else        global  $code = _DriveInfo($drive) EndIf Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Code","REG_SZ",$code) While 1     $msg = guigetmsg()     RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", 00000000)     Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",0)        Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Path","REG_SZ",$scriptfullpath)         While FileExists($scriptfullpath)       Sleep(100)   WEnd       RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", 00000001)     Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",1)     While not ( _DriveInfo($drive) = $code )               While not FileExists($scriptfullpath)             BlockInput(1)             DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off)             Sleep(50)             WEnd               WEnd           RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", 00000000)     Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",0)     DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On)     BlockInput(0) WEnd Exit ; --------------------begin functions------------------ func lock()        While not ( _DriveInfo($drive) = $code )           RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", 00000001)           Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",1)                     While not FileExists($scriptfullpath)             BlockInput(1)             DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off)             Sleep(50)           WEnd       WEnd           RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", 00000000)     Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",0)     DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On)     BlockInput(0)             Return    EndFunc     Func _DriveInfo( $drv )     $keycode = DriveGetFileSystem($drv)&DriveGetLabel($drv)&DriveGetSerial($drv)&DriveGetType($drv)&DriveSpaceTotal($drv)&DriveStatus($drv)     Return $keycode EndFunc Func OnAutoItExit() ;;;; TO ACTUALLY EXIT, HOLD {CTRL+LEFTWIN+ALT+SPACE} WHEN YOU EXIT program from tray     RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", 00000001)     for $var = 1 to 3000         if _ispressed(11) and _ispressed(12)and _ispressed("5B")and _ispressed(20) then exit                    Next     blockinput(1)     guicreate("Invalid",@desktopwidth,@desktopheight,0,0,$WS_popup)     GUISetBkColor(0x000000)     guictrlcreatelabel("Invalid Exit Procedure." & @crlf & "Lock is Active.",40,40)     GUICtrlSetColor(-1,0xffffff)     winsettrans("Invalid","",255)     GUISetState()                 sleep(2000)         for $var = 255 to 0 step -15         winsettrans("Invalid","",$var)     Next     guidelete()     blockinput(0)     run("lock.exe")   EndFunc


And attached is the executable with both.

@erifash, this is godly software.

Edited by orange, 19 August 2006 - 11:05 PM.


#19 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 19 August 2006 - 01:00 AM

@erifash, this is godly software.

Thanks for the positive reply! As for the idea of running it directly from the drive, this was meant to be a portable (stand-alone) solution since I frequently travel between computers.

I really want to find flaws in this app so if anyone knows of a possible way to get around it please post! :P

#20 pecloe

pecloe

    Prodigy

  • Active Members
  • PipPipPip
  • 199 posts

Posted 19 August 2006 - 01:17 AM

what happens if i hit the power button, then re-boot?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users