sensepost / objection

📱 objection - runtime mobile exploration
GNU General Public License v3.0
7.22k stars 829 forks source link

[bug] frida_commands.py read a utf-8 encoding error #519

Open Captain0X opened 2 years ago

Captain0X commented 2 years ago

Describe the bug

UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 761: illegal multibyte sequence`

To Reproduce Steps to reproduce the behavior:

com.dianping.v1 on (vivo: 7.1.2) [usb] # import change_network.js
An unexpected internal exception has occurred. If this looks like a code related error, please file a bug report!
'gbk' codec can't decode byte 0x80 in position 761: illegal multibyte sequence

Python stack trace: Traceback (most recent call last):
  File "C:\Program Files (x86)\python37\lib\site-packages\objection\console\repl.py", line 371, in start_repl
    self.run_command(document)
  File "C:\Program Files (x86)\python37\lib\site-packages\objection\console\repl.py", line 185, in run_command
    exec_method(arguments)
  File "C:\Program Files (x86)\python37\lib\site-packages\objection\commands\frida_commands.py", line 83, in load_background
    hook = ''.join(f.read())
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 761: illegal multibyte sequence`

in https://github.com/sensepost/objection/blob/master/objection/commands/frida_commands.py Line 81 should set encoding

with open(source, 'r',encoding="utf-8") as f:

Similar issues Please link the issues in this repository that is similar to yours.

For example: #358, #229 etc.

Expected behavior A clear and concise description of what you expected to happen.

Evidence / Logs / Screenshots Any output from objection, such as stack traces or errors that occurred. Be sure to run objection with the --debug flag so that errors from the agent are verbose enough to debug. For example:

objection --debug explore

Environment (please complete the following information):

Application If possible, please attach the target application where you can reproduce this bug to the issue.

Additional context Add any other context about the problem here.

leonjza commented 2 years ago

Thanks for the report. Curious, what does your source script contain that is tripping this up? Non-ascii comments or something else?

Captain0X commented 2 years ago

<p title=” <style onload= alert(document.domain)//"> {/all/color/all/:/all/#f78fb3/all/;} .qmbox .qmbox .qmbox {color:#f78fb3;}

leonjza commented 2 years ago

<p title=” <style onload= alert(document.domain)//"> {/all/color/all/:/all/#f78fb3/all/;} .qmbox .qmbox .qmbox {color:#f78fb3;}

Is this the source of the Frida script you are trying to import?

Captain0X commented 2 years ago

sorry this my email auto reply~I will try closed this function~Thanks

Captain0X commented 2 years ago

I think this bug can fix buy compatible utf-8 and gbk18030 and ascii