Skip to content

POC code to explore phishing attacks using OAuth 2.0 authorization flows, such as the device authorization grant.

License

BSD-3-Clause, BSD-3-Clause licenses found

Licenses found

BSD-3-Clause
LICENSE
BSD-3-Clause
COPYRIGHT
Notifications You must be signed in to change notification settings

netskopeoss/phish_oauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Netskope Threat Labs logo

Description

This project provides POC code to explore [OAuth 2.0](https://datatracker.ietf.org/doc/html/rfc6749)
authorization flows and how they can be abused in phishing attacks.

Specifically, we demonstrate a phishing attack using the device authorization grant
on Microsoft and intend to add additional flows as we go. An implementation of this 
is written in generic Powershell and can be run on any supported platform. Most cmdlet
calls are simple REST API calls and should be translateable to any language.

Running the Code

  1. Install Powershell 7.x
  2. Setup Microsoft Environments (for the victim only)
    1. NOTES:
      1. Victim environment setup: The attacker does not need a Microsoft account or environment, only the victim
      2. DO NOT run this in a production environment.
      3. Existing account: An existing Azure+Office365 account can be used, in which case just check that Azure+O365 access woorks for the existing accounts in steps 3 and 5.
      4. New account: These instructions are only needed if you want to create a new set of accounts to serve as the victim accounts.
      5. Admin privileges: You need administrator privileges to manage user accounts within Azure and Office 365.
      6. Trial accounts: this is the easiest way to create new accounts to test this POC (creating an O365 account should create the Azure account)
    2. AD Setup: Within Azure AD, login as an AD administrator and create victim account
      1. portal.azure.com > Azure Active Directory > Users
      2. ensure a subscription exists and some example resources exist that the user can access
    3. Check AD: Ensure the victim has read access to an Azure subscription and resources
      1. log into portal.azure.com as the victim, Search on subscriptions, should see at least 1
      2. search on All Resources, make sure at least one resource exists
      3. create some additional resources if you wish
    4. Office 365 Setup: Within the Office 365, login as the administrator and check that a license of Office 365 is associated with the victim
      1. login.onmicrosoft.com > Admin icon > Users > Active Users
    5. Check Office 365: Ensure the Office 365 Outlook email works for the victim
      1. login.onmicrosoft.com as the victim account > Outlook icon
  3. Configure demo_cfg.json
    • Set victim user email address in the "to" propery
    • Set SMTP settings if you want to have the demo code send an email phish
    • Keep other config settings as is (page=true, interactive=true, verbose=1, etc.)
  4. Run
    • command-line: Powershell.exe|pwsh demo_msft.ps1 -config demo_cfg.json
    • Step #0: user and device codes generated
    • Step #1: phish email sent (to user/victim set in demo_cfg.json)
    • Step #2: will loop waiting for user/victim to authenticate/authorize
    • In browser, <log in as user/victim to login.microsoft.com, check Outlook, follow phishing email link, authenticate)
    • Step #3: retrieve user''s oauth access tokens
    • Step #4: use access token to list users in Azure AD
    • Step #5: retrieve user''s email
    • Step #6: move laterally and use refresh token to get new access token for Azure
    • Step #7: will list resources within Azure subscriptions that the user/victim has access to

Directories / Files

device_code/pwsh/
    demo_msft.ps1       - main Powershell file. Usage: powershell|pwsh -h
    demo_cfg.json       - required config file
    demo_email.txt      - email template if sending phish email

OAuth Flows

Device Authorization Grant (device code flow)

Device Authorization Grant

References

  1. Evolving Phishing Attacks

  2. OAuth Device Code Flow

  3. Additional OAuth Research Areas

About

POC code to explore phishing attacks using OAuth 2.0 authorization flows, such as the device authorization grant.

Resources

License

BSD-3-Clause, BSD-3-Clause licenses found

Licenses found

BSD-3-Clause
LICENSE
BSD-3-Clause
COPYRIGHT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published