BishopFox / unredacter

Never ever ever use pixelation as a redaction technique
GNU General Public License v3.0
7.75k stars 717 forks source link

Can't run the test sapmle [Out of range error] #11

Open ShaoyuWang1 opened 2 years ago

ShaoyuWang1 commented 2 years ago

I have run npm install successfully, but the I cant run the test sample successfully the error is :

Error occurred in handler for 'redact': RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 47100. Received -3968 at boundsError (internal/buffer.js:72:9) at Buffer.readUInt32BE (internal/buffer.js:295:5) at Jimp. (/Users/windsky/Downloads/unredacter-main/node_modules/@jimp/plugin-crop/dist/index.js:43:37) at scan (/Users/windsky/Downloads/unredacter-main/node_modules/@jimp/utils/dist/index.js:53:9) at Jimp.scanQuiet (/Users/windsky/Downloads/unredacter-main/node_modules/@jimp/core/dist/index.js:1262:32) at Jimp.cropQuiet (/Users/windsky/Downloads/unredacter-main/node_modules/@jimp/plugin-crop/dist/index.js:42:12) at Jimp. [as crop] (/Users/windsky/Downloads/unredacter-main/node_modules/@jimp/core/dist/index.js:1176:23) at /Users/windsky/Downloads/unredacter-main/dist/main.js:363:47 at step (/Users/windsky/Downloads/unredacter-main/dist/main.js:52:23) at Object.next (/Users/windsky/Downloads/unredacter-main/dist/main.js:33:53) { code: 'ERR_OUT_OF_RANGE', methodName: 'crop', eventName: 'error' }

0xced commented 2 years ago

I got almost the same error with a slightly different value for the faulty offset when trying to unredact the sample pixellated secret.png:

Error occurred in handler for 'redact': RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 87804. Received -7040
    at boundsError (internal/buffer.js:77:9)
    at Buffer.readUInt32BE (internal/buffer.js:300:5)
    at Jimp.<anonymous> (~/Projects/unredacter/node_modules/@jimp/plugin-crop/dist/index.js:43:37)
    at scan (~/Projects/unredacter/node_modules/@jimp/utils/dist/index.js:53:9)
    at Jimp.scanQuiet (~/Projects/unredacter/node_modules/@jimp/core/dist/index.js:1262:32)
    at Jimp.cropQuiet (~/Projects/unredacter/node_modules/@jimp/plugin-crop/dist/index.js:42:12)
    at Jimp.<computed> [as crop] (~/Projects/unredacter/node_modules/@jimp/core/dist/index.js:1176:23)
    at ~/Projects/unredacter/dist/main.js:363:47
    at step (~/Projects/unredacter/dist/main.js:52:23)
    at Object.next (~/Projects/unredacter/dist/main.js:33:53) {
  code: 'ERR_OUT_OF_RANGE',
  methodName: 'crop',
  eventName: 'error'
}

Tried on macOS, just like @windskyshaoyu.

$ sw_vers 
ProductName:    Mac OS X
ProductVersion: 10.15.7
BuildVersion:   19H1615
ocean-zhc commented 2 years ago

me too

MKesenheimer commented 2 years ago

Same error for me. I'm on Linux and followed your installation instructions. The Current Guess and the Best Guess images are also not able to render. Maybe these problems are somehow connected. Screenshot_20220223_074016

MKesenheimer commented 2 years ago

Added a pull request to fix this issue: https://github.com/BishopFox/unredacter/pull/16

ercihan commented 2 years ago

Hi @MKesenheimer I tried your fix, which you have published on MKesenheimer Unfortunately I got nearly the same error as before:

(node:1764) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. Error occurred in handler for 'redact': RangeError [ERR_INVALID_OPT_VALUE]: The value "-792" is invalid for option "size" at Function.allocUnsafe (buffer.js:358:3) at Jimp.cropQuiet (C:\Users\kerci\Downloads\unredacter-main\node_modules\@jimp\plugin-crop\dist\index.js:40:27) at Jimp. [as crop] (C:\Users\kerci\Downloads\unredacter-main\node_modules\@jimp\core\dist\index.js:1176:23) at C:\Users\kerci\Downloads\unredacter-main\dist\main.js:289:47 at step (C:\Users\kerci\Downloads\unredacter-main\dist\main.js:52:23) at Object.next (C:\Users\kerci\Downloads\unredacter-main\dist\main.js:33:53) at fulfilled (C:\Users\kerci\Downloads\unredacter-main\dist\main.js:24:58) { code: 'ERR_INVALID_OPT_VALUE', methodName: 'crop', eventName: 'error' }

