Norsestar Posted November 20, 2007 Share Posted November 20, 2007 i've been looking around, and i found a thread where a person requested a validation script, so i copy and pasted the reply code, which is as follows: #include <file.au3> ; Each line of file is "User Name, Password" Global $sFile = "C:\Documents and Settings\MMurphy\Desktop\test.txt" Global $avFile, $sPasswd = "<Not Found>" ; Get user name to search for $sUser = InputBox("User Data", "Enter user name: ") If @error Then Exit ; Read file into an array _FileReadToArray($sFile, $avFile) If @error Then MsgBox(16, "Error", "Error opening file: " & $sFile) Exit EndIf ; Search array for user name and get password For $i = 1 To $avFile[0] If StringLeft($avFile[$i], StringLen($sUser) + 1) = $sUser & "," Then $sPasswd = StringStripWS(StringMid($avFile[$i], StringInStr($avFile[$i], ",") + 1), 8) ExitLoop EndIf Next ; Display results MsgBox(64, "Results", "User: " & $sUser & @CRLF & "Passwd: " & $sPasswd) and i've added a few things to it to make it more logical, here's what i've added so far. it's not much, but this is it: #include <file.au3> ; Each line of file is "User Name, Password" Global $sFile = "C:\Documents and Settings\MMurphy\Desktop\test.txt" Global $avFile, $sPasswd = "<Not Found>" ; Get user name to search for $sUser = InputBox("User Data", "Enter user name: ") $sPass = inputbox ("Password", "Enter password: ") If @error Then Exit ; Read file into an array _FileReadToArray($sFile, $avFile) If @error Then MsgBox(16, "Error", "Error opening file: " & $sFile) Exit EndIf ; Search array for user name and get password For $i = 1 To $avFile[0] If StringLeft($avFile[$i], StringLen($sUser) + 1) = $sUser & "," Then $sPasswd = StringStripWS(StringMid($avFile[$i], StringInStr($avFile[$i], ",") + 1), 8) ExitLoop EndIf Next ; Display results MsgBox(64, "Results", "User: " & $sUser & @CRLF & "Passwd: ******** ") but all it seems to do is bring up a message box telling me what my username / password is. i'm wanting it to actually authenticate and logon as said user, and if you type in the incorrect username/password, it'll exit the program. i have an idea of what command to type, but i'm having trouble finding the proper way of writing it. any ideas? [i did not come up with the original idea nor did i come up with the original code. i researched it on the forums and modified it slightly. i take no credit for the original, only for what i changed.] Thanks in advance, ZenMaster Education: Francis Tuttle Technology Center adult full-time studentCourse of study: Network TechnologyCurrent Course: Microsoft Windows Server 2003, Enterprise EditionCompleted Courses: CompTIA A+ Hardware and Software, Windows XP Professional, Microsoft Office 2003, Desktop Support and Troubleshooting, and CompTIA Network+Remaining Courses: Linux Administration, Copper Cabling, Microsoft Windows Server 2003, Enterprise EditionAchievements: @17 years old, scored 98th percentile U.S. in Algebra 2 and Advanced Chemistry. [i.e. Ranked top 2% in the nation of High School students] Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 20, 2007 Share Posted November 20, 2007 So... login to what? How? The code you have only looks up the user and gets the password, as you said. What are you wanting to login to? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Norsestar Posted November 20, 2007 Author Share Posted November 20, 2007 im wanting to make it to where i can add it to the beginning of any script i have written and/or modified so a person would have to authenticate before running it. i.e. mario beep song, or tetris, etc... another feature that *would* be nice is if i could have it write usernames/passwords to the file using an add users function, but not sure if that's even possible. p.s. i believe it was your original code psaulty lol. just didnt remember your S/N >.< Education: Francis Tuttle Technology Center adult full-time studentCourse of study: Network TechnologyCurrent Course: Microsoft Windows Server 2003, Enterprise EditionCompleted Courses: CompTIA A+ Hardware and Software, Windows XP Professional, Microsoft Office 2003, Desktop Support and Troubleshooting, and CompTIA Network+Remaining Courses: Linux Administration, Copper Cabling, Microsoft Windows Server 2003, Enterprise EditionAchievements: @17 years old, scored 98th percentile U.S. in Algebra 2 and Advanced Chemistry. [i.e. Ranked top 2% in the nation of High School students] Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 20, 2007 Share Posted November 20, 2007 im wanting to make it to where i can add it to the beginning of any script i have written and/or modified so a person would have to authenticate before running it.i.e. mario beep song, or tetris, etc...another feature that *would* be nice is if i could have it write usernames/passwords to the file using an add users function, but not sure if that's even possible.p.s. i believe it was your original code psaulty lol. just didnt remember your S/N >.<Well, you already know how to look up the user name and passwords from the file. What you need is a small GUI to prompt for user name and password (or just password if you want to go with @UserName macro for the user name). Sounds very basic. What have you coded so far? If you are stuck, look at the help file under GuiCreate() and GuiCtrlCreateInput().Post some code if you need more help. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Norsestar Posted November 20, 2007 Author Share Posted November 20, 2007 alright, thanks much. will reply back with what i have Education: Francis Tuttle Technology Center adult full-time studentCourse of study: Network TechnologyCurrent Course: Microsoft Windows Server 2003, Enterprise EditionCompleted Courses: CompTIA A+ Hardware and Software, Windows XP Professional, Microsoft Office 2003, Desktop Support and Troubleshooting, and CompTIA Network+Remaining Courses: Linux Administration, Copper Cabling, Microsoft Windows Server 2003, Enterprise EditionAchievements: @17 years old, scored 98th percentile U.S. in Algebra 2 and Advanced Chemistry. [i.e. Ranked top 2% in the nation of High School students] Link to comment Share on other sites More sharing options...
Valuater Posted November 20, 2007 Share Posted November 20, 2007 im wanting to make it to where i can add it to the beginning of any script i have written and/or modified so a person would have to authenticate before running it....Thats exactly what XProTec.au3 does, and moreXProTec.au38) Link to comment Share on other sites More sharing options...
John117 Posted November 20, 2007 Share Posted November 20, 2007 (edited) Here's something with some code PSalty posted earlier. I claim all the bugs! -P can't have rights to them cause I am sure I added them. Its a WIP. I will post more later. Hopefully shorter and cleaner. For it to work you must be using a txt file where each line has been formated using (C:\Program Files\AutoIt3\Examples\GUI\Advanced\encrypt.au3 - if you default installed) ****EDIT*** encrypt as level 1 password 12345 or change the script to match **ENDEDIT** You will need to encrypt the name and password together but do not encrypt two names at once. -It will put them on a single line and they will then belong to the same array location. Don't for get the comma "," between them and don't include a space. I will add more later, since these are kinda fun for me expandcollapse popup;Include Autoit Functions #include <file.au3> #include <guiconstants.au3> #include <string.au3> ;Set Hot Keys - (They call Functions listed near the bottom) HotKeySet("{ESC}", "Terminate") ; Each line of file is "User Name, Password" Global $sFile = "D:\Autoit Help\test.txt" Global $avFile, $sPasswd = "<not found>" ;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays;Arrays ;****************************************************************************************************************************************** ; Read file into an array _FileReadToArray($sFile, $avFile) If @error Then MsgBox(16, "Error", "Error opening file: " & $sFile) Exit EndIf ;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI;GUI ;****************************************************************************************************************************************** ;Create the basic GUI $window = GUICreate("MY Messenger", 610, 600, 300, 250) $Group1 = GUICtrlCreateGroup("Logon:", 24, 40, 561, 100) $Edit1 = GUICtrlCreateEdit("Username", 300, 80, 150, 17, $ES_WANTRETURN) $Edit2 = GUICtrlCreateEdit("Password", 300, 100, 150, 17, $ES_WANTRETURN) $Button1 = GUICtrlCreateButton("Submit", 495, 120, 60, 17) ;Show the finished resluts of the GUI GUISetState(@SW_SHOW) ;Keep the GUI open and monitoring. While 1 $nMsg = GUIGetMsg() $cursorinfo = GUIGetCursorInfo($window) If $cursorinfo[4] = $Edit1 Then If $cursorinfo[2] = 1 Then GUICtrlSetData($Edit1, "") EndIf EndIf If $cursorinfo[4] = $Edit2 Then If $cursorinfo[2] = 1 Then GUICtrlSetData($Edit2, "") EndIf EndIf Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case ($nMsg = $Button1) Submit() EndSelect WEnd ;FUNCTIONS;FUNCTIONS;FUNCTIONS;FUNCTIONS;FUNCTIONS;FUNCTIONS;FUNCTIONS;FUNCTIONS;FUNCTIONS;FUNCTIONS;FUNCTIONS;FUNCTIONS;FUNCTIONS;FUNCTIONS ;******************************************************************************************************************************************* Func Submit() ; Search array for user name and get password For $i = 1 To $avFile[0] ;The Below line decrypts at level "1" using "12345" as password. "1" Being lowest, "10" being highest. $Temp = _StringEncrypt(0, $avFile[$i], "12345", "1") If StringLeft($Temp, StringLen(GUICtrlRead($Edit1)) + 1) = GUICtrlRead($Edit1) & "," Then $sPasswd = StringStripWS(StringMid($Temp, StringInStr($Temp, ",") + 1), 8) ExitLoop EndIf Next ; Display results If $sPasswd = GUICtrlRead($Edit2) Then MsgBox(64, "Verified", "You could do whatever else here after it's verified.") Else MsgBox(64, "Woops", "Try again") MsgBox(64, "Stored", $sPasswd) ;used for debug only MsgBox(64, "Typed", GUICtrlRead($Edit2)) ;used for debug only EndIf EndFunc ;==>Submit Func Terminate() Exit 0 EndFunc ;==>Terminate Edited November 20, 2007 by Hatcheda Link to comment Share on other sites More sharing options...
John117 Posted November 20, 2007 Share Posted November 20, 2007 im wanting to make it to where i can add it to the beginning of any script i have written and/or modified so a person would have to authenticate before running it.i.e. mario beep song, or tetris, etc...another feature that *would* be nice is if i could have it write usernames/passwords to the file using an add users function, but not sure if that's even possible.p.s. i believe it was your original code psaulty lol. just didnt remember your S/N >.<Can you give alittle more info? Will you be the only one adding UserID's and passords? If so, do you need that to be in the same app even? -Doesn't have to be, but could if needed. (a little more work and maybe less secure) 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