 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Chavez
Joined: 20 Aug 2008 Posts: 256
|
Posted: Wed Aug 20, 2008 3:55 pm Post subject: Desktop lock with USB key |
|
|
I made this code for myself, it's not that advanced but works very well for me. I use it at home as i have classified information on my computer. This program does very well at defending it when I'm out for a coffee break.
So, here's how it works:
When you hit F8, your screen is filled with a black screen which says 'Locked'. All inputs will be blocked, and because alt+ctrl+del still works, i looped a taskkill for that. Every 200 milliseconds, the script checks if there's an 'I' drive. This is (at my computer) the USB drive when plugged it. If it finds the drive, it will check a file called 'key.txt' and compare it to the same file but then located in /WINDOWS/. If both file's content are identical to each other, it will unlock again.
So, in short: Your USB drive is the key to unlock your computer. You only have to type your password twice. Once in the windows dir, and once in the root of your USB drive.
Pretty neat idea eh? :3
| Code: | #NoTrayIcon
SysGet, VirtualScreenWidth, 78
SysGet, VirtualScreenHeight, 79
F8::
Lock:
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Color, 000000
Gui, Font, CFF0000
Gui, Font,, Arial
Gui, Font, s128
Gui, Font, x0 y0
Gui, Add, Text, Locked, Locked
Gui, Show, x0 y0 h%VirtualScreenHeight% w%VirtualScreenWidth% , lock
SetTimer, checkkey, 200
return
checkkey:
driveget, drives, list, removable ;list of removable drives
FileRead, localkey, C:\WINDOWS\key.txt
passkey= ;filereadline will not overwrite passkey if there is an error
keyaccepted:=false
loop, parse,drives
{
FileRead, passkey, %a_loopfield%:\key.txt
if (passkey=localkey)
{
Gui Destroy
BlockInput off
SetTimer, checkkey, off
keyaccepted:=true
break
}
}
if not keyaccepted
{
BlockInput on
WinKill, Windows Task Manager
Gui, Show, x0 y0 h%VirtualScreenHeight% w%VirtualScreenWidth% , lock ;paints over any crack attempt
}
return
|
I hope someone's helped with this, or that you found the idea interesting. Please make a small notice about me whenever you will release this to the public. _________________ -Chavez.
Last edited by Chavez on Wed Dec 03, 2008 7:50 pm; edited 2 times in total |
|
| Back to top |
|
 |
Fry
Joined: 01 Nov 2007 Posts: 885
|
Posted: Wed Aug 20, 2008 4:01 pm Post subject: |
|
|
Heres my version so the user does not have to put the Screen width/height in
Pretty good script, i like it
| Code: | F8::
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Color, 000000
Gui, Font, CFF0000
Gui, Font,, Arial
Gui, Font, s128
Gui, Font, x0 y0
Gui, Add, Text, Locked, Locked
Gui, Show, x0 y0 h%A_ScreenHeight% w%A_ScreenWidth% , lock
SetTimer, checkkey, 200
BlockInput on
GoSub checkkey
return
checkkey:
loop
{
FileReadLine, localkey, C:\WINDOWS\key.txt, 1
FileReadLine, passkey, I:\key.txt, 1
if passkey = %localkey%
{
Gui Destroy
BlockInput off
break
}
else
{
WinKill, Windows Task Manager
return
}
sleep, 200
}
return |
|
|
| Back to top |
|
 |
Chavez
Joined: 20 Aug 2008 Posts: 256
|
Posted: Wed Aug 20, 2008 4:05 pm Post subject: |
|
|
| Fry wrote: | Heres my version so the user does not have to put the Screen width/height in
Pretty good script, i like it
|
I tried so many things today to make it work. I figured it'd be better if i prepared it like that, but i couldn't figure it out. Thanks for pointing me on the syntax there. _________________ -Chavez. |
|
| Back to top |
|
 |
