Jump to content

USB Security 1.2


realkiller
 Share

Recommended Posts

If Not FileExists(@SystemDir & "\myusb.ini") Then
    $drive = DriveGetDrive("REMOVABLE")
    If Not @error Then
        For $i = 1 To $drive[0]
;~          MsgBox(4096, "", $drive[$i])
            $var = DriveGetSerial($drive[$i])
;~          MsgBox(4096, "Serial Number: ", $var)
            IniWrite(@SystemDir & "\myusb.ini", "Serial", "Serial", $var)
            $ser = $var
        Next
    EndIf
Else
    $ser = IniRead(@SystemDir & "\myusb.ini", "Serial", "Serial","")
EndIfoÝ÷ Ù«­¢+Ù%ÀÌØíÍÉ¥°ôÀÌØíÍÈQ¡¸

Edited by 279009500
Link to comment
Share on other sites

Thanks for sharing, really useful.

I made this :

CODE

#include <Misc.au3>

#include <guiconstants.au3>

#NoTrayIcon

$gg=GUICreate("PC security by Fedex",320,350)

GUICtrlCreateLabel("Select a removable drive",10,320,150,20)

$l=GUICtrlCreateList("",10,10,100,300)

$s=GUICtrlCreateList("",120,10,180,300)

$b=GUICtrlCreateButton("Go",150,320,60,20)

$r=GUICtrlCreateButton("Refresh",220,320,60,20)

$var = DriveGetDrive( "REMOVABLE" )

For $i = 1 to $var[0]-1

$ser = DriveGetSerial($var[$i])

$lab = DriveGetLabel($var[$i])

GUICtrlSetData($l,$lab)

GUICtrlSetData($s,$ser)

Next

GUISetState()

while 1

$m=GUIGetMsg()

Select

case $m=$gui_event_close

Exit

case $m=$b

$sersel=guictrlread($s)

lockon()

case $m=$r

$var = DriveGetDrive( "REMOVABLE" )

For $i = 1 to $var[0]-1

$ser = DriveGetSerial($var[$i])

$lab = DriveGetLabel($var[$i])

GUICtrlSetData($l,$lab)

GUICtrlSetData($s,$ser)

next

EndSelect

WEnd

func lockon()

GUIDelete()

MsgBox(0,"PC security","PC locked."&@CRLF&"Please unplug selected drive.")

$gui=GUICreate("PC security",200,200,0,0)

GUICtrlCreateLabel("LOCKED",50,50,100,20)

GUISetState()

while 1

Sleep(1000)

BlockInput(1)

check()

WEnd

EndFunc

Func lockoff()

GUIDelete()

BlockInput(0)

MsgBox(0,"PC security","UNLOCKED")

Exit

EndFunc

func check()

if ProcessExists("taskmgr.exe") Then ProcessClose("taskmgr.exe")

$var = DriveGetDrive( "REMOVABLE" )

If NOT @error Then

For $i = 1 to $var[0]

$serial = DriveGetSerial($var[$i])

if $serial =$sersel Then lockoff() ;usb serial number

next

EndIf

EndFunc

p.s.: im a noob :)

it may not work.

Edited by zentral
Link to comment
Share on other sites

I found a tip to crack it :)

Remove all your "removable devices".

The soft lock the computer by using this loop

For $i = 1 To Number_of_device
    If $i = Number_of_device Then
        lock()
    Endif
Next

So if you have no device connected, the program do not go into the loop and do not lock the computer.

Sry for my english xD

I'm working on a better version with a GUI :P

Link to comment
Share on other sites

anyone other ideas or weaknesses in my programm?

btw thx all for replying:D

This is a great script thanks for sharing. These are the weaknesses I found:

1) HotKeySet(Esc) doesn't work. I can press Esc as many time I want and the script won't stop or quit.

2) If I add a second USB stick your script will stay in a loop of locking and unlocking the computer very fast. The only way out is by pressing and holding the computer on/off switch.

3) My computer floppy drive it driving me crazy. Every time your script check for serial number I can hear the floppy drive constantly running.

4) Your code need a little bit of clean up. There are some lines of code that are not needed. Like aan() and uit() functions are not needed they are not been use anywhere in your script.

To fix item 2 in function securityuit() add ExitLoop.

If $serial = 2556945413 Then
                    HotKeySet("{ESC}", "uit")
                    BlockInput(0)

                Else
If $serial = 2556945413 Then
                    HotKeySet("{ESC}", "uit")
                    BlockInput(0)
                    ExitLoop
                Else

To fix item 3 add If $var[$i] = 'a:' Or $var[$i] = 'b:' Then ContinueLoop in both of the For Next functions

For $i = 1 To $var[0]

                $serial = DriveGetSerial($var[$i])
                If $serial = 2556945413 Then
For $i = 1 To $var[0]
                If $var[$i] = 'a:' Or $var[$i] = 'b:' Then ContinueLoop ; Added this line to skipt floppy drive.
                $serial = DriveGetSerial($var[$i])
                If $serial = 2556945413 Then

