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

Question or feature request: PyPanda API for timeout for panda.record_cmd() #1150

Open
rjzak opened this issue Dec 22, 2021 · 5 comments · May be fixed by #1151
Open

Question or feature request: PyPanda API for timeout for panda.record_cmd() #1150

rjzak opened this issue Dec 22, 2021 · 5 comments · May be fixed by #1151

Comments

@rjzak
Copy link

rjzak commented Dec 22, 2021

Since some programs being tested might not exit on their own, or might be stuck waiting for something, it would be useful to have an optional timeout parameter for panda.record_cmd(). Instead, it seems the program runs forever (it's a simple test app I wrote, doesn't do much) and the recording ends up filling up the partition.

I'm not using the latest version, but checking current sources & examples shows this feature isn't implemented.

Git hash: 713ebc3
Git date: 16 Nov 2021
Python: 3.8.10
Host OS: Ubuntu 20.04.3
Guest OS: Windows 10 64-bit (using os="windows", expect_prompt=rb"C*>" in the Panda() constructor in case I'm doing something wrong)

@lacraig2 lacraig2 linked a pull request Dec 23, 2021 that will close this issue
@lacraig2 lacraig2 linked a pull request Dec 23, 2021 that will close this issue
@lacraig2
Copy link
Member

Hello,

That's a great suggestion. I've opened a simple PR to address it.

Having said that I don't believe we've tested the serial mechanism you are using on Windows. Do the run_serial_cmd calls work for you?

@rjzak
Copy link
Author

rjzak commented Jan 6, 2022

I haven't confirmed that the program runs, but that the function did trigger a recording. I'll investigate further.

@lacraig2
Copy link
Member

lacraig2 commented Jan 6, 2022

Sure thing. I did want to point you to this resource where someone else was able to type commands on windows. https://adalogics.com/blog/Building-a-custom-malware-sandbox-with-PANDA-Part-1

@rjzak
Copy link
Author

rjzak commented Jan 7, 2022

Looking at that example, the author uses the subprocess module and stdio/stdin to send commands to the running panda qemu. Is there an equivalent way to use the socket connections that PyPandare uses? I noticed the sockets created in /tmp which are created as socket.socket(socket.AF_UNIX, socket.SOCK_STREAM), but I don't know how to read/write with them, or which socket to use (self.serial_socket vs. self.monitor_socket).

@lacraig2
Copy link
Member

lacraig2 commented Jan 8, 2022

If you can get a serial connection hooked up to something you would be using the self.serial_socket. The monitor_socket connects to the QEMU monitor, which controls QEMU functionality.

We do expose a lower level type_serial_cmd function, but you may be better off calling send and receive yourself based on what you're doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants