USB Write Blocker : Makes any USB drive Write protected.


Recommended Posts

Something that has boggled my mind for a while now. In the beginning write protected USB drives were pretty common place (so I've been told). But as the progression of Malware has increased, the number of write protected USB drives has decreased.

To be honest, most people don't even care if they stick their usb drive into an infested computer. Even though autorun, for the most part has been disabled on windows systems (so malware shouldn't technically get activated when sticking the stick into a clean machine) I would still never stick a usb flash drive that wasn't write protected into someone else machine. If I did, I would (and have in the past) format the stick from a BartPE environment on another machine before sticking it back into my own.

I was looking online and came across this neat little product. It's called the USB Write blocker. 1 end plugs into the computer and you plug your usb hard drive or USB memory stick into the other end.

41MsNWtLhbL.jpg

This device obviously isn't for everyone. But those who do repairs where write protection is a serious concern this might be for you. What I like about this idea, is that you would use it when ever you plug in a usb drive into someones computer. This way you KNOW it's write protected. The problem I had with USB memory sticks that had write protection switches, is I always had to check the switch to make sure it was activated, which means it would be possible to forget.

The only thing I wish it did was not to spoof the writes (showing it copied when it didn't) but just through up a write protection error. For this reason I could never temporary used it on an usb sata dock, because if It was behind the computer and if I forgot it was there, and i went to backup someones files, it would show they got backed up but in the end they would not be. But to be used in combination with a USB repair thumb drive or now a USB repair hard drive, would work great.

it's $160 on Amazon, I think I might get one. Lemme know what you think.

The idea itself is excellent. But 160 for that? What's in there - pure magic with unicorn horn salt? :huh:

I just bought one. This device is a dream come true. I'll do a review once it arrives.

Ah, well, forensics products, of course - when one sells for government officials and such nosy buggers, appending at least one zero to all prices can be completely justified.

Do review it, yes. If they call it a forensics device, I'd hope it's at least tamper proof and reasonably indestructible.

That is a really neat idea, but I agree with Phouchg that the price seems somewhat excessive.

While this certainly isn't the ideal solution, I pseudo write protect my flash drives which may be plugged into infected computers using a simple Batch script (or, more often than not, the equivalent BASH script, since I don't spend very much time in Windows anymore). The idea is that if there is no free space left on disk, no files can be infected and no new files can be added without deleting something. When I want to write to disk, I remove my dummy file, modify stuff, and "write protect" it again.

In case anyone is interested, the Batch script is below. There is a bug in the way disk space is calculated (not just in my script, by the way, in Windows itself), and you may need to eject the disk after "write protecting" it and run the script on it a second time. Sometimes it will claim to be 100% full before you eject it, but show 4.00 KiB of free space when you plug it back in. If anyone knows exactly why this happens or how to fix it please let me know.


