[Ex] Vraie fausse calculatrice pour lancer un navigateur protégé

Partagez vos scripts, et vos applications AutoIt.
Règles du forum
.
Répondre
perlinpinpin
Niveau 1
Niveau 1
Messages : 4
Enregistré le : mar. 04 mars 2014 21:21
Status : Hors ligne

[Ex] Vraie fausse calculatrice pour lancer un navigateur protégé

#1

Message par perlinpinpin » jeu. 28 avr. 2016 06:03

Salut à tous, je partage le petit utilitaire que j'ai créer,

C'est une calculatrice, mais si vous mettez une chaine de plus de 4chars qui n'est pas que des chiffres et que vous appuyez sur entrée ca utilise la chaine comme password pour monter un volume truecrypt puis lancer chrome avec un profil situé sur cette partition.

Ecrire "Conf" puis appuyer sur Entrée pour ouvrir la fenêtre de configuration.

Une fois la partition montée si vous relancez la calculatrice ca lance directement le profil chrome tant que cette dernière est montée.

Les settings sont codés en dur dans le code mais vous pouvez les modifier donc via la fenetre de config et ils seront sauvés dans un fichier crypté à partir du numéro de série du hdd qui sera sauvé dans le repertoire du script si l'app peut ecrire dans le repertoire (donc pas dans program files) sinon ca sera sauvé dans @AppDataDir.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Icon_1.ico
#AutoIt3Wrapper_Outfile=calc.exe
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_Res_Description=VAT Calculator
#AutoIt3Wrapper_Res_Fileversion=0.2.0.0
#EndRegion  ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt("TrayIconHide", 1)
Opt("GUIOnEventMode", 1)
#include <MsgBoxConstants.au3>
#include <GUIConstants.au3>
#include <Crypt.au3>
$settingskey = DriveGetSerial(@HomeDrive & "\")
FileChangeDir(@ScriptDir)
Global $drive, $browspath, $profiledir, $browser, $hidepass, $tcpath, $file
If FileExists("history.ini") = 1 And FileExists(@AppDataDir & "\VAT Calculator\history.ini") = 1 Then
        MsgBox(0, "!", "Config files conflict, please delete one of them" & @LF & @AppDataDir & "\VAT Calculator\history.ini" & @LF & @ScriptDir & "\history.ini")
        Exit
EndIf
If FileExists("history.ini") = 1 Then
        $drive = BinaryToString(_Crypt_DecryptData(IniRead("history.ini", "history", "4", ""), $settingskey, $CALG_AES_128))
        $browspath = BinaryToString(_Crypt_DecryptData(IniRead("history.ini", "history", "3", ""), $settingskey, $CALG_AES_128))
        $profiledir = BinaryToString(_Crypt_DecryptData(IniRead("history.ini", "history", "5", ""), $settingskey, $CALG_AES_128))
        $browser = BinaryToString(_Crypt_DecryptData(IniRead("history.ini", "history", "6", ""), $settingskey, $CALG_AES_128))
        $hidepass = Binary(_Crypt_DecryptData(IniRead("history.ini", "history", "7", ""), $settingskey, $CALG_AES_128))
        $tcpath = BinaryToString(_Crypt_DecryptData(IniRead("history.ini", "history", "1", ""), $settingskey, $CALG_AES_128))
        $file = BinaryToString(_Crypt_DecryptData(IniRead("history.ini", "history", "2", ""), $settingskey, $CALG_AES_128))
ElseIf FileExists(@AppDataDir & "\VAT Calculator\history.ini") = 1 Then
        $drive = BinaryToString(_Crypt_DecryptData(IniRead(@AppDataDir & "\VAT Calculator\history.ini", "history", "4", ""), $settingskey, $CALG_AES_128))
        $browspath = BinaryToString(_Crypt_DecryptData(IniRead(@AppDataDir & "\VAT Calculator\history.ini", "history", "3", ""), $settingskey, $CALG_AES_128))
        $profiledir = BinaryToString(_Crypt_DecryptData(IniRead(@AppDataDir & "\VAT Calculator\history.ini", "history", "5", ""), $settingskey, $CALG_AES_128))
        $browser = BinaryToString(_Crypt_DecryptData(IniRead(@AppDataDir & "\VAT Calculator\history.ini", "history", "6", ""), $settingskey, $CALG_AES_128))
        $hidepass = Binary(_Crypt_DecryptData(IniRead(@AppDataDir & "\VAT Calculator\history.ini", "history", "7", ""), $settingskey, $CALG_AES_128))
        $tcpath = BinaryToString(_Crypt_DecryptData(IniRead(@AppDataDir & "\VAT Calculator\history.ini", "history", "1", ""), $settingskey, $CALG_AES_128))
        $file = BinaryToString(_Crypt_DecryptData(IniRead(@AppDataDir & "\VAT Calculator\history.ini", "history", "2", ""), $settingskey, $CALG_AES_128))
Else
        DefaultSet()
EndIf

If FileExists($drive & ":/") = 0 Then

        Global $Display_String = '', $Real_String = '', $1, $2, $3, $5, $4, $6, $7, $DelButton

        $MainGui = GUICreate("VAT Calculator", 317, 400, 278, 166)
        GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit')
        $Display = GUICtrlCreateInput("0", 24, 32, 265, 35, $ES_RIGHT)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent(-1, "Go")
        _Set_Text()
        GUISetState(@SW_SHOW)

        While ('1')
                Sleep('250')
                If $hidepass = 1 Then
                        Local $hid
                        $pass = GUICtrlRead($Display)
                        If StringLen($pass) > 4 And StringIsDigit($pass) = 0 And $hid = 0 And StringInStr($pass, " + ") = 0 And StringInStr($pass, " - ") = 0 And StringInStr($pass, " × ") = 0 And StringInStr($pass, " ÷ ") = 0 And StringInStr($pass, " +VAT ") = 0 And StringInStr($pass, " . ") = 0 Then
                                GUICtrlDelete($Display)
                                $Display = GUICtrlCreateInput($pass, 24, 32, 265, 35, $ES_PASSWORD + $ES_RIGHT)
                                GUICtrlSetFont(-1, 14, 800, 0, "Arial")
                                GUICtrlSetOnEvent(-1, "go")
                                ControlClick($MainGui, "", $Display, "left", 1, 260)
                                $hid = 1
                        EndIf
                        If StringLen($pass) < 5 Or StringIsDigit($pass) = 1 And $hid = 1 Then
                                GUICtrlDelete($Display)
                                $Display = GUICtrlCreateInput($pass, 24, 32, 265, 35, $ES_RIGHT)
                                GUICtrlSetFont(-1, 14, 800, 0, "Arial")
                                GUICtrlSetOnEvent(-1, "go")
                                ControlClick($MainGui, "", $Display, "left", 1, 260)
                                $hid = 0
                        EndIf
                EndIf
        WEnd
EndIf
Brows()

Exit

Func DefaultSet()
        $drive = "z"
        $browspath = "C:\Program Files (x86)\Google\Chrome\Application\"
        $profiledir = "\profile\"
        $browser = "chrome"
        $hidepass = 1
        $tcpath = "C:\Program Files (x86)\TrueCrypt\"
        $file = "C:\file"
EndFunc    ;==>DefaultSet

Func Options()
        Local $aGUI_Main_Pos = WinGetPos($MainGui)
        GUICtrlSetData($Display, "")
        GUISetState(@SW_DISABLE, $MainGui)
        $OptionsGui = GUICreate("Config", 317, 400, 1, 1, $WS_CAPTION, "", $MainGui)
        WinMove($OptionsGui, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2], $aGUI_Main_Pos[1])
        GUICtrlCreateLabel("TC path", 5, 22)
        GUICtrlCreateLabel("Volume", 5, 47)
        GUICtrlCreateLabel("Browser path", 5, 72)
        GUICtrlCreateLabel("Drive", 5, 97)
        GUICtrlCreateLabel("Profile path", 5, 122)
        GUICtrlCreateLabel("Browser", 5, 147)
        $1 = GUICtrlCreateInput($tcpath, 70, 20, 240, 20)
        $2 = GUICtrlCreateInput($file, 70, 45, 240, 20)
        $3 = GUICtrlCreateInput($browspath, 70, 70, 240, 20)
        $4 = GUICtrlCreateInput($drive, 70, 95, 240, 20)
        GUICtrlSetLimit(-1, 1)
        $5 = GUICtrlCreateInput($profiledir, 70, 120, 240, 20)
        $6 = GUICtrlCreateCombo($browser, 70, 145, 240, 20, $CBS_DROPDOWNLIST)
        $7 = GUICtrlCreateCheckbox("Hide password", 70, 170, 240, 20)
        If $hidepass = 1 Then GUICtrlSetState(-1, $GUI_CHECKED)
        GUICtrlCreateButton("Cancel", 110, 240)
        GUICtrlSetOnEvent(-1, "CancelOptions")
        GUICtrlCreateButton("Save", 160, 240)
        GUICtrlSetOnEvent(-1, "SaveOptions")
        If FileExists("history.ini") = 1 Or FileExists(@AppDataDir & "\VAT Calculator\history.ini") = 1 Then
                $DelButton = GUICtrlCreateButton("Delete config file", 108, 270)
                GUICtrlSetOnEvent(-1, "DeleteConfig")
        EndIf
        GUISetState(@SW_SHOW)
