Commit e907231f authored by Yvan Masson's avatar Yvan Masson
Browse files

Initial commit

parents
#!/bin/sh
# RemoteHelpBuilder
# Copyright (C) 2017-2019 Yvan Masson <https://masson-informatique.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# package and script name
debian_package_name="$(basename $0)"
# retrieve variables
# shellcheck source=./variables
. /usr/share/"$debian_package_name"/variables
vnc_error_file=$(mktemp)
#####################
# Asking SSH password
#####################
pwd=$(yad \
--title "$window_title" \
--width=450 \
--window-icon="$icon" \
--text="$initial_msg" \
--entry --editable \
--entry-label="$initial_msg_pwd" \
--center)
if [ $? != 0 ]; then exit; fi
################
# SSH connection
################
export SSHPASS="$pwd"
sshpass -e ssh -o "GlobalKnownHostsFile=/usr/share/$debian_package_name/ssh_known_hosts" -p "$ssh_port" -T -N -R \*:"$vnc_port":localhost:"$vnc_port" "$remote_user"@"$server" &
sshpass_pid=$!
yad \
--title "$window_title" \
--width=450 \
--window-icon="$icon" \
--timeout="$ssh_max_connection_time" \
--timeout-indicator=bottom \
--text "$waiting_connection_msg" \
--no-buttons \
--no-escape \
--center
ssh_pid=$(ps -ef | grep -v sshpass | grep " ssh .*$server$" | sed 's/[[:space:]]\+/ /g' | cut -d " " -f 2)
if [ "$ssh_pid" = "" ]; then
ssh_pid="ssh_pid_not_found"
fi
if ! lsof -i | grep "^ssh" | grep " $ssh_pid " | grep "ESTABLISHED"
then
yad \
--title "$window_title" \
--width=450 \
--window-icon="$icon" \
--image="$error_icon" \
--text "$ssh_failed_msg" \
--button="$ssh_failed_button" \
--center
kill -9 "$sshpass_pid"
exit
fi
#####################
# Starting VNC server
#####################
x11vnc -localhost -forever -ncache 10 2> "$vnc_error_file" &
x11vnc_pid=$!
yad \
--title "$window_title" \
--width=450 \
--window-icon="$icon" \
--timeout="$vnc_max_start_time" \
--timeout-indicator=bottom \
--text "$waiting_vnc_startup_msg" \
--no-buttons \
--no-escape \
--center
if ! lsof -i | grep "^x11vnc" | grep " $x11vnc_pid " | grep "LISTEN"
then
yad \
--title "$window_title" \
--width=450 \
--window-icon="$icon" \
--image="$error_icon" \
--text "$vnc_failed_msg" \
--button="$vnc_failed_button" \
--center
kill -9 "$sshpass_pid" "$ssh_pid"
exit
fi
#########
# Working
#########
yad \
--title "$window_title" \
--width=450 \
--window-icon="$icon" \
--text "$help_ongoing_msg" \
--button="$help_ongoing_button" \
--no-escape \
--center
########
# Ending
########
kill -9 "$x11vnc_pid" "$sshpass_pid" "$ssh_pid"
rm "$vnc_error_file"
#!/bin/sh
# the intermediate server IP address or FQDN
server="help.my-domain-name.com"
# the port SSH listens on of the intermediate server
ssh_port="80"
# the user to connect to on the intermediate server
remote_user="remote-help"
# the port to forward to the intermediate server
vnc_port="5900"
# main icon name, or empty quotes ("") if you do not want an icon
icon="my-remote-help"
# icon that appears when an error is detected
error_icon="dialog-warning"
# title that appear on every windows
window_title="My remote help tool"
# text that appears on the button that initiate connection
initial_button="Validate"
# first window message
initial_msg="To get help:
- give me a phone call so that I give you a password
- type this password in the box
- click on $initial_button to initiate connection"
# first window entry label
initial_msg_pwd="password:"
# time before checking that SSH connection is done, in seconds
ssh_max_connection_time="10"
# corresponding message to show to the user
waiting_connection_msg="Connecting…"
# if the SSH connection does not succeed
ssh_failed_msg="Sorry, connection could not be be established."
ssh_failed_button="Quit"
# starting VNC server
waiting_vnc_startup_msg="Starting remote control…"
# time before checking that VNC server has properly started
vnc_max_start_time="3"
# Message shown when the VNC server can not start. Error returned by x11vnc will
# be displayed on a new line.
vnc_failed_msg="Sorry, remote control software could not be started:"
vnc_failed_button="Quit"
help_ongoing_msg="Connection established. Once assistance is finished please click on the button below."
help_ongoing_button="End connection and quit"
This diff is collapsed.
1.1 (2019-04-26)
- Initial release
; See http://www.jrsoftware.org/ishelp/index.php for documentation
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{396DB1FD-DA50-4D34-9EA2-E8217E3AB7E8}
AppName=My Remote Help Tool
AppVersion=1.1
AppPublisher=My Name
; Optional
AppPublisherURL=https://my-website.com
; Will install by default in "%PROGRAMFILES (X86)%" on Windows 64bits
DefaultDirName={pf32}\{#SetupSetting("AppName")}
SetupIconFile=My-icon.ico
; The end of the following value to append version to the installer
OutputBaseFilename=my-remote-help-tool_{#SetupSetting("AppVersion")}
; You should not need to modify those variables
DisableProgramGroupPage=yes
LicenseFile=Licence.txt
Compression=lzma
SolidCompression=yes
[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"
Name: "fr"; MessagesFile: "compiler:Languages\French.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
[Files]
Source: "RemoteHelp.vbs"; DestDir: "{app}"; Flags: ignoreversion
Source: "*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{commonprograms}\{#SetupSetting("AppName")}"; Filename: "{app}\RemoteHelp.vbs"; IconFilename: "{app}\{#SetupSetting("SetupIconFile")}"
Name: "{commondesktop}\{#SetupSetting("AppName")}"; Filename: "{app}\RemoteHelp.vbs"; IconFilename: "{app}\{#SetupSetting("SetupIconFile")}"; Tasks: desktopicon
[InstallDelete]
Type: files; Name: {app}\Putty*
Type: files; Name: {app}\UltraVNC*
This software uses files from different softwares and under different licences
and copyright (following files paths refer to the installation directory):
- PuTTY, under the MIT licence. Files are located under "PuTTY\" directory,
and full licence and copyright in "PuTTY\LICENCE"
- UltraVNC, under the GPL version 2 or higher. Files are located under
"UltraVNC\, and full licence and copyright in "UltraVNC\Readme.txt"
- RemoteHelpBuilder, under the GPL version 3. File is "RemoteHelp.vbs" and
includes copyright information.
' Remote Help Builder
' Copyright (C) 2017-2019 Yvan Masson <https://masson-informatique.fr>
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
' intermediate server FQDN or IP address
server="help.my-company.com"
' intermediate server's SSH port
ssh_port="80"
' SSH public key of the server (beware of the triple quotes)
hostkey="""ssh-ed25519 256 e5:32:8f:c3:fb:c6:e3:6e:8a:45:78:dc:d8:5c:84:03"""
' title that will be displayed on all the windows
windows_title="Help by My Company"
' first message show to the user
initial_message="To get help:" & vbCrlf & _
"- give me a phone call so that I give you a password" & vbCrlf & _
"- type this password in the box" & vbCrlf & _
"- click on OK to initiate connection"
' string displayed when waiting for SSH connection
connecting="Connecting..."
' string displayed when SSH server denies connection
wrong_password="Could not connect to " & server & ": incorrect password?"
' string displayed when SSH connection fails without log (should not happen)
unknown_ssh_error="Could not connect to " & server & ". Please try again."
' string displayed when SSH fails but returning an error message (the error
' message will be displayed on a new line after this)
ssh_error="Could not connect to " & server & ":"
' string displayed when starting VNC server
vnc_start="Starting remote control software..."
' string displayed when UltraVNC fails to start
vnc_error="Could not start remote control software, aborting."
' string displayed when help is ongoing
help_ongoing="Connection established." & _
"Once assistance is finished please click ""OK"" to close the connection."
' time to wait for SSH connection (milliseconds)
ssh_delay=13000
' time to wait for VNC startup (milliseconds)
vnc_delay=3000
' you should not need to change this
ssh_user="remote-help"
'''''''''''
' Functions
'''''''''''
' display msgbox in another process
' Written by Denis St-Pierre
Function ProgressMsg( strMessage, strWindowTitle )
Set wshShell = WScript.CreateObject( "WScript.Shell" )
strTEMP = wshShell.ExpandEnvironmentStrings( "%TEMP%" )
If strMessage = "" Then
On Error Resume Next
objProgressMsg.Terminate( )
On Error Goto 0
Exit Function
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
strTempVBS = strTEMP + "\" & "tmp-message.vbs"
Set objTempMessage = objFSO.CreateTextFile( strTempVBS, True )
objTempMessage.WriteLine( "MsgBox""" & strMessage & """, 4096, """ & strWindowTitle & """" )
objTempMessage.Close
On Error Resume Next
objProgressMsg.Terminate( )
On Error Goto 0
Set objProgressMsg = WshShell.Exec( "%windir%\system32\wscript.exe " & strTempVBS )
Set wshShell = Nothing
Set objFSO = Nothing
End Function
' Function to check if a process is running
function isProcessRunning(strComputer, strProcess)
Dim Process, strObject
IsProcessRunning = False
strObject = "winmgmts://" & strComputer
For Each Process in GetObject( strObject ).InstancesOf("Win32_process")
If UCase(Process.name) = UCase(strProcess) Then
IsProcessRunning = True
Exit Function
End If
Next
IsProcessRunning = False
end function
'''''''''''''
' Main script
'''''''''''''
Dim ObjProgressMsg
' get program path
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
path = objFSO.GetParentFolderName(objFile)
' get user temp folder
Set oShell = CreateObject( "WScript.Shell" )
user_temp=oShell.ExpandEnvironmentStrings("%TEMP%")
passwd=inputbox(initial_message, windows_title)
if passwd = "" Then Wscript.Quit
' kill old processes that could remain
Dim WshShell : Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "taskkill /F /im plink.exe", 0, true
WshShell.Run "taskkill /F /im uvnc.exe", 0, true
' start ssh
WSHShell.run "cmd /c """""&path&"\PuTTY\plink.exe"" -l " & ssh_user & " " & _
"-pw " & passwd & " -T -N -R 5900:localhost:5900 -P " & ssh_port & " " & _
server & " -hostkey " & hostkey & " " & _
"> %TEMP%\plink-stdout.log 2> %TEMP%\plink-stderr.log""", 0, false
ProgressMsg connecting, windows_title
Wscript.sleep ssh_delay
ProgressMsg "", windows_title
' if ssh password is denied
InputFile = user_temp&"\plink-stderr.log"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set rdFile = FSO.OpenTextFile(InputFile, 1)
strContents = rdFile.ReadAll
rdFile.Close
if not InStr(1, strContents, "Access Denied", 1) > 0 then
WshShell.Run "taskkill /F /im plink.exe", 0, False
msgbox wrong_password, vbOkOnly, windows_title
FSO.DeleteFile InputFile
Wscript.Quit
end if
' eventually display ssh error
if not isProcessRunning(".","plink.exe") then
InputFile = user_temp&"\plink-stderr.log"
Set FSO = CreateObject("Scripting.FileSystemObject")
set objFile = FSO.GetFile(InputFile)
if objFile.size = "0" then
msgbox unknown_ssh_error, vbOKOnly, windows_title
else
Set oFile = FSO.OpenTextFile(InputFile)
errorlog = oFile.ReadAll
oFile.Close
msgbox ssh_error & vbCrlf & vbCrlf & errorlog, vbOKOnly, windows_title
end if
WshShell.Run "taskkill /F /im plink.exe", 0, False
Wscript.Quit
end if
' start UltraVNC
WSHShell.run """"&path&"\UltraVNC\winvnc.exe"" -run", 0, false
ProgressMsg vnc_start, windows_title
Wscript.sleep vnc_delay
ProgressMsg "", windows_title
' eventually display UltraVNC error
if not isProcessRunning(".","winvnc.exe") then
msgbox vnc_error, vbOKOnly, windows_title
WshShell.Run "taskkill /F /im plink.exe", 0, False
Wscript.Quit
end if
msgbox help_ongoing, vbOKOnly, windows_title
' finally kill processes
WshShell.Run "taskkill /F /im plink.exe", 0, False
WshShell.Run "taskkill /F /im winvnc.exe", 0, False
[ultravnc]
passwd=2A4180B2E31F579086
passwd2=2A4180B2E31F579086
[admin]
UseRegistry=0
MSLogonRequired=0
NewMSLogon=0
DebugMode=2
Avilog=0
path=C:\Program Files (x86)\uvnc bvba\UltraVNC
kickrdp=0
service_commandline=
DebugLevel=10
DisableTrayIcon=0
rdpmode=0
LoopbackOnly=1
UseDSMPlugin=0
AllowLoopback=1
AuthRequired=1
ConnectPriority=0
DSMPlugin=
AuthHosts=
AllowShutdown=1
AllowProperties=1
AllowEditClients=1
FileTransferEnabled=1
FTUserImpersonation=1
BlankMonitorEnabled=1
BlankInputsOnly=0
DefaultScale=1
SocketConnect=1
HTTPConnect=0
AutoPortSelect=1
PortNumber=5900
HTTPPortNumber=5800
IdleTimeout=0
IdleInputTimeout=0
RemoveWallpaper=0
RemoveAero=0
QuerySetting=1
QueryTimeout=10
QueryAccept=0
QueryIfNoLogon=0
primary=1
secondary=0
InputsEnabled=1
LockSetting=0
LocalInputsDisabled=0
EnableJapInput=0
FileTransferTimeout=1
clearconsole=0
accept_reject_mesg=
KeepAliveInterval=5
[poll]
TurboMode=1
PollUnderCursor=0
PollForeground=0
PollFullScreen=1
OnlyPollConsole=0
OnlyPollOnEvent=0
EnableDriver=0
EnableHook=1
EnableVirtual=0
SingleWindow=0
SingleWindowName=
MaxCpu=40
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment