
Azure apim ミニプロキシ
apimsprayは、認可されたセキュリティ研究やRed Team活動のために設計された、専用のEntra IDパスワードスプレーツールキットです。Azure API Management(APIM)ゲートウェイを分散型・ローテーションプロキシレイヤーとして活用し、IPローテーションを実現します。
このプロジェクトの詳細については、ブログ記事をご覧ください。
az): リソースデプロイ用のローテータースクリプトに必要です。(Azure CLIに認証済みのCLIセッション、またはAzure Cloud Shellからスクリプトを実行してください)pip install -r requirements.txt
az login
認証済みのAzure環境から直接apimsprayを実行します。
git clone https://github.com/crtvrffnrt/apimspray.git
cd apimspray
python3 apimspray.py --help
複数のAPIMゲートウェイをさまざまな場所にデプロイします。
python3 apimspraycreate.py --count 5 --outfile urls.txt
germanywestcentralとwesteuropeに33個のAPIMインスタンスをデプロイし、urls.txtに保存します。
python3 apimspraycreate.py --location germanywestcentral,westeurope --count 33 --outfile urls.txt
apimspraycreate CLIリファレンス:
usage: apimspraycreate.py [-h] --outfile OUTFILE [--count COUNT] [--location LOCATION] [--prefix PREFIX] [--realm-prefix REALM_PREFIX] [--delete-old]
apimspraycreate - Azure APIM Deployer
options:
-h, --help show this help message and exit
--outfile OUTFILE Output file for URLs
--count COUNT Number of instances
--location LOCATION Comma-separated APIM location(s) to deploy into. When provided, only those regions are used and the first location is used for the resource group.
--prefix PREFIX API URL prefix
--realm-prefix REALM_PREFIX
Realm API prefix
--delete-old Delete old resource groups
重要: すべての方法において、バックグラウンドでアクティブなazセッション(az login)が必要です。
ターゲットリストを用意してください。
users.txt: UserPrincipalNameのリスト(例: [email protected])。passwords.txt: スプレーするパスワードのリスト。ユーザーリストがない場合は、ヘルパースクリプトgenerate_upns.pyを使用できます。このツールは:
users.txtに保存します。使用方法:
# 特定のドメインまたはテナントIDに対してusers.txtを生成
python3 generate_upns.py --target example.com
# またはテナントIDを使用
python3 generate_upns.py --target 00000000-0000-0000-0000-000000000000
generate_upns CLIリファレンス:
usage: generate_upns.py [-h] --target TARGET
Generate UPNs from connected Azure Tenants and Service Accounts.
options:
-h, --help show this help message and exit
--target TARGET Target Domain (e.g., example.com) or Tenant UUID
usage: apimspray.py [-h] [--urls URLS] [--users USERS] [--passwords PASSWORDS] [--output OUTPUT] [--tenant TENANT] [--domain DOMAIN] --mode {spray,validate} [--pace {stealth,low,mid,medium,high}]
[--continue-on-success]
apimspray - Entra ID Assessment Tool
options:
-h, --help show this help message and exit
--urls URLS Path to APIM URLs file (from apimspraycreate.py or apimsprayrotator.sh)
--users USERS Path to users file
--passwords PASSWORDS
Path to passwords file
--output OUTPUT Output directory
--tenant TENANT Tenant ID or Domain
--domain DOMAIN Append domain to users if missing
--mode {spray,validate}
Operation mode. 'spray' tests all passwords against all users (1:N). 'validate' performs 1:1 credential pair testing.
--pace {stealth,low,mid,medium,high}
Pacing profile for requests and lockout management:
- high: 15 workers, 0.1s delay, 10 passes/chunk, 5m lockout, 20 safe threshold
- medium: 5 workers, 1.0s delay, 5 passes/chunk, 10m lockout, 10 safe threshold, 10% jitter
- low: 2 workers, 5.0s delay, 2 passes/chunk, 15m lockout, 5 safe threshold, 20% jitter
- stealth: 1 worker, 30.0s delay, 1 pass/chunk, 20m lockout, 1 safe threshold, 40% jitter
--continue-on-success
Continue the assessment even after finding valid credentials.
validate: user:passwordペアのリストをチェックします。リストの長さは同じである必要があります。
python3 apimspray.py --urls urls.txt --mode validate --users u.txt --passwords p.txt
spray: 1つのパスワードを全ユーザーに対して試行し、設定された間隔を待ってから次のパスワードに移行します。
python3 apimspray.py --urls urls.txt --mode spray --users users.txt --passwords common_passwords.txt --pace medium
--pace引数はスプレーの攻撃性を制御します。値は安定性と安全性を確保するためにハードコードされています。
AADSTS50053)場合、ツールは即座に中止します。結果はresults/<timestamp>/ディレクトリに保存されます。
valid_*.txt: 認証成功(MFA要求あり、またはトークン受信)。blocked_*.txt: ロックされた、または条件付きでブロックされたアカウント。failed_*.txt: 無効な資格情報、またはユーザーが見つからなかったもの。| プロファイル | ワーカー数 | 遅延 | 試行数(チャンク) | ロックアウト待機 | 安全しきい値 | ジッター |
|---|
high | 15 | 0.1s | 10 | 5m | 20 ロック | 0% |
medium | 5 | 1.0s | 5 | 10m | 10 ロック | 10% |
low | 2 | 5.0s | 2 | 15m | 5 ロック | 20% |
stealth | 1 | 30.0s | 1 | 20m | 1 ロック | 40% |