I tried it with a Windows 10 machine Build 19044.1566

MKesenheimer commented 2 years ago

@ercihan Did you try with the image that comes with the installation or with your own image? You could try increasing or decreasing the font size and play with the other parameters. I added more global parameters at the top of src/main.ts as well.

9cco commented 2 years ago

Have the same issue on Ubuntu 20.04.4, Node v14.19.0, npm 6.14.16.

When running npm start, the images under 'Current Guess:' and 'Best Guess:' seems to be broken. After clicking on 'Click to Start' getting the error:

npm start

> unredacter@1.0.0 start /<path>/unredacter
> npm run build && electron ./dist/main.js

> unredacter@1.0.0 build /<path>/unredacter
> tsc

(node:3352458) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(node:3352505) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Error occurred in handler for 'redact': RangeError [ERR_INVALID_OPT_VALUE]: The value "-380" is invalid for option "size"
    at Function.allocUnsafe (buffer.js:358:3)
    at Jimp.cropQuiet (/<path>/unredacter/node_modules/@jimp/plugin-crop/dist/index.js:40:27)
    at Jimp.<computed> [as crop] (/<path>/unredacter/node_modules/@jimp/core/dist/index.js:1176:23)
    at /<path>/unredacter/dist/main.js:279:47
    at step (/<path>/unredacter/dist/main.js:52:23)
    at Object.next (/<path>/unredacter/dist/main.js:33:53)
    at fulfilled (/<path>/unredacter/dist/main.js:24:58) {
  code: 'ERR_INVALID_OPT_VALUE',
  methodName: 'crop',
  eventName: 'error'
}

Electron produces the log file:

undefined:1 GET file:///<path>/unredacter/undefined net::ERR_FILE_NOT_FOUND
Image (async)
(anonymous) @ renderer.ts:54
step @ renderer.ts:6
(anonymous) @ renderer.ts:6
(anonymous) @ renderer.ts:6
__awaiter @ renderer.ts:6
gatherResults @ renderer.ts:36
(anonymous) @ renderer.ts:24
postMessage (async)
(anonymous) @ renderer.ts:60
VM55 renderer_init.js:75 Uncaught (in promise) Error: Error invoking remote method 'redact': RangeError [ERR_INVALID_OPT_VALUE]: The value "-380" is invalid for option "size"
    at EventEmitter.o.send.o.invoke (VM55 renderer_init.js:75)
o.send.o.invoke @ VM55 renderer_init.js:75
Promise.then (async)
step @ VM56 preload.js:26
fulfilled @ VM56 preload.js:24
Promise.then (async)
step @ VM56 preload.js:26
fulfilled @ VM56 preload.js:24

The last 3 lines are then repeated several times. Hope this could help figuring out what is wrong.

MKesenheimer commented 2 years ago

@9cco Have you tried my pull request? Also look at this comment: https://github.com/BishopFox/unredacter/issues/11#issuecomment-1050271186

9cco commented 2 years ago

@MKesenheimer Yes I tried your pull request now. Unfortunately it is still the same problem. Also tried updating npm to version 8.5.3, but still doesn't work.

snowlrd commented 2 years ago

Error occurred in handler for 'redact': RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 47100. Received -21376 at boundsError (internal/buffer.js:72:9) main/nodemodules/@jimp_utils@0.16.1@@jimp/utils/dist/index.js:53:9) code: 'ERR_OUT_OF_RANGE', methodName: 'crop', eventName: 'error'

b1gcat commented 2 years ago

same error

addisoncrump commented 2 years ago

I dug a little deeper into this and found some items of note.

I dropped a console.log(image.bitmap) here and got the following output with the default images:

{
  width: 800,
  height: 190,
  depth: 8,
  interlace: false,
  palette: false,
  color: true,
  alpha: true,
  bpp: 4,
  colorType: 6,
  data: <Buffer ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ... 607950 more bytes>,
  gamma: 0
}

Now, when I was setting up to depixelate an image from Discord, I used the following html:

