Jump to content
Sign in to follow this  
Yashied

USBProtect

Recommended Posts

Yashied

LAST VERSION - 1.1

28-Jun-10

The program consists of only one executable file (USBProtect.exe), and is intended to lock any removable storage devices, such as Flash Drive, Hard Drive (external), etc. Just run USBProtect and all removable drives will be locked. If you try to open them, you get the "Access is denied" message. If the user's account is not included in the administrators group, the user not be able to unload the process by using Windows Task Manager. In this case, USBProtect can be unloaded only by using the "/u" command line parameter (see below). I must say that USBProtect is designed to work only in Windows Vista/7 (USBResolve, see below, works in any systems).

A distinctive feature of USBProtect is that you can create (mark) a "favorites" removable drives. These drives will not be locked by USBProtect. To create the "favorite" drive you have to do the following.

  • Create a text file named "Volume.dat" in the root directory of the required drive, for example "D:Volume.dat".
  • Place in this file a unique identifier which returns the following function. This identifier is based on the serial number of drive's file system, so if you format it, this process must be repeated again.

    #Include <Crypt.au3>
    
    Func _GetVolumeUniqueID($sVolume)
    
        Local $Serial = DriveGetSerial($sVolume)
    
        If @error Then
            Return ''
        EndIf
    
        Local $Hash = StringTrimLeft(_Crypt_HashData($Serial, $CALG_MD5), 2)
    
        If $Hash Then
            Return StringMid($Hash, 1, 8) & '-' & StringMid($Hash, 9, 4) & '-' & StringMid($Hash, 13, 4) & '-' & StringMid($Hash, 17, 4) & '-' & StringMid($Hash, 21, 12)
        Else
            Return ''
        EndIf
    EndFunc   ;==>_GetVolumeUniqueID

  • Set "Hidden" and "Read only" attributes for this file.
Now USBProtect will not lock this drive, and you can safely use it while all other drives will be locked. To not do every time this steps, I wrote a small utility USBResolve (inside the archive) which makes all the same but much faster and safer. Just select a drive from the list and click "Change Status" button for lock/unlock its. Naturally, this should be done while USBProtect is not launched, otherwise, drive will not be present in the list, or on another computer. Note, you can unlock only drives that have the FAT32 or NTFS file systems. And lastly, USBProtect does not write any data in the registry, it's does not need them.

You can use the following command line parameters:

"/c" or "/cd"

Locks access to all the internal CD/DVD/BD-ROM devces while the process is in memory.

"/u" or "/unload"

Unloads USBProtect from memory.

 

USBProtect.png

Supported operating systems

Windows Vista, 7

Files to download

Binary

Redirection to USBProtect_bin.7z, 605 KB

USBProtect_bin.html

Source

Redirection to USBProtect_source.7z, 125 KB

USBProtect_source.html

Note

Source code inside the archive is fully functional, but for security reasons I excluded from it a function that is responsible for protecting the process. I think that if someone who written something which really needed a protection of the process, he can independently implement that.

Edited by Yashied

Share this post


Link to post
Share on other sites
wakillon

Good Idea, thanks to share !

and for xp users like me, is there another version ? Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
slayerz

Really nice example Yashied... especially the exe protection feature.

BTW, if you have Unlocker installed, you can actually unlock your USB... but overall, it's a very nice program ;)


AUTOIT[sup] I'm lovin' it![/sup]

Share this post


Link to post
Share on other sites
Yashied

Hmm, it requires Windows Vista that I don't have. Can you develop a version for XP?

USBProtect uses the WinAPI functions to lock a devices that will not work properly in Windows XP. The program is designed only for Windows Vista or later. I'm sorry.

;)

Share this post


Link to post
Share on other sites
4Eyes

Yashied,

In relation to your comment "Source code inside the archive is fully functional, but for security reasons, I excluded from it a function that is responsible for protecting the process", I can't help but wonder....

is this 'protection' a method to prevent the process from being 'ProcessClosed' or does it hide the process?

Regards,

4Eyes

Share this post


Link to post
Share on other sites
Yashied

Yashied,

In relation to your comment "Source code inside the archive is fully functional, but for security reasons, I excluded from it a function that is responsible for protecting the process", I can't help but wonder....

is this 'protection' a method to prevent the process from being 'ProcessClosed' or does it hide the process?

Regards,

4Eyes

Prevents a closure process.

Share this post


Link to post
Share on other sites
Yashied
Yashied
Zmy

Download link not exist.

Share this post


Link to post
Share on other sites
BrewManNH

This thread is 5 years old, not surprised the link is dead.

Use Bitlocker to protect your USB drives, very simple to use.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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  

×