question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extraction stops if a file has a size of < 0

See original GitHub issue

Normally a file shouldn’t have a size less than 0, but when it does the extraction process just exits with:

$ asar extract app.asar extracted

buffer.js:250
    throw new ERR_INVALID_OPT_VALUE.RangeError('size', size);
    ^

RangeError [ERR_INVALID_OPT_VALUE]: The value "-1000" is invalid for option "size"
    at Function.alloc (buffer.js:259:3)
    at new Buffer (buffer.js:177:19)
    at Object.module.exports.readFileSync (C:\Users\Me\AppData\Roaming\npm\node_modules\asar\lib\disk.js:117:16)
    at C:\Users\Me\AppData\Roaming\npm\node_modules\asar\lib\asar.js:214:28
    at Array.map (<anonymous>)
    at Object.module.exports.extractAll (C:\Users\Me\AppData\Roaming\npm\node_modules\asar\lib\asar.js:192:20)
    at Command.<anonymous> (C:\Users\Me\AppData\Roaming\npm\node_modules\asar\bin\asar.js:60:15)
    at Command.listener (C:\Users\Me\AppData\Roaming\npm\node_modules\asar\node_modules\commander\index.js:315:8)
    at Command.emit (events.js:203:13)
    at Command.parseArgs (C:\Users\Me\AppData\Roaming\npm\node_modules\asar\node_modules\commander\index.js:651:12)

I think this is unexpected behaviour and the file should be skipped instead, allowing the extraction of other files in the archive to continue.

Here is a possible fix, but I’m not sure what your thoughts are on this, so ill wait with opening a pull request.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

38reactions
xssccommented, Jun 16, 2020

hey, @sleeyax , i think you should reopen this issue, it is very important “while experimenting with an electron-based application you do not own” as you put it

0reactions
andrewschreibercommented, Aug 10, 2022

Hey fellow investigators 😃

If you open up one of these “obfuscated” .asars with a compatible (!) text editor (~maybe vim app.asar) what you find is a header:

".codesign":{"size":-1000,"offset":"0"}

The only match for -1000 in the entire asar file. Compared to a normal asar, this obfuscated asar also has thousands of unicode characters between the header JSON and the first actual file.

I played with stripping out the unicode, changing the codesign size, etc. but kept running into JSON parsing issues when extracting.

Might revisit more later. Looks like there is a new (secret??) codesigning framework for sourcecode protection for electron. I suspect if you could figure out the right value for size, swap the value with the text editor, it might work. If anyone can find the electron codesigning package that does this, that would be very helpful!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Files Become 0 Bytes? Top 3 Ways to Restore Zero Byte Files
If a file itself is corrupted, it shows you zero-length or zero bytes. Many factors can result in zero-length files. The interruption when...
Read more >
Unable to get data from unzipped file - Super User
I have a file on MacOS that I extracted from a ZIP archive that appears to have 113020 bytes or zero bytes depending...
Read more >
ALL MY .EXE FILES SIZE TURNED TO 0kb
Recently, i plugged in a flash disk which i suspect w'd have been infected with a virus or malware that caused all my...
Read more >
Recover 0 Byte Files in Windows 10/8/7 - EaseUS
If your .exe files or programs turned into 0 bytes, the biggest reason is that the 0KB virus infected your files.
Read more >
An Empty file gets downloaded inbetween data extraction
i have been downloading files from the webpage and extracting data from ... After getting filesize, if it empty, it would be 0...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found