Sign in to follow this  
Followers 0
JohnWang

Mirage ~ Removable Drive Lock

9 posts in this topic

#1 ·  Posted (edited)

hello~

I made a program that locks the pc and can unlock the pc by using a "Memory Stick" or a removable Drive. No More typing pain in the ass long password, just pop in the Memory Sticks and Bingo its unlocked.

did this for fun, thought it might be neat/trying something new, to unlock your pc with a Memory Stick/Removable Drive.Longer password/Less typing i guess :o *Reminder: Acutally speed may vary on different computer caz i have a processor speed of 3.0 ghz so the Encrypt/Decrypt goes faster on my pc, but i think it should be fine on most of the other pcs..

IMPORTANT Please Read: There's a HotKey Put in Place for those who wants to test teh program but dont have a Removable Drive or those that are lazi to find their drive O_o.

HotKey:Ctrl + Alt + h

Try it at ur own risk lol.... (beta tested on my pc so it should be fine.. just in case so i placed a warning)

Special Thanks to Valuater, his code show me some neat way of locking ones pc. "*VAULTER* -PC LOCKOUT"

Anyways Heres the Code:

;Includes

#include <GUIConstants.au3>

#include <File.au3>

#include <String.au3>

;Variables

dim $Interface

dim $i_Buttons[4]dim $DriveLabel

;Declarations

dim $InterfaceTitle = "Mirage 1.01 Beta"

dim $InterfaceWidth = 240

dim $InterfaceHeight = 80

dim $doorKey = "123456"

dim $State = "Unlocked"

;AutoIt Options

opt("MustDeclareVars", 1)

Opt("GUIOnEventMode", 1)

Opt("WinTitleMatchMode", 4)

;Main

Interface()

While 1

HotKeySet("!^h","UnLock")

GUISetOnEvent($GUI_EVENT_CLOSE,"OnExit",$Interface)

If $State = "Locked" Then

If DriveDetect("REMOVABLE") <> False Then

$DriveLabel = DriveDetect("REMOVABLE")

CompareKey($DriveLabel)

EndIf

EndIf

Sleep(500)

Wend

;Functions

Func onstart()

Interface()

EndFunc

Func Interface()

$Interface = GUICreate($InterfaceTitle,$InterfaceWidth,$InterfaceHeight,-1,-1)

$i_Buttons[0] = GUICtrlCreateButton("Set Unlock Key",15,15,100,20)

GUICtrlSetOnEvent(-1,"onSetDoorKey")

$i_Buttons[1] = GUICtrlCreateButton("Lock Down",125,15,100,20)

GUICtrlSetOnEvent(-1,"Locked")

$i_Buttons[2] = GUICtrlCreateButton("Create Drive Key",15,45,100,20)

GUICtrlSetOnEvent(-1,"OnSetDriveKey")

$i_Buttons[3] = GUICtrlCreateButton("Exit Mirage",125,45,100,20)

GUiCtrlSetOnEvent(-1,"OnExit")

GUISetState(@SW_Show)

EndFunc

Func Encrypt($e_Text,$e_Pass,$e_Level)

return _StringEncrypt(1,$e_Text,$e_Pass,$e_Level)

EndFunc

Func Decrypt($e_Text,$e_Pass,$e_Level)

return _StringEncrypt(0,$e_Text,$e_Pass,$e_Level)

EndFunc

Func DriveDetect($d_Type)

Local $Drive = DriveGetDrive($d_Type)

If IsArray($Drive) Then

For $i = 1 to $Drive[0]

If FileExists($Drive[$i] & "\MirageEncrypt420.mir") Then

return $Drive[$i]

Else

return False

EndIf

Next

EndIf

EndFunc

Func CompareKey($d_Label)

Local $File = FileOpen($d_Label & "\MirageEncrypt420.mir",0)

Local $EntryKey = Decrypt(FileRead($File),"MirageEncrypted",4)

If $EntryKey <> $doorKey Then

Sleep(1000)

Else

UnLock()

EndIf

EndFunc

Func onSetDoorKey()

$doorKey = InputBox("Set the Unlock Key!","Please Enter a Unlock Key","Enter Unlock Key Here")

If $doorKey <> "" Then

TrayTip("Good to Go!","Unlock Key Set!",4)

Else

MsgBox(0,"Warning","Please Enter a Key other than Blanks, Thanks")

onSetDoorKey()

EndIf

EndFunc

Func OnSetDriveKey()

Local $tempKey = InputBox("Create a Drive Key!","Please Enter the desired Drive Key use to unlock a locked PC!","Enter Key Here")

If $tempKey <> "" Then

Local $t_Label = DriveDetect("REMOVABLE")

Local $EncryptedKey = Encrypt($tempKey,"MirageEncrypted",4)

If FileExists($t_Label & "\MirageEncrypt420.mir") Then

FileDelete($t_Label & "\MirageEncrypt420.mir")

FileWrite($t_Label & "\MirageEncrypt420.mir",$EncryptedKey)

Else

FileWrite($t_Label & "\MirageEncrypt420.mir",$EncryptedKey)

Sleep(2000)

EndIf

Else

MsgBox(0,"Warning","Please Enter a Key other than Blanks, Thanks")

OnSetDriveKey()

EndIf

TrayTip("Congrats","Mirage Key has now been set on your removable drive and ready to unlock you PC for you",4)

EndFunc

Func Locked()

$State = "Locked"

WinMinimizeAll()

Run("taskmgr.exe", "", @SW_DISABLE)

WinSetState("Program Manager", "", @SW_HIDE)

WinSetState("classname=Shell_TrayWnd", "", @SW_HIDE)

WinSetState ( "classname=Progman", "",@SW_DISABLE)

WinSetState("classname=Shell_TrayWnd", "", @SW_DISABLE)

WinSetState("classname=DV2ControlHost","",@SW_Disable)

Sleep(2000)

EndFunc

Func UnLock()

$State = "Unlocked"

WinMinimizeAllUndo()

WinClose("Windows Task Manager")

WinSetState("Program Manager", "", @SW_SHOW)

WinSetState("classname=Shell_TrayWnd", "", @SW_SHOW)

WinSetState ( "classname=Progman", "",@SW_Enable)

WinSetState("classname=Shell_TrayWnd", "", @SW_Enable)

WinSetState("classname=DV2ControlHost","",@SW_ENABLE)

Sleep(2000)

EndFunc

Func OnExit()

Exit

EndFunc

Edited by JohnWang

Share this post


Link to post
Share on other sites



Special Thanks to Valutar...

Valutar, Vulture....

its, Valuater

.... Thanks for the mention

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Valutar, Vulture....

its, Valuater

.... Thanks for the mention

8)

oops sry edited in the original post, No problem im just giving credit to where its due.. =D

Edited by JohnWang

Share this post


Link to post
Share on other sites

looks interesting..

however, i am not big on resetting the hotkey over and over in a loop

While 1
HotKeySet("!^h","UnLock")
..... blah
Wend

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Nice script! :o

Issue 1: This doesn't block the Start key on the keyboard.

Issue 2: I keep getting an error saying to "insert a disk into drive ." I think it's looking at the floppy drive and the script pauses until you click one of the buttons. You might want to exempt the A: and B: drives from the removable drive check.

FYI, I'm running WinXP SP2 and AutoIt3 beta 3.1.1.111

Edit: It might be nice to have a simple GUI saying the machine is locked, and hide the mouse cursor.

Edited by c0deWorm

My UDFs: ExitCodes

Share this post


Link to post
Share on other sites

Nice script! :o

Issue 1: This doesn't block the Start key on the keyboard.

