How do I directly modify a Google Chrome Extension File? (.CRX)

后端 未结 10 1275
挽巷
挽巷 2020-12-04 05:17

I\'m not sure in which languages those extensions are, I think the are written in Html, Javascript or JSON. As far as I know they are \"compressed\" in a .CRX file.

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 05:30

    A signed CRX file has a header that will cause most/all unzippers to barf. This is not the easiest way to go about it, but here's how to do it from a bash command line.

    The basic idea is to find where the original unsigned zipfile begins, then copy the CRX file to a zip file but exclude the CRX header.

    1. hexdump -C the_extension.crx | more
    2. Look in the output for the start of the zip file, which are the ASCII bytes "PK". In the sample I tried, the PK was at offset 0x132. (From reading the CRX spec, I think this number will vary from file to file because of different signature lengths.) That number is what we'll use in the next step.
    3. dd if=the_extension.crx of=the_extension.zip bs=1 skip=0x132 (For the skip parameter, substitute the offset you found in the previous step.)
    4. Now unzip the .zip that you just created.
    5. Fiddle with the files in the unzipped directory, then either install the unsigned/unpacked extension into your Chrome installation, or else repackage it just as you would any other Chrome extension.

    I'm sure that there is a more concise way to do this. Bash experts, please improve on my answer.

提交回复
热议问题