Jump to content

How To Prevents The Writing On Usb Flash Drive From Virus


Hackoo
 Share

Recommended Posts

After reading this Article: "Create Fake Dummy File on USB Flash Drive to Enable Write Protect and Prevent Modification"

So i have this idea to create a good Trick in Vbscript. ;)

So i explain what this script can do:

You carry your USB flash drive that contains a lot of portable tools with you all the time but you are afraid of one thing, which is a computer virus such as JambanMu or MaxTrox or Sality that are able to infect USB flash drives and bind themself to the executable files in there. So far there are only ways to disable writing to USB flash drive on your computer by editing the registry but if you plug it into a public computer which has virus, your USB flash drive will be writable and can be infected by virus. So is having a pendrive with a built-in write protect switch the only way to prevent the drive from virus infection?

The Script creates a “block” file to fill up the remaining free space on the USB flash drive. When there is no space left on the removable drive, virus won’t be able to copy itself to to drive or infect any executable files.

This Code is used to create a fake Dummy file on USB Flash Drive to Enable Write Protect and Prevent Modification.

 '----------------DummyFileCreator.vbs---------------
 '© Hackoo ©
 'web site http://hackoo.ifrance.com
 checkUSB
 DummyFileCreator
 '---------------DummyFileCreator-------------------
 Sub DummyFileCreator
 Dim WshShell,FSO,Drv,Dtype,Dfree,DfreeMB,Dtot,GB
 Dim Dname,Dpct,Dused,Dserial,Dinfo
 Set WshShell=WScript.CreateObject("WScript.Shell")
 Set FSO=CreateObject("Scripting.FileSystemObject")
 For each Drv in FSO.Drives
 'If Drv.DriveType=0 Then Dtype="Unknown "
 'If Drv.DriveType=1 Then Dtype="Removable"
 'If Drv.DriveType=2 Then Dtype="Fixed "
 'If Drv.DriveType=3 Then Dtype="Network "
 'If Drv.DriveType=4 Then Dtype="CD-ROM "
 'If Drv.DriveType=5 Then Dtype="RAM Disk "
 If Drv.DriveType=1 Then ' Disk Amovible Flash Disk
 If Drv.IsReady Then ' Si le Flash Disk est prêt
 Dfree=Drv.FreeSpace
 DfreeMB=FormatNumber(Drv.FreeSpace/(1024^2),0)&" Mo"
 'EspaceLibre = Drv.FreeSpace
 GB=round(Dfree/1073741824,2) & " Go"
 Label=Drv.DriveLetter
 'checkUSB
 'wscript.sleep 1000
 MsgBox "Espace Libre dans Le Flash Disk "&Label&":\"&" est Environ de " &GB& " soit environ "&DfreeMB,64,"Espace Libre"
 WshShell.run "cmd /c fsutil file createnew "&Label&":\IamDummy " &Dfree&"",0,True
 WshShell.Run "cmd /C attrib +h +s "&Label&":\IamDummy",0,TRUE
 MsgBox "Votre Flash Disk "&Label&":\ est désormais protégé contre les Malwares , les Worms et les Virus !",64,"Protection"
 end if
 end if
 Next
 end Sub
 '-----------------checkUSB-----------------------
 Sub checkUSB
 strComputer = "."
 On Error Resume Next
 Set WshShell = CreateObject("Wscript.Shell")
 beep = chr(007)
 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
 Set colItems = objWMIService.ExecQuery("Select * from Win32_DiskDrive WHERE InterfaceType='USB'",,48)
 intCount = 0
 For Each drive In colItems
 If drive.mediaType <> "" Then
 intCount = intCount + 1
 End If
 Next
 If intCount > 0 Then
 MsgBox "Votre Flash Disk est bien Connecté !",64,"Flash Drive Check !"
 else
 WshShell.Run "cmd /c @echo " & beep, 0
 wscript.sleep 1000
 MsgBox "Votre Flash n'est pas Connecté ",64,"Flash Drive Check !"
 End If
 End Sub 

And This Code is used to delete The Fake Dummy File and so let you write into your pendrive

'----------------NoDummyFile.vbs---------------
 '© Hackoo ©
 'web site http://hackoo.ifrance.com
 checkUSB
 NoDummyFile
 '---------------------------------------------
 sub NoDummyFile
 Dim WshShell,FSO,Drv,Dtype,Dfree,DfreeMB,Dtot,GB
 Dim Dname,Dpct,Dused,Dserial,Dinfo,filespec
 Set WshShell=WScript.CreateObject("WScript.Shell")
 Set FSO=CreateObject("Scripting.FileSystemObject")
 filespec="IamDummy"
 For each Drv in FSO.Drives
 'If Drv.DriveType=0 Then Dtype="Unknown "
 'If Drv.DriveType=1 Then Dtype="Removable"
 'If Drv.DriveType=2 Then Dtype="Fixed "
 'If Drv.DriveType=3 Then Dtype="Network "
 'If Drv.DriveType=4 Then Dtype="CD-ROM "
 'If Drv.DriveType=5 Then Dtype="RAM Disk "
 If Drv.IsReady Then
 If Drv.DriveType=1 Then
 Dfree=Drv.FreeSpace
 DfreeMB=FormatNumber(Drv.FreeSpace/(1024^2),0)&" MB"
 GB=round(Dfree/1073741824,2) & " Go"
 Label=Drv.DriveLetter
 If (fso.FileExists(Label&":\IamDummy")) Then
 Set MyFile = fso.GetFile(Label&":\IamDummy")
 MyFile.Delete
 End If
 MsgBox "Espace Libre dans Le Flash Disk "&Label&":\"&" est Environ de " &GB& " soit environ "&DfreeMB,64,"Espace Libre"
 MsgBox "Attention ! Votre Flash Disk "&Label&":\ n'est pas Protégé contre les Malwares , les Worms et les Virus !",64,"Protection"
 end if
 end if
 Next
 end Sub
 '-----------------checkUSB-----------------------
 Sub checkUSB
 strComputer = "."
 On Error Resume Next
 Set WshShell = CreateObject("Wscript.Shell")
 beep = chr(007)
 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
 Set colItems = objWMIService.ExecQuery("Select * from Win32_DiskDrive WHERE InterfaceType='USB'",,48)
 intCount = 0
 For Each drive In colItems
 If drive.mediaType <> "" Then
 intCount = intCount + 1
 End If
 Next
 If intCount > 0 Then
 MsgBox "Votre Flash Disk est bien Connecté !",64,"Flash Drive Check !"
 else
 WshShell.Run "cmd /c @echo " & beep, 0
 wscript.sleep 1000
 MsgBox "Votre Flash n'est pas Connecté ",64,"Flash Drive Check !"
 End If
 End Sub

DummyFileProtection.rar

Edited by Hackoo
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

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