Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompt for password for user/password authentication #9

Open
faustocarramate opened this issue Aug 25, 2022 · 3 comments
Open

Prompt for password for user/password authentication #9

faustocarramate opened this issue Aug 25, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@faustocarramate
Copy link

faustocarramate commented Aug 25, 2022

When executing without password flag AzureHound should interactively prompt for password but it is not. Affected version v1.1.3.

Executing:
.\azurehound.exe list -u '[email protected]' -t '123-123-123' -b 'abc-abc-abc' --json --log-file 'C:\output'

Output:

No configuration file located at C:\Users\user\.config\azurehound\config.json
{"level":"error","error":"unable to authenticate. no valid credential provided","time":"2022-08-25...","message":"encountered unrecoverable error"}
@ddlees ddlees added the enhancement New feature or request label Sep 12, 2022
@ddlees
Copy link
Contributor

ddlees commented Sep 12, 2022

@faustocarramate This functionality hasn't been implemented but you are more than welcome to submit a PR.

In the meantime, you can pass in the password using the AZUREHOUND_PASSWORD environment variable or storing it in a config.json which you can generate using azurehound configure.

Examples:

# For POSIX compliant systems
stty -echo; read AZUREHOUND_PASSWORD; stty echo
azurehound list -u '[email protected]' -t 'mytenant.onmicrosoft.com'
# For PowerShell
$password = Read-Host -assecurestring "Please enter your password"
$AZUREHOUND_PASSWORD = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password))
azurehound list -u '[email protected]' -t 'mytenant.onmicrosoft.com'

@ddlees ddlees changed the title Not prompting for password Prompt for password for user/password authentication Sep 12, 2022
@faustocarramate
Copy link
Author

Hi @ddlees ,
Thanks for your clarification.
What happens when login method requires MFA?

@ddlees
Copy link
Contributor

ddlees commented Sep 13, 2022

@faustocarramate Currently we don't handle MFA but you can get around this limitation by using a refresh token. Fortunately, obtaining a refresh token isn't all that difficult.

  1. Run this bit of PowerShell
$body = @{
    "client_id" =     "1950a258-227b-4e31-a9cf-717495945fc2"
    "resource" =      "https://graph.microsoft.com"  
}
$UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
$Headers=@{}
$Headers["User-Agent"] = $UserAgent
$authResponse = Invoke-RestMethod `
    -UseBasicParsing `
    -Method Post `
    -Uri "https://login.microsoftonline.com/common/oauth2/devicecode?api-version=1.0" `
    -Headers $Headers `
    -Body $body
$authResponse
  1. Copy the user_code value from the output

image

  1. Open a browser where your user is already logged in or where you user CAN log in.
  2. From that browser navigate to https://microsoft.com/devicelogin
  3. Enter the user_code value and allow the browser to finish the authentication/authorization process

image

  1. Continuing from the same PowerShell session, run this script
$body=@{
    "client_id" =  "1950a258-227b-4e31-a9cf-717495945fc2" 
    "grant_type" = "urn:ietf:params:oauth:grant-type:device_code"
    "code" =       $authResponse.device_code
}
$a = Invoke-RestMethod `
    -UseBasicParsing `
    -Method Post `
    -Uri "https://login.microsoftonline.com/Common/oauth2/token?api-version=1.0" `
    -Headers $Headers `
    -Body $body
$a
  1. Copy the refresh_token value from the output

image

  1. Use AzureHound with the --refresh-token flag and the refresh_token value
azurehound --refresh-token <refresh_token> <subcommand>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants