Jump to content
Sign in to follow this  
Kovacic

Simple password generator tool for a Help Desk

Recommended Posts

Kovacic

This is a simple incomplete password reset tool, my 3rd script with autoit, so the code is elementary. This is something you can use to customize and make your own. It will generate a password, and give you the nato readout so you can read it to an end user over the phone. Feel free to update and make it better, I no longer require it so enjoy!

post-63131-0-69924100-1407517311_thumb.p

#include <File.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <AD.au3>
#Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("AD PAssword Reset Tool", 509, 276, 250, 152)
    $Label1 = GUICtrlCreateLabel("Password Reset Tool", 40, 8, 442, 46)
    GUICtrlSetFont(-1, 28, 400, 0, "Arial")
    GUICtrlSetColor(-1, 0x000000)
    Global $rnd, $result2 = ""
    $Input3 = GUICtrlCreateInput("", 60, 96, 400, 32, $SS_CENTER)
    GUICtrlSetFont(-1, 16, 400, 0, "Arial")
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Button1 = GUICtrlCreateButton("Generate Password", 16, 64, 107, 25)
    $Button2 = GUICtrlCreateButton("Set Password", 260, 162, 75, 25)
    $Button3 = GUICtrlCreateButton("Unlock Account", 155, 162, 99, 25)
    $Input1 = GUICtrlCreateInput("", 16, 160, 121, 21)
    $Group1 = GUICtrlCreateGroup("Account status", 8, 188, 489, 81)
    $Label4 = GUICtrlCreateLabel("Username: ", 16, 204, 58, 17)
    $Label5 = GUICtrlCreateLabel("Locked: ", 16, 220, 46, 17)
    $Label6 = GUICtrlCreateLabel("Password Age:", 16, 236, 75, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Label7 = GUICtrlCreateLabel("", 26, 133, 436, 24, $SS_CENTER)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    $z = "rvxs|rdmf|jzlr|izez|lbyl|yjmz|wzet|pyau|qumv|aocr|wwal|qhyh|dlou|ruqj|vgmg|edpg|wsmv|qmnt|kwgr|tduz|jzgq|ywdn|etet|hxvj|ydwp|vvzx|cwcs|fcru|dnin|jwna|pwks|xoak|audd|ppwe|omzq|xwcy|dudn|rwtz|qvtg|jgzi|hxkr|azug|ixla|iikl|ovgk|skpj|kldj|ovwg|psfy|jmck|gkea|bjmq|trfc|tppm|jvae|fgah|scbj|pqtl|gses|gtzz|xtid|snds|xkok|zgcb|iktk|cvil|ynxn|fqqs|qakc|cnsc|jiaz|nryi|brev|olbe|whfs|kpro|lkcg|vvlp|pjlf|igvl|mnyp|shco|nite|exji|drai|gdgd|cylw|hlgr|qfya|dqle|xhgn|jkbl|cghi|xcow|iwui|ltqm|olmx|rujq|ehop|xpgr|zjfg|zebn|iezt|gazx|cgft|tefk|jijz|smhj|zbwr|vxsd|wjmp|sjbk|hyzm|sszr|iqbq|marj|pdsn|derh|sjit|udlh|xwaz|aodg|quab|gxka|exhs|pzdo|bpjf|pizm|xtio|tdiz|txxv|jaat|hcwi|ekrz|zpyy|ppnm|yewo|upzi|zfmw|suii|alvm|zklz|xesg|nyqk|lvih|eppa|mbdk|soju|hnkt|ifsd|wnzk|pndo|ydrj|bzfs|madj|jhcz|ygnw|zrdu|qskm|lbux|qtdt|xjyy|zkfd|yzhd|dwgn|jdun|kteh|geke|warj|qucv|lvqs|jdda|vrfb|qzjj|rvuo|kzfr|jlka|svhy|dctk|lkss|viju|dqpq|dgxw|mcwy|rtxw|ptsj|bebg|kduq|iivb|zygi|hwql|sgia|hvmj|msxx|woxb|vvsc|zplz|brpf|iyyq|vdvp|dxre|mtky|csjv|yfdl|podp|svrn|eovx|nzax|uplb|neiv|yzdk|mtgq|qrzx|kkhl|rxgm|brqr|fqsv|wcpe|acyf|oqeo|utci|susu|ttha|qnnx|utwc|eoih|bema|abjh|ijyx|tihy|gyll|bkae|kett|mbtk|fuyr|fokr|cazl|exro|azla|cyzv|bnfx|mnxi|qlak|jlai|tcor|fcpy|hudz|zosz|tgzl|zqli|rody|xrvj|ntit|keji|xixi|wbmd|lajm|rlps|klqj|woth|fhmk|psxp|npaz|naph|ahfz|pdkb|fnga|tisy|kijq|drqj|fyym|nfej|vaqa|hnrk|lkeh|wbrh|rmie|iuab|lbxz|mvto|qkqo|wfbk|zawj|sfnb|dagk|vxts|pfnn|eatb|ozor|pkje|slxb|fmpv|yqil|owry|ducb|dywa|xguz|ybrj|eoff|lhfp|qwqk|pada|oele|szmo|lvdw|rsjh|ygid|mtrh|zycp|pfoe|icpz|vxkd|rsdm|isrf|nhsh|mbzq|rukh|usrj|cwno|nxph|utro|xghu|ynvw|wswr|vngd|ahpw|uimq|tirj|ysbv|aetj|wwsx|jxcu|fxvw|mszs|pcuo|tvjf|tsef|setx|zrnr|vcmk|pthb|vqpl|tzfa|lqpu|jqbg|flru|jdrb|agfb|qajb|gopo|dfen|vfnp|myvp|fptx|qvbv|qiii|uuaw|khnh|ujnj|mlds|wicf|ihwv|wumi|smhd|pfda|tltj|ixdo|xvor|zuid|hgst|xfqf|yuuy|qesp|ulke|rqoc|yyae|ejbr|lrob|xwrw|fgcc|phmn|jeib|btmn|sxbn|znio|qxhe|trto|tzty|ohqn|qaej|pgdk|oqvy|dnqb|lfmh|guom|pumx|hxnl|jxxm|pipj|hxjw|jlvu|mbql|hvnh|dzii|xpyx|fjtx|gxjd|ixuy|evpb|ogjp|wqxi|bogv|laoo|bslx|axtq|uwca|qzmp|gojb|kctw|nzlj|fuyw|klzo|nvpg|vhfx|vnmj|jrtx|yuin|lwbr|bpsh|txok|gvrp|acfz|tjga|kgew|rmrh|wszy|fulz|otgd|gnyh|fvsk|roox|xixy|nwqu|rdne|rngx|tyjq|gbrj|kgtn|zoys|pten|sptz|oxkh|kbin|uvwr|cgqw|smec|pvoe|hmdw|nkxs|bzzp|dkzu|txzu|ktrm|bbgp|esgh|ocza|mnoy|ejfc|xfwb|rwkz|mrbl|apwe|wmdr|ojgb|pfvi|napt|mwmb|wukl|rfzs|injw|jmpw|pmxe|pncm|smtx|xgee|oqhe|cqry|sipu|vaew|fuzw|ymkc|vvnr|lrip|nbsn|kjdn|nfdd|amcg|cncw|gmiw|juzo"
    $wlist = StringSplit($z, "|", 3)
    GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_AD_OPEN()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _AD_CLOSE()
            Exit
        Case $Button1
            generate()
        Case $Button2
            setpw()
    EndSwitch
WEnd
Func GenSymbol()
    $symnum = Random(1, 7, 1)
    If $symnum = 1 Then Global $symbb = "!"
    If $symnum = 2 Then Global $symbb = "@"
    If $symnum = 3 Then Global $symbb = "$"
    If $symnum = 4 Then Global $symbb = ";"
    If $symnum = 5 Then Global $symbb = "?"
    If $symnum = 6 Then Global $symbb = "%"
    If $symnum = 7 Then Global $symbb = "#"
EndFunc   ;==>GenSymbol
Func generate()
    Global $rnd = Random(1000, 9999, 1)
    Global $result = ""
    GUICtrlSetData($Input3, $result)
    Global $line = $wlist[Random(1, UBound($wlist))]
    GenSymbol()
    nato1()
    $line = $symbb & $line & $rnd
    GUICtrlSetData($Input3, $line)
    $rnd2 = StringSplit($rnd, "")
EndFunc   ;==>generate
Func nato1()
    $myword = $line
    symbol($symbb)
    $array = StringSplit($myword, "", 1)
    For $i = 1 To UBound($array) - 1
        $z = nato2($array[$i])
        $result = $result & $nato & " "
    Next
    $nums = StringSplit($rnd, "", 1)
    For $i = 1 To UBound($nums) - 1
        $y = digit($nums[$i])
        $result2 = $result2 & $numb & " "
    Next
    $result = $symb & " " & $result & $result2
    GUICtrlSetData($Label7, $result)
    ;GUICtrlSetData($Label8, "")
    $result = ""
    $result2 = ""
EndFunc   ;==>nato1
Func setpw()
    If Not GUICtrlRead($Input3) Then
        MsgBox(0, "Error", "You must generate a password first.")
    Else
        MsgBox(0, "Complete", "Password has been set. Thank you.")
    EndIf
EndFunc   ;==>setpw
Func nato2($letter)
    If $letter = "a" Then Global $nato = "Alpha"
    If $letter = "b" Then Global $nato = "Bravo"
    If $letter = "c" Then Global $nato = "Charlie"
    If $letter = "d" Then Global $nato = "Delta"
    If $letter = "e" Then Global $nato = "Echo"
    If $letter = "f" Then Global $nato = "Foxtrot"
    If $letter = "g" Then Global $nato = "Golf"
    If $letter = "h" Then Global $nato = "Hotel"
    If $letter = "i" Then Global $nato = "India"
    If $letter = "j" Then Global $nato = "Juliet"
    If $letter = "k" Then Global $nato = "Kilo"
    If $letter = "l" Then Global $nato = "Lima"
    If $letter = "m" Then Global $nato = "Mike"
    If $letter = "n" Then Global $nato = "November"
    If $letter = "o" Then Global $nato = "Oscar"
    If $letter = "p" Then Global $nato = "Papa"
    If $letter = "q" Then Global $nato = "Quebec"
    If $letter = "r" Then Global $nato = "Romeo"
    If $letter = "s" Then Global $nato = "Sierra"
    If $letter = "t" Then Global $nato = "Tango"
    If $letter = "u" Then Global $nato = "Uniform"
    If $letter = "v" Then Global $nato = "Victor"
    If $letter = "w" Then Global $nato = "Whiskey"
    If $letter = "x" Then Global $nato = "X-ray"
    If $letter = "y" Then Global $nato = "Yankee"
    If $letter = "z" Then Global $nato = "Zulu"
    Return
EndFunc   ;==>nato2
Func symbol($sym)
    If $sym = "!" Then Global $symb = "Exclamation-Mark"
    If $sym = "@" Then Global $symb = "At-Sign"
    If $sym = "$" Then Global $symb = "Dollar-Sign"
    If $sym = ";" Then Global $symb = "Semi-Colon"
    If $sym = "?" Then Global $symb = "Question-Mark"
    If $sym = "%" Then Global $symb = "Percent-Sign"
    If $sym = "#" Then Global $symb = "Pound-Sign"
    Return
EndFunc   ;==>symbol
Func digit($num)
    If $num = "1" Then Global $numb = "One"
    If $num = "2" Then Global $numb = "Two"
    If $num = "3" Then Global $numb = "Three"
    If $num = "4" Then Global $numb = "Four"
    If $num = "5" Then Global $numb = "Five"
    If $num = "6" Then Global $numb = "Six"
    If $num = "7" Then Global $numb = "Seven"
    If $num = "8" Then Global $numb = "Eight"
    If $num = "9" Then Global $numb = "Nine"
    If $num = "0" Then Global $numb = "Zero"
    Return
EndFunc   ;==>digit

Feel free to update and make it better.

Edited by Kovacic
  • Like 1

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites
ViciousXUSMC

Cool, gets a like from me because being former Military I love phonetics :)

