Usa tu Pen-drive como llave de tu PC o programa

y programas personales para otros como tu, puede que te corrijan ;)
Responder
Avatar de Usuario
BasicOs
Site Admin
Mensajes: 2085
Registrado: 21 Nov 2006, 19:24
Ubicación: El Internet - (Canarias, España)
Contactar:

Usa tu Pen-drive como llave de tu PC o programa

Mensaje por BasicOs »

Cada vez que ejecutas este programa te engancha con el PEN (u otra unidad) y graba un fichero llave, que obliga a que esté el PEN, para que siga sin bloquearse el teclado y ratón.

3 usos de esta utilidad para bloquear el PC teniendo en cuenta que se encuentra una letra de unidad de disco (Pen, discos externos, discos internos)

1.-Este programa usa el Pen-drive com llave para bloquear el PC, :smt021
2.-Se puede usar tipo dongle para controlar ligado a un programa con el pen insertado.(Hay que incorporar en el arranque junto al programa, para que arranque cada vez el USBlock)
3.-Para no olvidarse LLEVARTE el PEN-Drive, que se queda frecuentemente olvidado, porque al sacar el PEN te pregunta si quieres apagar el PC. O sea no apagar el PC normalmente sino al SACAR EL PEN.

Observaciones:
-Tiene un sistema básico de bloquear el PC (teclado, ratón) alternativo al uso de entrada de usuario y contraseña del SISTEMA, no usar para seguridad extrema (habría que modificar alguna parte del código).
-No toca ni se incorpora al registro, arranque. O sea que si quieres tenerlo activado cada vez que se use el pc introducelo en el mismo Inicio. (Bajo propia responsabilidad) Ahora mismo, por precaución, si reinicias el PC desaparece el programa.
-Usar juiciosa y positivamente para con otras personas, Por favor!!. Sobran explicaciones. :smt035 :smt008


Poner en el mismo directorio las librerias que adjunto:
GUIConstants.au3
String.au3
=>>MD5.au3 (Frez Systems Limited - converted to Au3 by SvenP)
=>>Mytoast.au3
Autor de Md5.au3 http://www.autoitscript.com/forum/index ... =10590&hl=

Versión con modificación para apagar el PC para no olvidar Pen, y traducida al Spanish. Créditos de USBLock original para crashdemons

Código: Seleccionar todo

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=lock.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseAnsi=y
#AutoIt3Wrapper_Res_Comment=USBLock
#AutoIt3Wrapper_Res_Description=USBLock
#AutoIt3Wrapper_Res_Fileversion=1.1.0.18
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=Crash Daemonicus
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Run_AU3Check=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt("GUIOnEventMode", 1)
#include <GUIConstants.au3>
#include <String.au3>
#include <MD5.au3>
#include <myToast.au3>
Global $Locked=False
Global $Ready=False
Global $DebugMode=False
;If @Compiled Then $DebugMode=False ; for debugging without BlockInput()
Global $Drive
Global $KeyFilel=@ScriptDir&'\USBLock.key'
Global $KeyFile='USBLock.key'
Global $ini=@ScriptDir&'\USBLock.ini'
Global $cmd=StringLen($CmdLineRaw)
$Toast=ToastWin_Create('AYBABTU',@DesktopWidth-100,@DesktopHeight,100,100)
GUICtrlSetOnEvent($temp_ToastBox,"ToastWin_DisposeAuto2")
ToastWin_Show($Toast)
If $cmd And @Compiled Then
	$Ready=True
	$Drive="NonexistantDrive"
Else
	While $Ready==False
		NotifyOn("Introduzca la letra de unidad a Proteger.")
		$Drive=InputBox("USBLock","Por favor introduzca  la letra de unidad que se va a usar como llave para su PC.",$Drive)
		$Toast_StopSleep=False
		NotifyOff()
		If @error Or $Drive=='' Then Exit
		$Drive&=':\'
		If FileExists($Drive)=0 Or StringLower($Drive)=='a:\' Or StringLower($Drive)=='b:\' Or StringLower($Drive)=='c:\' Then
			NotifyOn(" Unidad de disco no encontrada."&@CRLF&" Por favor, Intentelo de nuevo")
			ToastWin_Sleep($Toast,2000)
			NotifyOff()
			ContinueLoop
		EndIf
		$Ready=True
	WEnd
	$key=_GetNewKey()
	FW($KeyFilel,MD5($key))
	FW($Drive&$KeyFile,$key)
	$key='';Clear original key from variables