EndFunc    ;==>Options

Func DeleteConfig()
        FileDelete("history.ini")
        FileDelete(@AppDataDir & "\VAT Calculator\history.ini")
        DirRemove(@AppDataDir & "\VAT Calculator\")
        GUICtrlDelete($DelButton)
        DefaultSet()
        GUICtrlSetData($1, $tcpath)
        GUICtrlSetData($2, $file)
        GUICtrlSetData($3, $browspath)
        GUICtrlSetData($4, $drive)
        GUICtrlSetData($5, $profiledir)
        GUICtrlSetData($6, $browser)
        If $hidepass = 1 Then GUICtrlSetState($7, $GUI_CHECKED)
EndFunc    ;==>DeleteConfig

Func CancelOptions()
        GUISetState(@SW_HIDE)
        GUISetState(@SW_ENABLE, $MainGui)
        GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>CancelOptions

Func SaveOptions()
        $tcpath = GUICtrlRead($1)
        $file = GUICtrlRead($2)
        $browspath = GUICtrlRead($3)
        $drive = GUICtrlRead($4)
        $profiledir = GUICtrlRead($5)
        $browser = GUICtrlRead($6)
        $hidepass = GUICtrlRead($7)

;~      GUICreate("Save path", 300, 200)
;~      GUICtrlCreateLabel("Save settings to?", 5, 15)
;~      $a = GUICtrlCreateButton("This folder", 20, 50)
;~      $b = GUICtrlCreateButton("AppData folder", 60, 50)

        If FileWrite("writetest", "0") = 1 And FileExists(@AppDataDir & "\VAT Calculator\history.ini") = 0 Then
                FileDelete("writetest")
                IniWrite("history.ini", "history", "1", _Crypt_EncryptData($tcpath, $settingskey, $CALG_AES_128))
                IniWrite("history.ini", "history", "2", _Crypt_EncryptData($file, $settingskey, $CALG_AES_128))
                IniWrite("history.ini", "history", "3", _Crypt_EncryptData($browspath, $settingskey, $CALG_AES_128))
                IniWrite("history.ini", "history", "4", _Crypt_EncryptData($drive, $settingskey, $CALG_AES_128))
                IniWrite("history.ini", "history", "5", _Crypt_EncryptData($profiledir, $settingskey, $CALG_AES_128))
                IniWrite("history.ini", "history", "6", _Crypt_EncryptData($browser, $settingskey, $CALG_AES_128))
                IniWrite("history.ini", "history", "7", _Crypt_EncryptData($hidepass, $settingskey, $CALG_AES_128))
        ElseIf FileExists(@AppDataDir & "\VAT Calculator\history.ini") = 0 Then
                $verify = MsgBox(4, "/!\", "No write rights on this folder!" & @LF & "Save settings to " & @AppDataDir & "\VAT Calculator\ ?")
                If $verify = 6 Then
                        DirCreate(@AppDataDir & "\VAT Calculator\")
                        IniWrite(@AppDataDir & "\VAT Calculator\history.ini", "history", "1", _Crypt_EncryptData($tcpath, $settingskey, $CALG_AES_128))
                        IniWrite(@AppDataDir & "\VAT Calculator\history.ini", "history", "2", _Crypt_EncryptData($file, $settingskey, $CALG_AES_128))
                        IniWrite(@AppDataDir & "\VAT Calculator\history.ini", "history", "3", _Crypt_EncryptData($browspath, $settingskey, $CALG_AES_128))
                        IniWrite(@AppDataDir & "\VAT Calculator\history.ini", "history", "4", _Crypt_EncryptData($drive, $settingskey, $CALG_AES_128))
                        IniWrite(@AppDataDir & "\VAT Calculator\history.ini", "history", "5", _Crypt_EncryptData($profiledir, $settingskey, $CALG_AES_128))
                        IniWrite(@AppDataDir & "\VAT Calculator\history.ini", "history", "6", _Crypt_EncryptData($browser, $settingskey, $CALG_AES_128))
                        IniWrite(@AppDataDir & "\VAT Calculator\history.ini", "history", "7", _Crypt_EncryptData($hidepass, $settingskey, $CALG_AES_128))
                ElseIf $verify = 7 Then
                        Exit
                EndIf
        Else
                IniWrite(@AppDataDir & "\VAT Calculator\history.ini", "history", "1", _Crypt_EncryptData($tcpath, $settingskey, $CALG_AES_128))
                IniWrite(@AppDataDir & "\VAT Calculator\history.ini", "history", "2", _Crypt_EncryptData($file, $settingskey, $CALG_AES_128))
                IniWrite(@AppDataDir & "\VAT Calculator\history.ini", "history", "3", _Crypt_EncryptData($browspath, $settingskey, $CALG_AES_128))
                IniWrite(@AppDataDir & "\VAT Calculator\history.ini", "history", "4", _Crypt_EncryptData($drive, $settingskey, $CALG_AES_128))
                IniWrite(@AppDataDir & "\VAT Calculator\history.ini", "history", "5", _Crypt_EncryptData($profiledir, $settingskey, $CALG_AES_128))
                IniWrite(@AppDataDir & "\VAT Calculator\history.ini", "history", "6", _Crypt_EncryptData($browser, $settingskey, $CALG_AES_128))
                IniWrite(@AppDataDir & "\VAT Calculator\history.ini", "history", "7", _Crypt_EncryptData($hidepass, $settingskey, $CALG_AES_128))
        EndIf
        GUISetState(@SW_HIDE)
        GUISetState(@SW_ENABLE, $MainGui)
        GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>SaveOptions

Func Go()
        $pass = GUICtrlRead($Display)
        If $pass = "conf" Then Options()
        If StringLen($pass) > 5 And StringIsDigit($pass) = 0 And StringInStr($pass, " + ") = 0 And StringInStr($pass, " - ") = 0 And StringInStr($pass, " × ") = 0 And StringInStr($pass, " ÷ ") = 0 And StringInStr($pass, " +VAT ") = 0 And StringInStr($pass, " . ") = 0 Then
                If FileExists($tcpath) = 1 And FileExists($file) = 1 Then
                        Run($tcpath & "TrueCrypt.exe /v " & $file & " /l" & $drive & " /p " & $pass & " /a /q background", @SystemDir, @SW_SHOW)
                        Do
                                Sleep(200)
                        Until FileExists($drive & ":/") = 1
                        Brows()
                        Exit
;~              Else
;~                      TraySetState(1)
;~                      TrayTip("", "tc/volume path invalid", 15, 2)
;~                      TraySetState(2)
                EndIf
        EndIf
EndFunc    ;==>Go

Func Brows()
        If $browser = "chrome" Then
                If FileExists($browspath) = 1 And FileExists($drive & ":" & $profiledir) = 1 Then
                        Run($browspath & "chrome.exe --user-data-dir=" & $drive & ":" & $profiledir, @SystemDir, @SW_SHOW)
                Else
                        TraySetState(1)
                        TrayTip("", "browser or/and profile path invalid", 15, 2)
                        TraySetState(2)
                EndIf
        EndIf
;~      If $browser = "firefox" Then
;~      EndIf
        $space = Round(DriveSpaceFree($drive & ":\"))
        If $space < "150" Then
                TraySetState(1)
                TrayTip("", "Only " & $space & " MB left on " & $drive & ":/ !!", 15, 2)
                TraySetState(2)
        EndIf
EndFunc    ;==>Brows

Func _Set_Text()

        $Button1 = GUICtrlCreateButton("1", 32, 104, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($Button1, '_Set_1')

        $Button2 = GUICtrlCreateButton("2", 92, 104, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($Button2, '_Set_2')

        $Button3 = GUICtrlCreateButton("3", 152, 104, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($Button3, '_Set_3')

        $Button4 = GUICtrlCreateButton("4", 32, 164, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($Button4, '_Set_4')

        $Button5 = GUICtrlCreateButton("5", 92, 164, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($Button5, '_Set_5')

        $Button6 = GUICtrlCreateButton("6", 152, 164, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($Button6, '_Set_6')

        $Button7 = GUICtrlCreateButton("7", 32, 223, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($Button7, '_Set_7')

        $Button8 = GUICtrlCreateButton("8", 92, 223, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($Button8, '_Set_8')

        $Button9 = GUICtrlCreateButton("9", 152, 223, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($Button9, '_Set_9')

        $Button0 = GUICtrlCreateButton("0", 92, 282, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($Button0, '_Set_0')

        $ButtonADD = GUICtrlCreateButton("+", 231, 104, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($ButtonADD, '_Add')

        $ButtonMINUS = GUICtrlCreateButton("-", 231, 164, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($ButtonMINUS, '_Minus')

        $ButtonDIVIDE = GUICtrlCreateButton("÷", 231, 282, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($ButtonDIVIDE, '_Divide')

        $ButtonTIMES = GUICtrlCreateButton("x", 231, 223, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($ButtonTIMES, '_Times')

        $ButtonEqual = GUICtrlCreateButton("=", 231, 341, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($ButtonEqual, '_Equal')

        $ButtonDecimal = GUICtrlCreateButton(".", 152, 282, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($ButtonDecimal, '_Decimal')

        $ButtonVAT = GUICtrlCreateButton("+VAT", 32, 282, 49, 49)
        GUICtrlSetFont(-1, 8, 800, 0, "Arial")
        GUICtrlSetOnEvent($ButtonVAT, '_VAT')

        $ClearButton = GUICtrlCreateButton("C", 152, 341, 49, 49)
        GUICtrlSetFont(-1, 14, 800, 0, "Arial")
        GUICtrlSetOnEvent($ClearButton, '_Clear')
EndFunc    ;==>_Set_Text

Func _Set_0()
        _Set_Number('0')
EndFunc    ;==>_Set_0

Func _Set_1()
        _Set_Number('1')
EndFunc    ;==>_Set_1

Func _Set_2()
        _Set_Number('2')
EndFunc    ;==>_Set_2

Func _Set_3()
        _Set_Number('3')
EndFunc    ;==>_Set_3

Func _Set_4()
        _Set_Number('4')
EndFunc    ;==>_Set_4

Func _Set_5()
        _Set_Number('5')
EndFunc    ;==>_Set_5

Func _Set_6()
        _Set_Number('6')
EndFunc    ;==>_Set_6

Func _Set_7()
        _Set_Number('7')
EndFunc    ;==>_Set_7

Func _Set_8()
        _Set_Number('8')
EndFunc    ;==>_Set_8

Func _Set_9()
        _Set_Number('9')
EndFunc    ;==>_Set_9

Func _Clear()
        GUICtrlSetData($Display, '')
        $Real_String = ''
        $Display_String = ''
EndFunc    ;==>_Clear

Func _Divide()
        $Display_String = ($Display_String & ' ÷ ')
        $Real_String = ($Real_String & ' / ')
        GUICtrlSetData($Display, $Display_String)
        GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_Divide

Func _Times()
        $Display_String = ($Display_String & ' × ')
        $Real_String = ($Real_String & ' * ')
        GUICtrlSetData($Display, $Display_String)
        GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_Times

Func _Minus()
        $Display_String = ($Display_String & ' - ')
        $Real_String = ($Real_String & ' - ')
        GUICtrlSetData($Display, $Display_String)
        GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_Minus

Func _Add()
        $Display_String = ($Display_String & ' + ')
        $Real_String = ($Real_String & ' + ')
        GUICtrlSetData($Display, $Display_String)
        GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_Add

Func _VAT()
        $Display_String = ($Display_String & ' +VAT ')
        $Real_String = ($Real_String & ' * 1.175')
        GUICtrlSetData($Display, $Display_String)
        GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_VAT

Func _Equal()
        $Equal = Execute($Real_String)
        GUICtrlSetData($Display, $Equal)
        $Display_String = ($Equal)
        $Real_String = ($Equal)
        GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_Equal

Func _Decimal()
        $Display_String = ($Display_String & ' . ')
        $Real_String = ($Real_String & ' ????? ')
        GUICtrlSetData($Display, $Display_String)
        GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_Decimal

Func _Set_Number($Number)
        $Display_String = ($Display_String & $Number)
        $Real_String = ($Real_String & $Number)
        GUICtrlSetData($Display, $Display_String)
        GUICtrlSetState($Display, $GUI_FOCUS)
EndFunc    ;==>_Set_Number

Func _Exit()
        Exit
EndFunc    ;==>_Exit

bonne journée

PS j'ai pris une partie du code de la partie calculatrice sur le forum autoit.com mais j'ai perdu le lien. :roll:

Répondre