<HTML/>
<body style="padding: 8px 0px 0px 8px; background-color:#36393f;">
<span style="padding 0px 0px 0px 0px; color: #dcddde; font-weight: 400; font-family: Whitney,'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 32px; margin: 0;">a</span><span style="padding 0px 0px 0px 0px; margin: 0; color: #0000ff; font-size: 32px; font-weight: 400; font-family: Whitney,'Helvetica Neue',Helvetica,Arial,sans-serif;">█</span>
</body>
</HTML>

And got the following image:

{
  width: 800,
  height: 190,
  depth: 8,
  interlace: false,
  palette: false,
  color: true,
  alpha: true,
  bpp: 4,
  colorType: 6,
  data: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 607950 more bytes>,
  gamma: 0
}

Concerningly, this shows that all the bytes are black.

What I suspect is that for whatever reason, the browser is not rendering the page, or is perhaps not rendering the page on time. I checked a variety of different possibilities (font? margin? something else?) but couldn't find the cause. If this was a timing issue, we'd expect to see some inconsistent failures in the base case, but that just doesn't happen. Perhaps someone with more insight on the matter could figure this out, but I'm afraid I just don't have time to at present.

DragonXXL commented 2 years ago

me, too

HaolunWang commented 2 years ago

@MKesenheimer Hi, there. I used your repo which was forked from here, and I used the same width and height (468 * 22) with yours in https://github.com/BishopFox/unredacter/issues/11#issuecomment-1048486482 However, got some errors in console: undefined:1 GET file:///Users/username/Dev/unredacter1/unredacter/undefined net::ERR_FILE_NOT_FOUND Image (async) (anonymous) @ renderer.ts:54 step @ renderer.ts:6 (anonymous) @ renderer.ts:6 (anonymous) @ renderer.ts:6 __awaiter @ renderer.ts:6 gatherResults @ renderer.ts:36 (anonymous) @ renderer.ts:24 postMessage (async) (anonymous) @ renderer.ts:60 VM55 renderer_init.js:75 Uncaught (in promise) Error: Error invoking remote method 'redact': RangeError [ERR_INVALID_OPT_VALUE]: The value "-368" is invalid for option "size" at EventEmitter.o.send.o.invoke (VM55 renderer_init.js:75)

and got errors in IDE console: Electron[13527:6416855] Warning: Expected min height of view: (<NSPopoverTouchBarItemButton: 0x7fb1e1ec4180>) to be less than or equal to 30 but got a height of 32.000000. This error will be logged once per view in violation. Error occurred in handler for 'redact': RangeError [ERR_INVALID_OPT_VALUE]: The value "-368" is invalid for option "size" at Function.allocUnsafe (buffer.js:358:3) at Jimp.cropQuiet (/Users/username/Dev/unredacter1/unredacter/node_modules/@jimp/plugin-crop/dist/index.js:40:27) at Jimp. [as crop] (/Users/username/Dev/unredacter1/unredacter/node_modules/@jimp/core/dist/index.js:1176:23) at /Users/username/Dev/unredacter1/unredacter/dist/main.js:289:47 at step (/Users/username/Dev/unredacter1/unredacter/dist/main.js:52:23) at Object.next (/Users/username/Dev/unredacter1/unredacter/dist/main.js:33:53) at fulfilled (/Users/username/Dev/unredacter1/unredacter/dist/main.js:24:58) { code: 'ERR_INVALID_OPT_VALUE', methodName: 'crop', eventName: 'error' }

so, always indicate "to be less than or equal to 30 but got a height of 32.000000" and "The value "-368" is invalid for option "size", have you met this, or do you know how to fix it now?

appreciate it!

MKesenheimer commented 2 years ago

Hey,

I am not sure what happens in your case. I'm also not the creator of the project so I do not have all the insights. You could try to play around with the values of blockSize and fontsize in ./src/main.ts. Let me know if this helps.

Cheers Matthias

HaolunWang commented 2 years ago

Hey,

I am not sure what happens in your case. I'm also not the creator of the project so I do not have all the insights. You could try to play around with the values of blockSize and fontsize in ./src/main.ts. Let me know if this helps.

Cheers Matthias

I think this problem somehow happens on macOS, but this project can be smoothly run on Windows (got this answer from some of my friends who run it on their Windows laptops). Not sure this solution is helpful for everyone. Anyways, thanks for @MKesenheimer 's help!