EndIf
While 1
	WaitRemoveDrive($Drive)
	IF MsgBox(4100, "Opción de Apagar", "¿Desea apagar su PC?", 10)=6 Then
		Shutdown(13)
	EndIf

	if InputBox("Sacó la llave"," Quiere apagar su PC",
	;Lock Screen here
	_BlockInput(1)
	$Locked=True
	$Drive=CheckForKey()
	If $Locked Then ; makes sure you aren't hassled if the USB is already in!
		NotifyOn("USBLock ha protegido este PC."&@CRLF&@CRLF&"Reconecte la Unidad para desbloquear.")
		ToastWin_Sleep($Toast,3000)
		NotifyOff()
		While $Locked
			Sleep(300)
			$Drive=CheckForKey()
			Sleep(100)
			_SecurityHandler()
		WENd
	EndIf
	_BlockInput(0)
	;Unlock Screen here
	NotifyOn("Unidad de disco USBLock reconocida."&@CRLF&@CRLF&" PC desbloqueado.")
	ToastWin_Sleep($Toast,2000)
	NotifyOff()
	$key=_GetNewKey()
	FW($KeyFilel,MD5($key))
	FW($Drive&$KeyFile,$key)
	$key=''
WEnd


Func NotifySecureWait($sleep)
	$t=TimerInit()
	While TimerDiff($t)<$sleep
		_SecurityHandler()
		Sleep(300)
	WEnd
EndFunc
Func NotifyOn($text)
	Global $Toast,$temp_ToastBox
	GUICtrlSetData($temp_ToastBox,$text)
	ToastWin_Size($Toast,2)
	ToastWin_SlideDown($Toast,@DesktopHeight,@DesktopHeight-200)
	ToastWin_OpenOut($Toast,2,100)
EndFunc
Func NotifyOff()
	Global $Toast,$temp_ToastBox
	ToastWin_OpenOut($Toast,100,2)
	ToastWin_SlideDown($Toast,@DesktopHeight-200,@DesktopHeight)
	ToastWin_Size($Toast,2)
	GUICtrlSetData($temp_ToastBox,'')
EndFunc
Func _SecurityHandler()
	Global $SecurityTimer
	$Secure=True
	If TimerDiff($SecurityTimer)>1000 Then
		;Because CTRL+ALT+DEL  and other apps can change whether BlockInput is on.
		$SecurityTimer=TimerInit()
		_BlockInput(1)
	EndIf
	$tskmgr_pid=ProcessExists("taskmgr.exe")
	If $tskmgr_pid<>0 Then
		WinClose("Windows Task Manager")
		WinKill("Windows Task Manager")
		ProcessClose($tskmgr_pid,1)
		_BlockInput(1)
		$Secure=False
	EndIf
	If $Secure=False Then
		;Security Evasion detected
		NotifyOn("USBLock ha bloqueado un intento de salir de la seguridad.")
		NotifySecureWait(2000)
		NotifyOff()
	EndIf
EndFunc
Func _BlockInput($i)
	Global $DebugMode
	If $DebugMode Then Return 0
	BlockInput($i)
EndFunc
Func _GetNewKey()
	$key=''
	For $i=1 To 300
		$key&=Chr(Random(0x20,0x7E,1))
	Next
	Return $key
EndFunc
Func WaitRemoveDrive($drv)
	If FileExists($drv)=0 Then Return 0
	NotifyOn("USBLock  va a esperar hasta que quite la unidad para bloquear su PC.")
	ToastWin_Sleep($Toast,3000)
	NotifyOff()
	While FileExists($drv)
		Sleep(300)
	WEnd
EndFunc
Func CheckForKey()
	Global $KeyFilel,$KeyFile,$Locked
	$var = DriveGetDrive( "all" )
	If NOT @error Then
		For $i = 1 to $var[0]
			$drv=$var[$i]
			If $drv=='a:' Or $drv=='b:' Or $drv=='c:' Then ContinueLoop
			If FileExists($drv&$KeyFile) Then
				$key=FR($KeyFilel)
				$key2=FR($drv&$KeyFile)
				If $key2=="~X@CD_USBLock_Author[Crash Daemonicus]::280f5a5a7cf59c589328841c9beb9532" Then
					BlockInput(0)
					NotifyOn("Unidad de USBLock reconocida."&@CRLF&@CRLF&"Bienvenido.")
					ToastWin_Sleep($Toast,2000)
					NotifyOff()
					Exit
				EndIf
				If MD5($key2)==$key Then
					$Locked=False
					Return $drv&'\'
				Else
					;Invalid Key actions
					FileDelete($drv&$KeyFile)
					NotifyOn("Esta unidad de USBLock no es válida."&@CRLF&" la llave de seguridad invalida se ha borrado.")
					NotifySecureWait(4000)
					NotifyOff()
				EndIf
			EndIf
		Next
		Return $Locked
	Else
		Exit
	EndIf
EndFunc

Func ToastWin_DisposeAuto2()
	;just here for the fake-close event ;)
	Global $temp_ToastForm
	$Toast_StopSleep=True
EndFunc
Func FR($file)
	$fh = FileOpen($file, 16)
	$d = BinaryToString(FileRead($fh))
	FileClose($fh)
	Return $d