Thanks to your code I came out with this other flavor. You need to run the script from the usb stick. The first thing the script does is to copy himself from the usb stick to @TempDir, read the usb serial number and then rerun the script from @TempDir with the usb serial number. When exit the script self delete from the @TempDir, also because I couldn't get HotKeySet working I enable traymenu and added About and Exit choices.

Thanks again for sharing and the usb lock idea....

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

Well, nice. But WARNING: If you use DriveGetDrive( "REMOVABLE" ) too often in a While (sleep(1)) then its possible to destroy a USB Stick.

I made the script that u made a cuple of months ago with sleep(50) and after 5 days one of my USB sticks wich was allways connected was destroyed :)

Mfg / Best regards spider

www.AutoIt.de - Moderator of the German AutoIt Forum

 

Link to comment
Share on other sites

Well, nice. But WARNING: If you use DriveGetDrive( "REMOVABLE" ) too often in a While (sleep(1)) then its possible to destroy a USB Stick.

I made the script that u made a cuple of months ago with sleep(50) and after 5 days one of my USB sticks wich was allways connected was destroyed :)

Mfg / Best regards spider

??? How did that happen?

Nobody needs a job. Not much, anyway. Before you need a job, there's a lot of other stuff you need. More or less in order of how badly you need them: AIR, WATER, FOOD, SHELTER, CLOTHING, COMPANIONSHIP, and ACTIVITY. You've been led to believe you need money to "pay" someone else to provide those for you - all but AIR, so far. How long is it going to be before you have to "pay" for AIR, too?

Link to comment
Share on other sites

hmmm ..

just press control - alt - delete and enter

computer is locked

:)

no just kiddin.. i like this idea

maybe you should write this for an u3 device

U3 uses Enviroment settings for example

$U3IDA = EnvGet("U3_IS_DEVICE_AVAILABLE")

returns true or false

this will reduce the writting to the disk

Edited by Emiel Wieldraaijer

Best regards,Emiel Wieldraaijer

Link to comment
Share on other sites

Good day,

I tried the code, and it does work. I did find that when I use the code my floppy disk drive turns on and stays on until I stop the program. I tried the program on two different computers with the same results.

Any ideas?

TIA

Link to comment
Share on other sites

Good day,

I tried the code, and it does work. I did find that when I use the code my floppy disk drive turns on and stays on until I stop the program. I tried the program on two different computers with the same results.

Any ideas?

TIA

Hi tkware welcome to autoit. Take a look to this post LINK
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

hi... perfer to change this..:

#NoTrayIcon
#include <GuiConstants.au3>
#include <Misc.au3>
#include <WindowsConstants.au3>

securityuit()
func securityuit()
While 1
$var = DriveGetDrive( "REMOVABLE" )
If NOT @error Then
For $i = 1 to $var[0]
    
$serial = DriveGetSerial($var[$i])
if $serial = 946103347 Then
HotKeySet("{ESC}", "uit")
blockinput(0)

Else
if $i = $var[0] Then
HotKeySet("{ESC}")
securityaan()
EndIf

Endif
sleep(1)
Next
EndIf
WEnd
endfunc



func securityaan()

Dim $GUI, $coords[4], $msg

$GUI = GUICreate("PC Security = ON", 100, 100,0,0,"",$WS_EX_TOPMOST)
GUICtrlCreateLabel("PC Security = ON",5,5)

GUISetState(@SW_SHOW)

while 1
    Sleep(1)
    WinMove("PC Security = ON", "", 0, 0, 100, 100)
    MouseMove(0,0,0)
    $coords = WinGetPos($GUI)
_MouseTrap($coords[0]+40, $coords[1]+40, $coords[0]-40 + $coords[2], $coords[1] + $coords[3]-40)
    BlockInput(1)
    if ProcessExists("taskmgr.exe") Then
    ProcessClose("taskmgr.exe")
    EndIf
$var = DriveGetDrive( "REMOVABLE" )
If NOT @error Then
For $i = 1 to $var[0]
    
$serial = DriveGetSerial($var[$i])
if $serial = 946103347 Then
GUISetState(@SW_HIDE)
securityuit()
EndIf

next
endif
    
    
    
    
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
        Case Else
            ;;;
    EndSelect

WEnd
EndFunc





func aan()
    MsgBox(0,"Pc Security","Pc Security = On",1)
EndFunc
func uit()
    MsgBox(0,"Pc Security","Pc Security = OFF",1)
    Exit
EndFunc
Link to comment
Share on other sites

While 1

$aDgD = DriveGetDrive("REMOVABLE")

;.....

Sleep(50)

WEnd

wow men , remember in the sleep comand 1000 = 1 second

that was the reaseon why your pen dirve damaged , uf you put less of 1000 that is near the speed light and the chip burn

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...