1
2 '''
3 vmware controler for Peach Agent. Allows manipulating the state of a vm
4 during a fuzzing run. Common use case here is to revert to a known good
5 state after a fault or N tests.
6
7 @author: Michael Eddington
8 @version: $Id: vm.py 780 2008-03-23 02:58:49Z meddingt $
9 '''
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 import sys
39 from Peach.agent import Monitor
40
41 try:
42 from vix import Vix
43 except:
44 print "Warning: Module pyvix not found. VMWare Monitor will not function."
45
47 '''
48 Control a vmware server instance to start/revert the
49 target vm.
50 '''
51
53 '''
54 Start VM
55 '''
56
57 index = -1
58
59 try:
60 if args['snapshotindex'] != None:
61 index = int(args['snapshotindex'])
62 except:
63 pass
64
65 self.vm = Vix()
66
67 try:
68 self.vm.Connect(str(args['host']))
69 except:
70 self.vm.Connect()
71
72 print "About to open:", args['vmx']
73 self.vm.Open(str(args['vmx']))
74
75 if index > -1:
76 self.vm.GetRootSnapshot(index)
77 else:
78 self.vm.GetRootSnapshot()
79
80 self.vm.RevertToSnapshot()
81
83 '''
84 On a fault, restart VM to save point.
85 '''
86 self.vm.RevertToSnapshot()
87
89 '''
90 Shutdown vm
91 '''
92 self.vm.PowerOff()
93 self.vm.Disconnect()
94
95
96