panda
panda copied to clipboard
How can I use panda to interact with a program.
Let's take this program as an example.
#include <stdio.h>
int main(int argc, char const *argv[])
{
setbuf(stdin,0);
setbuf(stdout,0);
char buf[0x100];
printf("Your input:");
read(0,buf,0x10);
printf("Your input is:%s",buf);
return 0;
}
When I copy it to a virtual machine using panda.copy_to_guest()
and run the program using panda.interact()
, I can't interact with it for any input-output.
Hello!
Can you show an example of how you're calling panda.interact()
?
In the interim I think an example that may help you is: https://github.com/panda-re/panda/blob/5472db214f56d0696694b416a1ebdcbaba8fa482/panda/plugins/signal/test/run.py#L42
panda = Panda(generic='x86_64_ubuntu_1804')
@panda.queue_blocking
def run_cmd():
panda.revert_sync("root")
panda.copy_to_guest("test")
panda.interact()
panda.run()
PANDA: entering interactive mode. Type pandaquit to exit
root@ubuntu:.*# ls
test test.ro
root@ubuntu:.*# file test
test: directory
root@ubuntu:.*# file test/test
test/test: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=1e16c3e5c9b3b168bac41d2c71638734782d9868, not stripped
root@ubuntu:.*# ./test/test
aaaaaa
There is no output from the program, and no response to input.
PyPANDA's interactive mode isn't something we've used too much, I honestly forgot it even existed. I think we only ever tested it with very basic shell interactions so there's a good chance there are issues if your program is printing output without newlines or trying to receive input one byte at a time. If you want to try fixing it, feel free. Otherwise, I'd recommend just taking recording of you interacting with the program using the panda cli or $(python -m pandare.qcows x86_64_ubuntu_1804)
then analyzing that.