arungeek
Hacks and Tweaks



Uncategorized

October 14, 2009

disable and enable usb port using C Program

More articles by »
Written by: arunenigma


In this post I will show you, how to create a simple virus that disables/blocks the USB ports on the computer (PC). As usual I am going to use my favorite C programming language to create this virus. Anyone with a basic knowledge of C language should be able to understand the working of this virus program.

Once this virus is executed it will immediately disable all the USB ports on the computer. As a result the you’ll will not be able to use your pen drive or any other USB peripheral on the computer. You can test this virus on your own computer without any worries since I have also given a program to re-enable all the USB ports.

Code: To disable the USB ports

#include

void main()

{

system(“reg add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR \/v Start \/t REG_DWORD \/d 4 \/f”);

}

Save the above program as block_usb.c and compile using turbo C. Upon compilation of block_usb.c you get block_usb.exe which is a simple virus that will block (disable) all the USB ports on the computer upon execution (double click).

To test this virus, just run the block_usb.exe file and insert a USB pen drive (thumb drive). Now you can see that your pen drive will never get detected.


Code: To re-enable the USB ports

#include

void main()

{

system(“reg add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR \/v Start \/t REG_DWORD \/d 3 \/f”);

}

Save the above program as unblock_usb.c and compile using turbo C.Then run the unblock_usb.exe (you need to compile unblock_usb.c) file.

Now insert the pen drive and it should get detected.



About the Author

arunenigma
Computer Science Graduate Student @ Case Western Reserve University, Cleveland, USA




 
 

 
Factory_1

Python Factory Design Patterns using Switch Case

I googled for Factory Method Design Pattern in Python but couldn’t find a good resource. So, I  am sharing an example program to demonstrate this design pattern in Python which I frequently use. The factory method pattern is...
by arunenigma
 

 
 
Gospers_glider_gun

Conway’s Game of Life Implemetation in Python with cool patterns

he Game of Life (or simply Life) is not a game in the conventional sense. There are no players, and no winning or losing. Once the “pieces” are placed in the starting position, the rules determine everything that ha...
by arunenigma
 

 
 
bin-tree

Python AVL Tree Implementation with ASCII visualization

n computer science, an AVL tree is a self-balancing binary search tree. It was the first such data structure to be invented. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any tim...
by arunenigma
 

 

 
bst

Binary Search Tree in Python with ASCII art visualization

Binary search tree implementation in Python with: in, post and pre-order traversals. Also includes methods for insertion, deletion and search of nodes. Deletion is fairly complex and is made possible by keeping track of parents...
by arunenigma
 

 
 
fibonacci

Python, Memoization, Dynamic Programming, Fibonacci Series and some Fun!

ython can implement the recursive formulation directly, caching return values. Memoization is a method where if a call is made more than once with the same arguments, and the result is returned directly from the cache. For exam...
by arunenigma
 

 




11 Comments


  1. Anonymous

    code is written in system function

    tell me the meaning of whatever is used in this function


  2. @ANONYMOUS

    I used block_usb.exe and unblock_usb.exe, both from the resource kit, to modify and set permissions on the registry's USBSTOR key. Offhand, I can think of a number of ways on how you can implement this; startup script (via GPOs), using a service, scheduled tasks (upon login, for example), etc.


  3. I guess this video can help you out, check out USB Protection


  4. Anonymous

    its giving a fatal error when i compile this code pls send me the solution to this prob soon


  5. its compiling in turbo C but not working and for borland c++ compiler its showing

    Error: Unable to include ' stdio.h '
    send the reply to vikask75@gmail.com


  6. its compiling in turbo C but not working and for borland c++ compiler its not working

    Error: Unable to include ' stdio.h '
    send the reply to vikask75@gmail.com


  7. its compiling in turbo C but not working and for borland c++ compiler its not working

    Error: Unable to include ' stdio.h '
    send the reply to vikask75@gmail.com


  8. Hundreds of millions of USB flash drives are currently in operation around the world, with the vast majority not offering proper usb protection


  9. rax

    hi,thanx for sharing information. usb protection


  10. great post, I really like it. Thanks for posting. 🙂


  11. Thanks Bro,
    But I want a program which can enable/disable specified usb ports not all.
    Can we do it using C language.
    For my project I want to send data 1 or 0 using C language to USB port but found it too difficult.
    So please can you do it for me.Plllllzzzzzz
    If you able to make the program send me to “bakshizaki{at}gmail{dot}com”
    Waiting for your reply.



You must be logged in to post a comment.