commit ef4ee4c38a8bb47a60a9ecbc7d156499a09b8e9d Author: Yorick Date: Tue Apr 5 16:52:05 2016 +0200 First commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..07187b9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +*.ps1 diff +*.cmd diff +*.ini diff +*.txt diff +*.svg diff +*.conf diff diff --git a/assets/avatar.svg b/assets/avatar.svg new file mode 100644 index 0000000..cc5fcae --- /dev/null +++ b/assets/avatar.svg @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/buildscript.ps1 b/buildscript.ps1 new file mode 100644 index 0000000..3e190e7 --- /dev/null +++ b/buildscript.ps1 @@ -0,0 +1,148 @@ +param([string]$appconf="", [string]$hotliners="") +#PS build script for PersonnalHelpDesk +# +#Version 0.1 + +$VERSION = "0.1" +$WORKING_DIR = Split-Path -path $($MyInvocation.MyCommand.Definition) +$BUILD_DIR = $WORKING_DIR + "\build" +$UTILS_DIR = $WORKING_DIR + "\utils" +$TMP_DIR = $WORKING_DIR + "\tmp" +$SRC_DIR = $WORKING_DIR + "\src" +$PS_EXEC_NAME = "launcher.exe" +$FINAL_EXEC_NAME = "helpdesk.exe" + +$VNC_URL = "http://www.uvnc.com/component/jdownloads/finish/5-bins/295-ultravnc-1210-all-bin-zip/0.html" +$PS2EXE_URL = "https://gallery.technet.microsoft.com/PS2EXE-Convert-PowerShell-9e4e07f1/file/134627/1/" +$7Z_URL = "http://www.7-zip.org/a/7za920.zip" +$7ZSFX_URL = "http://7zsfx.info/files/7zsd_160_2712.7z" + +function create_dir { + param([string]$dir) + if (Test-Path $dir){ + return $false + } + New-Item $dir -type directory | Out-Null + return $true + +} + +function extract{ + param( + [string]$dest_path, + [string]$zip_path + ) + $shell = new-object -com Shell.Application + Try { + $shell.NameSpace($dest_path).CopyHere($zip_path) | Out-Null + Write-Host -ForegroundColor Green "done" + } + Catch { + Write-Host -ForegroundColor Red " Error " + } +} + +function download_util{ + param( + [string]$util, + [string]$source, + [string]$file_to_extract + ) + create_dir "$UTILS_DIR\$VERSION\$util" + Write-Host -ForegroundColor white -NoNewline "Downloading $util please wait ... " + Try { + (New-Object System.Net.WebClient).DownloadFile($source,"$TMP_DIR\$util.zip") + } + Catch { + Write-Host -ForegroundColor Red " Error bad URL? " + return + } + Write-Host -ForegroundColor Green -NoNewline "done" + if ($file_to_extract -ne "false"){ + Write-Host -ForegroundColor white -NoNewLine " ... extracting : " + extract "$UTILS_DIR\$VERSION\$util\" "$TMP_DIR\$util.zip\$file_to_extract" + } +} + +if ( -Not $appconf -Or -Not (Test-Path $appconf) ){ + Write-Host -ForegroundColor White "Application configuration file $appconf not found, using default" + $appconf = "$SRC_DIR\res\conf\app.conf.ps1" +} + +if ( -Not $hotliners -Or -Not (Test-Path $hotliners) ){ + Write-Host -ForegroundColor White "Application configuration file $hotliners not found, using default" + $hotliners = "$SRC_DIR\res\conf\hotliners.conf.ps1" +} + + +if (-not (create_dir $BUILD_DIR)){ + Remove-Item $BUILD_DIR\* -recurse +} +create_dir $UTILS_DIR | Out-Null +create_dir $TMP_DIR | Out-Null +if ( create_dir $UTILS_DIR\$VERSION ) { + #then download VNC + PS2EXE + download_util "vnc" $VNC_URL "win7\winvnc.exe" + download_util "ps2exe" $PS2EXE_URL "*" + download_util "7z" $7Z_URL "7za.exe" + (New-Object System.Net.WebClient).DownloadFile($7ZSFX_URL,"$TMP_DIR\7zsd.7z") + cmd -ArgumentList @("/c", "$UTILS_DIR/$VERSION/7z/7za.exe", "e", "$TMP_DIR\7zsd.7z", "7zsd.sfx","-o$UTILS_DIR/$VERSION/", "-y") +} + +#applying personnal parameters +$patched_source = @() +Get-Content $SRC_DIR\helpdesk.ps1 | ForEach-Object { + switch ($_) { + {$_ -match "app.conf.ps1"} { + ForEach ($line in Get-Content $appconf) { + $patched_source += $line + } + break + } + {$_ -match "hotliners.conf.ps1"} { + ForEach ($line in Get-Content $hotliners){ + $patched_source += $line + } + break + } + default{$patched_source += $_} + } +} +$patched_source | Set-Content $BUILD_DIR\helpdesk.ps1 -Encoding "UTF8" +# Build executable from our PS script +Invoke-Expression "$UTILS_DIR\$VERSION\ps2exe\ps2exe.ps1 $BUILD_DIR\helpdesk.ps1 $BUILD_DIR\$PS_EXEC_NAME -noconsole -nested" +Remove-Item $BUILD_DIR\$PS_EXEC_NAME.config +Set-Location $WORKING_DIR + +# Copy all file to build Dir +create_dir $BUILD_DIR\res\ | Out-Null +Copy-Item $SRC_DIR\UltraVNC.ini $BUILD_DIR\res\ +Copy-Item $SRC_DIR\res\* $BUILD_DIR\res\ +Copy-Item $UTILS_DIR\$VERSION\vnc\winvnc.exe $BUILD_DIR\res\ + +create_dir $BUILD_DIR\res\conf\ | Out-Null +if ($appconf -ne "") { + $txtfile = Get-Content $appconf +} +else { + $txtfile = Get-Content $BUILD_DIR\res\conf\app.conf.ps1 +} + +if ($hotliners -ne "") { + Copy-Item $hotliners $BUILD_DIR\res\conf\hotliners.conf.ps1 +} +else { + Copy-Item $SRC_DIR\res\conf\hotliners.conf.ps1 $BUILD_DIR\res\conf\hotliners.conf.ps1 +} + +#Zip all elements +Set-Location $BUILD_DIR +cmd -ArgumentList @("/c", "$UTILS_DIR/$VERSION/7z/7za.exe", "a", "installer.7z", "*") + +#copy file for autoSFX archive. +Copy-Item $WORKING_DIR\src\config.txt $BUILD_DIR\ +Copy-Item $UTILS_DIR\$VERSION\7zsd.sfx $BUILD_DIR\ + +#concatenate binary files for creating ou auto-SFX file +cmd -ArgumentList @("/c", "copy", "/b","7zsd.sfx", "+", "config.txt", "+", "installer.7z", $FINAL_EXEC_NAME) +#Remove-Item $BUILD_DIR -recurse \ No newline at end of file diff --git a/make.cmd b/make.cmd new file mode 100644 index 0000000..9dc4c15 --- /dev/null +++ b/make.cmd @@ -0,0 +1,12 @@ +@echo off +REM Make.cmd +REM -------- +REM Helpdesk.exe build script for PernonnalHelpdesk +cd /d "%~dp0" +echo . +echo Launch build powershell script ... +powershell -ExecutionPolicy Bypass "%~dp0buildscript.ps1" + +REM Exemple of build script with personnal parameters +REM powershell -ExecutionPolicy Bypass "%~dp0buildscript.ps1" -appconf ".\personnal_conf\app.conf.ps1" -hotliners ".\personnal_conf\hotliners.conf.ps1" +PAUSE \ No newline at end of file diff --git a/src/UltraVNC.ini b/src/UltraVNC.ini new file mode 100644 index 0000000..c0189ba --- /dev/null +++ b/src/UltraVNC.ini @@ -0,0 +1,69 @@ +[Permissions] +[admin] +FileTransferEnabled=1 +FTUserImpersonation=1 +BlankMonitorEnabled=1 +BlankInputsOnly=0 +DefaultScale=1 +UseDSMPlugin=0 +DSMPlugin=No Plugin Detected +primary=1 +secondary=0 +SocketConnect=0 +HTTPConnect=0 +AutoPortSelect=1 +InputsEnabled=1 +LocalInputsDisabled=0 +IdleTimeout=0 +EnableJapInput=0 +QuerySetting=2 +QueryTimeout=10 +QueryAccept=0 +LockSetting=0 +RemoveWallpaper=1 +RemoveEffects=0 +RemoveFontSmoothing=0 +RemoveAero=1 +DebugMode=0 +Avilog=0 +path=C:\Users\tech\Desktop\win7 +DebugLevel=10 +AllowLoopback=1 +LoopbackOnly=0 +AllowShutdown=1 +AllowProperties=1 +AllowEditClients=1 +FileTransferTimeout=30 +KeepAliveInterval=5 +IdleInputTimeout=0 +DisableTrayIcon=0 +rdpmode=0 +MSLogonRequired=0 +NewMSLogon=0 +ConnectPriority=0 +UseRegistry=0 +kickrdp=0 +service_commandline= +AuthRequired=1 +AuthHosts= +PortNumber=5900 +HTTPPortNumber=5800 +QueryIfNoLogon=0 +clearconsole=0 +accept_reject_mesg= +[UltraVNC] +passwd=D1495AE77835039EA9 +passwd2=47F0AE72FB5DE16CFC +[poll] +TurboMode=1 +PollUnderCursor=0 +PollForeground=0 +PollFullScreen=1 +OnlyPollConsole=0 +OnlyPollOnEvent=0 +EnableDriver=0 +EnableHook=1 +EnableVirtual=0 +SingleWindow=0 +SingleWindowName= +MaxCpu=40 diff --git a/src/config.txt b/src/config.txt new file mode 100644 index 0000000..16fab7a --- /dev/null +++ b/src/config.txt @@ -0,0 +1,6 @@ +;!@Install@!UTF-8! +Title="ACAQB Helpdesk V0.1A" +GUIMode="1" +BeginPrompt="Vous allez demander une prise de contrôle, voulez-vous continuer?" +ExecuteFile="launcher.exe" +;!@InstallEnd@! \ No newline at end of file diff --git a/src/helpdesk.ps1 b/src/helpdesk.ps1 new file mode 100644 index 0000000..d7e67b5 --- /dev/null +++ b/src/helpdesk.ps1 @@ -0,0 +1,123 @@ + +[reflection.assembly]::LoadWithPartialName( "System.Windows.Forms") | Out-Null +#$ErrorActionPreference = "SilentlyContinue" +$VERSION = "0.1" + +. .\res\conf\app.conf.ps1 +. .\res\conf\hotliners.conf.ps1 + +#Variables +$buttons = @() +$Global:vnc_process = @() + +function start_vnc_session { + param([string]$port) + $Global:vnc_process = Start-Process res\$VNC_EXEC -ArgumentList ("-connect","$VNC_CLIENT_ADDR::$port","-run") -PassThru + $label.text = $MSG_VNC_STARTED +} + +function disable_buttons { + $buttons | ForEach { + $_.Enabled = $false + } +} + + +if ( -Not (Test-Path res\$VNC_EXEC)){ + Write-Host -ForegroundColor Red "Error : VNC executable not found, exiting" + break +} + +$hotliners | Foreach { + $current_btn = New-Object Windows.Forms.Button + $current_btn.text = $_.name + $current_btn.Tag = @{port=$_.port} #Tag=@{Script=$script} + $current_btn.height = $DEFAULT_BTN_HEIGHT + $current_btn.Width = $DEFAULT_BTN_WIDTH + $current_btn.FlatStyle = "Flat" + if ($USE_AVATAR) { + $current_btn.TextAlign = $HOTLINER_BTN_TEXEALIGN + $current_btn.ForeColor = $HOTLINER_BTN_FORECOLOR + if ($_.img){ + $file = Get-Item($_.img) + if (Test-Path $_.img ){ + $file = Get-Item($_.img) + } + else{ + $file = Get-Item("res\avatar.png") + Write-Host -ForegroundColor Yellow "$($_.img) not found, using default image for $($_.name)" + } + } + else { + $file = Get-Item("res\avatar.png") + } + Try { + $current_btn.BackgroundImage = [system.drawing.image]::FromFile($file) + } + Catch { Write-Host -ForegroundColor Red "Error : can't load $file, is this an image?" } + } + $current_btn.add_click({ + start_vnc_session $this.Tag.port + disable_buttons + }) + $buttons += $current_btn +} + + +# Application window definition +$window= New-Object Windows.Forms.Form +$window.text = $WINDOW_TITLE +$window.autosize = $true +$window.AutoSizeMode = "GrowAndShrink" +$window.FormBorderStyle = "FixedDialog" +$window.ControlBox = $false +$window.Padding = $DEFAULT_MARGIN +$window.StartPosition = "CenterScreen" +$window.icon = "res\icon.ico" + +# ControlBox containing label and Buttons +$ctrlbox = New-Object Windows.Forms.GroupBox +$ctrlbox.Location = New-Object Drawing.Point $DEFAULT_MARGIN,$DEFAULT_MARGIN +$ctrlbox.AutoSize=$true +$ctrlbox.Width = $DEFAULT_WINDOW_WIDTH +$ctrlbox.Height = $DEFAULT_MARGIN +$window.controls.add($ctrlbox) + +$xpos = $DEFAULT_MARGIN +$ypos = $DEFAULT_MARGIN * 2 +$label = New-Object Windows.Forms.Label +$label.Height = 40 +$label.Width = $DEFAULT_WINDOW_WIDTH - $DEFAULT_MARGIN * 2 +$label.Location = New-Object Drawing.Point $xpos,$ypos +$label.text = $MSG_HOME +$ctrlbox.controls.add($label) + +$ypos = $label.Bottom + $DEFAULT_MARGIN +$xpos = $DEFAULT_MARGIN + +$buttons | ForEach { + $t = $xpos + $_.Width + $DEFAULT_MARGIN + if ($t -ge $DEFAULT_WINDOW_WIDTH) { + $ypos += ( $DEFAULT_BTN_HEIGHT + $DEFAULT_MARGIN ) + $xpos = $DEFAULT_MARGIN + } + $_.Location = New-Object Drawing.Point $xpos,$ypos + $xpos += $_.Width + $DEFAULT_MARGIN + $ctrlbox.controls.add($_) +} + +$btnClose = New-Object Windows.Forms.Button +$btnClose.text = "Quitter" +$btnClose.Top = $ctrlbox.Bottom + $DEFAULT_MARGIN +$btnClose.Left = $ctrlbox.Right - $btnClose.Width +$btnClose.BackColor = "#ffaa99" +$btnClose.FlatStyle = "Flat" +$window.controls.add($btnClose) + +$btnClose.add_click({ + if ($Global:vnc_process) { + $Global:vnc_process | Stop-Process + } + $window.hide() +}) +$window.ShowDialog() | Out-Null \ No newline at end of file diff --git a/src/res/avatar.png b/src/res/avatar.png new file mode 100644 index 0000000..906df07 Binary files /dev/null and b/src/res/avatar.png differ diff --git a/src/res/conf/app.conf.ps1 b/src/res/conf/app.conf.ps1 new file mode 100644 index 0000000..481dcd6 --- /dev/null +++ b/src/res/conf/app.conf.ps1 @@ -0,0 +1,17 @@ +$VNC_EXEC = "winvnc.exe" +$VNC_CLIENT_ADDR = "" + +#Textual information +$WINDOW_TITLE = "Robco Personnal Helpdesk v.$VERSION" +$MSG_VNC_STARTED = "Hotliner get the control, please leave keyboard and mouse" +$MSG_HOME = "Welcome to our helpdesk program, which technician do you have on phone?" + +# Interface Constants +$DEFAULT_MARGIN = 10 +$DEFAULT_WINDOW_WIDTH = 300 +$DEFAULT_WINDOW_HEIGHT = 0 +$DEFAULT_BTN_HEIGHT = 90 +$DEFAULT_BTN_WIDTH = 90 +$USE_AVATAR = 1 +$HOTLINER_BTN_FORECOLOR = "#FFFFFF" +$HOTLINER_BTN_TEXEALIGN = "BottomCenter" \ No newline at end of file diff --git a/src/res/conf/hotliners.conf.ps1 b/src/res/conf/hotliners.conf.ps1 new file mode 100644 index 0000000..9bf689d --- /dev/null +++ b/src/res/conf/hotliners.conf.ps1 @@ -0,0 +1,4 @@ +$hotliners = ( + @{name = "John Doe"; port = "5500"; img = ""}, + @{name = "Marty Mc Fly"; port = "5501"; img = ""} +) \ No newline at end of file diff --git a/src/res/icon.ico b/src/res/icon.ico new file mode 100644 index 0000000..fb911f9 Binary files /dev/null and b/src/res/icon.ico differ