AmericanCheese Posted March 8, 2016 Share Posted March 8, 2016 I need to make the program so that when you run it, it will prompt you with a password screen (easy, I know how to do that) Then, if in the input slot you put in the correct password, will run another file. If wrong, does nothing. Any example scripts or syntax I should know? I don't need autoit for anything else, just this one project. Link to comment Share on other sites More sharing options...
spudw2k Posted March 8, 2016 Share Posted March 8, 2016 This thread may be of use. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
AutoBert Posted March 8, 2016 Share Posted March 8, 2016 (edited) I do it this way: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> #include <GuiImageList.au3> #include <Crypt.au3> #Include <Array.au3> ;#comments-start $sSalt = "Gelbe Früchte sind bei Affen sehr beliebt" $aCorrect=IniReadSection(@ScriptDir&"\PW_List.ini","User") _ArrayDelete($aCorrect,0) $sPicPath = @ScriptDir & "\bild.jpg" If Not FileExists($sPicPath) Then InetGet("http://www.codebot.de/wcf/images/codebot/fullheader.jpg", $sPicPath) ; kannst du ignorieren... $hGUI = GUICreate("Beispiel GUI", 500, 400) $hButton1 = GUICtrlCreateButton("Klick Mich!", 5, 5, 490, 50) $hPicture = GUICtrlCreatePic($sPicPath, 5, 60, 490, 200) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel("Benutzername:", 5, 265, 85, 21) $idInpUser = GUICtrlCreateInput("", 95, 265, 190, 21) GUICtrlCreateLabel("Passwort:", 5, 295, 85, 21) $idInpPW = GUICtrlCreateInput("123456789", 95, 295, 190, 21, $ES_PASSWORD) ; Input mit Passwort Style $idBtnLogin = GUICtrlCreateButton("&Login", 5, 317, 490, 80) GUISetState(@SW_SHOW) $iLoginTrys = 0 $iMaxTrys = 5 While 1 $LoginState = GUICtrlGetState($idBtnLogin) ;ermitteln welchen Status der Login-Button hat If GUICtrlRead($idInpPW) <> "" And GUICtrlRead($idInpUser) <> "" Then ;Wenn Passwort und Benutzer dann If BitAND($LoginState, $GUI_DISABLE) = $GUI_DISABLE Then GUICtrlSetState($idBtnLogin, $GUI_Enable) ;Wenn $LoginState nicht aktiv (also der Loginbutton nicht klickbar) ist dann Login-Button aktivieren Else ;entweder Passwort ider Benutzer sind nicht ausgefüllt If BitAND($LoginState, $GUI_Enable) = $GUI_Enable Then GUICtrlSetState($idBtnLogin, $GUI_DISABLE) ;Wenn $LoginState aktiv (also der Loginbutton klickbar) ist dann Login-Button deaktivieren EndIf $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $idBtnLogin ;Loginbutton wurde geklickt $bCorect = False ;diese Boolsche Variable auf FALSCH setzen For $i = 0 To UBound($aCorrect) - 1 If GUICtrlRead($idInpUser) = $aCorrect[$i][0] Then ;wenn das Arrayelement gleich dem eingegebenen Benutzer ist dann $bCorect = True ;diese Boolsche Variable auf WAHR setzen ExitLoop ;Schleife verlassen EndIf Next If $bCorect Then ;Es wurde ein Benutzer mit Zugangsberechtigung eingegeben ConsoleWrite($aCorrect[$i][1] & @CRLF) $sPW = _Crypt_HashData(GUICtrlRead($idInpPW) & $sSalt, $CALG_MD5) ;das eingegebene Passwort zusammen mit dem "Salz" verschüsseln ConsoleWrite($sPW & @CRLF) If $sPW <> $aCorrect[$i][1] Then $bCorect = False ;der Schlüssel des eingebenen Passworts und der im Array hinterlegte Schlüssel ;für das Passwort stimmen nicht überein also $bCorrect auf FALSCH setzen EndIf If Not $bCorect Then ;entweder kein Benutzer mit Zugangsberechtigung ;oder ungültige Passworteingabe $iLoginTrys += 1 ;Anzahl der Loginversuche um 1 erhöhen If $iLoginTrys > $iMaxTrys - 1 Then ;Anzahl der maximal zuässigen Loginversuche wurde überschritten MsgBox(16, $iMaxTrys & " falsche Loginversuche", "Computer wird für 15 Min. gesperrt", 0, $hGUI) ;Ausgabe Exit ;deshalb Programm beenden Else ;Anzahl der maximal zuässigen Loginversuche wurde nicht überschritten MsgBox(48, "noch " & $iMaxTrys - $iLoginTrys & " Loginversuch(e)!", "danach wird der Computer für 15 Min. gesperrt", 0, $hGUI) ;Anzeige der restichen Loginversuche EndIf Else ;Benutzer mit Zugangsberechtigung und gütiges Passwort wurden eingegeben MsgBox(64, "Login" & $iLoginTrys, "Sie haben sich erfolgreich angemeldet!", 0, $hGUI) GUIDelete() ;Gui löschen ExitLoop ;(GuiGetMsg-) Schleife verlassen EndIf EndSwitch WEnd ;und jetzt das eigentliche durch obigen Skriptcode geschützte Programm Opt("MustDeclareVars", 1) ConsoleWrite(@WindowsDir&@CRLF) Global $sBmpNormal = @ScriptDir & "\Pictures\left.bmp" Global $sBmpHot = @ScriptDir & "\Pictures\leftHover.bmp" Global $sBmpPress = @ScriptDir & "\Pictures\leftPressed.bmp" Global $sBmpDisabled = @ScriptDir & "\Pictures\leftDisabled.bmp" Global $sBmpImage = @WindowsDir & "\pchealth\helpctr\System\blurbs\watermark_300x.bmp" Global $idBtn1, $idBtn2, $idBtn3, $idBtn4, $msg Global $hImagebtn1, $hImagebtn2, $hImagebtn3, $hImagebtn4 ConsoleWrite(FileExists($sBMPDisabled)&@CRLF) ConsoleWrite(FileExists($sBMPImage)&@CRLF) ;Caveat: Minimum Operating Systems: Windows XP. ;Image list with multiple images will only show the images ;other than the 1st image when Themes are used. Global $hGUI = GUICreate("Button Imagelists - Minimum OS: Windows XP", 400, 300) GUICtrlCreatePic(@WindowsDir & "\Web\Wallpaper\Windows XP.jpg", 0, 0, 400, 300) GUICtrlSetState(-1, $GUI_DISABLE) ;multi state image Bitmap $idBtn1 = GUICtrlCreateButton("This Way", 30, 30, 90, 32) GUICtrlSetTip(-1, "Multi state bitmap imagelist") $hImagebtn1 = _GUIImageList_Create(32, 32, 5, 3, 6) _GUIImageList_AddBitmap($hImagebtn1, $sBMPNormal);1 - Normal _GUIImageList_AddBitmap($hImagebtn1, $sBMPHot) ;2 - Hot _GUIImageList_AddBitmap($hImagebtn1, $sBMPPress) ;3 - Pressed _GUIImageList_AddBitmap($hImagebtn1, $sBMPDisabled);4 - Disabled _GUIImageList_AddBitmap($hImagebtn1, $sBMPNormal);5 - Defaulted _GUIImageList_AddBitmap($hImagebtn1, $sBMPNormal);6 - Stylus Hot (tablet computers only) _GUICtrlButton_SetImageList($idBtn1, $hImagebtn1) ;single state image Bitmap $idBtn2 = GUICtrlCreateButton("This Way", 30, 70, 90, 32) GUICtrlSetTip(-1, "Single bitmap imagelist") $hImagebtn2 = _GUIImageList_Create(24, 24, 5, 3) _GUIImageList_AddBitmap($hImagebtn2, $sBMPNormal);1 - Normal _GUICtrlButton_SetImageList($idBtn2, $hImagebtn2) ;single state image Icon $idBtn3 = GUICtrlCreateButton("Unlock", 30, 110, 90, 40) GUICtrlSetTip(-1, "Single icon imagelist") $hImagebtn3 = _GUIImageList_Create(32, 32, 5, 3,6) _GUIImageList_AddIcon($hImagebtn3, "msrating.dll", 10, True) _GUICtrlButton_SetImageList($idBtn3, $hImagebtn3) ;single state image Bitmap with overlayed text $idBtn4 = GUICtrlCreateButton("Help", 30, 160, 90, 90) GUICtrlSetTip(-1, "Single bitmap imagelist with overlayed text") GUICtrlSetFont(-1, 14, 800, -1, "Comic Sans MS") $hImagebtn4 = _GUIImageList_Create(80, 80, 5, 3) _GUIImageList_AddBitmap($hImagebtn4, $sBMPImage) _GUICtrlButton_SetImageList($idBtn4, $hImagebtn4, 4) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $idBtn1 Case $idBtn2 GUICtrlSetState($idBtn1, $GUI_DISABLE) Case $idBtn3 GUICtrlSetState($idBtn1, $GUI_Enable) Case $idBtn4 EndSwitch WEnd Ini: [User] Admin=0x95C18B228E3470CB57CBA821590B47F1 and PW-Hasher: expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <Crypt.au3> $hGUI = GUICreate("PW-Hasher", 500, 170) GUICtrlCreateLabel("Benutzername:", 5, 5, 85, 21) $idInpUser = GUICtrlCreateInput("", 95, 5, 190, 21) GUICtrlCreateLabel("Passwort:", 5, 35, 85, 21) $idInpPW = GUICtrlCreateInput("", 95, 35, 190, 21) GUICtrlCreateLabel("PW bestätigen:", 5, 65, 85, 21) $idInpPW2 = GUICtrlCreateInput("", 95, 65, 190, 21) $idBtnCreate = GUICtrlCreateButton("&PW-Hash erzeugen", 5, 98, 490, 70) GUISetState(@SW_SHOW) $sSalt = "Gelbe Früchte sind bei Affen sehr beliebt" While 1 $CreateState = GUICtrlGetState($idBtnCreate) ;ermitteln welchen Status der Create-Button hat $sPW1 = GUICtrlRead($idInpPW) $sPW2 = GUICtrlRead($idInpPW2) If $sPW1 = $sPW2 And StringLen($sPW1) > 3 And GUICtrlRead($idInpUser) <> "" Then ;Wenn beide Passworteingaben übereinstimmen und das PW mind. 4stellig ist und ein Benutzer eingegeben dann If BitAND($CreateState, $GUI_DISABLE) = $GUI_DISABLE Then GUICtrlSetState($idBtnCreate, $GUI_Enable) ;Wenn $CreateState nicht aktiv (also der Createbutton nicht klickbar) ist dann Create-Button aktivieren Else ;ansonsten If BitAND($CreateState, $GUI_Enable) = $GUI_Enable Then GUICtrlSetState($idBtnCreate, $GUI_DISABLE) ;Wenn $CreateState aktiv (also der Createbutton klickbar) ist dann Create-Button deaktivieren EndIf $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $idBtnCreate ;Createbutton wurde geklickt $sPass=_Crypt_HashData(GUICtrlRead($idInpPW) & $sSalt, $CALG_MD5) IniWrite(@ScriptDir&"\PW_List.ini","User",GUICtrlRead($idInpUser),$sPass) EndSwitch WEnd The hasher never store on your HD only on USB.Stick. The created INI must be copied to scriptdir of loginscript. Edited March 8, 2016 by AutoBert Link to comment Share on other sites More sharing options...
czardas Posted March 9, 2016 Share Posted March 9, 2016 If you want the password to be excluded from the code (the only reasonable approach), then the only way to test password validity is to actually run the code and see whether the output matches expectations. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now