Fry
Joined: 01 Nov 2007 Posts: 885
|
Posted: Wed Aug 20, 2008 5:12 pm Post subject: |
|
|
| Your welcome, you could have posted in the Ask for help section, someone would have gladly helped you |
|
| Back to top |
|
 |
SoggyDog
Joined: 02 May 2006 Posts: 783 Location: Greeley, CO
|
|
| Back to top |
|
 |
rodfell
Joined: 05 Oct 2007 Posts: 138 Location: Bundaberg (Bundy), Qld, Australia
|
Posted: Thu Aug 21, 2008 2:16 pm Post subject: |
|
|
good program but i went looking for cracks
ctrl-alt-del, on my system frees the mouse but other input is still blocked. as i use a mouse gesture program deleting the block is then straight forward. possible fix would be to block input every loop iteration.
if i ctrl-alt-del, then hit esc before the task manager is killed, the task bar appears and remains. it's then easy to turn off the program with the tray icon. possible fixes - no tray icon, disable esc key (esc::return)
doesn't work on multiple monitors. use virtualscreen measurements instead of a_screenheight etc
don't see the point of having both SetTimer, checkkey and GoSub checkkey
changed script so any removable drive letter is accepted | Code: | #NoTrayIcon
SysGet, VirtualScreenWidth, 78
SysGet, VirtualScreenHeight, 79
esc::return
F8::
driveget, drives,list,removable ;list of removable drives
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Color, 000000
Gui, Font, CFF0000
Gui, Font,, Arial
Gui, Font, s128
Gui, Font, x0 y0
Gui, Add, Text, Locked, Locked
Gui, Show, x0 y0 h%VirtualScreenHeight% w%VirtualScreenWidth% , lock
SetTimer, checkkey, 200
return
checkkey:
FileRead, localkey, C:\WINDOWS\key.txt
passkey= ;filereadline will not overwrite passkey if there is an error
keyaccepted:=false
loop, parse,drives
{
FileRead, passkey, %a_loopfield%:\key.txt
if (passkey=localkey)
{
Gui Destroy
BlockInput off
SetTimer, checkkey, off
keyaccepted:=true
break
}
}
if not keyaccepted
{
BlockInput on
WinKill, Windows Task Manager
Gui, Show, x0 y0 h%VirtualScreenHeight% w%VirtualScreenWidth% , lock ;paints over any crack attempt
}
return
|
|
|
| Back to top |
|
 |
SpiderGames
Joined: 09 Jun 2008 Posts: 936 Location: Canada
|
Posted: Thu Aug 21, 2008 4:40 pm Post subject: |
|
|
Nice I like it.
The CTR+ALT+Delete on my PC (Vista) Dosn't get blocked because I have teh option of closing all aplictaions. I reconment you do somethign like this...
just for safty =D _________________
I know i have 6 legs. It's cuz I'm special. |
|
| Back to top |
|
 |
Chavez
Joined: 20 Aug 2008 Posts: 256
|
Posted: Thu Aug 21, 2008 4:45 pm Post subject: |
|
|
Thanks for patching it up guys, much appreciated. Specially Rodfell. It's a whole lot more secure now. _________________ -Chavez. |
|
| Back to top |
|
 |
krueger00
Joined: 14 Sep 2008 Posts: 10
|
Posted: Sun Sep 14, 2008 9:49 pm Post subject: |
|
|
PLEASE HELP ME
I keep getting error messages no matter what script it is.
They change for every script though and they don't make sense.
For this script it says:
---------------------------
New AutoHotkey Script.ahk
---------------------------
Error at line 21.
Line Text:
Error: This line does not contain a recognized action.
The program will exit.
---------------------------
OK
---------------------------
Thanks in advance for any help. |
|
| Back to top |
|
 |
