Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDA qiling plugin encounter an error. #1490

Open
g0mxxm opened this issue Aug 7, 2024 · 3 comments · May be fixed by #1493
Open

IDA qiling plugin encounter an error. #1490

g0mxxm opened this issue Aug 7, 2024 · 3 comments · May be fixed by #1493
Assignees

Comments

@g0mxxm
Copy link

g0mxxm commented Aug 7, 2024

Describe the bug
the log about this error:
[INFO][qilingida:2066] ['D:\Code_Files\ARM\Qiling-Lab\qilinglab-aarch64']
[INFO][qilingida:1032] Rootfs: D:\Code_Files\qiling\examples\rootfs\arm64_linux
[INFO][qilingida:1033] Custom user script: D:\Code_Files\IDA_DEV\IDA_QilingLab.py
[INFO][qilingida:1034] Custom env: {}
[INFO][qilingida:1042] Qiling is initialized successfully.
Traceback (most recent call last):
File "E:/Tools/IDA_Pro_7.7/plugins/qilingida.py", line 810, in activate
self.action_handler.ql_handle_menu_action(self.action_type)
File "E:/Tools/IDA_Pro_7.7/plugins/qilingida.py", line 2098, in ql_handle_menu_action
[x.handler() for x in self.menuitems if x.action == action]
File "E:/Tools/IDA_Pro_7.7/plugins/qilingida.py", line 2098, in
[x.handler() for x in self.menuitems if x.action == action]
File "E:/Tools/IDA_Pro_7.7/plugins/qilingida.py", line 1037, in ql_start
self.qlemu.start()
File "E:/Tools/IDA_Pro_7.7/plugins/qilingida.py", line 889, in start
self.ql = Qiling(argv=self.path, rootfs=self.rootfs, verbose=QL_VERBOSE.DEBUG, env=self.env, log_plain=True, *args, **kwargs)
File "C:\Users\g0mx\AppData\Roaming\Python\Python38\site-packages\qiling\core.py", line 169, in init
self._log_file_fd = setup_logger(self, log_devices, log_plain, log_override)
File "C:\Users\g0mx\AppData\Roaming\Python\Python38\site-packages\qiling\log.py", line 208, in setup_logger
raise TypeError(f'unexpected logging device type: {type(dev).name}')
TypeError: unexpected logging device type: StreamWrapper

Sample Code
I use the script is the official "custom_script.py"

pictrue of error
image

Additional context
I try to modify the log.py to add a class named "StreamWrapper", but the error is not resloved. I need help to resolve this error.

@g0mxxm
Copy link
Author

g0mxxm commented Aug 7, 2024

Modify
In log.py, I added an elif branch which successfully resolved the error related to the "StreamWrapper" device type. However, I am unsure where the device type of "StreamWrapper" comes from and whether this is the optimal solution for the problem.

        for dev in logdevs:
            if isinstance(dev, FileLike):
                handler = StreamHandler(dev)

            elif isinstance(dev, str):
                handler = FileHandler(dev)

            elif type(dev).__name__ == "StreamWrapper":
                handler = StreamHandler(dev)

image

Now is OK!
image

@elicn
Copy link
Member

elicn commented Aug 7, 2024

Hi there..!
IDA Python keeps surprising all the time. This is essentially because its standard streams do not support the fileno method, and the default logging stream is set to sys.stderr. Then it fails to match to FileLike and this is how we get the error message.

Though your modification works around the problem, is it not the 'right' way to fix this. I'll assign myself to fix this later on.

@elicn elicn self-assigned this Aug 7, 2024
@g0mxxm
Copy link
Author

g0mxxm commented Aug 8, 2024

Okay, I'm looking forward to the revised version, and I'll take a good look at it when it's ready.

@elicn elicn linked a pull request Sep 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants