Open jeroenheijmans opened 2 years ago
Oh, you know what I've seen this before on Mac. What's happening is a strange OS compatibility issue. For some reason Chrome renders the text totally wrong on non-Linux. I'm not totally sure why.
The reason it breaks on that crop is that it renders the text to a page and then tries to crop it down. But the image is a totally different size than expected and so it dies.
One way to debug is to stick a file write in the code...
image.writeAsync(path.join(__dirname, "../test_plaintext.png"));
At main.ts at around line 210. That will still crash, but it will spit out an image to file right before it does. Try posting that image
This is what the result looks like for me on Windows 11:
So there's at least two issues, one is that the window is too narrow vertically. It's set right here https://github.com/BishopFox/unredacter/blob/main/src/main.ts#L171
You can try increasing that but... 100px ought to be enough.
Secondly, the font is just wrong. You can see what it looks like on my machine.
Is Sans-Serif maybe not a default Windows font? Chrome will backup to some other font if you type gibberish there, so maybe that's what's happening
A height of 120 fixes the OUT_OF_RANGE error for me and keeps looping through from a to z. I don't know what to do about the font though, afaik Chrome uses Arial as default for sans-serif.
This seems like a promising project though. I'm sure one could create some gpu accelerated version of this trying to solve an image with a number of common fonts and sizes at the same time. Maybe even heuristics on common character combinations or even a neural network could be used to improve it even more.
Chrome on Linux apparently uses a different sans-serif font than Arial. It's just showing up as "custom"
Which is not helpful. I'm not really sure what font this is now.
I just changed the default font to Arial, works on my machine. :) See if it works on yours now
It still just iterates from a to z, maybe because I have to set the height to 120? Also without a dark theme enabled the window looks like the screenshot from the first post, white text on white background.
oh blah, right. 692144e39ac61b21be74f28f89bbcd22e5fd4577 should have a fix for that
oh, though actually it's supposed to iterate from a-z for a while. Maybe this isn't obvious from the interface. The interface is... lacking. But the first thing it does is auto-discover the x and y offsets. So you'll see it go through all the characters and eventually find offset [2, 5] as "good". And then once it goes through all the offsets, it will actually do the solution guessing.
So maybe just try waiting a bit longer. If it blows past [2, 5] without adding it to the "Good offsets to try" list, then there's something wrong
Oh I see. After a while it added [3,5] to the list, resulting in the text vu
. Maybe differences in font-rendering are the reason it doesn't work right, stuff like ClearType/DirectWrite, grayscale vs subpixel aliasing and so on... Also the reason why css fingerprinting works so well.
I was able to solve my own redacted text, so that's probably it. The performance could really be better though, but it's a nice proof-of-concept.
There must be some os-compatiblity thing going on. If you add that line of code I mentioned above, then maybe we can see better what that is:
image.writeAsync(path.join(__dirname, "../test_plaintext.png"));
As for performance, absolutely. I'm quite sure that this whole thing could be significantly faster. For one, Electron might not be the best environment. The whole thing is CPU-bound and single-threaded. About half way through I wished that I had done it in Go, so I could use some nice and speedy goroutines for the enumeration. But c'est la vie.
This is the final result for me:
Same issue to me, Windows 10. Height 120 doesn't fix the OUT_OF_RANGE error in my case.
In which OS it was tested to work?
Same issue on mac 🙈
plus
DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Same issue to me, Windows 10. Height 120 doesn't fix the OUT_OF_RANGE error in my case.
In which OS it was tested to work?
Vanilla Ubuntu 20.04 works. It's looking like cross-compatibility is quite hard. Unredacter needs the window and font and everything to line up exactly the same, so minor inconsistencies compound.
Yeah, that's totally fair. As I said in the original post: it might be just fine to either close the issue, or let it sit until someone from the community feels like adding cross-OS compatibility. Whatever you'd choose, I'd totally understand, and think it's already awesome that you open sourced the code companion to your blogpost! ❤️
@dan-bishopfox
Hey I don't mean to be off-topic or anything but for some reason I can't tag you in that thread. You worked on another project, untwister, which you released a long time ago but there seems to be a major issue with the CPU usage on it? If you have time, could you help me figure this out? https://github.com/altf4/untwister/issues/47
Saw the associated blog post linked on Hacker News, and was happy to see the source available. Thanks a bunch!
I tried the quick start from the README to see if I could get it to work locally, but failed to do so. For what it's worth, here's a way to reproduce my issue:
Environment:
navigator.appVersion
in the Electron app that starts:"5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.122 Electron/9.4.4 Safari/537.36"
Steps taken:
git clone
the repositorynpm i
npm start
Result:
Detailed output from Powershell window:
Output on the Electron dev tools (last part appears after pressing the start button):
Screenshot of the main window:
Of course my ultimate goal is to replace
secret.png
with my own image and try it out, but for now I'm stuck at the default setup.PS. I'd absolutely understand if you'd close this issue as "wontfix", given that you provide the source code as a courtesy and companion to a blog post. But just in case you'd be glad to get some feedback on others trying your solution, I figured I'd take a moment to write this issue.
Thanks again for a wonderful blog post and for sharing the code! 👍