Issue 2: I keep getting an error saying to "insert a disk into drive ." I think it's looking at the floppy drive and the script pauses until you click one of the buttons. You might want to exempt the A: and B: drives from the removable drive check.

FYI, I'm running WinXP SP2 and AutoIt3 beta 3.1.1.111

Edit: It might be nice to have a simple GUI saying the machine is locked, and hide the mouse cursor.

Hey Thanks for the post..

Issue one shouldnt be a problem since the menu is disabled, it will not respond as you click on any opions on the menu.

Issue 2: i back to the code and found some error with the way i detect the drive and i exempted "A:' drive from the detection. Im very sorry that i forgot to exempt the A drive in the first place as i dont have a floppy drive on my pc so obviously i didnt notice the problem in the first place. I went in and added a splash Text On When the PC locks up and turns off when its unlocked, hope this helps =D and thanks pointing out my errors again :geek:

Heres the new code:

;Includes

#include <GUIConstants.au3>

#include <File.au3>

#include <String.au3>

;Variables

dim $Interface

dim $i_Buttons[4]dim $DriveLabel

;Declarations

dim $InterfaceTitle = "Mirage 1.01 Beta"

dim $InterfaceWidth = 240

dim $InterfaceHeight = 80

dim $doorKey = "123456"

dim $State = "Unlocked"

;AutoIt Options

opt("MustDeclareVars", 1)

Opt("GUIOnEventMode", 1)

Opt("WinTitleMatchMode", 4)

;Main

Interface()

HotKeySet("!^h","UnLock")

While 1

GUISetOnEvent($GUI_EVENT_CLOSE,"OnExit",$Interface)

If $State = "Locked" Then

If DriveDetect("REMOVABLE") <> False Then

$DriveLabel = DriveDetect("REMOVABLE")

CompareKey($DriveLabel)

EndIf

EndIf

Sleep(500)

Wend

;Functions

Func onstart()

Interface()

EndFunc

Func Interface()

$Interface = GUICreate($InterfaceTitle,$InterfaceWidth,$InterfaceHeight,-1,-1)

$i_Buttons[0] = GUICtrlCreateButton("Set Unlock Key",15,15,100,20)

GUICtrlSetOnEvent(-1,"onSetDoorKey")

$i_Buttons[1] = GUICtrlCreateButton("Lock Down",125,15,100,20)

GUICtrlSetOnEvent(-1,"Locked")

$i_Buttons[2] = GUICtrlCreateButton("Create Drive Key",15,45,100,20)

GUICtrlSetOnEvent(-1,"OnSetDriveKey")

$i_Buttons[3] = GUICtrlCreateButton("Exit Mirage",125,45,100,20)

GUiCtrlSetOnEvent(-1,"OnExit")

GUISetState(@SW_Show)

EndFunc

Func Encrypt($e_Text,$e_Pass,$e_Level)

return _StringEncrypt(1,$e_Text,$e_Pass,$e_Level)

EndFunc

Func Decrypt($e_Text,$e_Pass,$e_Level)

return _StringEncrypt(0,$e_Text,$e_Pass,$e_Level)

EndFunc

Func DriveDetect($d_Type)

Local $Drive = DriveGetDrive($d_Type)

If IsArray($Drive) Then

For $i = 1 to $Drive[0]

if DriveGetType($Drive[$i]) = "Removable" Then

If $Drive[$i] <> "A:" Then

return $Drive[$i]

Else

return False

EndIf

Else

return False

EndIf

Next

EndIf

EndFunc

Func CompareKey($d_Label)

Local $File = FileOpen($d_Label & "\MirageEncrypt420.mir",0)

Local $EntryKey = Decrypt(FileRead($File),"MirageEncrypted",4)

If $EntryKey <> $doorKey Then

Sleep(1000)

Else

UnLock()

EndIf

EndFunc

Func onSetDoorKey()

$doorKey = InputBox("Set the Unlock Key!","Please Enter a Unlock Key","Enter Unlock Key Here")

