Open tower111 opened 1 year ago
I also meet the same problem when I tried to run tenda ac15 example. I thought I could simulate the httpd program. However, when I tried to get the request through the browser, the qiling terminal reported errors before the back end returned the page successfully. Some times it report Syscall ERROR: ql_syscall_shutdown DEBUG: [Errno 107] Transport endpoint is not connected
error. Some times it report Syscall ERROR: ql_syscall_recv DEBUG: [Errno 11] Resource temporarily unavailable
. In a very small probability, it can successfully return the page without an error.
My system is Ubuntu 20.04, and the version of qiling is 1.4.7.dev0. I'm running in a VMware virtual machine with 16G of memory and 8 cores. Python is 3.8.10, GCC is 9.4.0.
Has anyone met and solved this problem?
[+] 0x901ebf10: read(fd = 0x6, buf = 0x12c7f0, length = 0x800) = 0x294
[+] Received interrupt: 0x2
[+] 0x90226eb8: send(sockfd = 0x4, buf = 0x1251a0, length = 0x303, flags = 0x0) = 0x0
[+] Received interrupt: 0x2
[+] read() CONTENT: b''
[+] 0x901ebf10: read(fd = 0x6, buf = 0x12c7f0, length = 0x800) = 0x0
[+] Received interrupt: 0x2
[+] close(6) = 0
[+] 0x901ea670: close(fd = 0x6) = 0x0
[+] Received interrupt: 0x2
[+] 0x901ecd30: fcntl(fd = 0x4, cmd = 0x3, arg = 0x90) = 0x802
[+] Received interrupt: 0x2
[+] 0x901ecd30: fcntl(fd = 0x4, cmd = 0x4, arg = 0x2) = 0x0
[+] Received interrupt: 0x2
[+] 0x90226eb8: send(sockfd = 0x4, buf = 0x1251a0, length = 0x303, flags = 0x0) = 0x0
[+] Received interrupt: 0x2
[+] 0x901ecd30: fcntl(fd = 0x4, cmd = 0x3, arg = 0x10) = 0x2
[+] Received interrupt: 0x2
[+] 0x901ecd30: fcntl(fd = 0x4, cmd = 0x4, arg = 0x802) = 0x0
[+] Received interrupt: 0x2
[x] Syscall ERROR: ql_syscall_shutdown DEBUG: [Errno 107] Transport endpoint is not connected
Traceback (most recent call last):
File "/root/.local/lib/python3.8/site-packages/qiling/os/posix/posix.py", line 213, in load_syscall
retval = syscall_hook(self.ql, *params)
File "/root/.local/lib/python3.8/site-packages/qiling/os/posix/syscall/socket.py", line 364, in ql_syscall_shutdown
sock.shutdown(how)
File "/root/.local/lib/python3.8/site-packages/qiling/os/posix/filestruct.py", line 80, in shutdown
return self.__socket.shutdown(how)
OSError: [Errno 107] Transport endpoint is not connected
Traceback (most recent call last):
File "tendaac1518_httpd.py", line 100, in <module>
my_sandbox([fr'{ROOTFS}/bin/httpd'], ROOTFS)
File "tendaac1518_httpd.py", line 93, in my_sandbox
ql.run()
File "/root/.local/lib/python3.8/site-packages/qiling/core.py", line 597, in run
self.os.run()
File "/root/.local/lib/python3.8/site-packages/qiling/os/linux/linux.py", line 184, in run
self.ql.emu_start(self.ql.loader.elf_entry, self.exit_point, self.ql.timeout, self.ql.count)
File "/root/.local/lib/python3.8/site-packages/qiling/core.py", line 777, in emu_start
raise self.internal_exception
File "/root/.local/lib/python3.8/site-packages/qiling/core_hooks.py", line 127, in wrapper
return callback(*args, **kwargs)
File "/root/.local/lib/python3.8/site-packages/qiling/core_hooks.py", line 170, in _hook_intr_cb
ret = hook.call(ql, intno)
File "/root/.local/lib/python3.8/site-packages/qiling/core_hooks_types.py", line 25, in call
return self.callback(ql, *args)
File "/root/.local/lib/python3.8/site-packages/qiling/os/linux/linux.py", line 138, in hook_syscall
return self.load_syscall()
File "/root/.local/lib/python3.8/site-packages/qiling/os/posix/posix.py", line 231, in load_syscall
raise e
File "/root/.local/lib/python3.8/site-packages/qiling/os/posix/posix.py", line 213, in load_syscall
retval = syscall_hook(self.ql, *params)
File "/root/.local/lib/python3.8/site-packages/qiling/os/posix/syscall/socket.py", line 364, in ql_syscall_shutdown
sock.shutdown(how)
File "/root/.local/lib/python3.8/site-packages/qiling/os/posix/filestruct.py", line 80, in shutdown
return self.__socket.shutdown(how)
OSError: [Errno 107] Transport endpoint is not connected
[+] 0x901ed2ec: write(fd = 0x5, buf = 0x7ff3b284, count = 0x7e0) = 0x7e0
[+] Received interrupt: 0x2
[+] 0x901ebf10: read(fd = 0x5, buf = 0x7ff3b284, length = 0x7e0) = -0x9 (EBADF)
[+] Received interrupt: 0x2
[+] close(5) = 0
[+] 0x901ea670: close(fd = 0x5) = 0x0
[+] Received interrupt: 0x2
[+] 0x90226eb8: send(sockfd = 0x4, buf = 0x1251a0, length = 0x13, flags = 0x0) = 0x13
[+] Received interrupt: 0x2
[+] 0x90226eb8: send(sockfd = 0x4, buf = 0x1251a0, length = 0x2eb, flags = 0x0) = 0x2eb
[+] Received interrupt: 0x2
[+] 0x901ecd30: fcntl(fd = 0x4, cmd = 0x3, arg = 0x80) = 0x802
[+] Received interrupt: 0x2
[+] 0x901ecd30: fcntl(fd = 0x4, cmd = 0x4, arg = 0x2) = 0x0
[+] Received interrupt: 0x2
[+] 0x901ecd30: fcntl(fd = 0x4, cmd = 0x3, arg = 0x0) = 0x2
[+] Received interrupt: 0x2
[+] 0x901ecd30: fcntl(fd = 0x4, cmd = 0x4, arg = 0x802) = 0x0
[+] Received interrupt: 0x2
[+] 0x90226f84: shutdown(sockfd = 0x4, how = 0x1) = 0x0
[+] Received interrupt: 0x2
[x] Syscall ERROR: ql_syscall_recv DEBUG: [Errno 11] Resource temporarily unavailable
Traceback (most recent call last):
File "/root/.local/lib/python3.8/site-packages/qiling/os/posix/posix.py", line 213, in load_syscall
retval = syscall_hook(self.ql, *params)
File "/root/.local/lib/python3.8/site-packages/qiling/os/posix/syscall/socket.py", line 676, in ql_syscall_recv
content = sock.recv(length, flags)
File "/root/.local/lib/python3.8/site-packages/qiling/os/posix/filestruct.py", line 116, in recv
return self.__socket.recv(bufsize, flags)
BlockingIOError: [Errno 11] Resource temporarily unavailable
Traceback (most recent call last):
File "tendaac1518_httpd.py", line 100, in <module>
my_sandbox([fr'{ROOTFS}/bin/httpd'], ROOTFS)
File "tendaac1518_httpd.py", line 93, in my_sandbox
ql.run()
File "/root/.local/lib/python3.8/site-packages/qiling/core.py", line 597, in run
self.os.run()
File "/root/.local/lib/python3.8/site-packages/qiling/os/linux/linux.py", line 184, in run
self.ql.emu_start(self.ql.loader.elf_entry, self.exit_point, self.ql.timeout, self.ql.count)
File "/root/.local/lib/python3.8/site-packages/qiling/core.py", line 777, in emu_start
raise self.internal_exception
File "/root/.local/lib/python3.8/site-packages/qiling/core_hooks.py", line 127, in wrapper
return callback(*args, **kwargs)
File "/root/.local/lib/python3.8/site-packages/qiling/core_hooks.py", line 170, in _hook_intr_cb
ret = hook.call(ql, intno)
File "/root/.local/lib/python3.8/site-packages/qiling/core_hooks_types.py", line 25, in call
return self.callback(ql, *args)
File "/root/.local/lib/python3.8/site-packages/qiling/os/linux/linux.py", line 138, in hook_syscall
return self.load_syscall()
File "/root/.local/lib/python3.8/site-packages/qiling/os/posix/posix.py", line 231, in load_syscall
raise e
File "/root/.local/lib/python3.8/site-packages/qiling/os/posix/posix.py", line 213, in load_syscall
retval = syscall_hook(self.ql, *params)
File "/root/.local/lib/python3.8/site-packages/qiling/os/posix/syscall/socket.py", line 676, in ql_syscall_recv
content = sock.recv(length, flags)
File "/root/.local/lib/python3.8/site-packages/qiling/os/posix/filestruct.py", line 116, in recv
return self.__socket.recv(bufsize, flags)
BlockingIOError: [Errno 11] Resource temporarily unavailable
same issue here
i met the same issues when emulating tendaac httpd
Hi everyone, there is a blogpost on the subject where they explained how to overcame that issue:
https://labs.nettitude.com/blog/emulation-with-qiling/
I found the function in IDA (when looking at crossrefs from fcntl
there are four calls to fcntl, this is the function you are looking for:
Then you want to hook the address at which there is the comparison and set the right register so you do not enter the block. (everything is described in the blogpost)
*Describe the bug This bug be report,when run qiling?
It works fine when run with qemu-user-static.
Sample Code
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Here is the startup code
ql = Qiling(["./cpio-root/usr/bin/noodles","-d"], "cpio-root",profile='./linux.ql', verbose=QL_VERBOSE.DEBUG, console = True ,ostype=QL_OS.LINUX,multithread=True)
Upvote & Fund