::Write Protect Drive
::Description: This script will write protect a flash drive by using all the remaining free space.
::Modification: modifications are clearly marked by the <MOD> and </MOD> flags
::Last Synced with Awesome Script Version 1.3.5
::Author: xorangekiller
::Released: 10 December 2009
@echo off
::<MOD> the following code did not exist (it was handled by the awesome script)
:start
::set the default errorlevel
set exitCode=0
::change the starting directory (if necessary)
set firstdir=NULL
if "%cd%\"=="%~dp0" goto writeprotect
set firstdir=%cd%
cd /D "%~dp0"
::</MOD>
:writeprotect
::attempt the write protect the drive (presumably a flash drive) by creating a dummy file to use all remaining free space
::this prevents viruses and such from attaching themselves to files or copying themselves to your drive
::this does NOT, however, prevent files from being deleted and replaced!
::<MOD>set current=writeprotect</MOD>
fsutil 1>nul 2>nul
if %errorlevel%==1 goto writeprotectNoAdmin
:writeprotectDialog
echo.
echo Write protect the specified drive by using all available free space.
echo.
echo To protect the current drive just type "current" at the prompt.
echo.
set /p userinp=Which drive would you like to protect?
::special cases of the variable
if "%userinp%"=="" set userinp=%cd%
if "%userinp%"=="current" set userinp=%cd%
::check to make sure that we have a drive path
if not "%userinp:~1,1%"==":" goto writeprotectPathError
::only use the drive letter, colon, and slash regardless of the path entered
set userinp=%userinp:~0,3%
if not "%userinp:~2,2%"=="\" if not "%userinp:~2,2%"=="/" set userinp=%userinp%\
::this check was implemented because of Cooper... DO NOT TRY TO WRITE PROTECT YOUR C: DRIVE!
if "%userinp:~0,2%"=="%systemdrive%" ( echo.
echo Error! You are attempting to write protect your system drive.
::according to my PL (Dave DiCarlo) using rehtorical questions in this manner is something New Yorkers primarily do
echo Are you sure you want to do that? I don't think so!
echo.
echo Press any key to try again . . .
pause >nul
::<MOD> "goto start" is not the proper reference
goto writeprotect )
::</MOD>
::create a directory to hold the (potentially large) number of dummy files
::set /p userinp=%userinp%IamDummy\
::mkdir %userinp%IamDummy
setlocal ENABLEDELAYEDEXPANSION
:writeprotectCreateLoop
set bytesfree=0
::capture the bytes free determined by dir and remove the commas (because fsutil doesn't like those)
for /f "tokens=3-6 delims==, " %%a in ( 'dir "%userinp%" ^| findstr /C:"bytes free"' ) do ( if %%a==bytes goto writeprotectEndLoop
if %%a GTR 0 set bytesfree=%%a
if %%b==bytes goto writeprotectEndLoop
if %%b GTR 0 set bytesfree=!bytesfree!%%b
if %%c==bytes goto writeprotectEndLoop
if %%c GTR 0 set bytesfree=!bytesfree!%%c
if %%d==bytes goto writeprotectEndLoop
if %%d GTR 0 set bytesfree=!bytesfree!%%d
if %%e==bytes goto writeprotectEndLoop
if %%e GTR 0 set bytesfree=!bytesfree!%%e)
::the EndLoop label is a hack to break the loop if necessary
:writeprotectEndLoop
::it is absolutely necessary to check if there is no space left free and break the loop
::although there IS such a number as infinity most computers cannot reach it within a reasonable amount of time
::so this is a good "workaround"
if %bytesfree% EQU 0 goto writeprotectComplete
::1024 Bytes = 1 Kilobyte; 1048576 Bytes = 1 Megabyte; 1073741824 Bytes = 1 Gigabyte
::1 gigabyte in bytes
set gb=1073741824
::determine the dummy file(s) to create
if %bytesfree% GEQ %gb% set bytesfree=%gb%
set filenum=0
::check to make sure that the dummy file does not already exist... it causes problems
:writeprotectFileNumCheck
if not exist %userinp%IamDummy%filenum% goto writeprotectCreateDummy
set /A filenum=%filenum%+1
goto writeprotectFileNumCheck
:writeprotectCreateDummy
::create a dummy file
::echo Writing file %userinp%IamDummy%filenum% of size %bytesfree% . . .
fsutil file createnew "%userinp%IamDummy%filenum%" %bytesfree%
::check to see if we need to repeat the procedure with another dummy file (recurse)
::although infinite looping is generally not a good thing batch gives us no choice
::"The time has come for the cobra to come up and reveal himself. You will call me - Commander."
goto writeprotectCreateLoop
:writeprotectComplete
endlocal
::brag by printing a message informing the user that we did our job successfully (hopefully, bytes free should be ZERO)
echo.
dir "%userinp%" | findstr /C:"bytes free"
echo.
pause
::<MOD> "goto start" is not the proper reference
goto end
::</MOD>
:writeprotectNoAdmin
echo.
echo ERROR! You need administrative privileges to run this function!
echo.
pause
::<MOD> "goto start" is not the proper reference
goto end
::</MOD>
:writeprotectPathError
echo.
echo ERROR! You must enter a valid drive path!
echo.
echo Example: %cd:~0,3%
echo.
set /p userinp=Continue or Quit (C\Q)?
set userinp=%userinp:~0,1%
::<MOD> "goto start" is not the proper reference
if "%userinp%"=="Q" goto end
if "%userinp%"=="q" goto end
::</MOD>
goto writeprotectDialog
::<MOD> the following code did not exist (it was handled by the awesome script)
:end
::revert the current directory (if necessary)
if not "%firstdir%"=="NULL" cd /D "%firstdir%"
::exit the script but not cmd.exe
exit /B %exitCode%
::</MOD>
[/CODE]

The BASH version of this same script is below. It has been tested to work on Debian 6, Debian 7, Ubuntu 10.04, Ubuntu 12.04, and Fedora 17. Presumably it should work on any GUN/Linux distribution, and probably BSD and OS X too.

[CODE]
#!/bin/bash
# Write Protect Drive
# Description: This script will write protect a flash drive by using all the remaining free space.
# Last Synced with Awesomestik Installer 1.0
# Author: xorangekiller
# Released: 21 Feb 2012
writeprotect() {
loop=0
free=$(df $USBDEV | tail -n 1 | awk {'print $4;'})
echo "Free space on ${USBDEV}: ${free}K"
while [ $free -gt 0 ]; do
# Note that 1048576 is 1 gigabyte in kilobytes.
if [ $free -gt 1048576 ]; then
free=1048576
fi
# Check that the name of the file we want to write is not already taken.
while [ -e "${USBMNT}/IamDummy${loop}" ]; do
let loop=loop+1
done
echo "Writing file ${USBMNT}/IamDummy${loop} of size ${free}K . . ."
dd if=/dev/zero of=${USBMNT}/IamDummy${loop} bs=${free}K count=1
sleep 5 # Give everything time to settle.
free=$(df $USBDEV | tail -n 1 | awk {'print $4;'})
done
echo "Free space on ${USBDEV}: ${free}K"
}
# Check that we are root before doing anything particularly useful.
#if [ $(id -u) != 0 ]; then
# echo "You need to be root to run this script"
# exit 1
#fi
if [ -n "$1" ]; then
drivetoprotect="$1"
else
echo "Write protect the specified drive by using all available free space."
echo "To protect the current drive just type current at the prompt."
echo "Which drive would you like to protect?"
read drivetoprotect
fi
if [ "$drivetoprotect" == "current" ]; then
drivetoprotect=`pwd`
fi
if [ ! -d "$drivetoprotect" ]; then
echo "ERROR: $drivetoprotect is not a valid directory."
exit 1
fi
# This check was implemented in the original write protect script because of Cooper and carried over here... DO NOT TRY TO WRITE PROTECT YOUR SYSTEM DRIVE!
if [ "$(df "$drivetoprotect" | awk '{print $6}' | tail -n 1)" == "/" ]; then
echo "ERROR: You are attempting to write protect your system drive."
exit 1
fi
# Use the USBMNT variable to maintain compatability with the writeprotect function from the Awesomestik Installer script.
USBMNT=$drivetoprotect
USBDEV=$(df "$USBMNT" | awk '{print $1}' | tail -n 1)
writeprotect
echo "The drive is now write protected!"
exit 0
[/CODE]

Edit: Indentation and line spacing got a little bit messed up when I copy/pasted the scripts into the post editor, so I attached a zipped copy of both scripts to this post as well.

WriteProtect.zip

Something that has boggled my mind for a while now. In the beginning write protected USB drives were pretty common place (so I've been told).
My first USB pen (32 MB?) had a write-protect slider on the leaner side, and that was pretty much the norm.

Then someone or something made a jerk move.

Neat Script.
Yeah, but needs a license, less BASH, and more POSIX.

Neat Script. I just don't trust software. I need a physical lock or device.

I agree. That's why I said that it only pseudo write protects drives. It can fairly easily be circumvented. However, it seems to be fairly effective against most malware in lieu of a hardware write protected disk, which is clearly superior.

Yeah, but needs a license, less BASH, and more POSIX.

Please explain. I have been using this script for years, but I am open to suggestions. Why does it need a license? What do you mean by "less BASH, and more POSIX"? What should I do to improve it?

I'm curious if this will introduce compatibility issues (for example, certain machines not registering your USB key because it's attached to this $160 device).

Couldn't you also use an SD card with a USB adapter as an alternative? (Most) SD cards have lock switches.

I'm curious if this will introduce compatibility issues (for example, certain machines not registering your USB key because it's attached to this $160 device).

