Skrip Posted July 24, 2008 Share Posted July 24, 2008 (edited) Alright. You (the admin) sets up users that are restricted to using the computer only at certain times of the day that you specify. People are required to login with a user/pass that you supply. If you run it, it sets you up with a user/pass...soo yeah. NOTE: This writes heavily to the registry, but good news. It is all in one registry folder. expandcollapse popup#include <WindowsConstants.au3> #include <EditConstants.au3> #include <GUIConstants.au3> #include <String.au3> #include <Array.au3> #Include <Misc.au3> #include "Misc.au3" ;~ Sleep(500) ;~ if _Singleton("Pass",1) = 0 Then ;~ Msgbox(0,"Warning","An occurence of the password program is already running.." & @CRLF & "If you need to logout, please use the icon in the bottom corner.") ;~ Exit ;~ EndIf Dim $done Dim $user_num Global $hours[25] $test_user = 0 $i = 0 $tray = 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; FIRST RUN???? ;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $First_run = RegRead("HKLM\Software\security\lockout", "FirstRun") If @error Then;; IF IT CANNOT FIND THE REGISTERY KEY - THEN CREATE IT - SETUP ADMIN U/P $user = InputBox("Welcome!", "Hello, it seems this is the first time you have ran the program." & @CRLF & "Please enter the ADMIN username you want to use.", "", "", 600, 130) $pass = InputBox("", "Now set the ADMIN password.", "", "*", 600, 130) $user = _StringEncrypt(1, $user, "pazz", 3) $pass = _StringEncrypt(1, $pass, "pazz", 3) RegWrite("HKLM\Software\security\lockout", "AU", "REG_SZ", $user) RegWrite("HKLM\Software\security\lockout", "AP", "REG_SZ", $pass);; ENCRYPT THE USER/PASS AND WRITE TO REGISTERY RegWrite("HKLM\Software\security\lockout", "FirstRun", "REG_SZ", "");; IT IS RUNNING NOW, RIGHT? THE NEXT TIME IT WILL NOT BE THE 'FIRSTRUN' RegWrite("HKLM\Software\security\lockout", "Num", "REG_SZ", "1") EndIf Dim $Input1 Dim $Input2 Dim $Label1 Dim $Label2 Dim $Label3 Dim $Button1 Dim $Form1 Dim $Form2 Dim $Form3 Dim $Form4 Dim $status Opt("TrayMenuMode", 1) Opt("GUICloseOnESC", 0) $logout = TrayCreateItem("Logout") _GO("Waiting") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _GO($status) $tray = 0 $Form1 = GUICreate("Blank", @DesktopWidth + 5, @DesktopHeight + 5, -5, -5, BitOR($WS_POPUP, $WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE)) GUISetState(@SW_SHOW) ;;CREATED BACK DROP - SO YOU CANNOT SEE THE DESKTOP $Form2 = GUICreate("Login", 449, 123, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_BORDER, $WS_CLIPSIBLINGS));; CREATED LOGIN WINDOW $Label1 = GUICtrlCreateLabel("Username: ", 8, 8, 58, 17) $Input1 = GUICtrlCreateInput("", 72, 8, 369, 21) $Label2 = GUICtrlCreateLabel("Password: ", 8, 32, 56, 17) $Input2 = GUICtrlCreateInput("", 72, 32, 369, 21, $ES_PASSWORD) $Button1 = GUICtrlCreateButton("Log In", 128, 64, 177, 25, 0) $Label3 = GUICtrlCreateLabel("Status: " & $status, 8, 100, 400) GUISetState(@SW_SHOW) WinSetOnTop($Form1, "", 1);; MAKE SURE BACKDROP AND LOGIN WINDOW ARE ABOVE ALL ELSE WinSetOnTop($Form2, "", 1) Dim $Form3;; GETS THE PROGRAM READY FOR THE ADMIN PANEL (IF OPENED) Dim $Form4 While 1 If Not WinActive($Form2) Then;; IF THE LOGIN WINDOW IS NOT ACTIVE - SELECT IT WinActivate($Form2);; SELECT IT EndIf ProcessClose("taskmgr.exe");; CLOSE THE TASKMANAGER, IF IT IS OPEN $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1;; LOGIN Login() EndSwitch WEnd EndFunc ;==>_GO Func Login() $user = GUICtrlRead($Input1) $pass = GUICtrlRead($Input2) If $user = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "AU"), "pazz", 3) And $pass = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "AP"), "pazz", 3) Then;; IF THE ADMIN LOGS IN;; READ THE REGISTERY FOR USER/PASS GUICtrlSetData($Label3, "Status: Admin Logged In") GUICtrlSetData($Input1, "") GUICtrlSetData($Input2, "") _panel() EndIf $done = 0 $i = 0 $num_users = RegRead("HKLM\Software\security\lockout", "Num") Do $i = $i + 1 $user = GUICtrlRead($Input1) $pass = GUICtrlRead($Input2) $test_user = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "U" & $i), "pazz", 3) $test_pass = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "P" & $i), "pazz", 3) If $user = $test_user And $pass = $test_pass Then $done = 1 GUICtrlSetData($Input1, "") GUICtrlSetData($Input2, "") _Timer($i); IF NOT ADMIN - START THE TIMER ;~ ;Exit ;~ GUIDelete($Form1) ;~ GUIDelete($Form2);THIS IS HERE JUST FOR DEBUGGING;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;~ MsgBox(0, "", $test_user & @CRLF & $i) ;~ Exit EndIf If $i = $num_users Then $done = 1 GUICtrlSetData($Label3, "Status: Invalid User and/or Pass") EndIf Until $done = 1 EndFunc ;==>Login Func _panel() $Form3 = GUICreate("Admin Panel", 383, 270, -1, -1) $Group1 = GUICtrlCreateGroup("User Management", 64, 8, 257, 81) $Button1 = GUICtrlCreateButton("Add User", 72, 24, 121, 25, 0) $Button2 = GUICtrlCreateButton("Remove User", 200, 24, 113, 25, 0) $Button3 = GUICtrlCreateButton("Change Password", 72, 56, 121, 25, 0) $Button4 = GUICtrlCreateButton("View Users", 200, 56, 113, 25, 0) ControlDisable($Form3, "", $Button4) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Time Management", 32, 96, 321, 49) $Button6 = GUICtrlCreateButton("Set Allowed Times", 128, 112, 129, 25, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button7 = GUICtrlCreateButton("Set Admin Username", 40, 152, 129, 25, 0) $Button8 = GUICtrlCreateButton("Set Admin Password", 224, 152, 121, 25, 0) $Button5 = GUICtrlCreateButton("Go to Desktop (Admin Login - No Time Limit)", 24, 184, 241, 65, 0) $Button9 = GUICtrlCreateButton("Exit Program", 272, 184, 89, 65, 0) GUISetState(@SW_SHOW) WinSetOnTop($Form3, "", 1) WinActivate($Form3) While 1 If Not WinActive($Form3) Then;; IF THE ADMIN WINDOW IS NOT ACTIVE - SELECT IT WinActivate($Form3);; SELECT IT EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form1) GUIDelete($Form2) GUIDelete($Form3) MsgBox(0, "", "The program is going to auto-restart in 3 seconds..", 3) Run(@ScriptName) Exit ;~ $pass = "" ;~ $user = "" Case $Button1 _auser();; Go to the function _auser (add user) Case $Button2; R user _ruser() Case $Button3; Change Passwords _CP() Case $Button6 _SAT() Case $Button9 Exit Case $Button5 GUIDelete($Form1) GUIDelete($Form2) GUIDelete($Form3) MsgBox(0, "", "You logged in as ADMIN." & @CRLF & "PLEASE LOGOUT WITH THE ICON IN THR CORNER - WHEN YOU ARE DONE.", 5) While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $logout _GO("You have logged out. Thank you.") EndSelect WEnd Case $Button7 _SU() Case $Button8 _SP() EndSwitch WEnd EndFunc ;==>_panel Func _Timer($user_num) $TS = RegRead("HKLM\Software\security\lockout", "TS" & $user_num) $TE = RegRead("HKLM\Software\security\lockout", "TE" & $user_num) $TS = Number($TS) $TE = Number($TE) ;Lets see what hours are between TS and TE.. ;example: ;TS = 5; TE = 8 ;Time between = 6 and 7 ;Allowed times then equals...5,6,7,8 = 4hours $done = 0 $msgb = 0 Do $hour = String(@HOUR) If StringLeft($hour, 1) = "0" Then $hour = StringTrimLeft($hour, 1) EndIf If $hour <= $TE And $hour >= $TS Then; Constantly checks if it is within the 'hour' bounds If WinExists($Form1) Or WinExists($Form2) Then GUIDelete($Form1) GUIDelete($Form2) EndIf If $msgb = 0 Then MsgBox(0, "", "You logged in as " & $test_user & @CRLF & "You may be on from " & $TS & " and " & $TE & " Current: " & $hour & @CRLF & "PLEASE LOGOUT WITH THE ICON IN THR CORNER - WHEN YOU ARE DONE.", 5) $msgb = 1 EndIf ;~ If $tray = 0 Then ;~ _tray();Creates the tray ;~ EndIf $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $logout $done = 1 _GO("You have logged out. Thank you.") EndSelect Else $done = 1 _GO("You have been locked out. Your time is up. Start Time: " & $TS & " To: " & $TE & " C Hour: " & @HOUR) EndIf Until $done = 1 _GO("You have been locked out. Your time is up. Start Time: " & $TS & " To: " & $TE & " C Hour: " & @HOUR) EndFunc ;==>_Timer Func _SAT() $Form7 = GUICreate("Set Times", 200, 155, -1, -1) $Label1 = GUICtrlCreateLabel("User:", 8, 10, 29, 17) $Input1 = GUICtrlCreateInput("", 40, 8, 121, 21) $Label2 = GUICtrlCreateLabel("Time Start:", 8, 34, 55, 17) $Input2 = GUICtrlCreateInput("0", 64, 32, 97, 21) $Label3 = GUICtrlCreateLabel("Time End:", 8, 58, 52, 17) GUICtrlCreateInput("24", 64, 56, 97, 21) $Button1 = GUICtrlCreateButton("Set", 8, 104, 153, 25, 0) $Label4 = GUICtrlCreateLabel("YOU MUST USE A 24 HOUR CLOCK", 8, 80, 184, 17) $Label5 = GUICtrlCreateLabel("Status: Waiting", 8, 137, 192, 17) GUISetState(@SW_SHOW) WinSetOnTop($Form7, "", 1) WinActivate($Form7) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form7) GUIDelete($Form3) _panel() Case $Button1 If GUICtrlRead($Input1) = "" Or GUICtrlRead($Input2) = "" Then GUICtrlSetData($Label5, "Status: Please fill in all the fields") Else $done = 0 $i = 0 $num_users = RegRead("HKLM\Software\security\lockout", "Num") Do $i = $i + 1 $test_user = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "U" & $i), "pazz", 3) GUICtrlSetData($Label3, "Status: " & $test_user & "|" & GUICtrlRead($Input1) & "|" & $i & "|" & $num_users) If GUICtrlRead($Input1) = $test_user Then RegWrite("HKLM\Software\security\lockout", "TS" & $i, "REG_SZ", GUICtrlRead($Input1)) RegWrite("HKLM\Software\security\lockout", "TE" & $i, "REG_SZ", GUICtrlRead($Input2)) GUICtrlSetData($Label3, "Status: Times Changed") $done = 1 EndIf If $i = $num_users Then $done = 1 GUICtrlSetData($Label3, "Status: USER NOT FOUND") EndIf Until $done = 1 EndIf EndSwitch WEnd EndFunc ;==>_SAT Func _auser() $Form4 = GUICreate("Add User", 518, 101, -1, -1) $Label1 = GUICtrlCreateLabel("Username:", 8, 8, 55, 17) $Label2 = GUICtrlCreateLabel("Password:", 8, 32, 53, 17) $Input1 = GUICtrlCreateInput("", 64, 8, 201, 21) $Input2 = GUICtrlCreateInput("", 64, 32, 201, 21) $Label3 = GUICtrlCreateLabel("Allowed Time Start:", 272, 8, 95, 17) $Label4 = GUICtrlCreateLabel("Allowed Time End:", 272, 32, 92, 17) $Input3 = GUICtrlCreateInput("00", 368, 8, 33, 21) $Input4 = GUICtrlCreateInput("24", 368, 32, 33, 21) $Label5 = GUICtrlCreateLabel("Use a 24 hour clock. MUST HAVE TWO DIGITS (NOT 1 but 01)", 408, 12, 103, 70) $Button1 = GUICtrlCreateButton("Add User", 96, 64, 137, 25, 0) $Label6 = GUICtrlCreateLabel("Status: Waiting", 248, 68, 250, 17) GUISetState(@SW_SHOW) WinSetOnTop($Form4, "", 1) WinActivate($Form4) While 1 If Not WinActive($Form4) Then;; IF THE WINDOW IS NOT ACTIVE - SELECT IT WinActivate($Form4);; SELECT IT EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form4) GUIDelete($Form3) _panel() Case $Button1 If GUICtrlRead($Input1) = "" Or GUICtrlRead($Input2) = "" Or GUICtrlRead($Input3) = "" Or GUICtrlRead($Input4) = "" Then; did they type in the fields? GUICtrlSetData($Label6, "Status: FAILED! Fill in all input boxes!!") EndIf If StringIsAlpha(GUICtrlRead($Input3)) Or StringIsAlpha(GUICtrlRead($Input4)) Then GUICtrlSetData($Label6, "Status: FAILED! Time needs to be a digit!!") Else $num_users = RegRead("HKLM\Software\security\lockout", "Num"); How many users are there? RegWrite("HKLM\Software\security\lockout", "Num", "REG_SZ", $num_users + 1);adds to how many users there are RegWrite("HKLM\Software\security\lockout", "U" & $num_users, "REG_SZ", _StringEncrypt(1, GUICtrlRead($Input1), "pazz", 3));writes to a new user (encrypts) RegWrite("HKLM\Software\security\lockout", "P" & $num_users, "REG_SZ", _StringEncrypt(1, GUICtrlRead($Input2), "pazz", 3));writes to a new user (encrypts) RegWrite("HKLM\Software\security\lockout", "TS" & $num_users, "REG_SZ", GUICtrlRead($Input3));TS = Time Start RegWrite("HKLM\Software\security\lockout", "TE" & $num_users, "REG_SZ", GUICtrlRead($Input4));TE = Time End GUICtrlSetData($Label6, "Status: User Added Successfully.") EndIf EndSwitch WEnd EndFunc ;==>_auser Func _ruser() $Form5 = GUICreate("Remove User", 382, 111, -1, -1) $Label1 = GUICtrlCreateLabel("User:", 8, 10, 29, 17) $Input1 = GUICtrlCreateInput("", 40, 8, 121, 21) $Label2 = GUICtrlCreateLabel("Please enter the ADMIN password:", 8, 34, 170, 17) $Input2 = GUICtrlCreateInput("", 184, 32, 121, 21, $ES_PASSWORD) $Button1 = GUICtrlCreateButton("Remove User", 8, 56, 83, 25, 0) $Label3 = GUICtrlCreateLabel("Status: Waiting", 96, 60, 200, 17) GUISetState(@SW_SHOW) #EndRegion WinSetOnTop($Form4, "", 1) WinActivate($Form4) While 1 If Not WinActive($Form5) Then;; IF THE WINDOW IS NOT ACTIVE - SELECT IT WinActivate($Form5);; SELECT IT EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form5) GUIDelete($Form3) _panel() Case $Button1 If GUICtrlRead($Input1) = "" Or GUICtrlRead($Input2) = "" Then GUICtrlSetData($Label3, "Status: Please fill in all the fields") Else If GUICtrlRead($Input2) = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "AP"), "pazz", 3) Then $done = 0 $i = 0 $num_users = RegRead("HKLM\Software\security\lockout", "Num") Do $i = $i + 1 $test_user = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "U" & $i), "pazz", 3) GUICtrlSetData($Label3, "Status: " & $test_user & "|" & GUICtrlRead($Input1) & "|" & $i & "|" & $num_users) If GUICtrlRead($Input1) = $test_user Then RegDelete("HKLM\Software\security\lockout", "U" & $i) RegDelete("HKLM\Software\security\lockout", "P" & $i) RegDelete("HKLM\Software\security\lockout", "TS" & $i) RegDelete("HKLM\Software\security\lockout", "TE" & $i) RegWrite("HKLM\Software\security\lockout", "Num", "REG_SZ", $num_users - 1);removes one user from the total amount GUICtrlSetData($Label3, "Status: User Removed") $done = 1 EndIf If $i = $num_users Then $done = 1 GUICtrlSetData($Label3, "Status: USER NOT FOUND" & "| " & $test_user & "|" & $i & "|" & $num_users) EndIf Until $done = 1 Else GUICtrlSetData($Label3, "Status: INVALID PASSWORD") EndIf EndIf EndSwitch WEnd EndFunc ;==>_ruser Func _CP() $Form6 = GUICreate("Change Password", 202, 119, -1, -1) $Label1 = GUICtrlCreateLabel("User: ", 8, 10, 32, 17) $Input1 = GUICtrlCreateInput("", 40, 8, 153, 21) $Label2 = GUICtrlCreateLabel("NEW Pass: ", 8, 32, 62, 17) $Input2 = GUICtrlCreateInput("", 72, 32, 121, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL)) $Button1 = GUICtrlCreateButton("Change Password", 24, 72, 153, 25, 0) $Label3 = GUICtrlCreateLabel("Status: Waiting", 8, 100, 190) GUISetState(@SW_SHOW) WinSetOnTop($Form6, "", 1) WinActivate($Form6) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form6) GUIDelete($Form3) _panel() Case $Button1 If GUICtrlRead($Input1) = "" Or GUICtrlRead($Input2) = "" Then GUICtrlSetData($Label3, "Status: Please fill in all the fields") Else $done = 0 $i = 0 $num_users = RegRead("HKLM\Software\security\lockout", "Num") Do $i = $i + 1 $test_user = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "U" & $i), "pazz", 3) GUICtrlSetData($Label3, "Status: " & $test_user & "|" & GUICtrlRead($Input1) & "|" & $i & "|" & $num_users) If GUICtrlRead($Input1) = $test_user Then RegWrite("HKLM\Software\security\lockout", "P" & $i, "REG_SZ", _StringEncrypt(1, GUICtrlRead($Input2), "pazz", 3));Encrypts the new password and writes it. GUICtrlSetData($Label3, "Status: Password Changed") $done = 1 EndIf If $i = $num_users Then $done = 1 GUICtrlSetData($Label3, "Status: USER NOT FOUND") EndIf Until $done = 1 EndIf EndSwitch WEnd EndFunc ;==>_CP Func _SU() $Form8 = GUICreate("Set Username", 260, 110, -1, -1) $Label1 = GUICtrlCreateLabel("Current Admin Username:", 8, 8, 124, 17) $Input1 = GUICtrlCreateInput("", 136, 8, 121, 21) $Label2 = GUICtrlCreateLabel("Current Admin Password:", 8, 32, 122, 17) $Input2 = GUICtrlCreateInput("", 136, 32, 121, 21) $Label3 = GUICtrlCreateLabel("NEW Username:", 8, 56, 84, 17) $Input3 = GUICtrlCreateInput("", 96, 56, 161, 21) $Button1 = GUICtrlCreateButton("Set", 72, 80, 121, 25, 0) GUISetState(@SW_SHOW) WinSetOnTop($Form8, "", 1) WinActivate($Form8) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form8) GUIDelete($Form3) _panel() Case $Button1 Case $Button1 $user = GUICtrlRead($Input1) $pass = GUICtrlRead($Input2) If $user = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "AU"), "pazz", 3) And $pass = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "AP"), "pazz", 3) Then $user = "" $pass = "" RegWrite("HKLM\Software\security\lockout", "AU", "REG_SZ", _StringEncrypt(1, GUICtrlRead($Input3), "pazz", 3)) EndIf EndSwitch WEnd EndFunc Func _SP() $Form9 = GUICreate("Set Password", 260, 110, -1, -1) $Label1 = GUICtrlCreateLabel("Current Admin Username:", 8, 8, 124, 17) $Input1 = GUICtrlCreateInput("", 136, 8, 121, 21) $Label2 = GUICtrlCreateLabel("Current Admin Password:", 8, 32, 122, 17) $Input2 = GUICtrlCreateInput("", 136, 32, 121, 21) $Label3 = GUICtrlCreateLabel("NEW Password:", 8, 56, 84, 17) $Input3 = GUICtrlCreateInput("", 96, 56, 161, 21) $Button1 = GUICtrlCreateButton("Set", 72, 80, 121, 25, 0) GUISetState(@SW_SHOW) WinSetOnTop($Form9, "", 1) WinActivate($Form9) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form8) GUIDelete($Form3) _panel() Case $Button1 Case $Button1 $user = GUICtrlRead($Input1) $pass = GUICtrlRead($Input2) If $user = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "AU"), "pazz", 3) And $pass = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "AP"), "pazz", 3) Then $user = "" $pass = "" RegWrite("HKLM\Software\security\lockout", "AP", "REG_SZ", _StringEncrypt(1, GUICtrlRead($Input3), "pazz", 3)) EndIf EndSwitch WEnd EndFunc Yes. It is messy, and does have loops and shit that don't need to be there. I slapped this together pretty quick. I didn't write it to look good, only to work. Edited February 24, 2009 by Firestorm [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] 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