Skip to content

Instantly share code, notes, and snippets.

@mjdorma
mjdorma / adb-stty-cd-data-local-tmp2.diff
Last active August 29, 2015 14:18 — forked from jduck/adb-stty-cd-data-local-tmp2.diff
Patch for AOSP's adb client to automatically change directory, set terminal size, and set environment vars.
#
# patch adb to:
# 1. use busybox to set the same terminal size
# 2. change directory to /data/local/tmp automatically
#
# NOTE: needs an executable busybox in /data/local/tmp
#
# Joshua J. Drake - jduck
#
@mjdorma
mjdorma / pyvbox: setup appliance description and import_machines.py
Last active June 30, 2019 18:45
pyvbox: setup appliance description and import_machines.
"""pyvbox: setup appliance description and import_machines.
"""
import virtualbox
vbox = virtualbox.VirtualBox()
# Create new IAppliance and read the exported machine
# called 'ubuntu'.
appliance = vbox.create_appliance()
appliance.read("~/Documents/ubuntu.ova")
@mjdorma
mjdorma / pyvbox: Rename virtual machine.py
Last active August 29, 2015 14:00
pyvbox: Rename virtual machine.
"""pyvbox: Rename virtual machine.
"""
import virtualbox
vbox = virtualbox.VirtualBox()
vm = vbox.find_machine('oldname')
# Option #1
session = vm.create_session()
session.machine.name = 'newname'
@mjdorma
mjdorma / begin.until.choices.py
Last active August 29, 2015 13:57
begin.utils.choices
"""Assert a choice for the value of an argument.
Example::
@begin.start
@choices(foo=['meh', 'one'])
def main(foo):
print(foo)
"""
@mjdorma
mjdorma / script_subcommand.py
Last active August 29, 2015 13:57
begins: run a series of subcommands
"""
Run a series of subcommands from the script file.
"""
import shlex
import begin
import __main__
@begin.subcommand
@begin.convert(script=begin.utils.tofile())
def script(script):
@mjdorma
mjdorma / pyvbox: Register for decoded keystrokes.py
Last active April 20, 2022 12:40
pyvbox: Register for decoded keystrokes
"""pyvbox: Register for decoded keystrokes
The following code will print key press events from the guest
VM to the host's stdout.
"""
import sys
import virtualbox
vbox = virtualbox.VirtualBox()
m = vbox.find_machine("win7")
@mjdorma
mjdorma / pyvbox: Video capture to file.py
Last active August 29, 2015 13:56
pyvbox: Video capture to file.
"""pyvbox: Video capture to file.
"""
import os
import time
import virtualbox
# Assume machine is already running.
vbox = virtualbox.VirtualBox()
machine = vbox.find_machine("win7")
session = machine.create_session()
@mjdorma
mjdorma / pyvbox: Capture network traffic from adapter.py
Last active August 24, 2018 15:43
pyvbox: Capture network traffic from adapter.
"""pyvbox: Capture network traffic from adapter.
"""
import os
import time
import virtualbox
# Assume machine is already running.
vbox = virtualbox.VirtualBox()
machine = vbox.find_machine("win7")
session = machine.create_session()
@mjdorma
mjdorma / pyvbox: How to copy a file from a VM.py
Last active September 16, 2019 11:40
pyvbox: How to copy a file from a VM
"""pyvbox: How to copy a file from a VM.
"""
import os
import virtualbox
# Assume machine is already running.
vbox = virtualbox.VirtualBox()
machine = vbox.find_machine("win7")
session = machine.create_session()
@mjdorma
mjdorma / pyvbox: How to set the attachment_type of a network adapter.py
Last active February 19, 2019 23:37
pyvbox: set attachment type of network adapter for VirtualBox machine to "host_only"
"""pyvbox:How to set the attachment_type of a network adapter.
"""
import virtualbox
from virtualbox.library import NetworkAttachmentType
# Option 1
vbox = virtualbox.VirtualBox()
machine = vbox.find_machine('test_vm')
session = machine.create_session()