EndFunc   ;==>FileReadFull
Func FW($file, $data)
	$fh = FileOpen($file, 2 + 16)
	$d = FileWrite($fh, StringToBinary($data))
	FileClose($fh)
	Return $d
EndFunc   ;==>FileOverwrite
Enlace del Autor http://www.autoitscript.com/forum/index ... opic=71505
Adjuntos
UsbLock MD5 MyToast.zip
UsbLock.au3 en español, MD5.au3 y MyToast.au3
(10.81 KiB) Descargado 299 veces
USBLock_Emergency_Keyfile.zip
Fichero de emergencia para la unidad en caso de problemas
(194 Bytes) Descargado 237 veces
Avatar de Usuario
timistar
Hacker del Foro
Mensajes: 89
Registrado: 24 Jun 2008, 05:03

Re: Usa tu Pen-drive como llave de tu PC o programa

Mensaje por timistar »

gracias este esta bueno

pero siempre me ha botado estos errores, que le falta a mi autoit, aclaro soy novato por si es un error tonto :smt040

y el autoit mehabre el mytoast para editarlo

Código: Seleccionar todo


C:\Documents and Settings\t-cesesc\Escritorio\myToast.au3(16,62) : WARNING: $WS_POPUP: possibly used before declaration.
	$Form = GUICreate("CD_TOASTWIN", 100, 100, $x, $y, $WS_POPUP,
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\t-cesesc\Escritorio\myToast.au3(16,77) : WARNING: $WS_EX_TOPMOST: possibly used before declaration.
	$Form = GUICreate("CD_TOASTWIN", 100, 100, $x, $y, $WS_POPUP,$WS_EX_TOPMOST+
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\t-cesesc\Escritorio\myToast.au3(16,95) : WARNING: $WS_EX_TOOLWINDOW: possibly used before declaration.
	$Form = GUICreate("CD_TOASTWIN", 100, 100, $x, $y, $WS_POPUP,$WS_EX_TOPMOST+$WS_EX_TOOLWINDOW+
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\t-cesesc\Escritorio\myToast.au3(19,27) : WARNING: $SS_LEFTNOWORDWRAP: possibly used before declaration.
	$Style=$SS_LEFTNOWORDWRAP
	~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\t-cesesc\Escritorio\myToast.au3(20,31) : WARNING: $SS_LEFT: possibly used before declaration.
	If $Wrap Then $Style=$SS_LEFT
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\t-cesesc\Escritorio\USBLock.au3(60,53) : ERROR: syntax error
	if InputBox("Sacó la llave"," Quiere apagar su PC",
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\t-cesesc\Escritorio\USBLock.au3(62,16) : ERROR: multi-line 'If' missing 'Then'.
	_BlockInput(1)
	~~~~~~~~~~~~~~^
C:\Documents and Settings\t-cesesc\Escritorio\USBLock.au3(121,29) : ERROR: ProcessClose() [built-in] called with wrong number of args.
		ProcessClose($tskmgr_pid,1)
		~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\t-cesesc\Escritorio\myToast.au3(16,62) : ERROR: $WS_POPUP: undeclared global variable.
	$Form = GUICreate("CD_TOASTWIN", 100, 100, $x, $y, $WS_POPUP,
Avatar de Usuario
Rupert.25
Hacker del Foro
Mensajes: 247
Registrado: 17 Jul 2007, 18:27

Re: Usa tu Pen-drive como llave de tu PC o programa

Mensaje por Rupert.25 »

Hola basicOS. Muchas gracias por la aplicacion!

Es cuanto a Timistar:

Tienes que incluir las librerias en el programa:

#Include <GUIConstants.au3>
#Include<String.au3>

Y tambien las que Adjuntó BasicOS.

En caso de que no funcione, abre la ayuda y en buscar escribe la variable que dice que necesitas declarar. Ahi podras ver en que libreria se incluye. Regularmente son:

GUIConstants.au3
String.au3
WindowConstants.au3
WindowConstantsEx.au3

entre otras. pruebalo y luego me comentas. gracias!
Avatar de Usuario
XPyro
Profesional del Autoit
Mensajes: 542
Registrado: 04 Mar 2007, 10:12
Ubicación: México
Contactar:

Re: Usa tu Pen-drive como llave de tu PC o programa

Mensaje por XPyro »

Muy bueno el script de crashdemons, agradesco compartirlo :smt006
Imagen
Avatar de Usuario
Chefito
Profesional del Autoit
Mensajes: 2035
Registrado: 21 Feb 2008, 18:42
Ubicación: Albacete/Cuenca (España)

Re: Usa tu Pen-drive como llave de tu PC o programa

Mensaje por Chefito »

Muy buena la idea de proteger el ordenata con un pen usb :smt023 . Otro gran Script BasicOs :smt024 .

Saludos.
Cita vista en algún lugar de la red: En este mundo hay 10 tipos de personas, los que saben binario y los que no ;).
Responder