Couldn't you also use an SD card with a USB adapter as an alternative? (Most) SD cards have lock switches.

Maybe. I hope not, but we'll see. I'll let ya know what happens.

Dream come true?

Why not save $160 and not stick it anywhere unclean? :shifty:

Because I work on Malware infected machines almost every day. Even if I have no reason to suspect a machine is infected, I DO NOT put a usb thumb drive that is not write protected into another users PC other than my own.

The only exception is if i just preformed a clean install of windows. Once that known clean machine leaves my office a stick or drive that is not write protected will never be inserted into that machine unless a clean install has just been preformed again or if I'm in a clean PE or Linux environment.

If by chance it does accidentally occur that a stick that was not write protected gets inserted into a customers PC (without a clean install having just been done) the media is then hooked up to a machine that has no hard drive attached and is booted into a PE environment where it is formatted before it is inserted back into any of my workstations.

Those are the rules that I follow.

Maybe. I hope not, but we'll see. I'll let ya know what happens.

Because I work on Malware infected machines almost every day. Even if I have no reason to suspect a machine is infected, I DO NOT put a usb thumb drive that is not write protected into another users PC other than my own.

The only exception is if i just preformed a clean install of windows. Once that known clean machine leaves my office a stick or drive that is not write protected will never be inserted into that machine unless a clean install has just been preformed again or if I'm in a clean PE or Linux environment.

