A Virus Program to Disable USB Ports

Virus to disable USB portsIn this post, I will show how to create a simple virus that disables the USB ports on the computer (PC). As usual, I am using 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 you’ll will not be able to use your pen drive or any other USB peripheral devices on the computer. The source code for this virus is available for download. 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.

  1. Download the source code of the virus program on to your computer from the following link:

    The download contains the following 2 files:

    • block_usb.c (source code)
    • unblock_usb.c (source code)
  2. You need to compile them before you can run it. A step-by-step procedure to compile C programs is given in my post – How to Compile C Programs.

    3. 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).

  3. 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. To re-enable the USB ports just run the unblock_usb.exe  (you need to compile unblock_usb.c) file. Now insert the pen drive and it should get detected.

  4. You can also change the icon of this file to make it look like a legitimate program. For more details on this refer my post – How to Change the ICON of an EXE file (This step is also optional).

How it Works?

The idea behind the working of this virus is pretty straightforward. It works by gaining access to the Windows registry and modifying its settings to disable the USB device support on the computer.

On the other hand, the other program will re-set the registry settings back to the normal so that the support for USB devices is re-enabled. I hope you like this post. Please pass your comments.


  1. Ivan
    July 19, 2009 at 9:46 PM

    it works , thanks

  2. mahendra
    July 19, 2009 at 10:02 PM

    this code is not working on vista….

  3. rexter
    July 20, 2009 at 10:54 PM

    nice one…

  4. Ram sri
    July 22, 2009 at 6:46 AM


  5. boss
    July 24, 2009 at 8:24 AM

    it does not have the exe files….. only the 2 source files are present….!!!

    Check out…

  6. Gaurav
    July 24, 2009 at 3:57 PM

    This is working, is there any way to modify other registry entries using code like that you have written in the above program. I want to modify a registry value which is used when the option “show hidden files and folder” not work.Please give the code in C.

  7. Gaurav
    July 24, 2009 at 5:44 PM

    How to execute a bat file from pen drive using autorun.inf “forcefully” i.e. not asking the user to perform certain actions.Just inserting pen drive and executing the file?

  8. Abhijith
    July 25, 2009 at 6:22 AM

    Nice one ! Can give me links/resources on advanced topics in C

  9. tarun
    July 25, 2009 at 7:33 PM

    great it is working

  10. boss
    July 26, 2009 at 7:09 PM

    i told u the rar file only shows the source files…..

    what is the matter….

  11. parag
    July 27, 2009 at 11:58 AM

    hi its nice

  12. sunny
    July 28, 2009 at 11:45 AM

    boss, you just compile these source files in C compiler that will generate exe file.

  13. jonnel..
    August 6, 2009 at 12:45 PM

    its working.. i have a question, how can i enable the usb port on computer.. if that port is being disabled??

  14. jonnel..
    August 6, 2009 at 12:47 PM

    i mean.. the administrator disabled it.. can i modify it using only the registry editor?

  15. rahul
    August 11, 2009 at 12:21 AM

    dude………this is the best website i ever came across in my entire life!!! keep up the good work!!!

  16. Young Bastard
    September 15, 2009 at 6:55 PM

    Great article but can not do all the things cause I am using a school computer and downloading of some files is not allowed.I cant download the virus

  17. Transfer
    September 19, 2009 at 12:56 AM

    This is awesome!!

    This works!!


  18. Ankur
    September 20, 2009 at 2:04 PM

    Hey Srikanth nice work……….
    But can you post some virus programs in java language???????

  19. Akshay
    September 20, 2009 at 7:06 PM

    This is great.Thank you so much.

  20. hackster117
    September 21, 2009 at 12:27 AM

    This virus is amazing.I like it because it disables hardware which to me is pretty neat.I’m a bit new to this site but I really like it.It has alot of useful information.

  21. RANO
    September 25, 2009 at 4:52 PM

    any one have any code for disable /enable mouse,keyboard and cd-rom . in any code lang.,plz send to me:


  22. kanav
    October 3, 2009 at 2:23 AM

    this is not a exe files a two note pad files

    how can i run it?

    • Srikanth
      October 6, 2009 at 4:21 PM

      @ kanav

      You need to compile it before you can run them.

  23. Varun
    October 12, 2009 at 9:57 PM

    Gud Work Bro!!!

  24. madmax
    October 24, 2009 at 11:05 PM

    wow great man……….

  25. Govind
    October 24, 2009 at 11:12 PM

    thanks it’s working….

  26. sumeet
    October 28, 2009 at 6:10 AM

    great work… can u tell give me a c program that will allow to run certain program automatically!!!

  27. sachin nain
    November 6, 2009 at 2:35 PM

    good job ………..

  28. devendra
    November 11, 2009 at 6:36 PM

    there is also one option to disable to Usb Drive
    from regedit
    Search Usbstor value And Modify it 3 to 4.
    (note :- 3 is default value)

  29. Jimit
    November 19, 2009 at 1:48 PM

    hey man can u get me some tutorials of virus like da full coding nd not da readymade program……plz will b waitin for ur response

  30. summit
    December 11, 2009 at 9:09 AM

    this code is not working on my computer apparently… is it because i changed the file name or because i’m using vista?

  31. long
    December 14, 2009 at 5:42 AM

    hi everyone,now who can help me,how to create and use Virus to Disable USB,because i know a little of C++,thank Pls contact this chealong21@yahoo.com

  32. Nedim
    December 23, 2009 at 9:12 PM

    Does this work on windows 7

    • Srikanth
      December 29, 2009 at 1:42 PM

      @ Nedim

      Should work most probably. But UAC must be disabled!

  33. sandesh vaze
    January 2, 2010 at 11:14 AM

    hey man its very nice.
    i want to learn java for hacking .
    is it more powerfull than c or c++?

  34. visitor
    January 6, 2010 at 2:29 PM

    How will this so-called “virus” infect other computers? 😀

  35. nishant
    January 19, 2010 at 9:27 PM

    how can i compile this file

  36. Sanju
    February 2, 2010 at 3:10 PM

    Great It is working

  37. Madele
    February 15, 2010 at 10:48 PM

    thanks for the all the lessons, Please I will like to have a complete note on how to be a hack…. please let talk more with email.. thanks a lots

  38. sandilya
    March 24, 2010 at 6:02 AM

    hi srikanth,
    I have a doubt regarding usb virus removal programmes.
    Recently I have downloaded a free software from a website by name “usb virus scan”.Also I have installed it.
    I just wanted if the working of usb virus scan would effect the working of my kaspresky anti virus programme.

    • Srikanth
      March 24, 2010 at 11:47 AM

      @ sandilya

      Yes! Installing two antivirus and running them simultaneously can create conflicts and will affect their working

  39. Rajesh
    April 6, 2010 at 7:19 AM

    Hi Srikant,

    Great to see your effort , I have downloaded the files and compiled it there is no error , exe has also been created but when we run the usb is not getting disabled , I can sense all usb port is it due to Vista I am using. Pl help I need this for demonstration purpose , I think best example of Virus for the beginners, any other similar sample like disable printer or mouse will also be helpful , if you can reply on my email , a copy , this will be a great help to me.

    Keep us updating .

  40. chetan
    April 6, 2010 at 11:12 PM

    it’s good!……….