Closed 0x79H closed 3 months ago
i checkout last release tag:1.4.5 , and sys.stdin is None too. but ida plugin work well.
maybe bug after this commit https://github.com/qilingframework/qiling/commit/b3de208edb3888ee8a45462fa0a9df2bc9302f90
so maybe we should case exception: AttributeError
there
https://github.com/qilingframework/qiling/blob/1706049d10e955740bff29226bd98d334f902301/qiling/os/os.py#L63
let me just use 1.4.5 now π
and i still don't know why stdin is None, maybe it is None in linux version too? maybe stdin is None can crash something, any info?
I wasn't familiar with the fact that IDA does not define stdin
. We should consider the implications of that and think where redirect stdin
from in case the emulated program uses it.
As a short term workaround, however, you could set sys.stdin
to be a dummy pipe.InteractiveInStream
before Qiling is initialized.
i checkout last release tag:1.4.5 , and sys.stdin is None too. but ida plugin work well.
maybe bug after this commit b3de208 so maybe we should case exception:
AttributeError
therelet me just use 1.4.5 now π
and i still don't know why stdin is None, maybe it is None in linux version too? maybe stdin is None can crash something, any info?
did you solved the problem?
did you solved the problem?
two way in my comment https://github.com/qilingframework/qiling/issues/1362#issuecomment-1600375342
pip install qiling==1.4.5
if ur qiling version > https://github.com/qilingframework/qiling/commit/b3de208edb3888ee8a45462fa0a9df2bc9302f90
diff --git "a/C:\\Python\\Python3-10-5\\lib\\site-packages\\qiling\\os\\os.p_" "b/C:\\Python\\Python3-10-5\\lib\\site-packages\\qiling\\os\\os.py"
index 6d759bf..6018310 100755
--- "a/C:\\Python\\Python3-10-5\\lib\\site-packages\\qiling\\os\\os.p_"
+++ "b/C:\\Python\\Python3-10-5\\lib\\site-packages\\qiling\\os\\os.py"
@@ -61,7 +61,7 @@ class QlOs:
# such as fileno(). here we use this to determine how we are going to use
# the environment standard streams
sys.stdin.fileno()
- except UnsupportedOperation:
+ except (UnsupportedOperation, AttributeError):
# Qiling is used on an interactive shell or embedded python interpreter.
# if the internal stream buffer is accessible, we should use it
self._stdin = getattr(sys.stdin, 'buffer', sys.stdin)
i think this is not the best way to fix, because AttributeError
is not ideal. If we are in IDAPython, we need to set them using this code.
self._stdin = getattr(sys.stdin, 'buffer', sys.stdin)
self._stdout = getattr(sys.stdout, 'buffer', sys.stdout)
self._stderr = getattr(sys.stderr, 'buffer', sys.stderr)
Because qiling set them like this before 1.4.6, but this commit (https://github.com/qilingframework/qiling/commit/b3de208edb3888ee8a45462fa0a9df2bc9302f90) disrupts the original logic. And has been committed to the release version of 1.4.6 .
I haven't closed this issue because it remains unresolved, and I'm uncertain about any potential unintended consequences of my modifications. I only tested it on Windows with IDA 7.7, so I just opened an issue without submitting a pull request at that time.
Now, I believe it's better to use assert to check if sys.stdin
is None
in order to confirm Qiling in IDAPython, triggering AssertionError
instead of AttributeError
.
I believe this deliberate use of None (not use assert sys.stdin
) helps avoid potential issues, just as in the new pull request.
Covered by #1482
error
AttributeError: 'NoneType' object has no attribute 'fileno'
, when callsys.stdin.fileno()
atsetup
inqilingida.py
ida 7.7π windows 11 python 3.10.5 qiling version: 1706049d10e955740bff29226bd98d334f902301 target is arm elf file.
ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV)
i check sys.stdin is None and i know
$IDAdir/python/3/init.py
set stdout and stderr but not set stdintry to fix this and find https://github.com/qilingframework/qiling/issues/475#issuecomment-692589558, same problem but not helpful.
no idea why sys.stdin is None in idapython, and no idea how to fix this.
any idea? thanks.