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

How can I use panda to interact with a program. #1288

Open
ghost opened this issue Mar 13, 2023 · 3 comments
Open

How can I use panda to interact with a program. #1288

ghost opened this issue Mar 13, 2023 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 13, 2023

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.

@lacraig2
Copy link
Member

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:

panda.copy_to_guest(str(HOST_PROG_DIR))

@ghost
Copy link
Author

ghost commented Mar 17, 2023

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.

@AndrewFasano
Copy link
Member

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.

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

No branches or pull requests

2 participants