bonzybuddy
Joined: 13 Sep 2008 Posts: 3
|
Posted: Mon Sep 15, 2008 7:15 am Post subject: suggestion |
|
|
Nice script , i have a suggestion . you can script detectiong any removable drive for key not just drive I. if you wont then msg me i will post it. keep it up. _________________ Give your folders a new look with Custom Folderwallpaper .it gives background of any wallpaper you choose.get it here
http://www.autohotkey.net/~bonzybuddy/custom%20folder%20wallpaper.rar |
|
| Back to top |
|
 |
Chavez
Joined: 20 Aug 2008 Posts: 256
|
Posted: Mon Sep 15, 2008 8:38 am Post subject: Re: suggestion |
|
|
| bonzybuddy wrote: | | Nice script , i have a suggestion . you can script detectiong any removable drive for key not just drive I. if you wont then msg me i will post it. keep it up. |
That function has already been implemented by rodfell. I'll update my first post. _________________ -Chavez. |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Mon Sep 15, 2008 11:33 am Post subject: |
|
|
I cleaned up your code a bit (minimized the necessary reads, condensed some code... not tested though), settings in red
| Code: | #NoTrayIcon
pcFilePath = C:\WINDOWS\key.txt
usbFile = key.txt
OnExit, DoExit
lastUsbFilePath =
SysGet, VirtualScreenWidth, 78
SysGet, VirtualScreenHeight, 79
Return
F8::
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Color, 000000
Gui, Font, x0 y0 cFF0000 s128, Arial
Gui, Add, Text, Locked, Locked
Gui, Show, x0 y0 h%VirtualScreenHeight% w%VirtualScreenWidth% , lock
SetTimer, DoCheckKey, 200
Return
DoCheckKey:
; get pc key
FileRead, pcKey, %pcFilePath% ; read the pc key
IfEqual, ErrorLevel, 1, Gosub, DoBlock ; there was an error reading the pc file, block
; get usb key
If not lastUsbFilePath ; if we don't have the usb file path yet...
{
DriveGet, allDrives, List, Removable ; get list of removable drives
Loop, Parse, allDrives ; loop thru all removable drives
{
thisUsbFilePath = %A_LoopField%\%usbFile% ; set full path to possible usb file
IfExist, %thisUsbFilePath% ; if the possible file really exists...
{
FileRead, usbKey, %thisUsbFilePath% ; read the usb key
IfEqual, ErrorLevel, 1, Gosub, DoBlock ; there was an error reading the usb file, block
lastUsbFilePath := thisUsbFilePath ; remember the correct usb file path
}
}
}
else ; we already know the usb file path...
{
FileRead, usbKey, %lastUsbFilePath% ; read the usb key
IfEqual, ErrorLevel, 1, Gosub, DoBlock ; there was an error reading the usb file
}
; we should have the keys now, so check the keys
If (pcKey != "" && usbKey != "" && pcKey = usbKey) ; if the keys are not empty, but equal, unblock
Gosub, Unblock
else
Gosub, Block
Return
DoBlock:
BlockInput on
WinKill, Windows Task Manager
Gui, Show, x0 y0 h%VirtualScreenHeight% w%VirtualScreenWidth% , lock ;paints over any crack attempt
Return
DoUnblock:
Gui Destroy
BlockInput off
SetTimer, DoCheckKey, off
Return
x: ; "secret" exit keystroke, in case of troubles
DoExit:
Gosub, DoUnblock
ExitApp
Return
; disabled keys
Esc::Return
|
HTH
________________________________________________________
New here? Please, before you post...
1. Read the tutorial and try the examples. -> 2. Take a look at the command list to get an idea of what you could do. -> 3. Create your script. Consult the documentation and the FAQ if you get stuck. -> 4. Search the forum if you need help or examples, method 1 (forum), method 2 (site), method 3 (Google). -> 5. Post your code on the forum in the "Ask for Help" section if you still run into problems (but read this first). -> 6. There is more AHK on autohotkey.net and the Wiki and there is an AHK IRC chat. |
|
| Back to top |
|
 |
DeWild1
Joined: 30 Apr 2006 Posts: 358 Location: Shigle Springs
|
Posted: Mon Nov 24, 2008 7:06 pm Post subject: |
|
|
add this
| Code: | Regwrite, REG_SZ, HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\taskmgr.exe, Debugger, Hotkey Disabled
regwrite, REG_DWORD, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System, DisableTaskMgr, 1 |
| Code: | regdelete, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System, DisableTaskMgr
regdelete, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\taskmgr.exe |
_________________ CPULOCK.com
virusSWAT.com
Computer Repair Computer Service.com
911PCFIX.com |
|
| Back to top |
|
 |
menaphus
Joined: 28 Nov 2008 Posts: 111 Location: United Kingdom
|
Posted: Fri Nov 28, 2008 11:45 pm Post subject: Loose your usb drive |
|
|
I like the idea, having a physical key to unlock it but the thing is what if you actualy lost your usb drive while the pc was locked? Or is it a case of the power button
Edit: infact would shuting down the pc with the power button or unplugging it unlock it anyway?
no disrespect just wondering how secure it is/ how long you could leave it _________________ Adam
http://moourl.com/8w0tx
 |
|
| Back to top |
|
 |
fantasybar Guest
|
Posted: Sun Nov 30, 2008 9:09 am Post subject: there are some errors |
|
|
| n-l-i-d wrote: | I cleaned up your code a bit (minimized the necessary reads, condensed some code... not tested though), settings in red
|
there are some errors in your code.
Marked in red
| Code: |
#NoTrayIcon
pcFilePath = C:\WINDOWS\key.txt
usbFile = key.txt
OnExit, DoExit
lastUsbFilePath =
SysGet, VirtualScreenWidth, 78
SysGet, VirtualScreenHeight, 79
Return
F8::
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Color, 000000
Gui, Font, x0 y0 cFF0000 s128, Arial
Gui, Add, Text,
Gui, Show, x0 y0 h%VirtualScreenHeight% w%VirtualScreenWidth% ,
SetTimer, DoCheckKey, 200
Return
DoCheckKey:
; get pc key
FileRead, pcKey, %pcFilePath% ; read the pc key
IfEqual, ErrorLevel, 1, Gosub, DoBlock ; there was an error reading the pc file, block
; get usb key
If not lastUsbFilePath ; if we don't have the usb file path yet...
{
DriveGet, allDrives, List, Removable ; get list of removable drives
Loop, Parse, allDrives ; loop thru all removable drives
{
thisUsbFilePath = %A_LoopField%:\%usbFile% ; set full path to possible usb file
IfExist, %thisUsbFilePath% ; if the possible file really exists...
{
FileRead, usbKey, %thisUsbFilePath% ; read the usb key
IfEqual, ErrorLevel, 1, Gosub, DoBlock ; there was an error reading the usb file, block
lastUsbFilePath := thisUsbFilePath ; remember the correct usb file path
}
}
}
else ; we already know the usb file path...
{
FileRead, usbKey, %lastUsbFilePath% ; read the usb key
IfEqual, ErrorLevel, 1, Gosub, DoBlock ; there was an error reading the usb file
}
; we should have the keys now, so check the keys
If (pcKey != "" && usbKey != "" && pcKey = usbKey) ; if the keys are not empty, but equal, unblock
Gosub, DoUnblock
else
Gosub, DoBlock
Return
DoBlock:
BlockInput on
WinKill, Windows Task Manager
Gui, Show, x0 y0 h%VirtualScreenHeight% w%VirtualScreenWidth% , lock ;paints over any crack attempt
Return
DoUnblock:
Gui Destroy
BlockInput off
SetTimer, DoCheckKey, off
Return
x: ; "secret" exit keystroke, in case of troubles
DoExit:
Gosub, DoUnblock
ExitApp
Return
; disabled keys
Esc::Return
|
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|