Coder Social home page Coder Social logo

Comments (6)

zestrada avatar zestrada commented on August 19, 2024 1

A couple of things that might help:

  1. The root snapshot was taken with 1G of RAM, so you'll have to use that for our snapshot:
    https://github.com/panda-re/panda_image_generator/blob/master/make_image.py#49
    https://panda.re/frame.php?url=/qcows/
    so the panda command becomes:
panda-system-x86_64 -m 1G ~/.panda/bionic-server-cloudimg-amd64-noaslr-nokaslr.qcow2 -nographic -net nic -net user,hostfwd=tcp::8888-:8888 -loadvm root

Otherwise, you'll get those messages and hanging behavior you see above when running with -loadvm root

  1. You might have to grab a new ip. For me, just running dhclient in the guest did the trick:
root@ubuntu:~# dhclient ens3
cmp: EOF on /tmp/tmp.2Dd5p6Bq1V which is empty
root@ubuntu:~# ifconfig ens3
ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::5054:ff:fe12:3456  prefixlen 64  scopeid 0x20<link>
        inet6 fec0::5054:ff:fe12:3456  prefixlen 64  scopeid 0x40<site>
        ether 52:54:00:12:34:56  txqueuelen 1000  (Ethernet)
        RX packets 42  bytes 9366 (9.3 KB)
        RX errors 17  dropped 0  overruns 0  frame 17
        TX packets 40  bytes 4273 (4.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

After those two things, the netcat test passes:

#GUEST
root@ubuntu:~# nc -lnvp 8888
Listening on [0.0.0.0] (family 0, port 8888)
Connection from 10.0.2.2 44314 received!
aaaa

#HOST
root@430045c1f0b6:/# nc localhost 8888
aaaa

from panda.

AndrewFasano avatar AndrewFasano commented on August 19, 2024

We haven't messed with the standard qemu networking so those options should work. Can you provide an example pypanda script showing how you were adding them to extra args?

from panda.

Kirito0 avatar Kirito0 commented on August 19, 2024

Taking the following code as an example, I try to forward port 22 of the virtual machine to port 2222 of the host.

from pandare import Panda

panda = Panda(generic='x86_64_ubuntu_1804', extra_args='-net nic -net user,hostfwd=tcp::2222-:22')

@panda.queue_blocking
def run_cmd():
    print('==========================================================================')
    panda.revert_sync("root")
    print('Starting....')
    print(panda.run_serial_cmd("uname -a && ifconfig -a"))
    print(panda.run_serial_cmd("netstat -antp"))

panda.run()

Then I execute in the host:

ssh [email protected] -p 2222

And got no response.

from panda.

AndrewFasano avatar AndrewFasano commented on August 19, 2024

Hm, it looks like you're passing the args right. The first thing that might be the issue is that the snapshot you're restoring to was probably taken without those network arguments which might cause a problem, I'm not positive if qemu allows you do change the nic forwarding args when loading a snapshot, but it didn't give you an error so maybe it's allowed. If you run the guest interactively on the command line instead of with pypanda, do you see anything differet?

panda-system-x86_64 ~/.panda/bionic-server-cloudimg-amd64-noaslr-nokaslr.qcow2 -nographic -net nic -net user,hostfwd=tcp::2222-:22 -loadvm root

See if that works, or even drop the -loadvm root and wait for the guest to boot, then test it?

Also are you sure an ssh server is running inside the guest? Might be worth running netcat in the guest listening on port 22 to see if any traffic shows up

from panda.

Kirito0 avatar Kirito0 commented on August 19, 2024

If I run the following command I get an error.

panda-system-x86_64 ~/.panda/bionic-server-cloudimg-amd64-noaslr-nokaslr.qcow2 -nographic -net nic -net user,hostfwd=tcp::8888-:8888 -loadvm root

image

If I remove -loadvm root it works fine. I transferred port 8888 of the virtual machine to port 8888 of the host, and used nc to send data, but still did not get any response.

image

from panda.

Kirito0 avatar Kirito0 commented on August 19, 2024

Thank you so much guys, my problem was solved very well!

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.