If $doorKey <> "" Then

TrayTip("Good to Go!","Unlock Key Set!",4)

Else

MsgBox(0,"Warning","Please Enter a Key other than Blanks, Thanks")

onSetDoorKey()

EndIf

EndFunc

Func OnSetDriveKey()

Local $tempKey = InputBox("Create a Drive Key!","Please Enter the desired Drive Key use to unlock a locked PC!","Enter Key Here")

If $tempKey <> "" Then

Local $t_Label = DriveDetect("REMOVABLE")

Local $EncryptedKey = Encrypt($tempKey,"MirageEncrypted",4)

If FileExists($t_Label & "\MirageEncrypt420.mir") Then

FileDelete($t_Label & "\MirageEncrypt420.mir")

FileWrite($t_Label & "\MirageEncrypt420.mir",$EncryptedKey)

Else

FileWrite($t_Label & "\MirageEncrypt420.mir",$EncryptedKey)

Sleep(2000)

EndIf

Else

MsgBox(0,"Warning","Please Enter a Key other than Blanks, Thanks")

OnSetDriveKey()

EndIf

TrayTip("Congrats","Mirage Key has now been set on your removable drive and ready to unlock you PC for you " & $t_Label & "\MirageEncrypt420.mir",4)

EndFunc

Func Locked()

$State = "Locked"

WinMinimizeAll()

Run("taskmgr.exe", "", @SW_DISABLE)

WinSetState("Program Manager", "", @SW_HIDE)

WinSetState("classname=Shell_TrayWnd", "", @SW_HIDE)

WinSetState ( "classname=Progman", "",@SW_DISABLE)

WinSetState("classname=Shell_TrayWnd", "", @SW_DISABLE)

WinSetState("classname=DV2ControlHost","",@SW_Disable)

SplashTextOn($InterfaceTitle,"PC LockedDown with " & $InterfaceTitle,300,20,-1,-1)

Sleep(2000)

EndFunc

Func UnLock()

$State = "Unlocked"

WinMinimizeAllUndo()

WinClose("Windows Task Manager")

WinSetState("Program Manager", "", @SW_SHOW)

WinSetState("classname=Shell_TrayWnd", "", @SW_SHOW)

WinSetState ( "classname=Progman", "",@SW_Enable)

WinSetState("classname=Shell_TrayWnd", "", @SW_Enable)

WinSetState("classname=DV2ControlHost","",@SW_ENABLE)

SplashOff()

Sleep(2000)

EndFunc

Func OnExit()

Exit

EndFunc

Enjoy

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Thanks for the update. You might want to add "B:" to the list also, since it can only be a floppy or zip drive, and I have a couple of systems with internal floppies that I move one of those all-in-one card readers with a floppy drive around between them. The USB floppy shows up as B:, so while I might like to use one of the cards the reader supports, the floppy drive B: will interfere with that solution.

One other thing, I'm sure you don't need the GUISetOnEvent inside the main while loop. Put it before the loop with the HotKeySet.

Edit: You are correct about the Start Menu. While it will show when I press the Win key, I can't click on it or interact with it in anyway except to hit Win again to make it hide. Still a bit annoying. Great script!

P.S. Thanks for adding the "locked" status window.

Edited by c0deWorm

My UDFs: ExitCodes

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

This is a really cool script! :o I've been trying to make something like this but couldn't work out the code to lock everything down. The only problem i've found is you can use Alt Tab and change to any running programs. Anyone know how to disable the alt key?

EDIT:

I've managed to fix the Alt Tab problem by adding the following code:

Place this code below HotKeySet("!^h","UnLock")

HotKeySet("!{TAB}","Tablock")

Place this code above Func OnExit()

Func Tablock()
WinMinimizeAll()
Sleep(2000)
EndFunc
Edited by jake

Share this post


Link to post
Share on other sites

i like it really!

good for lan-partys!


[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

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