Skip to content

Instantly share code, notes, and snippets.

@mjdorma
Last active August 24, 2018 15:43
Show Gist options
  • Select an option

  • Save mjdorma/9045130 to your computer and use it in GitHub Desktop.

Select an option

Save mjdorma/9045130 to your computer and use it in GitHub Desktop.

Revisions

  1. mjdorma renamed this gist May 3, 2014. 1 changed file with 0 additions and 0 deletions.
  2. mjdorma revised this gist Feb 17, 2014. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions pyvbox: Capture network traffic from adapter.
    Original file line number Diff line number Diff line change
    @@ -3,14 +3,16 @@
    import os
    import time
    import virtualbox

    # Assume machine is already running.
    vbox = virtualbox.VirtualBox()
    machine = vbox.find_machine("win7")
    machine.launch_vm_process()
    session = machine.create_session()

    # Capture network traffic for 60 seconds.
    adapter = session.machine.get_network_adapter(0)
    adapter.trace_file = os.path.abspath('mycapture.pcap')
    adapter.trace_enabled = True
    # Capture network traffic for 60 seconds.
    time.sleep(60)
    adapter.trace_enabled = False

  3. mjdorma revised this gist Feb 17, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pyvbox: Capture network traffic from adapter.
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ session = machine.create_session()
    adapter = session.machine.get_network_adapter(0)
    adapter.trace_file = os.path.abspath('mycapture.pcap')
    adapter.trace_enabled = True
    # capture network traffic for 60 seconds
    # Capture network traffic for 60 seconds.
    time.sleep(60)
    adapter.trace_enabled = False

  4. mjdorma renamed this gist Feb 17, 2014. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    """pyvbox:Capture network traffic from adapter.
    """pyvbox: Capture network traffic from adapter.
    """
    import os
    import time
  5. mjdorma renamed this gist Feb 17, 2014. 1 changed file with 0 additions and 0 deletions.
  6. mjdorma revised this gist Feb 17, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pyvbox:Capture network traffic from adapter
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ import virtualbox
    vbox = virtualbox.VirtualBox()
    machine = vbox.find_machine("win7")
    machine.launch_vm_process()
    session = m.create_session()
    session = machine.create_session()
    adapter = session.machine.get_network_adapter(0)
    adapter.trace_file = os.path.abspath('mycapture.pcap')
    adapter.trace_enabled = True
  7. mjdorma created this gist Feb 17, 2014.
    16 changes: 16 additions & 0 deletions pyvbox:Capture network traffic from adapter
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    """pyvbox:Capture network traffic from adapter.
    """
    import os
    import time
    import virtualbox
    vbox = virtualbox.VirtualBox()
    machine = vbox.find_machine("win7")
    machine.launch_vm_process()
    session = m.create_session()
    adapter = session.machine.get_network_adapter(0)
    adapter.trace_file = os.path.abspath('mycapture.pcap')
    adapter.trace_enabled = True
    # capture network traffic for 60 seconds
    time.sleep(60)
    adapter.trace_enabled = False