Jump to content

_ValidUserPass - when password has %


gcue
 Share

Recommended Posts

Hello.

See many examples of folks using this function

Func _ValidUserPass($username, $computer, $password)

    Local $valid = True
    RunAs($username, $computer, $password, 0, @ComSpec & " /c echo test", @SystemDir, @SW_HIDE)
    If @error Then $valid = False
    Return $valid

EndFunc   ;==>_ValidUserPass

Been working great for me for years - thanks to original poster (not sure who it was).

I've seen an issue when password has the following characters "%%%"

I've tried putting double quotes and single quotes around the password variable but no luck.

Any other thoughts or ideas?

Thanks in advance! :)

obraz.png

obraz.png

Edited by gcue
Link to comment
Share on other sites

Func _ValidUserPass($username, $computer, $password)

    Local $valid = True
    RunAs($username, $computer, "'" & $password & "'", 0, @ComSpec & " /c echo test", @SystemDir, @SW_HIDE)
    $a_Password = StringSplit($password, "")
    For $i = 1 To $a_Password[0]
        If Asc($a_Password[$i]) = "&" Then
            ; Your code here
        EndIf
    Next
    If @error Then $valid = False
    Return $valid

EndFunc   ;==>_ValidUserPass

 

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Link to comment
Share on other sites

17 hours ago, jerem488 said:

If Asc($a_Password[$i]) = "&" Then

This expression can never be true as the ASCII value of any character is always numeric.

Also, if the value of @error is to be used to assign a value to a variable it should be assigned immediately after the function or statement that was used to set it. @error is somewhat dynamic and the value can change with every statement. You can't just arbitrarily grab its value and expect it to be representative of what you are testing.

Phil Seakins

Link to comment
Share on other sites

I don't have the ability to test this, so have you seen this issue elsewhere? It seems strange that the RunAs function would use the command line to run our programs internally. Are you sure you have the right password? (As stupid as it sounds, I've been there)

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

I would run tests to prove that it is the "%" causing the problem. Setup an account with a plain alphanumeric password and run a script that does work. Then add a single percent to the password and see what happens. You need a definitive pass/fail benchmark. If it fails you should change the position of the percent, beginning, middle, end to see if that changes anything.

Phil Seakins

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...