F3 – Fight Flash Fraud
fight-flash-fraud.readthedocs.io
fight-flash-fraud.readthedocs.io
To create simulated (2GiB) fake devices
fallocate -l 1G fff_test.flash
DEV=$(losetup --show --find fff_test.flash); echo $DEV
DEVNUM=$(stat -c %Hr:%Lr $DEV); echo $DEVNUM
With wrap-around sectors: dmsetup create --concise "fff_wrap,,,,0 2097152 linear $DEVNUM 0, 2097152 2097152 linear $DEVNUM 0"
With silently dropped writes: dmsetup create --concise "fff_drop,,,,0 2097152 linear $DEVNUM 0, 2097152 2097152 zero"
To test: fake_flash_finder.bash /dev/mapper/fff_wrap
Capacity mismatch at LBA 2097152, data wrapped around to block 0. Size is most likely really 1073741824 bytes
fake_flash_finder.bash /dev/mapper/fff_drop
Capacity mismatch at LBA 2097152, data does not match what was written. Size is most likely really 1073741824 bytes
To wipe the device if repeating tests: dd if=/dev/zero of=/dev/mapper/fff_wrap bs=64M status=progress conv=fdatasync
dd if=/dev/zero of=/dev/mapper/fff_drop bs=64M status=progress conv=fdatasync
To remove the device: dmsetup remove fff_wrap
dmsetup remove fff_drop
losetup --detach "$DEV"
rm fff_test.flash
[0] https://salsa.debian.org/-/snippets/732https://blog.elcomsoft.com/2019/01/identifying-ssd-controlle...
From the research I've done (mainly related to data recovery), the NAND flash industry seems extremely secretive and shady in many ways --- from the near-zero availability of public datasheets, to the many rebrands/"reclaimed"/recycled part sources, to what they're doing to SLC and higher-reliability technologies. There are also ways to determine how worn-out a NAND IC is, but even those may be reversible with the right physical treatments.
I'm really amazed that unbranded 512GB NVMe drives doesn't randomly eat my data at this point, yet I still can't trust any of these drives w/o file level checksum patrols. So, instead I buy Samsung 9xx drives and use them.
Can a Flipper Zero be programmed for this? It connects to Micro SD cards and USB ports.
Distributors that care probably use something like this: https://www.ureach-inc.com/
[0]: https://www.bunniestudios.com/blog/on-microsd-problems/
Cards were subpar at best, counterfeit at worst. Kingston exchanged them no questions asked after some pressing.
Delidding the cards revealed different components and construction.
So no, buying directly from the manufacturer brought no advantages or guarantees.
Regardless of the packaging and purchasing channel, I’ll only trust my own test. Nothing else.
Therefore, you indeed can't trust their original packaging if they themselves don't vet their supply chain properly.
This is in stark contrast to manufacturer-vendors like Samsung, Micron (Crucial), and SanDisk (Western Digital) who manufacture either all or at least the core components of their products and have their own manufacturing reputation on the line.
If you have to be 100% sure then there is no substitute for doing your own tests. But the context here is trying to avoid that either by paying someone to test for you, or by using a trusted source like some actual manufacturer.
I wrote something barebones for this on my Synology, using just a shell script and (hardware accelerated) openssl, if memory serves; that acceleration was crucial for handling, say, an 8TB hard drive.
ActionScript dates back to only 1998.
I don't blame anyone for not knowing about Toshiba because they actively detested the technology and shunned its inventor and employee Fujio Masuoka.[1][2]
[1]: https://en.wikipedia.org/wiki/Fujio_Masuoka
[2]: "Toshiba gave Masuoka a few hundred dollar bonus for the invention, and later tried to demote him. But it was American company Intel which made billions of dollars in sales on related technology. Toshiba press department told Forbes that it was Intel that invented flash memory."
Of course, it's better to back up the suspect one.
That strategy adds O(n^2) reads on top of O(n) writes, though.
Even reads don't come for free on modern multi-level cell NAND (due to read disturb), and for just a thousand blocks, you'd end up reading the first block a million times.
That's to say nothing of the time this would take.
Reading that back (either the full device or a random sample) should pretty quickly identify whether things are still in their expected location.
A too-simple scheme is likely to be detected (and bypassed!) by the firmware a nearly no time.
Conceptually,
# tee /dev/DEVICE </dev/random | sha256sum
# echo 1 > /proc/sys/vm/drop_caches
# sha256sum /dev/DEVICE
though I wouldn't expect this exact command sequence to work unless tee's buffer size divides /dev/DEVICE's capacity and tee errors out writing past the end of /dev/DEVICE before writing to stdout.the drive size divided by 4MB, so dd with bs=4M and fixed count
(with oflag=direct you don't even need to drop caches)
The "write the block #'s to the given block" would help identify where a fraudulent device goes wrong.
But for just checking if a device is storing data 100% correctly then your way would probably be more robust. :)
"it only writes what’s necessary to test the drive"
How does that actually work, wouldn't that mean the whole stated capacity would have to be written?
For a fake drive, it'll take awhile, because the underlying storage is much, much slower than it should be, often usb2 speeds.
Realistically, this is just a test that satisfies curiosity without opening the drive. It's obvious when you have a fake drive because it won't benchmark anywhere near what it should.
Or, for any mid to large sized real storage. Writing/reading 64GB takes a while, fake or not
But something like 2TB micro SD when actually it only has 64GB capacity, that will be very long time waiting 2TB to fully written.
How about write some file, then verify sometimes the new sometimes the old one, repeat until full.
Write(0.h2w) Write(1.h2w) Read(1.h2w) Write(2.h2w) Write(3.h2w) Read(3.h2w) Read(2.h2w) Write(4.h2w) Write(5.h2w) Read(5.h2w) Write(6.h2w) Write(7.h2w) Read(7.h2w) Read(6.h2w) Read(4.h2w) Write(8.h2w) Write(9.h2w) Read(9.h2w) Write(10.h2w) Write(11.h2w) Read(11.h2w) Read(10.h2w) Write(12.h2w) Write(13.h2w) Read(13.h2w) Write(14.h2w) Write(15.h2w) Read(15.h2w) Read(14.h2w) Read(12.h2w) Read(8.h2w) ...Read(0.h2w)
Define S = claimed total number of sectors.
for(i=0; i<S; ++i) {
write_sector(i, hash(i))
for(j=0; j<=i; ++j) {
if(hash(j) != read_sector(j)) {
return i
}
}
}
return S
The above pseudo code will return the number of sectors the flash drive actually has.You can map a lot of memory from pcie
This approach though, seems to require reading the first sector many times.
you just want two non-nested loops.
If it is non-genuine what do you care how many writes it will perform? In that case the media is trash anyways.
The quadratic test will take an eternity due to the n^2 hashing operations and reads unless it terminates extremely early.
If you really have a need to terminate writing early, you could at least perform only a few reads randomly after each write (which will terminate early with high probably not long after you reached the maximum).
Once you grab your dubious device, the seller has already got your bucks in exchange of a fake device.
You've been already and effectively cheated when those flash devices are being tested against cheats.
Unless you're buying your flash device on the street and paying cash, you likely can return it or initiate a chargeback.
And even if you can't undo the purchase, it's better to know whether a device is fraudulent before you start filling it up with real data that you don't want to lose.
Whether the fraudster has somebody's dollars varies, but for that kind of a scheme they're able to just hide in plain sight. If 100 people don't test the device (and it works for months or years) and 1 person does, they have a 5-star rating and can just eat the cost of returns. Even if everyone on Hacker News started testing devices it wouldn't make a dent in fraudulent profits.
So why state it again? This helps, for instance, people who go on vacation and takes pictures the entire trip, only to come home and realise they have only 16MB of storage, not 16GB, and their pics are gone.