#NoTrayIcon #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=IPSvc.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Description=Système antivol et d'information par mail ou ftp #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_LegalCopyright=GPL #AutoIt3Wrapper_Res_Language=1036 #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #region ;initialisation #region #include #include #include #include #include #include #include #include #include #Include #include #Include #include #include #endregion #region ;variables Global $MyError = ObjEvent("AutoIt.Error", "MyErrFunc") Global $oMyRet[2] Global $general_install_foler = [null] Global $general_ecart_test_mn = [null] Global $general_nb_test = [null] Global $general_msg_info = [null] Global $general_exec_fichier = [null] Global $general_key = [null] Global $general_id = [null] global $general_version = [null] global $general_tempo = [null] Global $antivol_actif = [null] Global $antivol_image_mode = [null] Global $antivol_message_mode = [null] Global $antivol_fichiers_mode = [null] Global $antivol_mdp = [null] Global $antivol_mac_actif = [null] Global $antivol_uuid_actif = [null] Global $antivol_serial_actif = [null] Global $antivol_Win_ID_actif = [null] global $antivol_screen_name = [null] global $antivol_webcam_name = [null] global $antivol_notif_name = [null] Global $rapport_actif = [null] Global $rapport_mode = [null] Global $rapport_send_wan_actif = [null] Global $rapport_send_wan_mode = [null] Global $rapport_send_first_notif = [null] Global $rapport_send_periode_actif = [null] Global $rapport_send_periode_jours = [null] Global $rapport_mode_liste_ip = [null] Global $rapport_liste_ip = [null] Global $rapport_contenu_infos_actif = [null] Global $rapport_contenu_boot_actif = [null] Global $rapport_contenu_OS_actif = [null] Global $rapport_contenu_sessions_actif = [null] Global $rapport_contenu_proc_actif = [null] Global $rapport_contenu_bios_actif = [null] Global $rapport_contenu_stockage_actif = [null] Global $rapport_contenu_user_actif = [null] Global $rapport_contenu_prog_actif = [null] Global $rapport_contenu_reseau_actif = [null] Global $mail_actif = [null] Global $mail_user = [null] Global $mail_mdp = [null] Global $mail_smtp = [null] Global $mail_port = [null] Global $mail_src = [null] Global $mail_sujet = [null] Global $mail_dst = [null] Global $mail_ssl_actif = [null] global $mail_sujet_screen = [null] global $mail_sujet_webcam = [null] Global $ftp_actif = [null] Global $ftp_user = [null] Global $ftp_mdp = [null] Global $ftp_server = [null] Global $ftp_folder = [null] Global $ftp_name = [null] Global $ftp_ssl_actif = [null] global $ftp_folder_screen = [null] global $ftp_folder_webcam = [null] global $ftp_folder_config = [null] global $ftp_folder_recup = [null] #endregion #region Global $username = $ftp_user Global $pass = $ftp_mdp Global $server = $ftp_server Global $dossier = $ftp_folder global $last_date, $last_ip, $tmp_tab, $tmp_name, $tab[1000][100],$supr_fi,$supr_do,$supr_er,$1 Global $type_envoi = "0" global $IP_wan = "[null]" global $IP_wan_statut = "[null]" global $tab_fi[100000] global $mode_instal = "instal" global $mode_gui = "gui" Global $tmp_fd = "/" Global $mode_general_log = "0" global $cmd_log = "" Global $mode_gui = "gui" global $erreur = "" if $dossier <> "" then Global $tmp_fd = $dossier & "/" Global $text_cmd = "Installe/désinstalle IPSvc ou met à jour les extentions." & @crlf & @crlf & _ 'IPSvc [[/I[T]] "chemin de instal_extensions.ini"[/R]] [/D]' & @crlf & _ ' [[/log] "chemin complet du fichier log"] ' & @crlf & @crlf & _ ' /I Installe IPSvc. instal_extensions.ini contient les chemins complet ' & @crlf & _ ' des fichiers supplémentaire à installer dans le dossier IPSvc' & @crlf & _ " /IT Ajoute un test mail et ftp en fin d'installation." & @crlf & _ ' /R Réinstalle completement IPSvc si il est déjà installé' & @crlf & _ ' /D Désinstalle IPSvc' & @crlf & _ " /log Ajoute les informations d'installation ou de mise à jour dans un fichier." & @crlf & @crlf & _ " Le service IPSvc renseignera le fichier log_service.ini situé dans le dossier d'installation """ & _adapt($general_install_foler) & """ (configuration actuelle) sur le bon fonctionnement du service."; Le fichier ""config.ini"" sera créé si il n'existe pas. il permet de modifier certains comportement du service sans devoir le réinstaller." global $variables_utilisables = "[variable_IPSvc]=résultat pour cet ordinateur" & @CRLF & @CRLF & _ "[computername]=" & @computername & @CRLF & _ "[homedrive]=" & @homedrive & @CRLF & _ "[homepath]=" & @homepath & @CRLF & _ "[logonserver]=" & @logonserver & @CRLF & _ "[OSVersion]=" & @OSVersion & @CRLF & _ "[OSArch]=" & @OSArch & @CRLF & _ "[WindowsDir]=" & @WindowsDir & @CRLF & _ "[SystemDir]=" & @SystemDir & @CRLF & _ "[username]=" & @username & @CRLF & _ "[MDAY]=" & @MDAY & @CRLF & _ "[MON]=" & @MON & @CRLF & _ "[YEAR]=" & @YEAR & @CRLF & _ "[HOUR]=" & @HOUR & @CRLF & _ "[MIN]=" & @MIN & @CRLF & _ "[SEC]=" & @SEC & @CRLF & _ "[DATE]=" & @MDAY & "-" & @MON & "-" & @YEAR & @CRLF & _ "[TIME]=" & @HOUR & "h" & @MIN & "m" & @SEC & @CRLF & _ "[ProgramFiles]=" & @ProgramFilesDir & @CRLF & @CRLF & _ "ATTENTION, certaines variables ne sont pas disponnible sur tous les systèmes d'exploitation.)" #endregion If $CmdLine[0] > 0 Then _cmd_mode() WinSetState(@ScriptFullPath, "", @SW_HIDE) #endregion #region ;initialisation de l'interface graphique #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("IPSvc", 615, 289, 234, 202) global $Label7 = GUICtrlCreateLabel("I", 8, 0, 100, 40) GUICtrlSetColor(-1, 0xDB5601) GUICtrlSetFont(-1, 25, 1, 0, "Arial Black") global $Label8 = GUICtrlCreateLabel("P", 22, 0, 100, 40) GUICtrlSetColor(-1, 0xFC772A) GUICtrlSetFont(-1, 25, 1, 0, "Arial Black") global $Label9 = GUICtrlCreateLabel("S", 46, 0, 100, 40) GUICtrlSetColor(-1, 0x030AFB) GUICtrlSetFont(-1, 25, 1, 0, "Arial Black") global $Label10 = GUICtrlCreateLabel("v", 70, 0, 100, 40) GUICtrlSetColor(-1, 0x575DFA) GUICtrlSetFont(-1, 25, 1, 0, "Arial Black") global $Label11 = GUICtrlCreateLabel("c", 90, 0, 100, 40) GUICtrlSetColor(-1, 0x8F92FA) GUICtrlSetFont(-1, 25, 1, 0, "Arial Black") $Tab1 = GUICtrlCreateTab(8, 48, 601, 233) $TabSheet1 = GUICtrlCreateTabItem("Général") $Button10 = GUICtrlCreateButton("Installer/Désinstaller", 20, 85, 193, 33) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Button11 = GUICtrlCreateButton("Ouvrir le dossier d'installation", 20, 129, 193, 25) GUICtrlSetTip(-1,"Le dossier d'installation contient des fichiers de log sur le fonctionnement du service IPSvc") $Button4 = GUICtrlCreateButton("Utilisation en ligne de commande", 232, 89, 201, 25) $Button12 = GUICtrlCreateButton("Démarrer/Arrêter le service", 232, 129, 201, 25) GUICtrlSetTip($Button12,"Le service IPSvc s'active automatiquement au démarrage du système. Il s'arrête aussi automatiquement au bout de quelques secondes au minimum.") _up_bs() $Group2 = GUICtrlCreateGroup("Mail", 456, 88, 137, 49) $Button7 = GUICtrlCreateButton("Envoyer un mail de test", 464, 104, 121, 25) if $mail_actif = "non" then GUICtrlSetState(-1,$GUI_disable) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group1 = GUICtrlCreateGroup("Ftp", 456, 152, 137, 81) $Button8 = GUICtrlCreateButton("Tester le serveur ftp", 464, 168, 121, 25) $Button9 = GUICtrlCreateButton("Ouvrir le dossier", 464, 200, 121, 25) if $ftp_actif = "non" then GUICtrlSetState(-1,$GUI_disable) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button5 = GUICtrlCreateButton("Faire un don (PayPal)", 445, 245, 115, 25) GUICtrlSetbkColor(-1, 0xFEE8C2) $Button19 = GUICtrlCreateButton("?", 573, 247, 20, 20) GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x0066CC) $Edit1 = GUICtrlCreateEdit("", 24, 160,409, 113) GUICtrlSetData(-1, "Détail des actions") GUICtrlSetState(-1,$GUI_HIDE) $Group3 = GUICtrlCreateGroup("Configuration", 24, 160, 409, 113) if $rapport_mode = "mail" then $tmp_var = "Mail" Else $tmp_var = "Ftp" EndIf if $rapport_actif = "non" then $tmp_var = "inactif" $Label3 = GUICtrlCreateLabel("Rapports: " & $tmp_var, 32, 180, 180, 15) if $antivol_actif = "non" then $tmp_var = "inactif" else $tmp_var = "actif" endif $Label4 = GUICtrlCreateLabel("Système antivol: " & $tmp_var, 220, 180, 180, 15) $Label1 = GUICtrlCreateLabel("", 32, 200, 399, 15) if $ftp_actif = "non" then GUICtrlSetData(-1,"Adresse ftp: par défaut") Else GUICtrlSetData(-1,"Adresse ftp: " & $ftp_server & $ftp_folder) EndIf $Label2 = GUICtrlCreateLabel("Compte mail utilisé: " & $mail_user, 32, 220, 399, 15) $Label6 = GUICtrlCreateLabel("Recepteur(s) mail: " & $mail_dst, 32, 234, 399, 30) GUICtrlCreateGroup("", -99, -99, 1, 1) if $antivol_actif = "oui" then $TabSheet2 = GUICtrlCreateTabItem("Gestion des alertes antivol") $Button1 = GUICtrlCreateButton("Ajouter", 16, 248, 85, 25) GUICtrlSetTip(-1,"Ajoute une alerte antivol contenant les instructions que l'ordinateur volé devra effectuer") $Button2 = GUICtrlCreateButton("Supprimer", 105, 248, 85, 25) GUICtrlSetTip(-1,"Supprime la/les alerte(s) sélectionné(s)") $Button3 = GUICtrlCreateButton("Actualiser", 194, 248, 85, 25) GUICtrlSetTip(-1,"Actualise la liste des alertes stockés sur le serveur ftp") $Button17 = GUICtrlCreateButton("Details", 283, 248, 85, 25) GUICtrlSetTip(-1,"Affiche les détails de l'alerte sélectionné") $Button18 = GUICtrlCreateButton("?", 575, 248, 20, 20) GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x0066CC) global $Label14 = GUICtrlCreateLabel("", 375, 248, 225, 27) $ListView1 = GUICtrlCreateListView("", 16, 80, 585, 161, BitOR($LVS_REPORT,$LVS_SHOWSELALWAYS)) _GUICtrlListView_AddColumn(-1, "Type ID", 52) _GUICtrlListView_AddColumn(-1, "ID", 250) _GUICtrlListView_AddColumn(-1, "Date de création", 98) _GUICtrlListView_AddColumn(-1, "Nom du fichier", 172) GUICtrlCreateTabItem("") $Label5 = GUICtrlCreateLabel($general_msg_info, 210, 1, 396, 58) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") if $antivol_actif = "non" then GUICtrlSetState($Button1,$GUI_HIDE) GUICtrlSetState($Button2,$GUI_HIDE) GUICtrlSetState($Button3,$GUI_HIDE) GUICtrlSetState($Button17,$GUI_HIDE) GUICtrlSetState($Button18,$GUI_HIDE) GUICtrlSetState($Label14,$GUI_HIDE) GUICtrlSetState($ListView1,$GUI_HIDE) GUICtrlSetState($Label5,$GUI_HIDE) EndIf global $Progress1 = GUICtrlCreateProgress(208, 48, 393, 17) GUICtrlSetState(-1,$GUI_HIDE) HotKeySet("{F1}","_chm") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _f2() _up_bi() #endregion While 1 $nMsg = GUIGetMsg(1) Switch $nMsg[0] Case $GUI_EVENT_CLOSE, $Button14 if $nMsg[1] = $Form1 then Exit if $nMsg[1] = $Form2 then GUISetState(@SW_HIDE,$Form2) case $button5 ShellExecute("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GM2U78ANLBHC2") case $Button11 $tmp_var = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\IPSvc","ImagePath") if $tmp_var <> "" Then $tmp_var2 = StringSplit($tmp_var,"\") ShellExecute("explorer.exe", StringLeft($tmp_var,StringLen($tmp_var) - StringLen($tmp_var2[$tmp_var2[0]]) - 1)) Else MsgBox(48,"Erreur","Aucun dossier d'installation trouvé car le service IPSvc n'est pas installé sur cet ordinateur.","",$form1) EndIf case $Button7 _mail() case $Button8 _ftp() case $Button9 if _mdp() = True then _open_ftp() case $Button4 _help_cmd() case $Button10 $tmp_var = "srvany" if $mode_instal = "instal" then $tmp_result = _installation($tmp_var) Else $tmp_result = _desinstallation() EndIf if $tmp_result = true Then MsgBox(64,"Fin du traitement","Cette oppération à été réalisé avec succès","",$form1) Else MsgBox(48,"Fin du traitement","Cette oppération à échoué" & @crlf & $erreur ,"",$form1) EndIf case $Button12 _service() case $Button18 _chm("Gestion des alertes antivol") case $Button1 if _mdp() = True then _add_alerte() case $Button3 DirRemove(@TempDir & "\tmp",1) if _mdp() = True then _update_alerte() GUICtrlSetData($Label14,"") GUICtrlSetState($Button18,$gui_show) GUICtrlSetState($Progress1,$GUI_HIDE) DirRemove(@TempDir & "\tmp",1) case $Button2 if _mdp() = True then _del_alerte() case $Button17 _detail_alerte() case $Button19 _chm("Général") case $Checkbox14,$Checkbox15,$Checkbox16,$Checkbox20,$Checkbox17,$Checkbox21 _up_gui() case $Button13 if _run_add_alerte() = true then GUISetState(@SW_HIDE,$Form2) _run_add_alerte2() GUICtrlSetData($Label14,"") GUICtrlSetState($Button18,$gui_show) GUICtrlSetState($Progress1,$GUI_HIDE) DirRemove(@TempDir & "\tmp",1) EndIf EndSwitch if StringLeft(StringRight(@SEC,1) & @MSEC,2) = "11" then _up_bs() if StringLeft(StringRight(@SEC,1) & @MSEC,2) = "51" then _up_bs() WEnd #region ;INTERFACE GRAPHIQUE ONGLET Général func _up_ba($tmp_var = "normal") if $tmp_var = "edit" then GUICtrlSetData($Edit1,"") GUICtrlSetState($Group3,$GUI_HIDE) GUICtrlSetState($Label3,$GUI_HIDE) GUICtrlSetState($Label4,$GUI_HIDE) GUICtrlSetState($Label1,$GUI_HIDE) GUICtrlSetState($Label2,$GUI_HIDE) GUICtrlSetState($Label6,$GUI_HIDE) GUICtrlSetState($Edit1,$gui_show) Else GUICtrlSetState($Group3,$gui_show) GUICtrlSetState($Label3,$gui_show) GUICtrlSetState($Label4,$gui_show) GUICtrlSetState($Label1,$gui_show) GUICtrlSetState($Label2,$gui_show) GUICtrlSetState($Label6,$gui_show) GUICtrlSetState($Edit1,$GUI_HIDE) endif EndFunc Func _ftp() GUICtrlSetState($Progress1,$gui_show) GUICtrlSetData($Progress1, 1) $tmp_fi = "tmp.txt" Filewrite(@TempDir & "\tmp.txt" , "test") GUICtrlSetData($Progress1, 10) $tmp_var = _test_ftp($server, $username, $pass, $tmp_fd, $tmp_fi) FileDelete(@TempDir & "\tmp.txt") DirRemove(@TempDir & "\tmp",1) GUICtrlSetState($Progress1,$GUI_HIDE) GUICtrlSetData($Button8,"Tester le serveur ftp") EndFunc Func _mail() GUICtrlSetState($Progress1,$gui_show) GUICtrlSetData($Progress1, 1) $as_Body = "Message de test" Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"IPSvc" <' & $mail_src & '>' $objEmail.To = $mail_dst Local $i_Error = 0 Local $i_Error_desciption = "" ;If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress ;If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = _adapt($mail_sujet) If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf $s_AttachFiles = "" If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) SetError(1) Return 0 EndIf Next EndIf GUICtrlSetData($Progress1, 40) $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $mail_smtp $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $mail_port If $mail_user <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $mail_user $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $mail_mdp EndIf If $mail_ssl_actif = "oui" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf $objEmail.Configuration.Fields.Update $s_Importance = "Normal" Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update GUICtrlSetData($Progress1, 70) $objEmail.Send If @error Then SetError(2) GUICtrlSetState($Progress1,$GUI_HIDE) Return $oMyRet[1] Else MsgBox(0,"","Message envoyé") EndIf GUICtrlSetState($Progress1,$GUI_HIDE) $objEmail="" EndFunc Func MyErrFunc() $oMyRet[1] = StringStripWS($MyError.description, 3) if $mode_gui = "gui" then MsgBox(48,"Erreur",$oMyRet[1]) SetError(1) Return EndFunc ;==>MyErrFunc Func _test_ftp($server, $username, $pass, $tmp_fd, $tmp_fi) GUICtrlSetData($Progress1, 25) GUICtrlSetData($Button8,"Test d'upload ...") $tmp_var = _upload_ftp($server, $username, $pass, $tmp_fd, $tmp_fi,@TempDir) if $tmp_var = False then MsgBox(48,"ERREUR", "Echec du test d'upload") Return False EndIf GUICtrlSetData($Progress1, 50) GUICtrlSetData($Button8,"Test download ...") $tmp_var = _download_ftp($server, $username, $pass, $tmp_fd, $tmp_fi,@TempDir) if $tmp_var <> True then MsgBox(48,"ERREUR", "Echec du test de download") Return False EndIf GUICtrlSetData($Progress1, 75) GUICtrlSetData($Button8,"Test delete ...") if _del_ftp($server, $username, $pass, $tmp_fd, $tmp_fi,@TempDir) = False then MsgBox(48,"ERREUR", "Echec de suppression") Return False EndIf MsgBox(0,"OK", "Test ftp réeussi") EndFunc func _open_ftp() $tmp_mdp = "" $tmp_id = "" $tmp_ad = "" $tmp_fd = "" $tmp_var = "" if $ftp_user <> "" Then $tmp_id = $ftp_user $tmp_var = "@" EndIf if $ftp_mdp <> "" then $tmp_mdp = ":" & $ftp_mdp if $ftp_folder <> "" then $tmp_fd = $ftp_folder ShellExecute("explorer.exe", """ftp://" & $tmp_id & $tmp_mdp & $tmp_var & $ftp_server & $tmp_fd) EndFunc Func _help_cmd() MsgBox(64,"Syntaxe IPSvc",$text_cmd,"",$form1) EndFunc func _up_bs() If _ServiceRunning("", "IPSvc") Then GUICtrlSetData($Button12,"Arrêter le service IPSvc") GUICtrlSetBkColor($Button12,0xFF90A2) return true Else GUICtrlSetData($Button12,"Démarrer le service IPSvc") GUICtrlSetBkColor($Button12,0x90FFA6) return False EndIf EndFunc func _service() if _up_bs() = true then $tmp_var = RunWait(@ComSpec & " /c sc stop IPSvc ", @ScriptDir, @SW_HIDE) Else $tmp_var = RunWait(@ComSpec & " /c sc start IPSvc ", @ScriptDir, @SW_HIDE) EndIf if _ServiceExists("","IPSvc") <> 0 and $tmp_var <> 0 then msgbox(48,"Erreur","echec de la commande.") _up_bs() if _ServiceExists("","IPSvc") = 0 then msgbox(48,"Erreur","Impossible d'effectuer cette Action car le service IPSvc n'est pas installé.") EndFunc func _up_bi() $tmp_var = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\IPSvc","ImagePath") if $tmp_var = "" Then $mode_instal = "instal" GUICtrlSetData($Button10,"Installer IPSvc") GUICtrlSetTip($Button10,"Installer le service IPSvc sur cet ordinateur") GUICtrlSetBkColor($Button10,0x90FFA6) Else $mode_instal = "désinstal" GUICtrlSetData($Button10,"Désinstaller IPSvc") GUICtrlSetTip($Button10,"Désinstaller le service IPSvc de cet ordinateur") GUICtrlSetBkColor($Button10,0xFF90A2) EndIf EndFunc #endregion #region ;FONCTIONS func _chm($1 = "") DirCreate(@TempDir & "\IPSvc") FileInstall("IPSvc.chm",@TempDir & "\IPSvc\IPSvc.chm",1) if $1 <> "" then run('"hh.exe" "' & @TempDir & '\IPSvc\IPSvc.chm' & '::/' & $1 & '.html"',@WindowsDir) if $1 = "" then run('"hh.exe" "' & @TempDir & '\IPSvc\IPSvc.chm',@WindowsDir) EndFunc Func _adapt($tmp_var) $tmp_var = StringReplace ( $tmp_var, "[computername]", @computername) $tmp_var = StringReplace ( $tmp_var, "[homedrive]", @homedrive) $tmp_var = StringReplace ( $tmp_var, "[homepath]", @homepath) $tmp_var = StringReplace ( $tmp_var, "[logonserver]", @logonserver) $tmp_var = StringReplace ( $tmp_var, "[OSVersion]", @OSVersion) $tmp_var = StringReplace ( $tmp_var, "[OSArch]", @OSArch) $tmp_var = StringReplace ( $tmp_var, "[WindowsDir]", @WindowsDir) $tmp_var = StringReplace ( $tmp_var, "[SystemDir]", @SystemDir) $tmp_var = StringReplace ( $tmp_var, "[username]", @username) $tmp_var = StringReplace ( $tmp_var, "[mday]", @mday) $tmp_var = StringReplace ( $tmp_var, "[mon]", @MON) $tmp_var = StringReplace ( $tmp_var, "[year]", @YEAR) $tmp_var = StringReplace ( $tmp_var, "[hour]", @HOUR) $tmp_var = StringReplace ( $tmp_var, "[min]", @min) $tmp_var = StringReplace ( $tmp_var, "[sec]", @sec) $tmp_var = StringReplace ( $tmp_var, "[date]", @MDAY & "-" & @MON & "-" & @YEAR) $tmp_var = StringReplace ( $tmp_var, "[time]", @HOUR & "h" & @MIN & "m" & @SEC) $tmp_var = StringReplace ( $tmp_var, "[ProgramFiles]", @ProgramFilesDir) Return $tmp_var EndFunc Func _list_ftp($server, $username, $pass, $tmp_fd, $tmp_fi,$tmp_list = "",$tmp_path = @ScriptDir) _dep_curl($tmp_path) if $ftp_ssl_actif = "oui" then $tmp_var2 = " -k --ftp-ssl " else $tmp_var2 = " " EndIf $tmp_var = StringSplit(_cmd('"' & $tmp_path & '\tmp\curl.exe" -l' & $tmp_var2 & '"ftp://' & $username & ':' & $pass & '@' & $server & $tmp_fd & '"'), @CRLF) $result = False for $i = 1 to $tmp_var[0] if $tmp_var[$i] <> "" and StringInStr($tmp_var[$i],$tmp_fi) = 22 then if $tmp_list <> "" then FileWriteLine($tmp_list,$tmp_var[$i]) $result = True EndIf next return $result EndFunc Func _download_ftp($server, $username, $pass, $tmp_fd, $tmp_fi,$tmp_path = @ScriptDir) _dep_curl($tmp_path) if $ftp_ssl_actif = "oui" then $tmp_var2 = " -k --ftp-ssl " else $tmp_var2 = " " EndIf $tmp_var = ShellExecuteWait('"' & $tmp_path & '\tmp\curl.exe"' , ' -O' & $tmp_var2 & '"ftp://' & $username & ':' & $pass & '@' & $server & $tmp_fd & $tmp_fi & '"',$tmp_path,"open",@SW_HIDE) if $tmp_var = 0 then Return True Return False EndFunc Func _upload_ftp($server, $username, $pass, $tmp_fd, $tmp_fi,$tmp_path = @ScriptDir,$tmp_p1 = "-T") _dep_curl($tmp_path) if $ftp_ssl_actif = "oui" then $tmp_var2 = " -k --ftp-ssl " else $tmp_var2 = " " EndIf $tmp_var = ShellExecuteWait('"' & $tmp_path & '\tmp\curl.exe"' , ' ' & $tmp_p1 & ' "' & $tmp_fi & '"' & $tmp_var2 & '--ftp-create-dirs "ftp://' & $username & ':' & $pass & '@' & $server & $tmp_fd & '"',$tmp_path,"open",@SW_HIDE) ;msgbox(0,$tmp_var,' -T "' & $tmp_fi & '"' & $tmp_var2 & '"ftp://' & $username & ':' & $pass & '@' & $server & $tmp_fd & '"') if $tmp_var = 0 then Return True Return False EndFunc Func _del_ftp($server, $username, $pass, $tmp_fd, $tmp_fi,$tmp_path = @ScriptDir) _dep_curl($tmp_path) if $ftp_ssl_actif = "oui" then $tmp_var2 = " -k --ftp-ssl " else $tmp_var2 = " " EndIf $tmp_var = ShellExecuteWait('"' & $tmp_path & '\tmp\curl.exe"' , $tmp_var2 & '--quote "-dele ' & $tmp_fi & '" "ftp://' & $username & ':' & $pass & '@' & $server & $tmp_fd & '"',$tmp_path,"open",@SW_HIDE) if $tmp_var = 0 then Return True Return False EndFunc Func _adapt_cmd($tmp_var) $tmp_var = StringReplace ( $tmp_var, "é", "‚") $tmp_var = StringReplace ( $tmp_var, "è", "Š") $tmp_var = StringReplace ( $tmp_var, "â", "ƒ") $tmp_var = StringReplace ( $tmp_var, "ê", "ˆ") $tmp_var = StringReplace ( $tmp_var, "à", "…") $tmp_var = StringReplace ( $tmp_var, "ù", "—") $tmp_var = StringReplace ( $tmp_var, "ç", "‡") Return $tmp_var EndFunc func _cmd($tmp_var) $iPID = Run($tmp_var,"", @SW_HIDE, $STDOUT_CHILD) $sStdOut = "" Do $sStdOut &= StdoutRead($iPID) Until @error return _adapt_aut($sStdOut) EndFunc func _mdp() if GUICtrlRead($Input11) == $antivol_mdp then return True GUISetState(@SW_SHOW,$Form3) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE,$Button16 GUISetState(@SW_HIDE,$Form3) return False Case $Button15 if GUICtrlRead($Input11) == $antivol_mdp then GUISetState(@SW_HIDE,$Form3) return True Else MsgBox(48,"Erreur","Mot de passe invalide") GUICtrlSetData($Input11,"") EndIf EndSwitch WEnd EndFunc Func _adapt_aut($tmp_var) $tmp_var = StringReplace ( $tmp_var, "‚", "é") $tmp_var = StringReplace ( $tmp_var, "Š", "è") $tmp_var = StringReplace ( $tmp_var, "ƒ", "â") $tmp_var = StringReplace ( $tmp_var, "ˆ", "ê") $tmp_var = StringReplace ( $tmp_var, "…", "à") $tmp_var = StringReplace ( $tmp_var, "—", "ù") $tmp_var = StringReplace ( $tmp_var, "‡", "ç") $tmp_var = StringReplace ( $tmp_var, "ÿ", " ") Return $tmp_var EndFunc func _dep_curl($var = @ScriptDir) DirCreate($var & "\tmp") FileInstall("curl.exe",$var & "\tmp\curl.exe") FileInstall("libssl32.dll",$var & "\tmp\libssl32.dll") FileInstall("libeay32.dll",$var & "\tmp\libeay32.dll") EndFunc func _get_ProfileUser() $tmp_var = "" if FileExists(@HomeDrive & "\Documents and settings") then $tmp_var = @HomeDrive & "\Documents and settings" if FileExists(@HomeDrive & "\Users") then $tmp_var = @HomeDrive & "\Users" if $tmp_var = "" then $tmp_var = "Erreur, imposible d'identifier le dossier" return $tmp_var EndFunc func _get_SID() $count = 0 $tmp_var = "" While 1 $count += 1 $key = RegEnumKey("HKEY_USERS", $count) If @error Then ExitLoop if stringlen($key) > 40 and stringlen($key) < 50 then $tmp_var = $key & ";" & $tmp_var WEnd return $tmp_var EndFunc func _get_folder_var($tmp_var2) $tmp_var3 = "" $tmp_var = StringSplit(_get_SID(), ";") For $i = 1 To $tmp_var[0] $tmp_var4 = RegRead("HKEY_USERS\" & $tmp_var[$i] & "\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders",$tmp_var2) if FileExists($tmp_var4) then $tmp_var3 = $tmp_var4 & ";" & $tmp_var3 Next return $tmp_var3 EndFunc Func _smail($mail_sujet,$as_Body = "Message de test",$s_AttachFiles = "",$tmp_path2 = @ScriptDir) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"IPSvc" <' & $mail_src & '>' $objEmail.To = $mail_dst Local $i_Error = 0 Local $i_Error_desciption = "" ;If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress ;If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = _adapt($mail_sujet) If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x],$tmp_path2) If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) ;_log('ajout pj: '&$S_Files2Attach[$x]) Else return False EndIf Next EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $mail_smtp $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $mail_port If $mail_user <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $mail_user $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $mail_mdp EndIf If $mail_ssl_actif = "oui" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf $objEmail.Configuration.Fields.Update $s_Importance = "Normal" Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update $objEmail.Send If @error Then return false Else return true EndIf $objEmail="" EndFunc func _charge_liste() $tmp_var = @ScriptDir & "\liste_ip.ini" if not FileExists($tmp_var) then $tmp_var2 = StringSplit($rapport_liste_ip,";") FileWrite($tmp_var,"") for $i = 1 to $tmp_var2[0] FileWrite($tmp_var,$tmp_var2[$i] & @CRLF) Next EndIf $read = FileRead($tmp_var) global $IP = StringSplit($read, @CRlf) $i2 = 0 For $i = 1 To $IP[0] if $IP[$i] <> "" and not _verif_ip($IP[$i]) = False then $i2 = $i2 + 1 _log('chargement de l''ip ' & $i2 & ":" & _verif_ip($IP[$i])) endif Next _log("Fin du chargement de la liste d'adresse IP.") EndFunc func _verif_ip($tmp_var) $tmp_var = StringReplace($tmp_var," ","") $tmp = StringSplit($tmp_var,".") if $tmp[0] <> 4 then return False For $i = 1 To $tmp[0] if $tmp[$i] < 0 or $tmp[$i] > 255 then return False Next return $tmp_var EndFunc Func import($tmp_var,$tmp_exp = "") $bRead = InetRead($tmp_var,1) if $tmp_exp <> "" then $tmp_r = StringRegExp(BinaryToString($bRead),$tmp_exp, 3) if not @error then $tmp_r = $tmp_r[0] Else $tmp_r = BinaryToString($bRead) EndIf return $tmp_r EndFunc func _get_ip_wan($var = 0) $tmp_var = _verif_ip(import("http://checkip.dyndns.org/",'Current IP Address:(.*?)')) if $var = 0 and not $tmp_var = False then if _get_ip_wan(1) = $tmp_var then global $IP_wan = $tmp_var global $IP_wan_statut = "confirmé" Else global $IP_wan = $tmp_var global $IP_wan_statut = "non confirmé" EndIf EndIf $tmp_var = _verif_ip(import("http://automation.whatismyip.com/n09230945.asp")) if $var = 0 and not $tmp_var = False then if _get_ip_wan(2) = $tmp_var then global $IP_wan = $tmp_var global $IP_wan_statut = "confirmé" Else global $IP_wan = $tmp_var global $IP_wan_statut = "non confirmé" EndIf EndIf if $var < 2 and not $tmp_var = False then return $tmp_var $tmp_var = _verif_ip(import("http://whatismyip.org/")) if $var = 0 and not $tmp_var = False then if _get_ip_wan(3) = $tmp_var then global $IP_wan = $tmp_var global $IP_wan_statut = "confirmé" Else global $IP_wan = $tmp_var global $IP_wan_statut = "non confirmé" EndIf EndIf if $var < 3 and not $tmp_var = False then return $tmp_var $tmp_var = _verif_ip(import("http://votreip.free.fr/",'IP :(.*?)')) if $var = 0 and not $tmp_var = False then if _get_ip_wan(4) = $tmp_var then global $IP_wan = $tmp_var global $IP_wan_statut = "confirmé" Else global $IP_wan = $tmp_var global $IP_wan_statut = "non confirmé" EndIf EndIf if $var < 4 and not $tmp_var = False then return $tmp_var $tmp_var = _verif_ip(import("http://www.mon-ip.com/",'Votre adresse IP est : (.*?)')) if $var = 0 and not $tmp_var = False then if _get_ip_wan(5) = $tmp_var then global $IP_wan = $tmp_var global $IP_wan_statut = "confirmé" Else global $IP_wan = $tmp_var global $IP_wan_statut = "non confirmé" EndIf EndIf if $var < 5 and not $tmp_var = False then return $tmp_var $tmp_var = _verif_ip(import("http://www.adresseip.com/",'Votre Adresse IP est :(.*?)')) if $var = 0 and not $tmp_var = False then global $IP_wan = $tmp_var global $IP_wan_statut = "non confirmé" EndIf if not $tmp_var = False then return $tmp_var return False EndFunc func _test_wan($var = 1) for $i = 1 to $general_nb_test if $var = 1 then _log('test ' & $i & ' sur ' & $general_nb_test & ' ...') if Inetread("http://www.google.com/",1) <> "" then return True if Inetread("http://symbolics.com/",1) <> "" then return True if Inetread("http://www.hp.com/",1) <> "" then return True if Inetread("http://www.ibm.com/",1) <> "" then return True if $var <> 1 then ExitLoop Sleep(60000 * $general_ecart_test_mn) next return False EndFunc func _test_periode() _log('Status de la notification périodique:' & $rapport_send_periode_jours & ' jours.') if not FileExists(@ScriptDir & '\last_notif_periodique.ini') Then _log('Création du fichier last_notif_periodique.ini') FileWrite(@ScriptDir & '\last_notif_periodique.ini',@YEAR & "/" & @MON & "/" & @MDAY) EndIf $last_notif = FileRead(@ScriptDir & '\last_notif_periodique.ini') _log('Dernière notification périodique: ' & $last_notif) $ecart = _DateDiff("D",$last_notif,@YEAR & "/" & @MON & "/" & @MDAY) _log('Ecart: ' & $ecart) if $ecart > $rapport_send_periode_jours then $type_envoi = "Notification périodique" _log('Type d''envoi: Notification périodique') EndIf EndFunc func _test_mode() $last_ip = FileRead(@ScriptDir & '\last_ip.ini') $last_ip = StringSplit($last_ip," ") $last_date = $last_ip[2] $last_ip = $last_ip[1] _log('Ip précédente: ' & $last_ip) if $rapport_send_wan_mode = "ip" Then $type_tmp = "Sur changement d'ip" _log('Mode de notification sur chagement d''ip') if _verif_ip($last_ip) = _verif_ip($IP_wan) Then _log ('IP identique détecté '& $last_ip & '/' & $IP_wan) Return Else _log('IP différente détecté ' & $last_ip & '/' & $IP_wan) EndIf EndIf if $rapport_send_wan_mode = "toujours" Then $type_tmp = "Toujours" _log('Mode de notification: Toujours') EndIf _log("vérification avec la liste " & $rapport_mode_liste_ip) if $rapport_mode_liste_ip = "blanche" Then $lock_envoi = 0 EndIf if $rapport_mode_liste_ip = "noir" Then $lock_envoi = 1 EndIf _log('IP actuelle: ' & $IP_wan) $i2 = 0 $result = "" For $i = 1 To $IP[0] if $IP[$i] <> "" and not _verif_ip($IP[$i]) = False then $i2 = $i2 + 1 _log('test de l''ip ' & $i2 & ":" & _verif_ip($IP[$i])) if _verif_ip($IP[$i]) = $IP_wan then $result = "OK" _log('test ip ' & $i2 & ' positif') EndIf endif Next if $rapport_mode_liste_ip = "blanche" and $result = "OK" Then $lock_envoi = 1 _log('IP blanche détecté donc envoi inactif') EndIf if $rapport_mode_liste_ip = "noir" and $result = "OK" Then $lock_envoi = 0 _log('IP noir détecté donc envoi actif') EndIf if $lock_envoi = 0 then $type_envoi = $type_tmp _log('Envoi du rapport actif, type de notification: ' & $type_envoi) EndIf EndFunc func _verif_id() $tmp_txt = "Adresse(s) MAC:" $tmp_var = StringSplit(_cmd("ipconfig /all"),":" & @CRLF) for $i = 1 to $tmp_var[0] if Stringleft(StringReplace($tmp_var[$i]," ",""),15) = "Adressephysique" then if StringLen($tmp_var[$i+1]) = 18 then if $antivol_mac_actif = "oui" and $tmp_var[$i+1] <> " 00-00-00-00-00-00" and $tmp_var[$i+1] <> " ff-ff-ff-ff-ff-ff" then $tmp_txt = $tmp_txt & @CRLF & "-" & stringreplace($tmp_var[$i+1],"-",":") endif EndIf next if $antivol_mac_actif = "non" then $tmp_txt = $tmp_txt & @CRLF & "- MAC désactivé pour cette configuration" $tmp_txt = $tmp_txt & @CRLF & @CRLF & "UUID:" $tmp_var = StringSplit(_cmd("wmic csproduct get /value"),"=" & @CRLF) for $i = 1 to $tmp_var[0] if $tmp_var[$i] = "UUID" then if $antivol_uuid_actif = "oui" then $tmp_txt = $tmp_txt & @CRLF & "- " & $tmp_var[$i+1] EndIf next if $antivol_uuid_actif = "non" then $tmp_txt = $tmp_txt & @CRLF & "- UUID désactivé pour cette configuration" $tmp_txt = $tmp_txt & @CRLF & @CRLF & "Numéro de série:" $tmp_var = StringSplit(_cmd("wmic csproduct get /value"),"=" & @CRLF) for $i = 1 to $tmp_var[0] if $tmp_var[$i] = "IdentifyingNumber" then if $antivol_serial_actif = "oui" then $tmp_txt = $tmp_txt & @CRLF & "- " & $tmp_var[$i+1] EndIf next if $antivol_serial_actif = "non" then $tmp_txt = $tmp_txt & @CRLF & "- Numéro de série désactivé pour cette configuration" FileDelete("TempWmicBatchFile.bat") $tmp_txt = $tmp_txt & @CRLF & @CRLF & "Identifiant Windows:" $tmp_var = RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion", "ProductId") if $tmp_var = "" then $tmp_var = RegRead("HKLM64\Software\Microsoft\Windows NT\CurrentVersion", "ProductId") $tmp_txt = $tmp_txt & @CRLF & "- " & $tmp_var if $antivol_Win_ID_actif = "non" then $tmp_txt = $tmp_txt & @CRLF & "- Identifiant Windows désactivé pour cette configuration" return $tmp_txt EndFunc func _add_boot() if not FileExists(@ScriptDir & "\log_boot.ini") then _log('aucun fichier de boot') return False EndIf FileWrite(@ScriptDir & '\rapport\01 boot.txt',"DEMARRAGES SYSTEME" & @CRLF & @CRLF) $read = FileRead(@ScriptDir & "\log_boot.ini") $line = StringSplit($read, @CR) for $i = 1 to $line[0] FileWriteLine(@ScriptDir & '\rapport\01 boot.txt',$line[$i]) next EndFunc Func _add_bios() FileWrite(@ScriptDir & '\rapport\02 bios.txt',"BIOS" & @CRLF & @CRLF) $tmp_var = StringSplit(_cmd("wmic BIOS get /value"),"=" & @CRLF) for $i = 1 to $tmp_var[0] if $tmp_var[$i] = "Name" then FileWrite(@ScriptDir & '\rapport\02 bios.txt',"Nom: " & $tmp_var[$i+1] & @CRLF) if $tmp_var[$i] = "Manufacturer" then FileWrite(@ScriptDir & '\rapport\02 bios.txt',"Fabricant: " & $tmp_var[$i+1] & @CRLF) if $tmp_var[$i] = "Version" then FileWrite(@ScriptDir & '\rapport\02 bios.txt',"Version: " & $tmp_var[$i+1] & @CRLF) next EndFunc func _add_OS() FileWrite(@ScriptDir & '\rapport\04 OS.txt',"OS" & @CRLF & @CRLF) $tmp_var = StringSplit(_cmd("wmic OS get /value"),"=" & @CRLF) for $i = 1 to $tmp_var[0] if $tmp_var[$i] = "Caption" then FileWrite(@ScriptDir & '\rapport\04 OS.txt',"Nom de l'OS: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "CSDVersion" then FileWrite(@ScriptDir & '\rapport\04 OS.txt',"Service pack installé: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "OSArchitecture" then FileWrite(@ScriptDir & '\rapport\04 OS.txt',"Architecture de l'OS: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "OSLanguage" then FileWrite(@ScriptDir & '\rapport\04 OS.txt',"Code langue: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "SystemDirectory" then FileWrite(@ScriptDir & '\rapport\04 OS.txt',"Dossier d'installation système: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "Version" then FileWrite(@ScriptDir & '\rapport\04 OS.txt',"Version: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) next EndFunc func _add_stock() FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',"STOCKAGE" & @CRLF) $tmp_var = StringSplit(_cmd("wmic diskdrive get /value"),"=" & @CRLF) for $i = 1 to $tmp_var[0] if $tmp_var[$i] = "Caption" then FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',@CRLF & "Nom: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "InterfaceType" then FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',"Type d'interface: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "Size" then FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',"Taille du disque: " & _adapt_aut($tmp_var[$i+1]) & " Octets" & @CRLF) if $tmp_var[$i] = "Partitions" then FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',"Nombre de partitions: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "TotalSectors" then FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',"Nombre de secteur: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "Status" then FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',"Statut du disque: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) next FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',@CRLF) $tmp_var = StringSplit(_cmd("wmic logicaldisk get /value"),"=" & @CRLF) for $i = 1 to $tmp_var[0] if $tmp_var[$i] = "Caption" then FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',@CRLF & "Lettre de lecteur: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "Description" then FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',"Type: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "FileSystem" then FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',"Format: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "FreeSpace" then FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',"Espace libre: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "VolumeName" then FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',"Nom: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "VolumeSerialNumber" then FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',"Numéro de série du volume: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "Size" then FileWrite(@ScriptDir & '\rapport\08 STOCKAGE.txt',"Taille: " & _adapt_aut($tmp_var[$i+1]) & " Octets" & @CRLF) next EndFunc func _add_session() FileWrite(@ScriptDir & '\rapport\07 SESSIONS.txt',"SESSIONS" & @CRLF & @CRLF) $tmp_var = StringSplit(_cmd("wmic netlogin get /value"),"=" & @CRLF) for $i = 1 to $tmp_var[0] if _adapt_aut($tmp_var[$i]) = "Caption" then $lock = 1 if _adapt_aut($tmp_var[$i]) = "Caption" and stringleft(_adapt_aut($tmp_var[$i+1]),8) <> "AUTORITE" then $lock = 0 FileWrite(@ScriptDir & '\rapport\07 SESSIONS.txt',@CRLF & "Nom de la session: " & _adapt_aut($tmp_var[$i+1]) & @CRLF ) EndIf if _adapt_aut($tmp_var[$i]) = "NumberOfLogons" and _adapt_aut($tmp_var[$i+1]) <> "" then FileWrite(@ScriptDir & '\rapport\07 SESSIONS.txt',"Nombre de connexion: " & _adapt_aut($tmp_var[$i+1]) & @CRLF ) next EndFunc func _add_proc() FileWrite(@ScriptDir & '\rapport\05 PROCESSEUR.txt',"PROCESSEUR" & @CRLF & @CRLF) $tmp_var = StringSplit(_cmd("wmic cpu get /value"),"=" & @CRLF) for $i = 1 to $tmp_var[0] if $tmp_var[$i] = "Name" then FileWrite(@ScriptDir & '\rapport\05 PROCESSEUR.txt',"Nom du processeur: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "NumberOfCores" then FileWrite(@ScriptDir & '\rapport\05 PROCESSEUR.txt',"Nombre: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "NumberOfLogicalProcessors" then FileWrite(@ScriptDir & '\rapport\05 PROCESSEUR.txt',"Nombre de thread: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "MaxClockSpeed" then FileWrite(@ScriptDir & '\rapport\05 PROCESSEUR.txt',"Vitesse maximale de l'horloge sans le turbo boost: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "AddressWidth" then FileWrite(@ScriptDir & '\rapport\05 PROCESSEUR.txt',"Architecture: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "L2CacheSize" then FileWrite(@ScriptDir & '\rapport\05 PROCESSEUR.txt',"Taille du cache L2: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "L3CacheSize" then FileWrite(@ScriptDir & '\rapport\05 PROCESSEUR.txt',"Taille du cache L3: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) next EndFunc func _add_user() FileWrite(@ScriptDir & '\rapport\09 USERS.txt',"USERS" & @CRLF & "Utilisateur courrant: " & @UserName & @CRLF) $tmp_var = StringSplit(_cmd("wmic useraccount get /value"),@CRLF) for $i = 1 to $tmp_var[0] if StringLeft($tmp_var[$i],11) = "AccountType" then FileWrite(@ScriptDir & '\rapport\09 USERS.txt', @CRLF) if _adapt_aut($tmp_var[$i]) <> "" then FileWrite(@ScriptDir & '\rapport\09 USERS.txt',_adapt_aut($tmp_var[$i])& @CRLF) next EndFunc Func _add_prog() FileWrite(@ScriptDir & '\rapport\06 LOGICIELS.txt',"LOGICIELS" & @CRLF ) $count = 0 $tmp_var = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" While 1 $count += 1 $key = RegEnumKey($tmp_var, $count) If @error Then ExitLoop $count2 = 0 While 1 $count2 += 1 $key2 = RegEnumVal($tmp_var & '\' & $key, $count2) If @error Then ExitLoop if $key2 = "DisplayName" then FileWrite(@ScriptDir & '\rapport\06 LOGICIELS.txt',@CRLF & "Logiciel: " & RegRead($tmp_var & '\' & $key,$key2) & @CRLF) WEnd $count2 = 0 While 1 $count2 += 1 $key2 = RegEnumVal($tmp_var & '\' & $key, $count2) If @error Then ExitLoop if $key2 = "Publisher" then FileWrite(@ScriptDir & '\rapport\06 LOGICIELS.txt',"Fabricant: " & RegRead($tmp_var & '\' & $key,$key2) & @CRLF) if $key2 = "InstallDate" then FileWrite(@ScriptDir & '\rapport\06 LOGICIELS.txt',"Date d'installation: " & RegRead($tmp_var & '\' & $key,$key2) & @CRLF) if $key2 = "InstallLocation" then FileWrite(@ScriptDir & '\rapport\06 LOGICIELS.txt',"Dossier: " & RegRead($tmp_var & '\' & $key,$key2) & @CRLF) if $key2 = "DisplayVersion" then FileWrite(@ScriptDir & '\rapport\06 LOGICIELS.txt',"Version: " & RegRead($tmp_var & '\' & $key,$key2) & @CRLF) WEnd WEnd EndFunc Func _add_reseau() FileWrite(@ScriptDir & '\rapport\10 RESEAUX.txt',"RESEAUX" & @CRLF ) $tmp_var = StringSplit(_cmd("ipconfig /all"),@CRLF) for $i = 1 to $tmp_var[0] if _adapt_aut($tmp_var[$i]) <> "" then FileWrite(@ScriptDir & '\rapport\10 RESEAUX.txt',_adapt_aut($tmp_var[$i]) & @CRLF) next EndFunc func _add_infos() FileWrite(@ScriptDir & '\rapport\03 infos.txt',"INFOS" & @CRLF & @CRLF & "NOM [computername]: " & @ComputerName & @CRLF & "UserDomain: " & @LogonDomain & @CRLF) $tmp_var = StringSplit(_cmd("wmic csproduct get /value"),"=" & @CRLF) for $i = 1 to $tmp_var[0] if $tmp_var[$i] = "IdentifyingNumber" then FileWrite(@ScriptDir & '\rapport\03 infos.txt',"Numéro de série: " & $tmp_var[$i+1] & @CRLF) if $tmp_var[$i] = "Name" then FileWrite(@ScriptDir & '\rapport\03 infos.txt',"Type: " & $tmp_var[$i+1] & @CRLF) if $tmp_var[$i] = "UUID" then FileWrite(@ScriptDir & '\rapport\03 infos.txt',"UUID: " & $tmp_var[$i+1] & @CRLF) if $tmp_var[$i] = "Vendor" then FileWrite(@ScriptDir & '\rapport\03 infos.txt',"Marque: " & $tmp_var[$i+1] & @CRLF) if $tmp_var[$i] = "Version" then FileWrite(@ScriptDir & '\rapport\03 infos.txt',"Version: " & $tmp_var[$i+1] & @CRLF) next $tmp_var = StringSplit(_cmd("systeminfo"),":" & @CRLF) for $i = 1 to $tmp_var[0] if $tmp_var[$i] = "Propri‚taire enregistr‚" then FileWrite(@ScriptDir & '\rapport\03 infos.txt',"Propriétaire enregistré: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "Identificateur de produit" then FileWrite(@ScriptDir & '\rapport\03 infos.txt',"Identificateur de produit: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "Date d'installation originale" then FileWrite(@ScriptDir & '\rapport\03 infos.txt',"Date d'installation originale: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "M‚moire physique totale" then FileWrite(@ScriptDir & '\rapport\03 infos.txt',"Mémoire physique totale: " & _adapt_aut($tmp_var[$i+1]) & @CRLF) if $tmp_var[$i] = "Correctif(s)" then FileWrite(@ScriptDir & '\rapport\03 infos.txt',"Correctif(s): " & _adapt_aut($tmp_var[$i+1]) & @CRLF) next EndFunc func _def_boot() $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,(Security)}!\\" & @ComputerName & "\root\cimv2") If IsObj($objWMIService) Then $colItems = $objWMIService.ExecQuery ("Select * FROM Win32_NTLogEvent WHERE Logfile = 'System' AND SourceName = 'eventlog' AND EventCode = 6005") If IsObj($colItems) Then For $objEvent In $colItems $tmp_var = $objEvent.TimeGenerated FileWriteLine(@ScriptDir & "\log_boot.ini","Start_ " & _get_date($tmp_var) & " (UTC)") ExitLoop Next EndIf $colItems = $objWMIService.ExecQuery ("Select * FROM Win32_NTLogEvent WHERE Logfile = 'System' AND SourceName = 'eventlog' AND EventCode = 6006") If IsObj($colItems) Then For $objEvent In $colItems $tmp_var = $objEvent.TimeGenerated FileWriteLine(@ScriptDir & "\log_boot.ini","Stop_ " & _get_date($tmp_var) & " (UTC)") ExitLoop Next EndIf EndIf EndFunc func _notif() if $antivol_message_mode <> "inactif" Then _log('Envoi de la notification ...') _get_ip_wan() $txt = "Le système antivol à été activé sur l'ordinateur " & @ComputerName & "." & @CRLF & "IP Publique actuele: " & $IP_wan & "[" & @MDAY & "/" & @MON & "/" & @YEAR & '-' & @HOUR & "h" & @MIN & "m" & @SEC & " - " & $IP_wan_statut & "]" & @CRLF & _ "Détails supplémentaire sur l'ip publique à l'adresse http://whatismyipaddress.com/ip/" & $IP_wan & @CRLF & _ "ID de l'installation IPSvc: " & $general_id & @CRLF & @CRLF & _ "Identifiants utilisable par le service antivol pour l'ordinateur " & @ComputerName & ":" & @CRLF & _verif_id() if $antivol_message_mode = "mail" Then if _smail(_adapt($antivol_notif_name),$txt) = True then _log('Le mail à bien été envoyé') else _log('Echec mail') EndIf endif if $antivol_message_mode = "ftp" Then FileWrite(@ScriptDir & "\" & _adapt($antivol_notif_name) & ".txt",$txt) if _upload_ftp($server, $username, $pass, $tmp_fd,@ScriptDir & "\" & _adapt($antivol_notif_name) & ".txt") = true Then _log('Le fichier à bien été uploadé') Else _log('Echec ftp') EndIf FileDelete(@ScriptDir & "\" & _adapt($antivol_notif_name) & ".txt") EndIf Else _log('Notification antivol inactive') EndIf EndFunc func _get_date($tmp_var) $tmp_var = stringleft($tmp_var,14) $tmp_yyyy = stringleft($tmp_var,4) $tmp_mm = StringRight(stringleft($tmp_var,6),2) $tmp_dd = StringRight(stringleft($tmp_var,8),2) $tmp_hh = StringRight(stringleft($tmp_var,10),2) $tmp_m = StringRight(stringleft($tmp_var,12),2) $tmp_ss = StringRight(stringleft($tmp_var,14),2) return $tmp_dd & "/" & $tmp_mm & "/" & $tmp_yyyy & "-" & $tmp_hh & "h" & $tmp_m & "m" & $tmp_ss EndFunc func _log($tmp_var) FileWriteLine($fichier_log,"[" & @HOUR & "h" & @MIN & "m" & @SEC & "] " & $tmp_var) return True EndFunc func _fin_r() _log("====ARRET=RAPPORT========================") Exit EndFunc func _fin_a() _log("====ARRET=ANTIVOL========================") Exit EndFunc func _verif_a_id($var) $var = StringReplace($var,":","-") $tmp_var = StringSplit(_cmd("ipconfig /all"),":" & @CRLF) for $i = 1 to $tmp_var[0] if Stringleft(StringReplace($tmp_var[$i]," ",""),15) = "Adressephysique" then if StringLen($tmp_var[$i+1]) = 18 then if $antivol_mac_actif = "oui" and $var <> "00-00-00-00-00-00" and $var <> "ff-ff-ff-ff-ff-ff" and $var = StringReplace($tmp_var[$i+1]," ","") then return true endif EndIf next $tmp_var = StringSplit(_cmd("wmic csproduct get /value"),"=" & @CRLF) for $i = 1 to $tmp_var[0] if $tmp_var[$i] = "UUID" then if $antivol_uuid_actif = "oui" and $var = $tmp_var[$i+1] then return true EndIf next $tmp_var = StringSplit(_cmd("wmic csproduct get /value"),"=" & @CRLF) for $i = 1 to $tmp_var[0] if $tmp_var[$i] = "IdentifyingNumber" then if $antivol_serial_actif = "oui" and $var = $tmp_var[$i+1] then return true EndIf next FileDelete("TempWmicBatchFile.bat") $tmp_var = RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion", "ProductId") if $tmp_var = "" then $tmp_var = RegRead("HKLM64\Software\Microsoft\Windows NT\CurrentVersion", "ProductId") if $antivol_Win_ID_actif = "oui" and $var = $tmp_var then return true return False EndFunc func _import_alertes() _log("Importation de la liste des fichiers...") $tmp_var2 = @ScriptDir & "\tmp\liste.txt" FileDelete($tmp_var2) if _list_ftp($server, $username, $pass, $tmp_fd & _adapt($ftp_folder_config), ".IPSvc", $tmp_var2) = False then _log("Aucun fichier trouvé sur le serveur ou impossible de récupérer la liste") _fin_a() EndIf If FileExists($tmp_var2) = 1 Then $read = FileRead($tmp_var2) $line = StringSplit($read,@CRLF) $i2 = 100 / ( $line[0] - 1) $i3 = 0 $i4 = 0 For $i = 1 To ($line[0] - 1) $tmp_name = $line[$i] $tmp_fi = @ScriptDir & "\" & $tmp_name _log("Traitement du fichier [" & $i & "/" & ( $line[0] - 1) & "] """ & $tmp_name & """ ...") $tmp_var3 = _download_ftp($server, $username, $pass, $tmp_fd & _adapt($ftp_folder_config), $tmp_name) $i4 = $i4 + 1 $read2 = FileRead($tmp_fi) FileDelete(@ScriptDir & "\*.IPSvc") if $read2 <> "" then $tmp_decrypt = _StringEncrypt(0,$read2,$general_key) $tmp_tab = StringSplit($tmp_decrypt, "|") if $tmp_tab[0] > 60 then _log('Décryptage OK pour l''alerte "' & $tmp_name & '"') if _verif_a_id($tmp_tab[2]) = true then return true _log('L''alerte "' & $tmp_name & '" ne concerne pas cet ordinateur') EndIf EndIf $i3 = $i3 + $i2 Next Else msgbox(48,"","Erreur de lecture de la liste") _fin_a() Endif EndFunc Func _update($var) $tmp_var2 = "" for $i = 1 to $tmp_tab[0] $tmp_var2 &= $tmp_tab[$i] & "|" next $tmp_var2 = StringLeft($tmp_var2,StringLen($tmp_var2) - 1) $tmp_encrypt = _StringEncrypt(1,$tmp_var2,$general_key) $tmp_var3 = @ScriptDir & "\tmp\" & $var FileDelete($tmp_var3) FileWrite($tmp_var3,$tmp_encrypt) if _upload_ftp($server, $username, $pass, $tmp_fd & _adapt($ftp_folder_config), $tmp_var3) = False then _log('Erreur, Upload sur le serveur échoué') return false EndIf EndFunc func _arbo1($path,$filtre = "*") Local $search = FileFindFirstFile($path & "\" & $filtre) If $search = -1 Then return False While 1 Local $file = FileFindNextFile($search) If @error Then ExitLoop $fi = $path & "\" & $file $nxi = $file if FileGetAttrib($fi) = "D" then _arbo1($fi) Else FileMove($fi,$path & "\" & _adapt($antivol_screen_name) & $file) $fi = $path & "\" & _adapt($antivol_screen_name) & $file if $antivol_image_mode = "mail" Then if _smail(_adapt($mail_sujet_screen),"",$fi) = True then _log('Le mail à bien été envoyé') Else _log('Echec mail') EndIf endif if $antivol_image_mode = "ftp" Then if _upload_ftp($server, $username, $pass, $tmp_fd & _adapt($ftp_folder_screen), $fi) = true Then _log('Le fichier à bien été uploadé') Else _log('Echec ftp') EndIf EndIf FileDelete($fi) EndIf WEnd FileClose($search) EndFunc func _arbo2($name,$path,$path2,$filtre = "*",$sd = "") $tmp_result = True Local $search = FileFindFirstFile($path & "\" & $filtre) If $search = -1 Then return False While 1 Local $file = FileFindNextFile($search) If @error Then ExitLoop $fi = $path & "\" & $file $nxi = $file if FileGetAttrib($fi) = "D" then if _arbo2($name,$fi,$path2,"*",StringRight($fi,stringlen($fi) - stringlen($path2))) = True and $tmp_tab[19] = 1 then DirRemove($fi) Else if stringregexp($nxi,$tmp_tab[57],0) = 1 then While 1 if _test_wan(0) = True then ExitLoop Sleep(60000) _log('Tempo, echec connexion...') WEnd if $sd <> "" then $sd &= "/" $sd1 = StringReplace(StringRight($sd,stringlen($sd) - 1),"\","/") if _upload_ftp($server, $username, $pass, $tmp_fd & _adapt($ftp_folder_recup) & $name & "/"& $sd1, $fi) = true Then if $tmp_tab[19] = 1 then FileDelete($fi) Else _log('Echec d''upload ftp pour le fichier :' & $fi & " /// " & $tmp_fd & "RECUP_" & @ComputerName & "/" &$name& "/"& $sd1) $tmp_result = False EndIf EndIf EndIf WEnd FileClose($search) return $tmp_result EndFunc func _arbo3($path,$path2,$filtre = "*",$sd = "") Local $search = FileFindFirstFile($path & "\" & $filtre) If $search = -1 Then return False While 1 Local $file = FileFindNextFile($search) If @error Then ExitLoop $fi = $path & "\" & $file $nxi = $file if FileGetAttrib($fi) = "D" then _arbo3($fi,$path2,"*",StringRight($fi,stringlen($fi) - stringlen($path2))) if DirRemove($fi) = 1 Then $supr_do = $supr_do +1 Else $supr_er = $supr_er +1 EndIf Else if FileDelete($fi) = 1 Then $supr_fi = $supr_fi +1 Else $supr_er = $supr_er +1 EndIf EndIf WEnd FileClose($search) EndFunc #endregion #region ;INTERFACE GRAFIQUE ONGLET Gestion des alertes; func _add_alerte() GUISetState(@SW_SHOW,$Form2) _up_gui() winsettitle("Ajouter une alerte antivol","","Patientez ...") if _test_wan(0) = False then msgbox(48,"Pas de connexion","Attention, Vous ne pouvez pas ajouter d'alerte sans connexion internet",$Form2) winsettitle("Patientez ...","","Ajouter une alerte antivol") EndFunc func _f2() #include #include #Region ### START Koda GUI section ### Form= global $Form2 = GUICreate("Ajouter une alerte antivol", 357, 315, 288, 294,-1,-1,$form1) global $Checkbox14= GUICtrlCreateCheckbox("Activer la webcam toute les ", 8, 48, 153, 17) global $Input6 = GUICtrlCreateInput("300", 161, 49, 33, 17, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) global $Label12= GUICtrlCreateLabel("secondes", 200, 50, 50, 17) global $Checkbox15 = GUICtrlCreateCheckbox("Activer les screenshot toute les ", 8, 72, 169, 17) global $Input7 = GUICtrlCreateInput("300", 177, 73, 33, 17, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) global $Label13 = GUICtrlCreateLabel("secondes", 216, 74, 50, 17) global $combo1 = GUICtrlCreateCombo("", 8, 16, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL,$CBS_DROPDOWNLIST)) GUICtrlSetTip(-1, "Sélectionnez le type d'identifiant utilisé.") if $antivol_Win_ID_actif = "oui" then GUICtrlSetData(-1, "Win ID","Win ID") if $antivol_serial_actif = "oui" then GUICtrlSetData(-1, "SERIAL","SERIAL") if $antivol_UUID_actif = "oui" then GUICtrlSetData(-1, "UUID","UUID") if $antivol_mac_actif = "oui" then GUICtrlSetData(-1, "MAC","MAC") global $Input8 = GUICtrlCreateInput("", 88, 16, 265, 21) GUICtrlSetTip(-1,"IDentifiant de la machine ciblé" & @CRLF & "Exemples:" & @crlf & "MAC: 5E:FF:56:A2:AF:15" & @crlf & "Windows ID: 00569-OEM-5247836-13846" & @crlf & "UUID: 110E8400-E29B-11D4-A716-446655440000" ) GUIStartGroup() global $Checkbox20 = GUICtrlCreateCheckbox("Récupérer des fichiers à distance", 8, 96, 177, 17) global $Checkbox21 = GUICtrlCreateCheckbox("", 24, 120, 17, 17) global $Input10 = GUICtrlCreateInput("", 48, 120, 305, 21) GUICtrlSetTip(-1, "Chemin du dossier distant à récupérer(ex:""c:\dossier1;c:\dossier2"")."& @crlf & @crlf & $variables_utilisables) global $Checkbox23 = GUICtrlCreateCheckbox("Documents", 24, 144, 81, 17) GUICtrlSetTip(-1, "Dossier(s) corespondant pour cette machine: " & _get_folder_var("Personal")) global $Checkbox24 = GUICtrlCreateCheckbox("Bureaux", 112, 144, 65, 17) GUICtrlSetTip(-1, "Dossier(s) corespondant pour cette machine: " & _get_folder_var("Desktop")) global $Checkbox25 = GUICtrlCreateCheckbox("Favoris", 184, 144, 65, 17) GUICtrlSetTip(-1, "Dossier(s) corespondant pour cette machine: " & _get_folder_var("Favorites")) global $Checkbox26 = GUICtrlCreateCheckbox("Médias", 256, 144, 65, 17) GUICtrlSetTip(-1, "Dossier(s) corespondant pour cette machine: " & _get_folder_var("My Music")& _get_folder_var("My Pictures")& _get_folder_var("My Video")) global $Checkbox22 = GUICtrlCreateCheckbox("Mode déplacement", 24, 168, 113, 17) GUICtrlSetTip(-1, "les fichiers sont supprimé une fois uploadé sur le serveur ftp") global $Input12 = GUICtrlCreateInput(".*", 152, 168, 201, 17) GUICtrlSetTip(-1, "Filtre pour les fichiers (exemple pour récupérer les fichiers csv et pdf: .*csv|.*pdf)" & @CRLF & "caractères spéciaux: ""OU"" (|), jocker (.), caractères de répétition (*, +, ?, {...} )") GUIStartGroup() GUIStartGroup() global $Checkbox16 = GUICtrlCreateCheckbox("Supprimer des fichiers à distance", 8, 192, 177, 17) global $Input9 = GUICtrlCreateInput("", 48, 216, 297, 21) GUICtrlSetTip(-1, "Chemin du dossier distant à supprimer(ex:""c:\dossier1;c:\dossier2"")."& @crlf & @crlf & $variables_utilisables) global $Checkbox17 = GUICtrlCreateCheckbox("", 24, 216, 17, 17) global $Checkbox18 = GUICtrlCreateCheckbox("Profils utilisateurs", 24, 240, 105, 17) GUICtrlSetTip(-1, "Dossier corespondant pour cette machine: " & _get_ProfileUser()) global $Checkbox19 = GUICtrlCreateCheckbox("Programmes", 136, 240, 81, 17) GUICtrlSetTip(-1, "Dossiers corespondant pour cette machine: " & @ProgramFilesDir & ";" & @ProgramsCommonDir ) GUIStartGroup() global $checkbox27 = GUICtrlCreateCheckbox("Supprimer l'espace libre des volumes de stockage",8,264,250,17) global $Button13 = GUICtrlCreateButton("Valider", 16, 285, 145, 25) global $Button14 = GUICtrlCreateButton("Annuler", 192, 285, 145, 25) Dim $Form2_AccelTable[2][2] = [["{ENTER}", $Button13],["{ESC}", $Button14]] GUISetAccelerators($Form2_AccelTable) GUISetState(@SW_hide) #EndRegion ### END Koda GUI section ### global $Form3 = GUICreate("", 202, 64, 590, 569) global $Input11 = GUICtrlCreateInput("", 80, 8, 113, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL)) global $Label15 = GUICtrlCreateLabel("Mot de passe:", 8, 10, 71, 17) global $Button15 = GUICtrlCreateButton("OK", 8, 32, 89, 25) global $Button16 = GUICtrlCreateButton("Annuler", 104, 32, 89, 25) Dim $Form3_AccelTable[2][2] = [["{ENTER}", $Button15],["{ESC}", $Button16]] GUISetAccelerators($Form3_AccelTable) GUISetState(@SW_hide) EndFunc func _run_add_alerte() $tmp_var = "" if GUICtrlRead($combo1) = "" then $tmp_var = "Vous devez sélectionner le type de l'identifiant de la machine" & @crlf & $tmp_var if GUICtrlRead($Input8) = "" then $tmp_var = "Vous devez indiquer l'identifiant de la machine cible pour pouvoir lui envoyer cette alerte" & @crlf & $tmp_var if GUICtrlRead($combo1) = "MAC" Then $tmp_var2 = StringSplit(GUICtrlRead($Input8),":") if $tmp_var2[0] <> 6 then $tmp_var = "Une adresse MAC est composé de 6 octets" & @crlf & $tmp_var EndIf if GUICtrlRead($combo1) = "Win ID" Then $tmp_var2 = StringSplit(GUICtrlRead($Input8),"-") if $tmp_var2[0] <> 4 then $tmp_var = "Format Windows ID invalide" & @crlf & $tmp_var EndIf if GUICtrlRead($combo1) = "UUID" Then $tmp_var2 = StringSplit(GUICtrlRead($Input8),"-") if $tmp_var2[0] <> 5 then $tmp_var = "Format UUID invalide" & @crlf & $tmp_var EndIf if $tmp_var <> "" then msgbox(48,"Erreur",$tmp_var,"",$Form2) return False EndIf return true EndFunc func _run_add_alerte2() GUICtrlSetState($Progress1,$gui_show) GUICtrlSetState($Button18,$GUI_HIDE) GUICtrlSetData($Progress1, 0) GUICtrlSetData($Label14,"Création du contenu du fichier ...") $tmp_var2 = GUICtrlRead($combo1) & "|" & GUICtrlRead($Input8) & "|CAM|" & GUICtrlRead($Checkbox14) & "|" & GUICtrlRead($Input6) & "|SCREEN|" & GUICtrlRead($Checkbox15) & "|" & GUICtrlRead($Input7) & _ "|SUPPR|" & GUICtrlRead($Checkbox16) & "|" & GUICtrlRead($Checkbox17) & "|" & GUICtrlRead($Input9) & "|" & GUICtrlRead($Checkbox18) & "|" & GUICtrlRead($Checkbox19) & _ "|RECUP|" & GUICtrlRead($Checkbox20) & "|" & GUICtrlRead($Checkbox21) & "|" & GUICtrlRead($Input10) & "|" & GUICtrlRead($Checkbox22) & "|" & GUICtrlRead($Checkbox23) & "|" & GUICtrlRead($Checkbox24) & "|" & GUICtrlRead($Checkbox25) & "|" & GUICtrlRead($Checkbox26) & _ "|0xFE7373|0x81FE73|" & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & "h" & @MIN & "|aucune|Cette information sera récupérré lors de l'activation de cette alerte|aucune|aucune|aucune|aucune||||36||aucune||||||||46||||||||||56|" & GUICtrlRead($Input12) & "|" & GUICtrlRead($Checkbox27) & "||||||64|||||||||73|" GUICtrlSetData($Label14,"Cryptage ...") $tmp_encrypt = _StringEncrypt(1,$tmp_var2,$general_key) GUICtrlSetData($Label14,"Création du fichier ...") $tmp_var5 = @MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC $tmp_var3 = @TempDir & "\tmp\ALERTE_" & $tmp_var5 & ".IPSvc" $tmp_var4 = @TempDir & "\tmp\ALERTE_" & $tmp_var5 & ".IPSvc" DirCreate(@TempDir & "\tmp") FileWrite($tmp_var3,$tmp_encrypt) GUICtrlSetData($Label14,"Upload du fichier ...") GUICtrlSetData($Progress1, 40) if _upload_ftp($server, $username, $pass, $tmp_fd & _adapt($ftp_folder_config), $tmp_var4,@TempDir) = False then msgbox(48,"Erreur","Upload sur le serveur échoué","",$form2) return false EndIf GUICtrlSetData($Progress1, 90) $item1 = GUICtrlCreateListViewItem(GUICtrlRead($combo1) & "|" & GUICtrlRead($Input8) & "|" & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & "h" & @MIN & "|" & "ALERTE_" & $tmp_var5 & ".IPSvc", $ListView1) GUICtrlSetBkColor(-1, "0xFE7373") EndFunc func _up_gui() ;Global $antivol_image_mode = "ftp" ;Global $antivol_message_mode = "mail" ;Global $antivol_fichiers_mode = "ftp" If GUICtrlread($Checkbox14) = 1 Then if $antivol_image_mode = "inactif" then GUICtrlSetState($Checkbox14, $GUI_unchecked) msgbox(48,"Erreur","La gestion des images n'a pas été activé pour ce profil de configuration","",$form2) Else GUICtrlSetState($input6, $GUI_ENABLE) EndIf Else GUICtrlSetState($input6, $GUI_DISABLE) EndIf If GUICtrlread($Checkbox17) = 1 Then GUICtrlSetState($input9, $GUI_ENABLE) Else GUICtrlSetState($input9, $GUI_DISABLE) EndIf If GUICtrlread($Checkbox21) = 1 Then GUICtrlSetState($input10, $GUI_ENABLE) Else GUICtrlSetState($input10, $GUI_DISABLE) EndIf If GUICtrlread($Checkbox15) = 1 Then if $antivol_image_mode = "inactif" then GUICtrlSetState($Checkbox15, $GUI_unchecked) msgbox(48,"Erreur","La gestion des images n'a pas été activé pour ce profil de configuration","",$form2) Else GUICtrlSetState($input7, $GUI_ENABLE) EndIf Else GUICtrlSetState($input7, $GUI_DISABLE) EndIf If GUICtrlread($Checkbox16) = 1 Then GUICtrlSetState($Checkbox17, $GUI_ENABLE) GUICtrlSetState($Checkbox18, $GUI_ENABLE) GUICtrlSetState($Checkbox19, $GUI_ENABLE) Else GUICtrlSetState($input9, $GUI_DISABLE) GUICtrlSetState($Checkbox17, $GUI_DISABLE) GUICtrlSetState($Checkbox18, $GUI_DISABLE) GUICtrlSetState($Checkbox19, $GUI_DISABLE) EndIf If GUICtrlread($Checkbox20) = 1 Then if $antivol_fichiers_mode = "inactif" then GUICtrlSetState($Checkbox20, $GUI_unchecked) msgbox(48,"Erreur","La gestion des fichiers n'a pas été activé pour ce profil de configuration","",$form2) Else GUICtrlSetState($Checkbox21, $GUI_ENABLE) GUICtrlSetState($Checkbox22, $GUI_ENABLE) GUICtrlSetState($Checkbox23, $GUI_ENABLE) GUICtrlSetState($Checkbox24, $GUI_ENABLE) GUICtrlSetState($Checkbox25, $GUI_ENABLE) GUICtrlSetState($Checkbox26, $GUI_ENABLE) GUICtrlSetState($Input12, $GUI_ENABLE) EndIf Else GUICtrlSetState($input10, $GUI_DISABLE) GUICtrlSetState($Checkbox21, $GUI_DISABLE) GUICtrlSetState($Checkbox22, $GUI_DISABLE) GUICtrlSetState($Checkbox23, $GUI_DISABLE) GUICtrlSetState($Checkbox24, $GUI_DISABLE) GUICtrlSetState($Checkbox25, $GUI_DISABLE) GUICtrlSetState($Checkbox26, $GUI_DISABLE) GUICtrlSetState($Input12, $GUI_DISABLE) EndIf EndFunc func _update_alerte() GUICtrlSetState($Progress1,$gui_show) GUICtrlSetState($Button18,$GUI_HIDE) GUICtrlSetData($Progress1, 0) GUICtrlSetData($Label14,"Importation de la liste des fichiers...") $tmp_var2 = @TempDir & "\tmp" & "\liste" & @AutoItPID & ".txt" FileDelete($tmp_var2) _GUICtrlListView_DeleteAllItems($ListView1) if _list_ftp($server, $username, $pass, $tmp_fd & _adapt($ftp_folder_config), ".IPSvc", $tmp_var2,@TempDir) = False then msgbox(48,"","Aucun fichier trouvé sur le serveur ou impossible de récupérer la liste","",$form1) return false EndIf If FileExists($tmp_var2) = 1 Then $read = FileRead($tmp_var2) $line = StringSplit($read,@CRLF) $var = "" for $i = 1 to $line[0] if StringInStr($line[$i],".IPSvc") <> 0 then $var &=$line[$i]&"/" EndIf next $line = StringSplit($var,"/") $i2 = 100 / ( $line[0] - 1) $i3 = 0 $i4 = 0 $i5 = 0 For $i = 1 To ($line[0] - 1) $tmp_name = $line[$i] $tmp_fi = @TempDir & "\" & $tmp_name GUICtrlSetData($Label14,"Traitement du fichier [" & $i & "/" & ( $line[0] - 1) & "] """ & $tmp_name & """ ...") $tmp_var3 = _download_ftp($server, $username, $pass, $tmp_fd & _adapt($ftp_folder_config), $tmp_name,@TempDir) $i4 = $i4 + 1 $read2 = FileRead($tmp_fi) FileDelete(@TempDir & "\*.IPSvc") if $read2 <> "" then $tmp_decrypt = _StringEncrypt(0,$read2,$general_key) $tmp_tab = StringSplit($tmp_decrypt, "|") if $tmp_tab[0] > 20 then $tab_fi[$i5] = $tmp_name for $i6 = 1 to $tmp_tab[0] $tab[$i5][$i6] = $tmp_tab[$i6] next $item1 = GUICtrlCreateListViewItem($tmp_tab[1] & "|" & $tmp_tab[2] & "|" & $tmp_tab[26] & "|" & $tmp_name, $ListView1) GUICtrlSetBkColor(-1, $tmp_tab[24]) $i5 = $i5 + 1 EndIf EndIf $i3 = $i3 + $i2 GUICtrlSetData($Progress1, $i3) Next Else msgbox(48,"","Erreur de lecture de la liste, redémarrez le programme et réessayez.","",$form1) return false Endif EndFunc func _detail_alerte() for $i = 0 to _GUICtrlListView_GetItemCount($ListView1) if _GUICtrlListView_GetItemFocused($ListView1,$i) = true Then if $tab[$i][33] = "" and $tab[$i][35] = "" then $tab[$i][33] = "la liste des dossiers n'a pas encore été récupéré" if $tab[$i][33] = "" and $tab[$i][35] = "OK" then $tab[$i][33] = "Tous les dossiers ont été traités, la récupération des fichiers est terminée" $tmp_msg = "GENERAL:" & @CRLF & "- type d'identifiant: " & $tab[$i][1] & @CRLF & "- identifiant de l'ordinateur ciblé: " & $tab[$i][2] & @crlf & _ "- date de création de l'alerte :" & $tab[$i][26] & @crlf & _ "- nom de l'ordinateur :" & $tab[$i][28] & @crlf & _ "- dèrnière exécution de l'alerte :" & $tab[$i][32] & @crlf & @CRLF & _ "WEBCAM:" & @CRLF & "- dèrnière exécution :" & $tab[$i][27] & @crlf &@CRLF& _ "SCREENSHOTS:" & @CRLF & "- dèrnière exécution :" & $tab[$i][29] & @crlf & @CRLF & _ "RECUPERATION DE FICHIERS:" & @CRLF & "- dèrnière exécution :" & $tab[$i][30] & @crlf & _ "- dossiers restants à traiter :" & $tab[$i][33] & @CRLF & _ "- dossiers traités :" & $tab[$i][34] & @CRLF & @CRLF & _ "SUPPRESSION DE FICHIERS:" & @CRLF & "- dèrnière exécution :" & $tab[$i][31] & @crlf & _ "- résultat des actions :" & $tab[$i][37] & @crlf & @crlf & _ "SUPPRESSION DE L'ESPACE LIBRE" & @CRLF & "- dèrnière exécution :" & $tab[$i][38] & @crlf & _ "- résultat des actions :" & $tab[$i][59] if $tab[$i][1] <> "" then msgbox(0,$tab_fi[$i],$tmp_msg,"",$form1) Else msgbox(48,"Erreur","1: Aucune alerte n'à été sélectionné" & @CRLF & "2: Impossible d'afficher le detail de cette alerte, actualisez puis recommencez","",$form1) endif EndIf next EndFunc func _del_alerte() GUICtrlSetState($Progress1,$gui_show) GUICtrlSetData($Progress1, 0) $nb_focus = 0 for $i = 0 to _GUICtrlListView_GetItemCount($ListView1) if _GUICtrlListView_GetItemSelected($ListView1,$i) = true or _GUICtrlListView_GetItemFocused($ListView1,$i) = true Then $nb_focus = $nb_focus + 1 next $i2 = 100 / $nb_focus $i3 = 0 for $i = 0 to _GUICtrlListView_GetItemCount($ListView1) if _GUICtrlListView_GetItemSelected($ListView1,$i) = true or _GUICtrlListView_GetItemFocused($ListView1,$i) = true Then $tmp_col = _GUICtrlListView_GetItemText($ListView1,$i) GUICtrlSetData($Label14,"Suppression de l'alerte """ & $tab_fi[$i] & """...") _del_ftp($server, $username, $pass, $tmp_fd & _adapt($ftp_folder_config), $tab_fi[$i],@TempDir) $i3 = $i3 + $i2 GUICtrlSetData($Progress1, $i3) EndIf next _update_alerte() GUICtrlSetState($Progress1,$GUI_HIDE) GUICtrlSetData($Label14,"") GUICtrlSetState($Button18,$gui_show) DirRemove(@TempDir & "\tmp",1) EndFunc #endregion #region ;INSTALLATION/DESINSTALLATION ;mode_gui= gui/cmd func _installation($mode_service = "srvany",$test_actif = "non",$extensions_ini = "0",$reinstal_actif = "non") ;mode_service=srvany/service_runner if $mode_gui = "gui" then GUICtrlSetState($Progress1,$gui_show) GUICtrlSetData($Progress1,0) _up_ba("edit") EndIf _msg("=======INSTALLATION==" & @MDAY & "/" & @MON & "/" & @YEAR & "==========") _msg("démarrage à " & @HOUR & "h" & @MIN) if $mode_general_log = "1" then _msg("log actif sur: " & $cmd_log) if $reinstal_actif = "oui" then _msg("Paramètre de réinstallation actif") if $extensions_ini <> 0 then _msg("Fichier d'extensions sur: " & $extensions_ini) $tmp_var = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\IPSvc","ImagePath") if $tmp_var <> "" Then _msg("Installation existante détecté") $tmp_var2 = StringSplit($tmp_var,"\") $tmp_instalfolder = StringLeft($tmp_var,StringLen($tmp_var) - StringLen($tmp_var2[$tmp_var2[0]]) - 1) if $reinstal_actif = "oui" Then _msg("Suppression de l'ancienne installation ...") if _desinstallation("2") = true Then _msg("Ancienne installation supprimé avec succès") Else _msg("Echec de suppression de l'ancienne installation") _fin_i($mode_gui) $erreur = "Echec de suppression de l'ancienne installation" return false EndIf Else _msg("Annulation de l'installation") _fin_i($mode_gui) $erreur = "Erreur,IPSvc est déjà installé" return false EndIf EndIf _msg("Installation des fichiers ...") if _instal_fichiers($mode_service) = true Then _msg("OK.") Else _msg("ECHEC.") _desinstallation("2") _fin_i($mode_gui) $erreur = "Echec de l'installation des fichiers" return false EndIf if $extensions_ini <> "0" then _msg("Copie des extensions ...") if FileExists($extensions_ini) = 0 then _msg('impossible de trouver le fichier "' & $extensions_ini & '".') if _instal_ext($extensions_ini) = true Then _msg("OK.") Else _msg("ECHEC de copie des extensions.") _desinstallation("2") _fin_i($mode_gui) $erreur = "Echec de l'installation des extensions" return false EndIf EndIf _msg("Création du service ...") if _create_svc($mode_service) = true Then _msg("OK.") Else _msg("ECHEC.") _desinstallation("2") _fin_i($mode_gui) $erreur = "Echec de la création du service" return false EndIf _msg("Modification des attributs de dossier ...") if fileSetAttrib(_adapt($general_install_foler) & "\","+HS") = 1 Then _msg("OK.") Else _msg("ECHEC.") _desinstallation("2") _fin_i($mode_gui) $erreur = "Echec de la modification des attributs de dossier" return false EndIf if $test_actif = "oui" then if $ftp_actif = "oui" Then $tmp_fi = "tmp.txt" Filewrite(_adapt($general_install_foler) & "\tmp.txt" , "test") DirCreate(_adapt($general_install_foler) & "\tmp\") _msg("Test ftp upload ...") if _upload_ftp($server, $username, $pass, $tmp_fd, $tmp_fi,_adapt($general_install_foler)) = true Then _msg("OK.") Else _msg("ECHEC.") EndIf _msg("Test ftp download ...") if _download_ftp($server, $username, $pass, $tmp_fd, $tmp_fi,_adapt($general_install_foler)) = true Then _msg("OK.") Else _msg("ECHEC.") EndIf _msg("Test ftp delete ...") if _del_ftp($server, $username, $pass, $tmp_fd, $tmp_fi) = False then _msg("ECHEC.") Else _msg("OK.") EndIf FileDelete(@ScriptDir & "\tmp.txt") Else _msg("test: ftp inactif") EndIf if $mail_actif = "oui" then _msg("Test mail ...") if _smail($mail_sujet) = true Then _msg("OK.") Else _msg("ECHEC.") EndIf Else _msg("test: mail inactif") EndIf EndIf _fin_i($mode_gui) return true EndFunc func _create_svc($mode_service) fileinstall("instsrv.exe",@TempDir & "\instsrv.exe") $tmp_var = RunWait(@TempDir & "\instsrv.exe IPSvc """ & _adapt($general_install_foler) & "\run.bat"" ") FileDelete(@TempDir & "\instsrv.exe") if $tmp_var <> 0 then return false if RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\IPSvc","ImagePath","REG_EXPAND_SZ",_adapt($general_install_foler) & "\srvany.exe") <> 1 then return false if RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\IPSvc\Parameters") <> 1 then return false if RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\IPSvc\Parameters","Application","REG_SZ",_adapt($general_install_foler) & "\run.bat") <> 1 then return false if RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\IPSvc\Parameters","Version","REG_SZ",$general_version) <> 1 then return false if RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\IPSvc\Parameters","Date_instal","REG_SZ",@MDAY & "/" & @MON & "/" & @YEAR) <> 1 then return false return true EndFunc func _instal_ext($extensions_ini) $read = FileRead($extensions_ini) $line = StringSplit($read, @CR) For $i = 1 To $line[0] $tmp_var = StringReplace($line[$i],@lf,"") _msg("copie: " & $tmp_var) if FileCopy($tmp_var,_adapt($general_install_foler) & "\",1) = 1 Then _msg("OK.") Else _msg("ECHEC.") return false EndIf Next return True EndFunc func _desinstallation($niveau_interactif = "1") ;$niveau_interactif=1(maximal)/2(réduis, utilisé pour l'annulation d'installation par exemple) if $mode_gui = "gui" then GUICtrlSetState($Progress1,$gui_show) GUICtrlSetData($Progress1,0) _up_ba("edit") EndIf if $niveau_interactif = 1 then _msg("====DESINSTALLATION==" & @MDAY & "/" & @MON & "/" & @YEAR & "==========") _msg("démarrage à " & @HOUR & "h" & @MIN) if $mode_general_log = "1" then _msg("log actif sur: " & $cmd_log) EndIf if $mode_gui = "gui" then GUICtrlSetData($Progress1,30) $tmp_var = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\IPSvc","ImagePath") if $niveau_interactif <> 1 then $tmp_var = _adapt($general_install_foler) & "\IPSvc.exe" if $tmp_var <> "" Then $tmp_var2 = StringSplit($tmp_var,"\") $tmp_instalfolder = StringLeft($tmp_var,StringLen($tmp_var) - StringLen($tmp_var2[$tmp_var2[0]]) - 1) Else _msg("Erreur,Aucune installation trouvé") _fin_d($niveau_interactif) $erreur = "Erreur,Aucune installation trouvé" return false EndIf if $mode_gui = "gui" then GUICtrlSetData($Progress1,50) If _ServiceRunning("", "IPSvc") Then _msg("Arrêt du service ...") if ShellExecuteWait(@ComSpec , " /c sc stop IPSvc ","","", @SW_HIDE) = 0 then _msg("OK.") Else _msg("ECHEC.") _fin_d($niveau_interactif) $erreur = "Echec de l'arrêt du service" return false EndIf EndIf _msg("Suppression des fichiers ...") if DirRemove($tmp_instalfolder,1) = 1 Then _msg("OK.") Else _msg("ECHEC.") _fin_d($niveau_interactif) $erreur = "Echec de suppression des fichiers, merci de redémarrer votre session puis réessayez." return false EndIf if $mode_gui = "gui" then GUICtrlSetData($Progress1,80) _msg("Suppression du service ...") if ShellExecuteWait(@ComSpec , " /c sc delete IPSvc ","","", @SW_HIDE) = 0 Then _msg("OK.") Else _msg("ECHEC.") _fin_d($niveau_interactif) $erreur = "Echec de suppression du service" return false EndIf if $mode_gui = "gui" then GUICtrlSetData($Progress1,100) _fin_d($niveau_interactif) return True EndFunc func _instal_fichiers($mode_service) if DirCreate(_adapt($general_install_foler)) = 0 then Return False if FileInstall("srvany.exe",_adapt($general_install_foler) & "\srvany.exe",1) = 0 then return false if FileCopy(@ScriptFullPath,_adapt($general_install_foler) & "\" & @ScriptName,1) = 0 then return false if FileWrite(_adapt($general_install_foler) & "\run.bat",'start "IPSvc" "' & _adapt($general_install_foler) & "\" & @ScriptName & '" /run') = 0 then _msg("run.bat") return false EndIf return true EndFunc func _fin_d($niveau_interactif = "1") if $niveau_interactif = 1 then _msg("fin de la désinstallation sur " & @ComputerName) _msg("=========================================") if $mode_gui = "gui" then if $niveau_interactif = "1" then GUICtrlSetState($Progress1,$GUI_HIDE) _up_bi() _up_ba() EndIf EndIf EndFunc Func _fin_i($mode_gui) _msg("fin de l'installation sur " & @ComputerName) _msg("=========================================") if $mode_gui = "gui" then ;msgbox(0,"","pause") GUICtrlSetState($Progress1,$GUI_HIDE) _up_bi() _up_ba() EndIf EndFunc func _msg($msg) if $mode_general_log = "1" then FileWriteLine($cmd_log,"[" & @HOUR & "h" & @MIN & "m" & @SEC & "] " &$msg) if $mode_gui = "gui" then GUICtrlSetData($Edit1,GUICtrlRead($Edit1) & @CRLF & $msg) Else ConsoleWrite(_adapt_cmd($msg) & @crlf) EndIf return True EndFunc #endregion func _cmd_mode() $mode_gui = "cmd" $cmd_instal = "non défini" $cmd_reinstal = "non" $cmd_ext_ini = "0" $cmd_log = "non défini" for $i = 1 to $cmdline[0] if $cmdline[$i] = "/I" then $cmd_instal = "instal normal" $tmp_var2 = $i + 1 if $tmp_var2 < $cmdline[0]+1 and StringLeft($cmdline[$tmp_var2],1) <> "/" then $cmd_ext_ini = $cmdline[$tmp_var2] EndIf if $cmdline[$i] = "/IT" then $cmd_instal = "instal normal + test" $tmp_var2 = $i + 1 if $tmp_var2 < $cmdline[0]+1 and StringLeft($cmdline[$tmp_var2],1) <> "/" then $cmd_ext_ini = $cmdline[$tmp_var2] EndIf if $cmdline[$i] = "/log" then $tmp_var2 = $i + 1 if $tmp_var2 < $cmdline[0]+1 and StringLeft($cmdline[$tmp_var2],1) <> "/" then $cmd_log = $cmdline[$tmp_var2] $mode_general_log = "1" EndIf EndIf if $cmdline[$i] = "/R" then $cmd_reinstal = "oui" next Switch $cmdline[1] case "/?" ConsoleWrite(_adapt_cmd($text_cmd)) Exit case "/I" case "/IT" case "/D" $cmd_instal = "Désinstallation" case "/run" _run_service() case "/_run_rapports" _run_rapports() case "/_run_antivol" _run_antivol() case "/_run_cam" _run_cam($cmdline[2]) case "/_run_screen" _run_screen($cmdline[2]) case Else ConsoleWrite(_adapt_cmd("Paramètre de ligne de commande non reconu:" & $cmdline[1])) exit EndSwitch ;ConsoleWrite(_adapt_cmd("instal=" & $cmd_instal & @CRLF & "réinstal=" & $cmd_reinstal & @CRLF & "cmd_ext_ini=" & $cmd_ext_ini & @CRLF & "cmd_log=" & $cmd_log & @CRLF)) $tmp_var = "srvany" if $cmd_instal = "instal normal" then _installation($tmp_var,"non",$cmd_ext_ini,$cmd_reinstal) if $cmd_instal = "instal normal + test" then _installation($tmp_var,"oui",$cmd_ext_ini,$cmd_reinstal) if $cmd_instal = "Désinstallation" then _desinstallation() exit endfunc #region ;SERVICE func _run_service() global $fichier_log = @ScriptDir & "\log_service.ini" FileDelete(@ScriptDir & "\log_service.ini") FileDelete(@ScriptDir & "\log.txt") _log("==DEMMARAGE=SERVICE==" & @MDAY & "/" & @MON & "/" & @YEAR & "==========") _log("temporisation de " & $general_tempo & "ms.") Sleep($general_tempo) if $general_exec_fichier <> "" then _log('Execution du fichier "' & $general_exec_fichier & '"') Run($general_exec_fichier) if @error then _log("erreur d'éxecution") Else _log("Aucun fichier à éxecuter au démarrage") EndIf if $rapport_actif = "oui" then _log("lancement du rapport automatique") ShellExecuteWait(@ScriptFullPath , ' /_run_rapports') if @error then _log("erreur d'éxecution") _log("fin du rapport automatique") Else _log("le rapport n'est pas actif") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","IPtmpScreen") EndIf if $antivol_actif = "oui" then _log("lancement du système antivol") ShellExecuteWait(@ScriptFullPath , " /_run_antivol") if @error then _log("erreur d'éxecution") _log("fin du système antivol") Else _log("le système antivol n'est pas actif") EndIf _log("====ARRET=SERVICE========================") RunWait(@ComSpec & " /c sc stop IPSvc ", @ScriptDir, @SW_HIDE) EndFunc func _run_rapports() global $fichier_log = @ScriptDir & "\log_rapport.ini" FileDelete($fichier_log) _log("==DEMMARAGE=RAPPORT==" & @MDAY & "/" & @MON & "/" & @YEAR & "==========") _log('Le rapport est actif en mode ' & $rapport_mode) _def_boot() _log('Chargement de la liste ' & $rapport_mode_liste_ip) _charge_liste() _log('Détection de connexion internet') if _test_wan(0) = False then _fin_r() Else _log('Connexion internet OK') EndIf _log('Détection de l''adresse ip publique') _get_ip_wan() _log('Adresse IP publique:' & $IP_wan & '(' & $IP_wan_statut & ')') if not FileExists(@ScriptDir & '\last_ip.ini') Then FileWrite(@ScriptDir & '\last_ip.ini',$IP_wan & ' ' & @MDAY & "/" & @MON & "/" & @YEAR & '-' & @HOUR & "h" & @MIN & "m" & @SEC) _log('fichier last_ip.ini créé') EndIf _log('Détermination du comportement en fonction de l''ip') if not FileExists(@ScriptDir & '\first_notif.ini') then FileWrite(@ScriptDir & '\first_notif.ini',@MDAY & "/" & @MON & "/" & @YEAR & '-' & @HOUR & "h" & @MIN & "m" & @SEC) if $rapport_send_first_notif = "oui" then $type_envoi = "Première notification" _log('Type d''envoi: Première notification') endif EndIf if $rapport_send_periode_actif = "non" then _log('La notification périodique est désactivé') if $rapport_send_wan_actif = "non" then _log('La notification par détection wan est désactivé') if not FileExists(@ScriptDir & '\last_notif_periodique.ini') and $rapport_send_periode_actif = "oui" Then _log('Création du fichier last_notif_periodique.ini') FileWrite(@ScriptDir & '\last_notif_periodique.ini',@YEAR & "/" & @MON & "/" & @MDAY) EndIf if $type_envoi = "0" and $rapport_send_periode_actif = "oui" then _test_periode() if $type_envoi = "0" and $rapport_send_wan_actif = "oui" then _test_mode() if $type_envoi = "0" Then _log('Aucune notification à effectuer') _fin_r() EndIf _log('Notification à effectuer (' & $type_envoi & ')') _log('création du rapport') DirRemove(@scriptdir & "\rapport",1) DirCreate(@scriptdir & "\rapport") $tmp_d = @MDAY & "/" & @MON & "/" & @YEAR & '-' & @HOUR & "h" & @MIN & "m" & @SEC $first_notif = FileRead(@ScriptDir & '\first_notif.ini') $tmp_msg = "Première execution d'IPSvc: " & $first_notif & @CRLF & @CRLF if $type_envoi = "Notification périodique" then $tmp_msg = $tmp_msg & "Type de notification: périodique [tous les " & $rapport_send_periode_jours & " jours]" & @CRLF if $type_envoi = "Première notification" then $tmp_msg = $tmp_msg & "Première notification" & @CRLF if $type_envoi = "Sur changement d'ip" then $tmp_msg = $tmp_msg & "Type de notification: sur changement d'ip publique [précédente=" & $last_ip & "," & $last_date & "]." & @CRLF if $type_envoi = "toujours" then $tmp_msg = $tmp_msg & "Type de notification: Toujours notifier en cas de connexion." & @CRLF $tmp_msg = $tmp_msg & "IP actuelle: " & $IP_wan & "[" & $tmp_d & "]" & @CRLF & @CRLF& _ "Détails supplémentaire sur l'ip publique à l'adresse http://whatismyipaddress.com/ip/" & $IP_wan & @CRLF & _ "ID de l'installation IPSvc: " & $general_id & @CRLF & @CRLF & _ "Identifiants utilisable par le service antivol pour l'ordinateur " & @ComputerName & ":" & @CRLF & _ _verif_id() & @crlf if $rapport_mode = "ftp" then FileWrite(@ScriptDir & "\rapport\00 msg.txt",$tmp_msg) _log('Création du contenu du rapport') if $rapport_contenu_boot_actif = "oui" Then _add_boot() if $rapport_contenu_bios_actif = "oui" Then _add_bios() if $rapport_contenu_infos_actif = "oui" Then _add_infos() if $rapport_contenu_OS_actif = "oui" Then _add_OS() if $rapport_contenu_proc_actif = "oui" Then _add_proc() if $rapport_contenu_prog_actif = "oui" Then _add_prog() if $rapport_contenu_sessions_actif = "oui" Then _add_session() if $rapport_contenu_stockage_actif = "oui" Then _add_stock() if $rapport_contenu_user_actif = "oui" Then _add_user() if $rapport_contenu_reseau_actif = "oui" Then _add_reseau() _log('Fin de création du contenu du rapport') _log('Envoi du rapport par ' & $rapport_mode) if $rapport_mode = "mail" Then $tmp_pj = "" Local $search = FileFindFirstFile(@ScriptDir & "\rapport\*.txt") if @error then _log('erreur FileFindFirstFile') While 1 Local $file = FileFindNextFile($search) If @error Then ExitLoop $tmp_pj &=$file & ";" ;_log('Detection pj: '&$file) WEnd if _smail(_adapt($mail_sujet),$tmp_msg,StringLeft($tmp_pj,StringLen($tmp_pj)-1),@ScriptDir & "\rapport") = True then _log('Le mail à bien été envoyé') if $type_envoi = "Notification périodique" then _log("Mise à jours du fichier last_notif_periodique.ini") FileDelete(@ScriptDir & '\last_notif_periodique.ini') FileWrite(@ScriptDir & '\last_notif_periodique.ini',@YEAR & "/" & @MON & "/" & @MDAY) EndIf _log("Suppression du fichier log_boot.ini") FileDelete(@ScriptDir & "\log_boot.ini") Else _log('Echec mail') _fin_r() EndIf EndIf if $rapport_mode = "ftp" Then $tmp_fftp = @ScriptDir & "\rapport\" & _adapt($ftp_name) & ".log" Local $search = FileFindFirstFile(@ScriptDir & "\rapport\*.txt") if @error then _log('erreur FileFindFirstFile') While 1 Local $file = FileFindNextFile($search) If @error Then ExitLoop $read = FileRead(@ScriptDir & "\rapport\" & $file) $line = StringSplit($read, @CRLF) for $i = 1 to $line[0] if not $line[$i] = "" then FileWrite($tmp_fftp,@crlf & $line[$i]) $tmp_lock = 0 EndIf if $line[$i] = "" and $tmp_lock = 1 then $tmp_lock = 2 FileWrite($tmp_fftp,@crlf) EndIf if $line[$i] = "" and $tmp_lock = 0 then $tmp_lock = 1 next FileWrite($tmp_fftp,@CRLF & @CRLF & "=============================" & @CRLF & @crlf) WEnd if _upload_ftp($server, $username, $pass, $tmp_fd,$tmp_fftp) = true Then _log('Upload du fichier "' & $tmp_fftp & '" réeussi') if $type_envoi = "Notification périodique" then _log("Mise à jours du fichier last_notif_periodique.ini") FileDelete(@ScriptDir & '\last_notif_periodique.ini') FileWrite(@ScriptDir & '\last_notif_periodique.ini',@YEAR & "/" & @MON & "/" & @MDAY) EndIf _log("Suppression du fichier log_boot.ini") FileDelete(@ScriptDir & "\log_boot.ini") Else _log('Upload du fichier "' & $tmp_fftp & '" échoué') endif EndIf _fin_r() EndFunc func _run_antivol() global $fichier_log = @ScriptDir & "\log_antivol.ini" FileDelete($fichier_log) _log("==DEMMARAGE=ANTIVOL==" & @MDAY & "/" & @MON & "/" & @YEAR & "==========") _log('Identifiant de l''installation IPSvc: ' & $general_id) _log('Détection de connexion internet') if _test_wan() = False then _fin_a() Else _log('Connexion internet OK') EndIf _log('importation des alertes sur le serveur ...') if _import_alertes() = True Then _log('L''alerte corespond bien à cet ordinateur') Else _log('Aucune alerte trouvé pour cette ordinateur') if RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","IPtmpScreen") = 1 then _log('clé IPtmpScreen supprimée') _fin_a() EndIf $tmp_tab[32] = @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & "h" & @MIN & "m" & @SEC $tmp_tab[24] = "0xE97500" $tmp_tab[28] = @ComputerName _update($tmp_name) _notif() if $antivol_image_mode <> "inactif" Then _log('Images activent en mode ' & $antivol_image_mode) if $tmp_tab[4] = 1 Then _log('Démarrage du module webcam sur ' & $tmp_tab[5] & ' secondes.') ShellExecute(@ScriptFullPath,"/_run_cam " & $tmp_tab[5]) $tmp_tab[27] = @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & "h" & @MIN & "m" & @SEC _update($tmp_name) EndIf if $tmp_tab[7] = 1 Then _log('Démarrage du module screenshots sur ' & $tmp_tab[8] & ' secondes.') ShellExecute(@ScriptFullPath,"/_run_screen " & $tmp_tab[8]) $tmp_tab[29] = @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & "h" & @MIN & "m" & @SEC _update($tmp_name) Else if RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","IPtmpScreen") = 1 then _log('clé IPtmpScreen supprimée') EndIf Else if RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","IPtmpScreen") = 1 then _log('clé IPtmpScreen supprimée') EndIf if $antivol_fichiers_mode = "ftp" and $tmp_tab[16] = 1 Then $tmp_tab[30] = @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & "h" & @MIN & "m" & @SEC _update($tmp_name) _run_recup_fichiers() EndIf if $tmp_tab[10] = 1 Then $tmp_tab[31] = @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & "h" & @MIN & "m" & @SEC _update($tmp_name) _run_suppr_fichiers() EndIf if $tmp_tab[58] = 1 then _log('Démarrage du module suppression d''espace libre') $tmp_tab[38] = @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & "h" & @MIN & "m" & @SEC $tmp_tab[59] = $tmp_tab[59] & ";[debut:" & @HOUR & "h" & @MIN & "]" _update($tmp_name) Local $aArray = DriveGetDrive("FIXED") If not @error Then For $i = 1 To $aArray[0] $tmp_tab[59] = $tmp_tab[59] & "[" & StringUpper($aArray[$i]) & " " _update($tmp_name) _log('Début pour le lecteur' & StringUpper($aArray[$i])) $var = RunWait(@WindowsDir & "\system32\cipher.exe /W:" & StringUpper($aArray[$i])) if @error then $tmp_tab[59] = $tmp_tab[59] & "erreur d'execution]" Else if $var = "0" then $tmp_tab[59] = $tmp_tab[59] & "OK]" Else $tmp_tab[59] = $tmp_tab[59] & "erreur " & $var & " de la commande]" EndIf EndIf _update($tmp_name) Next EndIf $tmp_tab[59] = $tmp_tab[59] & "[fin:" & @HOUR & "h" & @MIN & "]" _update($tmp_name) _log('fin de suppression d''espace libre') EndIf $tmp_tab[24] = "0x81FE73" _update($tmp_name) _fin_a() EndFunc func _run_cam($tmp_var) global $fichier_log = @ScriptDir & "\log_antivol_cam.ini" _log("==DEMMARAGE=CAM==" & @MDAY & "/" & @MON & "/" & @YEAR & "==========") _log('tempo de ' & $tmp_var & ' secondes') DirCreate(@ScriptDir & "\cam") FileInstall("cam.exe",@ScriptDir & "\tmp\cam.exe") While 1 While 1 if _test_wan(0) = True then ExitLoop Sleep(60000) _log('Tempo, echec connexion...') WEnd if ShellExecuteWait(@ScriptDir & "\tmp\cam.exe","",@ScriptDir & "\cam") = 0 Then if FileExists(@ScriptDir & "\cam\image.bmp") Then $tmp_1 = _adapt($antivol_webcam_name) & ".bmp" FileMove(@ScriptDir & "\cam\image.bmp",@ScriptDir & "\cam\" & $tmp_1) if $antivol_image_mode = "mail" Then if _smail(_adapt($mail_sujet_webcam),"",@ScriptDir & "\cam\" & $tmp_1) = True then _log('Le mail à bien été envoyé') Else _log('Echec mail') EndIf endif if $antivol_image_mode = "ftp" Then if _upload_ftp($server, $username, $pass, $tmp_fd & _adapt($ftp_folder_webcam), @ScriptDir & "\cam\" & $tmp_1) = true Then _log('Le fichier à bien été uploadé') Else _log('Echec ftp') EndIf EndIf FileDelete(@ScriptDir & "\cam\" & $tmp_1) EndIf EndIf Sleep($tmp_var*1000) WEnd EndFunc func _run_suppr_fichiers() _log('Démarrage du module suppression de fichiers') $paths = $tmp_tab[12] & ";" if $tmp_tab[13] = 1 then $paths &= _get_ProfileUser() & ";" if $tmp_tab[14] = 1 then $paths &= @ProgramFilesDir & ";" & @ProgramsCommonDir & ";" $paths = _adapt($paths) _log('Dossiers à supprimer :' & $paths) $paths = StringSplit(StringReplace(stringleft($paths,StringLen($paths) - 1),'"',''),";") for $i = 1 to $paths[0] if FileExists($paths[$i]) then _log('Dossier:' & $paths[$i]) $supr_do = 0 $supr_er = 0 $supr_fi = 0 _arbo3($paths[$i],$paths[$i]) if $supr_do + $supr_er + $supr_fi <> 0 then $tmp_tab[37] = $tmp_tab[37] & "/ [" & $paths[$i] & "]->[" & $supr_er & "]err. [" & $supr_fi & "]fichiers sup. [" & $supr_do & "]dossiers sup. /" _update($tmp_name) endif Else $tmp_tab[37] = $tmp_tab[37] & "/ [" & $paths[$i] & "]-> Erreur, ce dossier n'existe pas /" _update($tmp_name) endif next EndFunc func _run_recup_fichiers() _log('Démarrage du module récupération de fichiers') $paths = $tmp_tab[18] & ";" if $tmp_tab[20] = 1 then $paths &= _get_folder_var("Personal") if $tmp_tab[21] = 1 then $paths &= _get_folder_var("Desktop") if $tmp_tab[22] = 1 then $paths &= _get_folder_var("Favorites") if $tmp_tab[23] = 1 then $paths &= _get_folder_var("My Music")& _get_folder_var("My Pictures")& _get_folder_var("My Video") $paths = _adapt($paths) _log('Dossiers à récupérer :' & $paths) if $tmp_tab[33] = "" and $tmp_tab[35] = "" then $tmp_tab[33] = $paths $tmp_tab[35] = "OK" _update($tmp_name) EndIf if $tmp_tab[35] = "OK" and $tmp_tab[33] = "" then _log('Tous les dossiers on déjà été traité') return EndIf $paths = StringSplit(StringReplace(stringleft($paths,StringLen($paths) - 1),'"',''),";") for $i = 1 to $paths[0] if FileExists($paths[$i]) then _log('Dossier:' & $paths[$i]) While 1 if _test_wan(0) = True then ExitLoop Sleep(60000) _log('Tempo, echec connexion...') WEnd $tmp_1 = StringSplit($paths[$i],"\") _arbo2($tmp_1[$tmp_1[0]],$paths[$i],$paths[$i]) $tmp_tab[33] = StringReplace($tmp_tab[33],$paths[$i] & ";","") $tmp_tab[34] &= $paths[$i] & ";" _update($tmp_name) Else $tmp_tab[33] = StringReplace($tmp_tab[33],$paths[$i] & ";","") $tmp_tab[34] &= "ERREUR, ce dossier n'existe pas: [" & $paths[$i] & "];" _update($tmp_name) EndIf next EndFunc func _run_screen($tmp_var) global $fichier_log = @ScriptDir & "\log_antivol_screen.ini" _log("==DEMMARAGE=SCREEN==" & @MDAY & "/" & @MON & "/" & @YEAR & "==========") _log('tempo de ' & $tmp_var & ' secondes') DirCreate(@ScriptDir & "\screen") FileInstall("nircmd.exe",@ScriptDir & "\tmp\nircmd.exe") $tmp_var = $tmp_var * 1000 $tmp_var2 = RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","IPtmpScreen","REG_SZ",'"' & @ScriptDir & '\tmp\nircmd.exe" loop 10000 ' & $tmp_var & ' savescreenshot "' & @ScriptDir & '\screen\_~$currdate.dd_MM_yyyy$-~$currtime.HH_mm_ss$.jpg" ') if $tmp_var2 = 1 then _log('clé IPtmpScreen ok') While 1 While 1 if _test_wan(0) = True then ExitLoop Sleep(60000) _log('Tempo, echec connexion...') WEnd _arbo1(@ScriptDir & '\screen',"*.jpg") $tmp_var2 = $tmp_var/5 Sleep($tmp_var/5) WEnd EndFunc #endregion