Exemplo n.º 1
0
def do_snapshot(image, vmname, ipaddr, resolution, ramsize, cpus,
                hostname, adapter, vm_visible):
    m, h = initvm(image, name=vmname, multi=True, ramsize=ramsize, cpus=cpus)

    m.start_vm(visible=vm_visible)

    wait_for_host(image.ipaddr, image.port)
    a = Agent(image.ipaddr, image.port)
    a.ping()

    # Assign a new hostname.
    a.hostname(hostname)
    a.reboot()
    a.kill()

    # Wait for the reboot to kick in.
    time.sleep(10)
    wait_for_host(image.ipaddr, image.port)
    a.ping()

    if resolution:
        width, height = resolution.split("x")
        a.resolution(width, height)

    a.remove("C:\\vmcloak")
    a.static_ip(ipaddr, image.netmask, image.gateway, h.interface)

    m.snapshot("vmcloak", "Snapshot created by VM Cloak.")
    m.stopvm()

    # Create a database entry for this snapshot.
    snapshot = Snapshot(image_id=image.id, vmname=vmname, ipaddr=ipaddr,
                        port=image.port, hostname=hostname)
    return snapshot
Exemplo n.º 2
0
def do_snapshot(image, vmname, ipaddr, resolution, ramsize, cpus,
                hostname, adapter, vm_visible):
    m, h = initvm(image, name=vmname, multi=True, ramsize=ramsize, cpus=cpus)

    m.start_vm(visible=vm_visible)

    wait_for_host(image.ipaddr, image.port)
    a = Agent(image.ipaddr, image.port)
    a.ping()

    # Assign a new hostname.
    a.hostname(hostname)
    a.reboot()
    a.kill()

    # Wait for the reboot to kick in.
    time.sleep(10)
    wait_for_host(image.ipaddr, image.port)
    a.ping()

    if resolution:
        width, height = resolution.split("x")
        a.resolution(width, height)

    a.remove("C:\\vmcloak")
    a.static_ip(ipaddr, image.netmask, image.gateway, h.interface)

    m.snapshot("vmcloak", "Snapshot created by VM Cloak.")
    m.stopvm()

    # Create a database entry for this snapshot.
    snapshot = Snapshot(image_id=image.id, vmname=vmname, ipaddr=ipaddr,
                        port=image.port, hostname=hostname)
    return snapshot
Exemplo n.º 3
0
def do_snapshot(image, vmname, ipaddr, resolution, ramsize, cpus, hostname,
                adapter, vm_visible, vrde, vrde_port, interactive):
    m, h = initvm(image, name=vmname, multi=True, ramsize=ramsize, cpus=cpus)

    if vrde:
        m.vrde(port=vrde_port)

    m.start_vm(visible=vm_visible)

    wait_for_host(image.ipaddr, image.port)
    a = Agent(image.ipaddr, image.port)
    a.ping()

    # Assign a new hostname.
    a.hostname(hostname)
    a.reboot()
    a.kill()

    # Wait for the reboot to kick in.
    time.sleep(10)
    wait_for_host(image.ipaddr, image.port)
    a.ping()

    if resolution:
        width, height = resolution.split("x")
        a.resolution(width, height)

    if interactive:
        a.upload(
            "C:\\vmcloak\\interactive.txt",
            "Please make your final changes to this VM. When you're"
            "done, close this window and we'll create a snapshot.")

        log.info("You've started the snapshot creation in interactive mode!")
        log.info("Please make your last changes to the VM.")
        log.info(
            "When you're done close the spawned notepad process in the VM to take the final snapshot."
        )
        a.execute("notepad.exe C:\\vmcloak\\interactive.txt", async=False)

    a.remove("C:\\vmcloak")
    a.static_ip(ipaddr, image.netmask, image.gateway, h.interface)
    m.snapshot("vmcloak", "Snapshot created by VMCloak.")
    m.stopvm()

    # Create a database entry for this snapshot.
    snapshot = Snapshot(image_id=image.id,
                        vmname=vmname,
                        ipaddr=ipaddr,
                        port=image.port,
                        hostname=hostname)
    return snapshot
Exemplo n.º 4
0
def do_snapshot(image, vmname, ipaddr, resolution, ramsize, cpus,
                hostname, adapter, vm_visible, vrde, vrde_port, interactive):
    m, h = initvm(image, name=vmname, multi=True, ramsize=ramsize, cpus=cpus)

    if vrde:
        m.vrde(port=vrde_port)

    m.start_vm(visible=vm_visible)

    wait_for_host(image.ipaddr, image.port)
    a = Agent(image.ipaddr, image.port)
    a.ping()

    # Assign a new hostname.
    a.hostname(hostname)
    a.reboot()
    a.kill()

    # Wait for the reboot to kick in.
    time.sleep(10)
    wait_for_host(image.ipaddr, image.port)
    a.ping()

    if resolution:
        width, height = resolution.split("x")
        a.resolution(width, height)

    if interactive:
        a.upload("C:\\vmcloak\\interactive.txt",
                 "Please make your final changes to this VM. When you're"
                 "done, close this window and we'll create a snapshot.")

        log.info("You've started the snapshot creation in interactive mode!")
        log.info("Please make your last changes to the VM.")
        log.info("When you're done close the spawned notepad process in the VM to take the final snapshot.")
        a.execute("notepad.exe C:\\vmcloak\\interactive.txt", async=False)

    a.remove("C:\\vmcloak")
    a.static_ip(ipaddr, image.netmask, image.gateway, h.interface)
    m.snapshot("vmcloak", "Snapshot created by VMCloak.")
    m.stopvm()

    # Create a database entry for this snapshot.
    snapshot = Snapshot(image_id=image.id, vmname=vmname, ipaddr=ipaddr,
                        port=image.port, hostname=hostname)
    return snapshot
Exemplo n.º 5
0
def snapshot(name, vmname, ipaddr, resolution, ramsize, cpus, hostname,
             adapter, vm_visible):
    session = Session()

    image = session.query(Image).filter_by(name=name).first()
    if not image:
        log.error("Image not found: %s", name)
        exit(1)

    # From now on this image is multiattach.
    image.mode = "multiattach"
    session.commit()

    m, h = initvm(image, name=vmname)

    m.start_vm(visible=vm_visible)

    wait_for_host(image.ipaddr, image.port)
    a = Agent(image.ipaddr, image.port)
    a.ping()

    # Assign a new hostname.
    a.hostname(hostname)
    a.reboot()
    a.kill()

    # Wait for the reboot to kick in.
    time.sleep(10)
    wait_for_host(image.ipaddr, image.port)
    a.ping()

    if resolution:
        width, height = resolution.split("x")
        a.resolution(width, height)

    a.remove("C:\\vmcloak")
    a.static_ip(ipaddr, image.netmask, image.gateway, h.interface)

    m.snapshot("vmcloak", "Snapshot created by VM Cloak.")
    m.stopvm()

    # Create a database entry for this snapshot.
    snapshot = Snapshot(image_id=image.id, vmname=vmname, ipaddr=ipaddr,
                        port=image.port, hostname=hostname)
    session.add(snapshot)
    session.commit()