-
Notifications
You must be signed in to change notification settings - Fork 0
/
remoterun.vbs
116 lines (110 loc) · 3.98 KB
/
remoterun.vbs
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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell=Wscript.CreateObject("Wscript.Shell")
'Command format: <command>`<parameter>
Dim Command, Temp, HelpMsg
Function Timestamp ()
strSafeDate = DatePart("yyyy",Date) & "-" & Right("0" & DatePart("m",Date), 2) & "-" & Right("0" & DatePart("d",Date), 2)
strSafeTime = Right("0" & Hour(Now), 2) & " " & Right("0" & Minute(Now), 2) & " " & Right("0" & Second(Now), 2)
Timestamp = strSafeDate & "," & strSafeTime
End Function
Sub AppendToLog (text)
Wscript.Sleep 500
Set WriteFile = objFSO.OpenTextFile ("Logs\log.txt", 8, False)
WriteFile.Write Timestamp & " OUTPUT " & text & vbCrLf
WriteFile.Close
Wscript.Echo Timestamp & " OUTPUT " & text
End Sub
Sub WriteReply (text)
objFSO.CreateTextFile "Output\output.txt", True
Set WriteFile = objFSO.OpenTextFile ("Output\output.txt", 2)
WriteFile.Write text
WriteFile.Close
AppendToLog "Sent reply " & text
End Sub
Sub SendHelp (command)
If command = "" then
Set ReadHelp = objFSO.OpenTextFile ("Help\help.txt", 1)
HelpMsg = ReadHelp.ReadAll
ReadHelp.Close
objFSO.CreateTextFile "Output\output.txt", True
Set WriteFile = objFSO.OpenTextFile ("Output\output.txt", 2)
WriteFile.Write HelpMsg
WriteFile.Close
AppendToLog "Sent general help"
Elseif objFSO.FileExists ("Help\" & command & ".txt") then
Set ReadHelp = objFSO.OpenTextFile ("Help\" & command & ".txt", 1)
HelpMsg = ReadHelp.ReadAll
ReadHelp.Close
objFSO.CreateTextFile "Output\output.txt", True
Set WriteFile = objFSO.OpenTextFile ("Output\output.txt", 2)
WriteFile.Write HelpMsg
WriteFile.Close
AppendToLog "Sent help for command " & command
Else
WriteReply "No help for " & command & " exists."
End If
End Sub
'This is so it doesn't get into a crash loop
If objFSO.FileExists ("Input\command.txt") then
objFSO.DeleteFile ("Input\command.txt")
End if
do
Wscript.Sleep 2000
If objFSO.FileExists ("Input\command.txt") then
Set ReadFile = objFSO.OpenTextFile ("Input\command.txt", 1)
Command = ReadFile.ReadLine
ReadFile.Close
objFSO.DeleteFile ("Input\command.txt")
Wscript.Sleep 2000
'wait for dropbox to sync input
AppendToLog "Received Input: " & Command
if InStr (Command, "`") then
Temp = Split (Command, "`")
if Temp(0) = "run" then
WshShell.Run Temp(1)
WriteReply "Successfully executed " & Temp(1)
elseif Temp(0) = "nircmd" then
WshShell.Run "Utilities\nircmd.exe " & Temp(1)
WriteReply "Successfully executed nircmd.exe " & Temp(1)
elseif Temp(0) = "nircmdc" then
WshShell.Run "Utilities\nircmdc.exe " & Temp(1)
WriteReply "Successfully executed nircmdc.exe " & Temp(1)
elseif Temp (0) = "takescreenshot" then
if Temp(1) = "" then
WshShell.Run ("Utilities\nircmd.exe savescreenshot " & chr(34) & "Screenshots\" & Timestamp & ".png" & chr(34))
WriteReply "Successfully took screenshot with name " & Timestamp & ".png"
else
WshShell.Run ("Utilities\nircmd.exe savescreenshot " & chr(34) & "Screenshots\" & Temp(1) & ".png" & chr(34))
WriteReply "Successfully took screenshot at " & Timestamp & " with name " & Temp(1) & ".png"
end if
elseif Temp (0) = "sendkeys" then
if not Temp(1) = "" then
WshShell.SendKeys Temp (1)
WriteReply "Successfully sent keystrokes " & Temp (1)
end if
elseif Temp(0) = "log" then
AppendToLog Temp(1)
elseif Temp(0) = "reply" then
WriteReply Temp(1)
elseif Temp(0) = "ping" then
WriteReply "Pong!"
elseif Temp(0) = "moo" then
WriteReply "MoooOoOOoOOooOOOooOoOOoooOOooooOOOooo!"
elseif Temp(0) = "help" then
SendHelp Temp(1)
elseif Temp(0) = "exit" then
if Temp(1) = "" then
WriteReply "Successfully quit at " & Timestamp
Wscript.Quit
else
WriteReply "Successfully quit with reason: " & Temp(1)
Wscript.Quit
end if
else
WriteReply "Command invalid. Send help`commands for a listing of commands."
end if
Else
WriteReply "Command missing a `. If you don't want to specify parameters, just send command`."
End If
End If
loop