USB Drive Disabler is an application developed in C#.net framework which allows you to block all USB storage devices from accessing your computer.
Instead of blocking the USB devices with Registry command, we can use this application which can make less time requirement, avoid unwanted doubts and sometimes it can also cause data loss in pen drive.
2. “USB Drive Disabler
CHAPTER - 1
ABSTRACT
USB Drive Disabler is an application developed in C#.net framework which allows you to
block all USB storage devices from accessing your computer.
Instead of blocking the USB devices with Registry command, we can use this application
which can make less time requirement, avoid unwanted doubts and sometimes it can also
cause data loss in pen drive.
It has a very simple interface and in just one click, your device is protected. This software is
portable and can be used on any Windows PC.
When run, you will be asked either to enable or disable the drive and it has one additional
option which is to make the USB Device Read-Only or Read-Write and adds more security
for the application.
Need of the project:
1. Disgruntled employees can easily steal data using USB drives
2. Booby-trapped USB drives can destroy your network.
3. Unidentified devices can wreak havoc in your organization.
4. Encrypting USB drives isn’t enough to effectively secure them.
5. The ability to block and unblock USB devices improves USB security.
3. CHAPTER - 2
PROJECT DESCRIPTION
OBJECTIVE OF THE PROJECT
1) The USB drive disabler provides protection against any malicious programs trying
to attack via USB drive.
2) It delivers high level of protection against theft and accidental disclosure of
confidential data, and prevents unauthorized persons from stealing your data.
When the application is opened with Administrator privileges, it shows two options -
1. To enable or disable the USB Port in the computer.
2. Read only or Read and Write option.
If we choose the disable option it will disable all USB Ports in the computer by
changing the Registry settings automatically and does not allow any USB devices to
access the computer. In this mode we cannot select the options like Read-only and
Read - Write.
4. If we choose the enable option it will allow all USB Ports in the computer by
changing the Registry settings automatically and allow any USB devices to access
the computer. In this mode we can select Read-only and Read-Write.
1. In the Read-only mode we can able to access the data in the USB Device but
cannot be able modify or delete the data present in the USB Device.
2. In the Read and Write mode we can access the data in the USB Device and can
perform all kind of operations like delete, modify.
CHAPTER - 3
SOFTWARE DESCRIPTION
For this project we have used the Microsoft Visual Studio. Microsoft Visual Studio is
an Integrated Development Environment (IDE) from Microsoft. It is used to develop
computer programs, websites, web apps, web services and mobile apps. Visual Studio
uses Microsoft software development platforms such as Windows API, Windows
Forms, Windows Presentation Foundation, Windows Store and Microsoft Silverlight.
Visual Studio does not support any programming language, solution or tool
intrinsically; instead, it allows the plugging of functionality coded as a VS Package.
In Visual Studio we use .net framework in C#. C# is an elegant and type-safe object-
oriented language that enables developers to build a variety of secure and robust
applications that run on the .NET Framework.
You can use C# to create Windows client applications, XML Web services, distributed
components, client-server applications, database applications, and much, much more.
Visual C# provides an advanced code editor, convenient user interface designers,
integrated debugger, and many other tools to make it easier to develop applications
based on the C# language and the .NET Framework.
5. MINIMUM HARDWARE / SOFTWARE REQUIREMENTS
• Any Pentium IV or higher Computers
• Any Windows OS
• Require administrative rights
SOURCE CODE OF USB DRIVE PROTECTOR
using System;
using System.Collections.Generic; using
System.ComponentModel; using System.Data; using
System.Drawing; using System.Linq; using System.Text;
using System.Runtime.InteropServices; using
Microsoft.Win32; using System.Threading; using
System.Windows.Forms;
namespace Aashiq123 {
public partial class Form1 : Form {
public Form1()
{
InitializeComponent();
}
RegistryKey Regkey, RegKey2;
Int32 rValue,rsvalue,Gvalue,tvalue;
//setting the registry path to enable and disable
automatically string Regpath =
"SystemCurrentControlSetServicesUSBSTOR"; string
ReadAndWriteRegPath2 =
"SystemCurrentControlSetControl"; string
ReadAndWriteRegPath =
"SystemCurrentControlSetControlStorageDevicePolicies"
;
//when cancel button is clicked private void
ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
6. //when ok button is clicked
private void ButtonOk_Click(object sender, EventArgs e)
{
Regkey = Registry.LocalMachine.OpenSubKey(Regpath, true);
Regkey.SetValue("Start", rValue); if (GroupBox2.Enabled ==
true)
{RegKey2 =
Registry.LocalMachine.OpenSubKey(ReadAndWriteRegPath2, true);
RegKey2.CreateSubKey("StorageDevicePolicies");
RegKey2 =
Registry.LocalMachine.OpenSubKey(ReadAndWriteRegPath, true);
RegKey2.SetValue("WriteProtect", rsvalue);
}//to set the values to perform
if ((rValue == 3) && (rsvalue == 1))
{MessageBox.Show ("USB Port were enable and Read only is
enabled");
}else if ((rValue == 3) && (rsvalue == 0))
{MessageBox.Show ("USB Port were enable and Read and write is
enabled");
}else
{MessageBox.Show ("USB Port were disable");
}}private void RadioButtondisable_CheckedChanged(object
sender, EventArgs e)
{GroupBox2.Enabled = false; rValue = 4;
}private void RadioButtonenable_CheckedChanged(object sender,
EventArgs e){
GroupBox2.Enabled = true; rValue = 3;
}private void RadioButtonreadonly_CheckedChanged(object
sender, EventArgs e)
{rsvalue = 1;
}private void RadioButtonreadwrite_CheckedChanged(object
sender, EventArgs e) {
rsvalue = 0;}
7. bool isAdmin;
[DllImport ("shell32")]
static extern bool IsUserAnAdmin();
private void Form1_Load(object sender, EventArgs e)
{
//to check user is in admin mode or in guest mode
isAdmin = IsUserAnAdmin(); if (isAdmin == false)
//to display compilation error {
MessageBox.Show("You don't have proper privileges level to
make changes, administrators privileges are required",
"Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
Close();
}else
{Regkey = Registry.LocalMachine.OpenSubKey(Regpath, true);
Gvalue = Convert .ToInt32 (Regkey.GetValue("Start"));
//check the current state of the usb/whether is enabled or
disabled if (Gvalue == 3)
{RadioButtonenable.Checked = true;
}else if (Gvalue == 4)
{RadioButtondisable.Checked = true;
}RegKey2 =
Registry.LocalMachine.OpenSubKey(ReadAndWriteRegPath, true);
try {
tvalue = Convert.ToInt32(RegKey2.GetValue("WriteProtect")); if
(tvalue == 1)
{RadioButtonreadonly.Checked = true;
}else if (tvalue == 0)
{RadioButtonreadwrite.Checked = true;
}}
catch (NullReferenceException) { }
}
}
}
}
8. CHAPTER - 4
SCREEN SHOTS
How to run the application with Administrator rights
The application must be selected with Administrator privilege for proper functioning of the
application otherwise it will show a compilation error.
After selecting with Administrator privilege it will show a User Account Control dialog box
press YES option to open the next window otherwise it will be terminated.
9. CHAPTER - 5
FUTURE ENHANCEMENTS
• In the future days we are planning to modify this project by extra futures like when an pen
drive is inserted to the port the alert message will be sent to the administrator.
• The login history about the inserted USB devices in to the computer will be stored in the
computer.
CHAPTER - 6
CONCLUSION
USB Drive Protector Tool is a great tool for adding some additional security to your USB drives.
The powerful write protection included in the application prevents the unauthorized altering of
files saved on your USB devices.
In addition to this, the application offers registry protection as well as disabling of USB ports on
your computer.
CHAPTER - 7
REFERENCES
https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2013-sysrequirements-vs
10. CHAPTER - 5
FUTURE ENHANCEMENTS
• In the future days we are planning to modify this project by extra futures like when an pen
drive is inserted to the port the alert message will be sent to the administrator.
• The login history about the inserted USB devices in to the computer will be stored in the
computer.
CHAPTER - 6
CONCLUSION
USB Drive Protector Tool is a great tool for adding some additional security to your USB drives.
The powerful write protection included in the application prevents the unauthorized altering of
files saved on your USB devices.
In addition to this, the application offers registry protection as well as disabling of USB ports on
your computer.
CHAPTER - 7
REFERENCES
https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2013-sysrequirements-vs