If by chance it does accidentally occur that a stick that was not write protected gets inserted into a customers PC (without a clean install having just been done) the media is then hooked up to a machine that has no hard drive attached and is booted into a PE environment where it is formatted before it is inserted back into any of my workstations.

Those are the rules that I follow.

How about a better idea and NOT use USB drives in infected machines. Burn a CD with whatever utilities that you need. ZERO chance of infection.

That device you've showed there has the same flaw as cheap IDE or SATA drive write blockers, it only catches the most common write codes, so yeah, for the majority of the time you won't be able to write to it.

Got an unusual USB device or one that writes data differently to how that blocker picks it up? Writes will still occur.

Same as if malware uses strage/forged methods to write to a USB device, that thing won't block it at all.

From doing forensics before, if you're worried about malware, you've just wasted your money.

  • Like 2

How about a better idea and NOT use USB drives in infected machines. Burn a CD with whatever utilities that you need. ZERO chance of infection.

lolwut... optical drives? it hurts my brain just thinking about it.

slow burn time... no/slow rewrite... not to mention that many machines now have no optical drives.

How about a better idea and NOT use USB drives in infected machines. Burn a CD with whatever utilities that you need. ZERO chance of infection.

CD's do work well, I use USB because I have a backup routine setup inside Syncback which automatically updates the key as necessary with all the new updated apps. Pretty much a 1 click sort of things.

That device you've showed there has the same flaw as cheap IDE or SATA drive write blockers, it only catches the most common write codes, so yeah, for the majority of the time you won't be able to write to it.

Got an unusual USB device or one that writes data differently to how that blocker picks it up? Writes will still occur.

Same as if malware uses strage/forged methods to write to a USB device, that thing won't block it at all.

From doing forensics before, if you're worried about malware, you've just wasted your money.

You know this device suffers from the same flaw as cheap IDE or Sata write blockers how?

lolwut... optical drives? it hurts my brain just thinking about it.

slow burn time... no/slow rewrite... not to mention that many machines now have no optical drives.

WTF? Never heard of an external USB optical drive?

Here's what you do:

Plug in the external drive.

Throw in the utilities disk.

Clean that **********ing machine.

Send a bill.

:|

  • Like 2

You know this device suffers from the same flaw as cheap IDE or Sata write blockers how?

Because back in the forensics division of the uni. I was in, we had a load and got to test them and see their flaws.