But we always just give people a easy PW and set it so they must change at next login.

What I do like is seeing the status (is that working though?) and setting the password/unlocking so I may modify so we can just enter own own password.

Edited by ViciousXUSMC

Share this post


Link to post
Share on other sites
Kovacic

Cool, gets a like from me because being former Military I love phonetics :)

But we always just give people a easy PW and set it so they must change at next login.

What I do like is seeing the status (is that working though?) and setting the password/unlocking so I may modify so we can just enter own own password.

 

I didnt put that in yet. i was going to along with time remaining on password, locked or unlocked, etc.. but I no longer had a need for the tool so I kind of abandoned it. Adding password reset features would be very easy to do using AD.au3. The finished version would have even had built in validation, so you put in a users Employee ID and another piece of data, the tool will validate them. I was going to build it to conform to all standards specified by the Sarbanes–Oxley Act. I just never finished it.


C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • water
      By water
      Extensive library to control and manipulate Microsoft Active Directory.

      Threads: Development - General Help & Support - Example Scripts - Wiki
      Previous downloads: 30467
       
      Known Bugs: (last changed: 2018-08-08)
      _AD_IsPasswordExired: It compares the expiration time (UTC - but should be local time) with the current time (local time). Which is 2 hours off here. Will be fixed in the next version.
      Or replace line If $aTemp[11] <= _NowCalc() Then Return 1 with
      If $aTemp[9] <= _NowCalc() Then Return 1  
      Things to come: (last changed: 2018-08-08)
      Internal function to convert Large Integer to Date String. _AD_ModifyAttribute fully supports single-value and multi-value attributes. Returns better error information. Better support for Fine Grained Password Policy
      BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort
    • Blois
      By Blois
      Hey Guys,
      Good?
      I'm ned help to consult in other domain. My three domain contains any domains.
      How do I get this query done?
       
      Tks for the Help!
       
    • water
      By water
      Hello all!
      As I have just read access to my companies Active Directory I need some users willing to test the rewritten _AD_ModifyAttribute function.
      My goal is to have the function handle single and multi value attributes the same way and support CLEAR, UPDATE, APPEND and DELETE for the attributes.
      First step is to test how the function handles single value attributes:
      Please modify the following script to specify the object (I suggest a dummy user in your test AD environment - the function might still be buggy).
      Then please run the script and post the restults!
      If everything works as expected we will test multi value attributes. AD attributes: http://www.rlmueller.net/UserAttributes.htm
      #include <AD.au3> _AD_Open() $sObject = "user-to-modify" ; <== NEEDS TO BE CHANGED BY YOU! $sAttribute = "Description" ; CLEAR - single value attribute _AD_ModifyAttribute($sObject, $sAttribute, "Original value", 2) ; Set the original value If @error Then Exit MsgBox(0, "Single value - Error!", "CLEAR: Set original value returned @error = " & @error & ", @extended = " & @extended) _AD_ModifyAttributeEX($sObject, $sAttribute, "", 1) If @error Then Exit MsgBox(0, "Single value - Error!", "CLEAR returned @error = " & @error & ", @extended = " & @extended) $sReturnValue = _AD_GetObjectAttribute($sObject, $sAttribute) If @error Then Exit MsgBox(0, "Single value - Error!", "CLEAR: Query new value returned @error = " & @error & ", @extended = " & @extended) MsgBox(0, "Success!", "Value after CLEAR: " & $sReturnValue & @CRLF & "Expected value: ''") ; UPDATE - single value attribute _AD_ModifyAttribute($sObject, $sAttribute, "Original value", 2) ; Set the original value If @error Then Exit MsgBox(0, "Single value - Error!", "UPDATE: Set original value returned @error = " & @error & ", @extended = " & @extended) _AD_ModifyAttributeEX($sObject, $sAttribute, "UPDATE", 2) If @error Then Exit MsgBox(0, "Single value - Error!", "UPDATE returned @error = " & @error & ", @extended = " & @extended) $sReturnValue = _AD_GetObjectAttribute($sObject, $sAttribute) If @error Then Exit MsgBox(0, "Single value - Error!", "UPDATE: Query new value returned @error = " & @error & ", @extended = " & @extended) MsgBox(0, "Success!", "Value after UPDATE: " & $sReturnValue & @CRLF & "Expected value: 'UPDATE'") ; APPEND - single value attribute - APPEND should work the same way as UPDATE _AD_ModifyAttribute($sObject, $sAttribute, "Original value", 2) ; Set the original value _AD_ModifyAttributeEX($sObject, $sAttribute, "APPEND", 3) $sReturnValue = _AD_GetObjectAttribute($sObject, $sAttribute) If @error Then Exit MsgBox(0, "Single value - Error!", "APPEND returned @error = " & @error & ", @extended = " & @extended) MsgBox(0, "Success!", "Value after APPEND: " & $sReturnValue & @CRLF & "Expected value: 'APPEND'") ; DELETE - single value attribute - DELETE should work the same way as CLEAR _AD_ModifyAttribute($sObject, $sAttribute, "Original value", 2) ; Set the original value _AD_ModifyAttributeEX($sObject, $sAttribute, "DELETE", 4) $sReturnValue = _AD_GetObjectAttribute($sObject, $sAttribute) If @error Then Exit MsgBox(0, "Single value - Error!", "DELETE returned @error = " & @error & ", @extended = " & @extended) MsgBox(0, "Success!", "Value after DELETE: " & $sReturnValue & @CRLF & "Expected value: ''") _AD_Close() Exit ; #FUNCTION# ==================================================================================================================== ; Name...........: _AD_ModifyAttribute ; Description ...: Modifies an attribute of the given object to the value specified. ; Syntax.........: _AD_ModifyAttribute($sObject, $sAttribute[, $vValue = ""[, $iOption = 1]]) ; Parameters ....: $sObject - Object (user, group ...) to add/delete/modify an attribute (sAMAccountName or FQDN) ; $sAttribute - Attribute to add/delete/modify ; $vValue - Optional: Value(s) to modify the attribute with. Use a blank string ("") to remove all values (default). ; +$vValue can be a single value (as a string) or a multi-value (as a zero-based one-dimensional array) ; $iOption - Optional: Indicates the mode of modification: Clear, Update, Append, Delete. ; |1 - CLEAR: remove all value(s) from the attribute (default when $vValue = "" or Default) ; |2 - UPDATE: replace the current value(s) with the specified value(s) ; |3 - APPEND: append the specified value(s) to the existing values(s) ; |4 - DELETE: delete the specified value(s) from the object ; Return values .: Success - 1 ; Failure - 0, sets @error to: ; |1 - $sObject does not exist ; |2 - Parameter $iOption is invalid. needs to be in the range1 to 4. ; |x - Error returned by SetInfo method (Missing permission etc.) ; Author ........: Jonathan Clelland ; Modified.......: water ; Remarks .......: ; Related .......: _AD_GetObjectAttribute, _AD_GetObjectProperties, _AD_AddEmailAddress ; Link ..........: http://msdn.microsoft.com/en-us/library/aa746353(VS.85).aspx (ADS_PROPERTY_OPERATION_ENUM Enumeration) ; Example .......: Yes ; =============================================================================================================================== Func _AD_ModifyAttributeEX($sObject, $sAttribute, $vValue = "", $iOption = 1) Local $aValue[1] If $vValue = Default Then $vValue = "" If IsArray($vValue) Then $aValue = $vValue Else ; Move the string value to the array $aValue[0] = $vValue EndIf If $iOption = Default Then $iOption = 1 If $iOption < 1 Or $iOption > 4 Then Return SetError(2, 0, 0) If Not _AD_ObjectExists($sObject) Then Return SetError(1, 0, 0) Local $sProperty = "sAMAccountName" If StringMid($sObject, 3, 1) = "=" Then $sProperty = "distinguishedName" ; FQDN provided $__oAD_Command.CommandText = "<LDAP://" & $sAD_HostServer & "/" & $sAD_DNSDomain & ">;(" & $sProperty & "=" & $sObject & ");ADsPath;subtree" Local $oRecordSet = $__oAD_Command.Execute ; Retrieve the ADsPath for the object Local $sLDAPEntry = $oRecordSet.fields(0).Value Local $oObject = __AD_ObjGet($sLDAPEntry) ; Retrieve the COM Object for the object $oObject.GetInfo Switch $iOption Case 1 $oObject.PutEx(1, $sAttribute, 0) ; CLEAR: remove all the property value(s) from the object Case 2 $oObject.PutEx(2, $sAttribute, $aValue) ; UPDATE: replace the current value(s) with the specified value(s) Case 3 $oObject.PutEx(3, $sAttribute, $aValue) ; APPEND: append the specified value(s) to the existing values(s) Case 4 $oObject.PutEx(4, $sAttribute, $aValue) ; DELETE: delete the specified value(s) from the object EndSwitch $oObject.SetInfo If @error Then Return SetError(@error, 0, 0) Return 1 EndFunc ;==>_AD_ModifyAttributeEX  
    • Trinnon
      By Trinnon
      I have a question about the @error logging features in _AD_CreateUser.  Hopefully I am just missing something obvious.
      In my app I am creating a user if it does not exist then manipulating some attributes. 
      If the user does exist I would then call another function to remove groups from the user and modify some attributes.
      My question is...
      If the user already Exists, the _AD_CreateUser option gives $iValue = 0 and @error = 0.
      How can @error = 1 for the condition that the user already exists?
       
      I copied a small ship of the code in question along with my full .au3. 
      I am using AD UDF 1.4.9.0 (Water, thanks for the awesome work on this!!!).
      $iValue = _AD_CreateUser ($sOU, $sUser, $sCN)
      If $iValue = 1 Then
            _FileWriteLog ($Log, "Func UserCheck() - User '" & $sUser & "' successfully created ==> Calling UserAttribsNewUser Function.")
            Call ("NewUser")
      ElseIf @error = 1 Then
            _FileWriteLog ($Log, $sUser & " already exists ==> Calling UserAttribsExistingUser Function.")
            Call ("ExistingUser")
       
      AccountSettingConfigurations-Test1.au3
       
×