Certain d'entre vous le savent peut être, je code sous autoit pour aider des gens a distance.
Mais de tout les programme autoit que l'on pourrait imaginer, aucun ne remplacera VNC !
Sauf que voila, j'ai souvent des problème avec lui :/ Il plante, il est mal configuré, l'useur a tué le process car... heu... enfin bref
J'ai donc crée un petit logiciel de control a distance sans prétention me permettant d'accéder a l'ordi facilement pour notamment, relancer VNC !
Le script coté server attend les ordre de clic, ou de send() (dans le future pourra aussi directement exécuter du code autoit reçu)
Prend des capture d'écran et les envoi au client
Le script coté client affiche la capture d'écran du server, récupère les clic sur l'image, les converti en commande et les envoi au server. Une zone de saisie est prévu pour envoyer du texte
Voici le script client/server
► Afficher le texte
Code : Tout sélectionner
#include <ScreenCapture.au3>
#include <GUIConstantsEx.au3>
#Include <Misc.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
; #INDEX# =======================================================================================================================
; Nom .............: µVNC
; Version d'Autoit : v3.3.0.0
; Langage .........: Français
; Description .....: Client/Serveur d'assistance à distance
; Auteur ..........: Damian Iste
; ===============================================================================================================================
If MsgBox(4, "", "Choix") = 6 Then
Serveur()
Else
Client()
EndIf
Func Serveur()
_ScreenCapture_SetJPGQuality(10)
_ScreenCapture_SetTIFColorDepth(24)
; #VARIABLES# ===================================================================================================================
Local $IPaEouter = TCPNameToIP(@ComputerName)
Local $Port = 52001
Local $MainSocket, $ConnectedSocket, $IPdelAccepte
Local $Commande
Local $Data
Local $calcul
Local $GOOEY, $edit, $img
; ===============================================================================================================================
TCPStartup()
$MainSocket = TCPListen($IPaEouter, $Port, 100000)
If $MainSocket = -1 Then
Sleep(100)
Serveur()
EndIf
$GOOEY = GUICreate("Mon Server (IP: " & $IPaEouter & ")", 300, 200)
$edit = GUICtrlCreateEdit("", 10, 10, 280, 180)
GUISetState()
$ConnectedSocket = -1
Do
$ConnectedSocket = TCPAccept($MainSocket)
Until $ConnectedSocket <> -1
$IPdelAccepte = SocketToIP($ConnectedSocket)
While 1
$Commande = TCPRecv($ConnectedSocket, 100000)
If @error Then ExitLoop
If $Commande <> "" Then
GUICtrlSetData($edit," > " & $Commande & @CRLF & GUICtrlRead($edit))
Select
Case StringLeft ($Commande,2) = "ST"
$calcul = StringSplit ($Commande,"||",1)
if IsArray ($calcul) Then Send($calcul[2],1)
Case StringLeft ($Commande,2) = "SE"
$calcul = StringSplit ($Commande,"||",1)
if IsArray ($calcul) Then Send($calcul[2])
Case $Commande = "getinfo"
TCPSend($ConnectedSocket, "getinfo ||" & @DesktopWidth & "||" & @DesktopHeight & "||" & @UserName & "||")
Sleep (1000)
Case StringLeft ($Commande,2) = "GC"
$calcul = StringSplit ($Commande,"||",1)
if IsArray ($calcul) And $calcul[2] > 0 And $calcul[3] > 0 Then MouseClick("left",$calcul[2],$calcul[3],1,0)
Case StringLeft ($Commande,2) = "GD"
$calcul = StringSplit ($Commande,"||",1)
if IsArray ($calcul) Then
MouseMove ($calcul[2],$calcul[3],0)
Sleep(100)
MouseDown ("left")
MouseMove ($calcul[4],$calcul[5],0)
Sleep(100)
MouseUp ("left")
EndIf
;~ if IsArray ($calcul) Then MouseClickDrag("left",$calcul[2],$calcul[3],$calcul[4],$calcul[5],0)
Case StringLeft ($Commande,2) = "DC"
$calcul = StringSplit ($Commande,"||",1)
if IsArray ($calcul) And $calcul[2] > 0 And $calcul[3] > 0 Then MouseClick("right",$calcul[2],$calcul[3],1,0)
Case StringLeft ($Commande,2) = "DD"
$calcul = StringSplit ($Commande,"||",1)
if IsArray ($calcul) Then
MouseMove ($calcul[2],$calcul[3],0)
Sleep(100)
MouseDown ("right")
MouseMove ($calcul[4],$calcul[5],0)
Sleep(100)
MouseUp ("right")
EndIf
;~ if IsArray ($calcul) Then MouseClickDrag("right",$calcul[2],$calcul[3],$calcul[4],$calcul[5],0)
Case StringLeft ($Commande,2) = "CC"
$calcul = StringSplit ($Commande,"||",1)
if IsArray ($calcul) And $calcul[2] > 0 And $calcul[3] > 0 Then MouseClick("middle",$calcul[2],$calcul[3],1,0)
Case StringLeft ($Commande,2) = "CD"
$calcul = StringSplit ($Commande,"||",1)
if IsArray ($calcul) Then
MouseMove ($calcul[2],$calcul[3],0)
Sleep(100)
MouseDown ("middle")
MouseMove ($calcul[4],$calcul[5],0)
Sleep(100)
MouseUp ("middle")
EndIf
EndSelect
Sleep(100)
_ScreenCapture_Capture(@DesktopCommonDir & "\screen.jpg")
$img = FileOpen (@DesktopCommonDir & "\screen.jpg",16)
$Data = FileRead ($img)
TCPSend($ConnectedSocket, $Data)
EndIf
WEnd
If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
TCPShutdown()
GUIDelete($edit)
;~ GUICtrlSetData($edit," > DECO" & @CRLF & GUICtrlRead($edit))
Serveur()
EndFunc ;==>Serveur
Func Client()
$IP = "192.168.1.1"
FileDelete("DL.jpg")
; #VARIABLES# ===================================================================================================================
Local $IPaEouter = TCPNameToIP(@ComputerName)
Local $Port = 52001
Local $MainSocket, $IPduServeur
Local $Commande
Local $ConnectedSocket, $szData
Local $i = 0
Local $calcul, $calcul2
Local $Gui, $msg, $pic, $F5, $Send, $text, $check, $buttoncontext, $buttonitemtext, $buttonitemaide
Local $editgui, $edittext, $editsend
; ===============================================================================================================================
TCPStartup()
;~ $IPduServeur = InputBox("", "", @IPAddress1)
$IPduServeur = InputBox("", "", $IP)
$ConnectedSocket = -1
$ConnectedSocket = TCPConnect($IPduServeur, $Port)
TCPSend($ConnectedSocket, "getinfo")
Sleep(1000)
$Commande = TCPRecv($ConnectedSocket, 100000)
Sleep(1000)
$calcul = StringSplit ($Commande, "||",1)
If IsArray ($calcul) Then
;~ $oIE = ObjCreate("Shell.Explorer.2")
$Gui = GUICreate($calcul[4] & " ( " & $IPduServeur & " )",($calcul[2]),($calcul[3])+25,-1,-1);,$WS_SIZEBOX
$pic = GUICtrlCreatePic("",0,0,($calcul[2]),($calcul[3]))
;~ $pic = GUICtrlCreateObj($oIE,0,0,($calcul[2]),($calcul[3]))
$F5 = GUICtrlCreateButton("Rafraichir",0,$calcul[3],50)
$text = GUICtrlCreateInput ("",55,$calcul[3]+2.5,$calcul[2]-55-55-10,20)
$check = GUICtrlCreateCheckbox("",$calcul[2]-62,$calcul[3]+10,10,10)
GUICtrlSetTip (-1,"Mode texte")
$Send = GUICtrlCreateButton("Send()",$calcul[2]-50,$calcul[3],50)
$buttoncontext = GUICtrlCreateContextMenu($Send)
$buttonitemtext = GUICtrlCreateMenuItem("Envoyer un text", $buttoncontext)
GUICtrlCreateMenuItem("", $buttoncontext, 2)
$buttonitemaide = GUICtrlCreateMenuItem("Guide des commandes", $buttoncontext)
EndIf
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
If WinActive($Gui) Then Exit
If WinActive($editgui) Then GUIDelete($editgui)
Case $msg = $editsend And $msg <> ""
FileDelete("DL.jpg")
TCPSend($ConnectedSocket,"ST||"&$calcul&"||" )
GUIDelete($editgui)
Case $msg = $buttonitemtext
$editgui = GUICreate("Texte",500,525,-1,-1,-1,-1,$Gui)
$edittext = GUICtrlCreateEdit("",0,0,500,500)
$editsend = GUICtrlCreateButton("Envoyer",100,500,300,25)
GUISetState()
Case $msg = $Send Or $msg = $text
FileDelete("DL.jpg")
$calcul = GUICtrlRead($text)
If GUICtrlRead ($check) = $GUI_CHECKED Then
TCPSend($ConnectedSocket,"ST||"&$calcul&"||" )
Else
TCPSend($ConnectedSocket,"SE||"&$calcul&"||" )
EndIf
GUICtrlSetData($text,"")
Case $msg = $F5
;~ GUICtrlSetImage($pic,"DL.jpg")
FileDelete("DL.jpg")
TCPSend($ConnectedSocket,"f5")
Case _IsPressed(01) = 1
If WinActive($Gui) Then
$calcul = GUIGetCursorInfo($Gui)
If $calcul[4] = $pic Then
FileDelete("DL.jpg")
While _IsPressed(01)
Sleep(100)
WEnd
$calcul2 = GUIGetCursorInfo($Gui)
If $calcul[0] = $calcul2[0] And $calcul[1] = $calcul2[1] Then
TCPSend($ConnectedSocket, "GC ||" & $calcul[0] &"||"& $calcul[1]&"||")
Else
TCPSend($ConnectedSocket, "GD ||" & $calcul[0] &"||"& $calcul[1] &"||"& $calcul2[0] &"||"& $calcul2[1]&"||")
EndIf
EndIf
EndIf
Case _IsPressed(02) = 1
If WinActive($Gui) Then
$calcul = GUIGetCursorInfo($Gui)
If $calcul[4] = $pic Then
FileDelete("DL.jpg")
While _IsPressed(02)
Sleep(100)
WEnd
$calcul2 = GUIGetCursorInfo($Gui)
If $calcul[0] = $calcul2[0] And $calcul[1] = $calcul2[1] Then
TCPSend($ConnectedSocket, "DC ||" & $calcul[0] &"||"& $calcul[1]&"||")
Else
TCPSend($ConnectedSocket, "DD ||" & $calcul[0] &"||"& $calcul[1] &"||"& $calcul2[0] &"||"& $calcul2[1]&"||")
EndIf
EndIf
EndIf
Case _IsPressed(04) = 1
If WinActive($Gui) Then
$calcul = GUIGetCursorInfo($Gui)
If $calcul[4] = $pic Then
FileDelete("DL.jpg")
While _IsPressed(04)
Sleep(100)
WEnd
$calcul2 = GUIGetCursorInfo($Gui)
If $calcul[0] = $calcul2[0] And $calcul[1] = $calcul2[1] Then
TCPSend($ConnectedSocket, "CC ||" & $calcul[0] &"||"& $calcul[1]&"||")
Else
TCPSend($ConnectedSocket, "CD ||" & $calcul[0] &"||"& $calcul[1] &"||"& $calcul2[0] &"||"& $calcul2[1]&"||")
EndIf
EndIf
EndIf
EndSelect
$Commande = TCPRecv($ConnectedSocket, 100000)
If $Commande <> "" Then
GUICtrlSetImage($pic,"DL.jpg")
FileWrite("DL.jpg",$Commande)
GUICtrlSetImage($pic,"DL.jpg")
;~ $oIE.navigate(@ScriptDir & "/dl.html")
EndIf
WEnd
TCPShutdown()
EndFunc ;==>Client
Func SocketToIP($SHOCKET)
Local $sockaddr, $aRet
$sockaddr = DllStructCreate("short;ushort;uint;char[8]")
$aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _
"ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr))
If Not @error And $aRet[0] = 0 Then
$aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3))
If Not @error Then $aRet = $aRet[0]
Else
$aRet = 0
EndIf
$sockaddr = 0
Return $aRet
EndFunc ;==>SocketToIP
En espérant que cela puisse aider certain se lancant dans l'aventure TCPIP !
Edit : Client/Server inversé ! Cela permet de ne plus a avoir a configurer les port sur le post assisté. Le code tel qu'il est doit voir l'IP de l'assistant écrite en dur avant compilation, mais tres facile a changer pour un fileread qui lirait un txt fourni, ou meme une adresse internet