This repository was archived by the owner on May 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug.py
More file actions
53 lines (43 loc) · 1.4 KB
/
debug.py
File metadata and controls
53 lines (43 loc) · 1.4 KB
1
2
3
4
5
6
7
8
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#coding = utf-8
import os, sys
import vmware
from ctypes import *
import subprocess
debug = r'd:\src\pe\build\nmake.win32\debug'
bin = "bin\\petool.exe"
parm = r'c:\windows\system32\kernel32.dll'
#启动虚拟机
vm_path = r"d:\ace\debugger_wxpsp3cn\debugger_wxpsp3cn.vmx"
username = None
password = None
snapshot = None
vm = vmware.VMWare()
vm.Connect( c_int(0), 0, c_int(0), c_int(0), 0 )
vm.OpenVM(vm_path, vmware.VIX_VMOPEN_NORMAL)
username = "administrator"
password = ""
snapshot = "ready"
remote_dir = "C:\\debug"
vm.GetNamedSnapshot(snapshot)
vm.RevertToSnapshot(0)
vm.LoginInGuest(username, password, 0)
vm.CreateDirectoryInGuest(remote_dir)
#将debug目录下所有文件复制到目标虚拟机中
for root, dirs, files in os.walk(debug):
for name in files:
dir_name = root.replace(debug, remote_dir)
remote_file = os.path.join(dir_name, name);
local_file = os.path.join(root, name)
vm.CopyFileFromHostToGuest(local_file, remote_file, 0)
for name in dirs:
dir_name = root.replace(debug, remote_dir)
remote = os.path.join(dir_name, name)
vm.CreateDirectoryInGuest(remote)
#启动远程连接
print os.path.join(remote_dir, bin)
cmdline = ["d:\\app\\windbg\\x86\\windbg.exe",
"-premote",
"tcp:port=6422, server=192.168.184.11",
"%s" % os.path.join(remote_dir, bin),
parm]
subprocess.call(cmdline)