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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/knj/win_tightvnc.rb', line 2
def initialize(args)
@args = ArrayExt.hash_sym(args)
@args[:port] = 5900 if !@args[:port]
@args[:port_http] = 5800 if !@args[:http_port]
raise "No path given." if !@args[:path]
exefile = @args[:path] + "/WinVNC.exe"
raise "#{exefile} was not found." if !File.exists?(exefile)
@wmi = WIN32OLE.connect("winmgmts://")
processes = @wmi.ExecQuery("SELECT * FROM win32_process")
ended = false
for process in processes do
if process.Name == "WinVNC.exe"
process.Terminate
ended = true
end
end
sleep 1 if ended
Win::Registry.set(:cur_user, 'Software\ORL\WinVNC3', [
["AutoPortSelect", 1, :dword],
["BlankScreen", 0, :dword],
["DontSetHooks", 0, :dword],
["DontUseDriver", 0, :dword],
["DriverDirectAccess", 1, :dword],
["EnableFileTransfers", 1, :dword],
["HTTPPortNumber", @args[:port_http], :dword],
["IdleTimeout", 0, :dword],
["InputsEnabled", 1, :dword],
["LocalInputsDisabled", 0, :dword],
["LocalInputsPriority", 0, :dword],
["LocalInputsPriorityTime", 3, :dword],
["LockSetting", 0, :dword],
["OnlyPollConsole", 1, :dword],
["OnlyPollOnEvent", 0, :dword],
["PollForeground", 1, :dword],
["PollFullScreen", 0, :dword],
["PollingCycle", 300, :dword],
["PollUnderCursor", 0, :dword],
["PollUnderCursor", @args[:port], :dword],
["QueryAccept", 0, :dword],
["QueryAllowNoPass", 0, :dword],
["QuerySetting", 2, :dword],
["QueryTimeout", 30, :dword],
["RemoveWallpaper", 0, :dword],
["SocketConnect", 1, :dword],
["Password", ["160e9d46f26586ca"].pack('H*'), :bin],
["PasswordViewOnly", ["160e9d46f26586ca"].pack('H*'), :bin]
])
Win::Registry.set(:local_machine, 'Software\ORL\WinVNC3', [
["AllowLoopback", 1, :dword],
["LoopbackOnly", 0, :dword]
])
@wmi = WIN32OLE.connect("winmgmts://")
processes = @wmi.ExecQuery("SELECT * FROM win32_process")
ended = false
for process in processes do
if process.Name == "WinVNC.exe"
process.Terminate
ended = true
end
end
sleep 1 if ended
Knj::Thread.new do
IO.popen(exefile) do |process|
end
end
sleep 1
@processes = @wmi.ExecQuery("SELECT * FROM win32_process")
for process in @processes do
if process.Name == "WinVNC.exe"
@process = process
break
end
end
raise "Could not start WinVNC.exe." if !@process
Kernel.at_exit do
self.close
end
end
|