There's a reason why ALL the officers in the met cybercrime unit have specialist hand-held disk data transferrers and use the write blockers on them and then ONLY work with the cloned drives to dig up data on pretty modified machines.

WTF? Never heard of an external USB optical drive?

Here's what you do:

Plug in the external drive.

Throw in the utilities disk.

Clean that **********ing machine.

Send a bill.

:|

I personally stopped using optical drives years ago for several reasons, some which I listed above.

In a few years, we'll think of CDs the way we think about floppies - archaic (even though I already consider them archaic).

Please explain.

Your script works for /bin/bash. By changing a few things that are bashisms (Bash specific), your script would be more portable. I'll post something when I get to a terminal at home.

Why does it need a license?

If it's in public domain it doesn't need one. Otherwise what gives? Can I modify and redistribute your code? If so in what terms?

lolwut... optical drives? it hurts my brain just thinking about it.

slow burn time... no/slow rewrite... not to mention that many machines now have no optical drives.

No matter if customer has a optical drive or not.

If customer has it, then I can load an utilities CD in it so I could fix the computer with. Otherwise, I can download the drivers or whatever from the internet as long as the computer has internet connection. If no internet, then I ask customer to bring it to my workplace... or I take it with me if I show up on-site. I have thousands thousands of drivers on CD since 90's. Ahhell's right... external USB optical drive is useful if customer has no internet or on a dial-up.

That way, you never know how old the computer is.... There are some people who have old computers that who can not afford to get a new one. From the stats I have viewed, I have seen people who are using 98, XP, Vista, etc.

Warwagon, you are paranoid and wasted your money on that crap. I haven't used that device.. I have fixed computers for myself and others for many years, no problems...

Could you give any links to that. I'd like t read up on it but I can't seem to hit anything on google.

You probably won't find them, you'd need viruses that exploit that flaw and dissassemblers to view how it's communicating with the hardware and whatnot.

If you really want read-only, get an SD card and an SD-reader.

