Well, I’ve been scammed. You might have heard of the SD card scam, when you buy a card, and it reports to be bigger, than it actually is, and whatever you write beyond the boundary of the really available space gets lost.
I ordered a bunch of 5 microSD cards, 4GiB each, and they were a pure scam with about 115 MiB instead of 4 GiB.
Luckily, I managed to get my money back, via opening a dispute and later a claim (Scammers didn’t want to give the money back, did they?), but the cards still remained here.
To test such shitty cards there exist 2 tools: h2testw and f3. First for windows, second for linux. Thy figure out the real capacity for you. I didn’t like them, because they took ages to scan one 4 GiB card. And, they operated upon a upon a filesystem, that I didn’t like as well. So I wrote my own tool.
It’s dumb as hell, and was created while f3 was still scanning one card. And it’s a lot faster. Meet ‘scam-o-matic’.
It writes some preudorandom data to the card, until it detects something bad. Usually that happens when we reach the boundary of ‘good’, somewhat ‘reliable’ memory. Then it double-checks the region, and if everything is fine (e.g. no mismatches between first and second pass) it creates a partition table for you, with one partition that covers only working area of the card.
Now just format it, alter the type with cfdisk, and make use of it.

The ugly (I mean it, really ugly) source code can be found at github

USAGE: scam-o-matic /dev/sdX
/dev/sdX – should be the path to the device node of the card.
e.g. /dev/sdf

The program will prompt you for everything else. Sometimes, one pass gives some unreliable results,
that screw, when you verify them. A second shot gives you some better ones.
Have fun.

Example output with time consumption measurement:

necromant@ilwyn:~/Dev/software/scam-o-matic$ time sudo ./scam-o-matic /dev/sdf
!!!WARNING!!! I will now destroy all data on the device /dev/sdf
!!!WARNING!!! If you are ok with that - type OK & press enter
Rock'n'roll, then!
Device reports to be 4194304000 bytes long.
Sectors are presumably 512 bytes each.
!!!WARNING!!! Last chance to stop. Are you sure? If so - type YES
Starting a desructive surface test
Testing at position: 115343360

Ooops: 0xE383DF81 vs 0x8D5A303E

Mismatch at 115834880 detected
Sorry, dude, but it look like you've been scammed.
Or you might just have a old'n'corrupt card.
In case of scam you still have 115834876 usable bytes
That we can salvage. Let me double check the area for overwrites
Double checking at position: 113246208/115834876

Ooops: 0x202059EE vs 0x2122330B

Double checking at position: 115343360/115834876

Ooops: 0xE383DF81 vs 0x8D5A303E

The region looks fine. That's 0% of reported capacity.
Clearing first sector...
Would you like me to run fdisk and
Automagically create a partition, that will use only
the really avaliable space? (YEP/NOPE)YEP
Creating partition with 224191 sectors. Command line below
(echo n; echo p; echo 1; echo 2048; echo +224191; echo w)|fdisk /dev/sdf
Устройство не содержит ни верной таблицы разделов DOS, ни метки диска Sun, SGI или OSF
Building a new DOS disklabel with disk identifier 0x4fc8d399.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Предупреждение: неверный флаг 0x0000 таблицы разделов 4 будет исправлен записью

Команда (m для справки): Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): Номер раздела (1-4, по умолчанию 1): Первый сектор (2048-8191999, по умолчанию 2048): Last сектор, +секторы or +size{K,M,G} (2048-8191999, по умолчанию 8191999):
Команда (m для справки): Таблица разделов была изменена!

Вызывается ioctl() для перечитывания таблицы разделов.
Синхронизируются диски.
I've done all I could. Good Bye.
Some rights reserved. (c) Necromant 2011

real 0m44.373s
user 0m1.748s
sys 0m0.666s

Print Friendly

11 thoughts on “Scam-o-matic”

  1. Of course the scammer would like to send money back. If they can placate you to keep the scam secret, then they get to keep scamming others.

  2. It may be quick and dirty but I can see this evolve into a relatively widely used tool, given its forte, the speed, which other tools lack. Fix up a nice GUI, release a win version and you are set. YEP/NOPE is also a welcome deviation from the norm. Anyway nice stuff.

  3. @frenzic: Sorry, no windows version anytime soon. If you want – you can make one, the source is all open, consider it open under WTFPL license, but I’m afraid this is something I do not have time for.

    @AS: Looks like they got totally busted with bad feedback at aliexpress, and tried to state they did send me good cards. Didn’t work for ali mediation team though. Too bad, that the bad feedback appeared only when I already bought that scam. Anyway, I got the money and the (crappy) cards, which I consider a win.

  4. Thanks man, I just might do that. WTF is a killer concept is it not. IF NOT GOTO MSTRASH WTF. Yup feel like it already.

Leave a Reply