Coder Social home page Coder Social logo

Can the default qcow2 provided by Panda for x86_64 be replaced? If so, what issues might there be with my operation steps? about panda HOT 4 OPEN

CorneliaStreet1 avatar CorneliaStreet1 commented on June 22, 2024
Can the default qcow2 provided by Panda for x86_64 be replaced? If so, what issues might there be with my operation steps?

from panda.

Comments (4)

AndrewFasano avatar AndrewFasano commented on June 22, 2024

Why are you using workstation? Just use panda/qemu/kvm with the original qcow. You can install software into the qcow filesystem as needed. You can't take a snapshot with qemu/kvm that can then be loaded into panda, but after modifying the filesystem with qemu/kvm you can boot it under panda and then take a new snapshot.

Also try interacting with your guest instead of using the python interface, it's likely printing something other than a PS1 style prompt via the serial console which is causing your exception. You can run python3 -m pandare.qcows x86_64 to get a command that you can use to launch the generic x86_64 images interactively.

from panda.

CorneliaStreet1 avatar CorneliaStreet1 commented on June 22, 2024

Why are you using workstation? Just use panda/qemu/kvm with the original qcow. You can install software into the qcow filesystem as needed. You can't take a snapshot with qemu/kvm that can then be loaded into panda, but after modifying the filesystem with qemu/kvm you can boot it under panda and then take a new snapshot.

Also try interacting with your guest instead of using the python interface, it's likely printing something other than a PS1 style prompt via the serial console which is causing your exception. You can run python3 -m pandare.qcows x86_64 to get a command that you can use to launch the generic x86_64 images interactively.

I'm just an undergraduate student majoring in Computer Science and Technology who use Panda for my undergraduate project. I'm not very familiar with this field. That's why I was using workstation(It's very stupid).

I followed your guidance to boot the original image using Panda (specifically, ./panda/bionic-server-cloudimg-amd64-noaslr-nokaslr.qcow2), then enabled networking, and installed software (i.e., modified the file system). After that, I rebooted this qcow2 under Panda and took a new snapshot named "root." However, it seems that this snapshot cannot be used with PyPanda.

What issues might there be with my steps?

Here are my steps:

  1. Boot the original qcow2 using Panda: ./panda-system-x86_64 -hda ~/.panda/bionic-server-cloudimg-amd64-noaslr-nokaslr.qcow2 -nographic -m 1G
  2. Enable networking and installe software (i.e., modify the file system).
  3. Reboot the system and take a new snapshot at the login page using the QEMU monitor: (qemu) savevm root

Then, I wrote a short Python code to test if the new snapshot is usable, and PyPanda threw a timeout exception.
I think my code is correct, it's very simple:

from pandare import Panda

panda = Panda(generic="x86_64")

@panda.queue_blocking
def run_cmd():
# First revert to root snapshot, then type a command via serial
panda.revert_sync("root")
print(panda.run_serial_cmd("ls"))
panda.end_analysis()

panda.run()

but I got the exception:
PANDA[core]:os_familyno=2 bits=64 os_details=ubuntu:4.15.0-72-generic-noaslr-nokaslr
[PYPANDA] Panda args: [/usr/local/build/x86_64-softmmu/libpanda-x86_64.so -L /usr/local/build/pc-bios /home/jyq/.panda/bionic-server-cloudimg-amd64-noaslr-nokaslr.qcow2 -display none -m 1024 -serial unix:/tmp/pypanda_s3loy_jeb,server,nowait -monitor unix:/tmp/pypanda_m93csxqt4,server,nowait]
Traceback (most recent call last):
File "/home/jyq/PyPandaCode/run_cmd.py", line 25, in
panda.run()
File "/usr/local/lib/python3.10/dist-packages/pandare/panda.py", line 555, in run
raise saved_exception
File "/usr/local/lib/python3.10/dist-packages/pandare/panda.py", line 972, in wrapper
f()
File "/usr/local/lib/python3.10/dist-packages/pandare/utils.py", line 106, in wrapper
return func(*args, **kwargs)
File "/home/jyq/PyPandaCode/run_cmd.py", line 22, in run_cmd
print(panda.run_serial_cmd("ls"))
File "/usr/local/lib/python3.10/dist-packages/pandare/utils.py", line 106, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/pandare/panda.py", line 2416, in run_serial_cmd
result = self.serial_console.expect(timeout=timeout)
File "/usr/local/lib/python3.10/dist-packages/pandare/panda_expect.py", line 435, in expect
raise TimeoutExpired(f"{self.name} Read message \n{full_buffer}\n")
pandare.panda_expect.TimeoutExpired: serial Read message
['ls', bytearray(b'Password: \r')]

Does Panda have any special requirements for newly created snapshots?
Is the timing of when I save the snapshot incorrect? What is the correct timing to save the snapshot?
Should I save the snapshot before entering the username 'root,' or after entering the username but before entering the password, or after successfully logging in?
Or is there a problem with the way I took the snapshot?
Please help me, I would greatly appreciate it.

from panda.

AndrewFasano avatar AndrewFasano commented on June 22, 2024

If you want to use a new snapshot with run_serial_command the snapshot will need to be taken after you log in and there's a command prompt for it to type commands into.

from panda.

AndrewFasano avatar AndrewFasano commented on June 22, 2024

I don't think there's much documentation around this (sorry!) it's not a feature that gets much use. If you want to help fix that PRs are always welcome :)

from panda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.