This topic is now closed to further replies.
  • Posts

    • This AMD RX 9070 16GB GPU that performs close to Nvidia 5070 is under $600 by Sayan Sen With the memory shortage that's prevalent nowadays, discounts are super-hard to get. As such we post good deals whenever they pop up. Recently, we covered a few great discounts on SSDs wherein you can get a 4TB TeamGroup NVMe PCIe Gen4 drive for just $400 thanks to a special coupon. If you want a faster product but don't need all that capacity, you can also opt for Samsung's 990 PRO 2TB that is on sale for its lowest price in over three months. Let's say though that you are on the hunt for a 1440p gaming card. In that case AMD's RX 9070 non-XT can help, and with its 16GB VRAM, you can also run AI models locally without worrying about bottlenecking (check out our recent 9070 GRE reviews for gaming and productivity to get an idea). The PowerColor Reaper variant of the RX 9070 is currently on sale for just $580 which is a very good price in the current state of affairs (purchase link under the specs table down below). The Reaper cooler on this 9070 uses a triple‑fan design with ring‑blade fans, paired with premium dual ball bearings to extend lifespan and reduce friction. "Intelligent" fan control allows the fans to remain idle at lower temperatures, only spinning up when the GPU is under load. A nickel‑plated copper base makes direct contact with both the GPU and memory modules, helping to spread heat evenly. PowerColor also applies Honeywell PTM7950 phase‑change thermal interface material (TIM), which fills microscopic gaps between the die and heatsink for more efficient thermal transfer. The fan shroud is shorter in height as the firm has made it such that it can be used in certain SFF (small form factor) cases. The technical specifications of the Reaper RX 9070 are given in the table below: Specification Value Stream Processors 3584 Units Video Memory 16GB GDDR6 Memory Speed 20.0 Gbps Memory Interface 256-bit Engine Clock Game Clock: up to 2070 MHz Boost Clock: up to 2520 MHz Bus Standard PCI Express 5.0 x16 Display Connectors 1 x HDMI 2.1b, 3 x DisplayPort 2.1a Maximum Resolution DisplayPort: 7680 × 4320 HDMI: 7680 × 4320 Board Dimensions 289mm × 111mm × 41mm 304mm × 127mm × 42mm (with bracket) Slot 2 Minimum System Power Requirement 600W Power Connectors Two 8-pin PCI Express Get the PowerColor Reaper RX 9070 at the links below (you get only a 90-day warranty on Woot): PowerColor Reaper Radeon RX 9070 16GB Graphics Card (RX9070 16G-A): $579.99 (Sold and Shipped by Amazon US) (Was: $700) PowerColor Reaper Radeon RX 9070 16GB Graphics Card (RX9070 16G-A): $559.99 (Sold and Shipped by Woot US) Good to know This Amazon deal is U.S. specific, and not available in other regions unless specified. We only use first-party seller links (at the time of article publishing); ensure that you purchase from a first-party seller link only. Check out Today's Deals on Amazon | or our recent tech deals. Become a Prime member (for Students or SNAP) via Neowin Get Prime Access - Prime for half price (for qualifying Medicaid, EBT, SNAP) Subscribe to Prime Video, Audible Plus, Music Unlimited or Kindle Unlimited via Neowin As an Amazon Associate, we earn from qualifying purchases.
    • Are they marketed as an entry into astronomy or astrophotography? I do astrophotography. With big rigs, lots of computers, cables and headaches. I love it. And by learning this ridiculously complex hobby, I’ve learned about the objects I’m shooting. Astronomy followed from photography.
    • Microsoft confirms Recycle Bin bug across all versions of Windows by Usama Jawad A couple of days ago, we reported that the latest Patch Tuesday update has seemingly resulted in a lot of issues for many users, including OneDrive and Dropbox access problems, BitLocker recovery lockouts, and BSODs. Although Microsoft is yet to acknowledge these bugs, it has confirmed another, relatively smaller issue across all supported versions of Windows. In an update on its Windows Release Health Dashboard, Microsoft has confirmed that after installing June's Patch Tuesday update (KB5094126), you'll experience unexpected behavior when leveraging Recycle Bin. Basically, when you attempt to delete an item from the Recycle Bin, the confirm dialog will show you the internal file name of that content rather than the actual name. For example, the file may be named abc.png, but the confirm dialog will ask if you're sure that you want to permanently delete $Rxxxxx.png from the Recycle Bin. This is pretty much it for the scope of the bug itself; it just displays the wrong name in the confirm dialog. The correct name will be shown in the list view of the Recycle Bin and if you restore the file, it will return with the correct name as well. This issue affects pretty much all supported versions of Windows client and server, including: Client: Windows 11, version 26H1; Windows 11, version 25H2; Windows 11, version 24H2; Windows 11, version 23H2; Windows 10, version 22H2; Windows 10 Enterprise LTSC 2021; Windows 10 Enterprise LTSC 2019; Windows 10 Enterprise LTSB 2016 Server: Windows Server 2025; Windows Server 2022; Windows Server 2019; Windows Server 2016; Windows Server 2012 R2; Windows Server 2012 As things currently stand, Microsoft is working on a concrete solution that will be released in a "future" Windows update. It remains to be seen if the firm will wait till the next Patch Tuesday or roll out an out-of-band (OOB) fix. The good news is that commercial customers can deploy a workaround right now, but they will have to reach out to Microsoft Support for Business for additional details.
    • They said by this time everyone will have flying cars. WELL...
    • A study by physicist Henry Tye of Cornell University suggests that the universe may not expand forever. Instead, it could eventually stop expanding, begin contracting and end in a "Big Crunch" roughly 20 billion years from now. Maybe not as we now know that time can flow backwards.
  • Recent Achievements

    • Week One Done
      Jordan Smith earned a badge
      Week One Done
    • Reacting Well
      BizSAR earned a badge
      Reacting Well
    • First Post
      AndreaB earned a badge
      First Post
    • Week One Done
      Huge Trailer earned a badge
      Week One Done
    • Week One Done
      Classifyskilleducation earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      578
    2. 2
      +Edouard
      184
    3. 3
      PsYcHoKiLLa
      75
    4. 4
      Michael Scrip
      72
    5. 5
      neufuse
      64
  • Tell a friend

    Love Neowin? Tell a friend!