From 05bbdc65c18190d44438e2609408e5afdc9171df Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 15 Jun 2025 02:06:58 +0900 Subject: [PATCH 01/14] feat: add Google login hint functionality - Add environment configuration files (.env, .env.example) - Implement GoogleLoginHint addon module - Update addon initialization to include new module --- .env | 2 ++ .env.example | 2 ++ addon/GoogleLoginHint.py | 71 ++++++++++++++++++++++++++++++++++++++++ addon/init.py | 12 ++++++- 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .env create mode 100644 .env.example create mode 100644 addon/GoogleLoginHint.py diff --git a/.env b/.env new file mode 100644 index 0000000..cf32153 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +# Google OAuth 설정 +GOOGLE_ID=bot.imnya.ng@gmail.com diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..cf32153 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +# Google OAuth 설정 +GOOGLE_ID=bot.imnya.ng@gmail.com diff --git a/addon/GoogleLoginHint.py b/addon/GoogleLoginHint.py new file mode 100644 index 0000000..6d80669 --- /dev/null +++ b/addon/GoogleLoginHint.py @@ -0,0 +1,71 @@ +import lib.target as target +from lib.report import save_report +import os +from urllib.parse import urlparse, parse_qs, urlencode, urlunparse +from dotenv import load_dotenv + +# .env 파일 로드 +load_dotenv(override=True) + +class GoogleLoginHint: + def __init__(self): + self.google_id = os.getenv('GOOGLE_ID', '') + if not self.google_id: + print("⚠️ Warning: GOOGLE_ID not found in .env file") + + async def request(self, flow): + """Google OAuth 요청을 가로채서 login_hint를 추가하거나 수정""" + req = flow.request + method = req.method + url = req.pretty_url + + # Google OAuth 인증 URL인지 확인 + if self._is_google_oauth_url(url): + print(f"🔍 Google OAuth URL detected: {url}") + + # URL 파싱 + parsed_url = urlparse(url) + query_params = parse_qs(parsed_url.query) + + # login_hint 추가 또는 수정 + if self.google_id: + query_params['login_hint'] = [self.google_id] + print(f"✅ Added/Updated login_hint: {self.google_id}") + + # 새로운 쿼리 스트링 생성 + new_query = urlencode(query_params, doseq=True) + + # 새로운 URL 생성 + new_url = urlunparse(( + parsed_url.scheme, + parsed_url.netloc, + parsed_url.path, + parsed_url.params, + new_query, + parsed_url.fragment + )) + + # 요청 URL 수정 + flow.request.pretty_url = new_url + print(f"🔄 Modified URL: {new_url}") + + + def _is_google_oauth_url(self, url): + """Google OAuth URL인지 확인""" + google_oauth_domains = [ + 'accounts.google.com', + 'oauth2.googleapis.com' + ] + + parsed_url = urlparse(url) + domain = parsed_url.netloc.lower() + + # Google OAuth 도메인 확인 + for google_domain in google_oauth_domains: + if google_domain in domain: + # OAuth 관련 경로 확인 + path = parsed_url.path.lower() + if any(oauth_path in path for oauth_path in ['/oauth2', '/auth', '/login']): + return True + + return False \ No newline at end of file diff --git a/addon/init.py b/addon/init.py index 78e616a..afb3db8 100644 --- a/addon/init.py +++ b/addon/init.py @@ -6,6 +6,7 @@ from csrf_check import CsrfChecker from nonce_check import NonceChecker from redirect_uri_check import RedirectBypassChecker from access_token import AccessTokenScanner +from GoogleLoginHint import GoogleLoginHint class PKCEAddon: def __init__(self): @@ -87,4 +88,13 @@ class RedirectBypassAddon: except Exception as e: print(f"[ERROR] RedirectBypass Addon failed: {e}") -addons = [PKCEAddon(), ScopeAddon(), CsrfAddon(), NonceAddon(), AccessTokenAddon(), RedirectBypassAddon()] +class GoogleLoginHintAddon(): + def __init__(self) -> None: + self.checker = GoogleLoginHint() + def request(self, flow: http.HTTPFlow): + try: + asyncio.run(self.checker.request(flow)) + except Exception as e: + print(f"[ERROR] GoogleLoginHint Addon failed: {e}") + +addons = [PKCEAddon(), ScopeAddon(), CsrfAddon(), NonceAddon(), AccessTokenAddon(), RedirectBypassAddon(), GoogleLoginHintAddon()] From c311aaad71ef0030eb85a49a67ca504f10025e9f Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 15 Jun 2025 12:36:43 +0900 Subject: [PATCH 02/14] fix: update proxy test URL to use GitHub OAuth endpoint with certificate --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32a975c..d990669 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: sleep 5 # Test proxy functionality - curl -x http://localhost:11080 http://example.com + curl --cacert ~/.mitmproxy/mitmproxy-ca-cert.pem -x http://localhost:11080 https://github.com/login/oauth/authorize?client_id=Ov23lixietSCQOHxPvcr&redirect_uri=http%3A%2F%2Flocalhost%3A8787&scope=read%3Auser+user%3Aemail&skip_account_picker=true --silent # Clean up kill $APP_PID From 40867acb26db3b2a90e0cac7afea4490ea2b21f1 Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 15 Jun 2025 12:53:07 +0900 Subject: [PATCH 03/14] =?UTF-8?q?feat:=20=ED=99=98=EA=B2=BD=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=EB=A5=BC=20=EC=84=A4=EC=A0=95=ED=95=98=EA=B3=A0=20Goo?= =?UTF-8?q?gle=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=ED=9E=8C=ED=8A=B8=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EC=9D=84=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 4 ++++ addon/init.py | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d990669..bf5d5a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,10 @@ jobs: - name: Install dependencies run: uv sync + + - name: Set up environment variables + run: | + echo "GOOGLE_ID=bot.imnya.ng@gmail.com" > .env - name: Start application and run proxy test run: | diff --git a/addon/init.py b/addon/init.py index afb3db8..b022811 100644 --- a/addon/init.py +++ b/addon/init.py @@ -1,3 +1,4 @@ +from json import load from mitmproxy import http import asyncio from pkce_check import PKCEDowngradeChecker @@ -7,6 +8,10 @@ from nonce_check import NonceChecker from redirect_uri_check import RedirectBypassChecker from access_token import AccessTokenScanner from GoogleLoginHint import GoogleLoginHint +import os +from dotenv import load_dotenv + +load_dotenv(override=True) class PKCEAddon: def __init__(self): @@ -90,8 +95,14 @@ class RedirectBypassAddon: class GoogleLoginHintAddon(): def __init__(self) -> None: - self.checker = GoogleLoginHint() + if os.getenv('GOOGLE_ID'): + self.checker = GoogleLoginHint() + else: + self.checker = None + def request(self, flow: http.HTTPFlow): + if self.checker is None: + return try: asyncio.run(self.checker.request(flow)) except Exception as e: From 00e395830085a245c9a0b85fa5b09d2692c1c5d9 Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 15 Jun 2025 13:15:11 +0900 Subject: [PATCH 04/14] fix: remove unused import of json.load in init.py --- addon/init.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addon/init.py b/addon/init.py index b022811..bf19b6d 100644 --- a/addon/init.py +++ b/addon/init.py @@ -1,4 +1,3 @@ -from json import load from mitmproxy import http import asyncio from pkce_check import PKCEDowngradeChecker From 3850b0de2f42d3a22f2c68289b0831f2045f768c Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 15 Jun 2025 13:15:11 +0900 Subject: [PATCH 05/14] fix: change GoogleLoginHintAddon request method to async --- addon/init.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addon/init.py b/addon/init.py index b022811..c54a7fc 100644 --- a/addon/init.py +++ b/addon/init.py @@ -1,4 +1,3 @@ -from json import load from mitmproxy import http import asyncio from pkce_check import PKCEDowngradeChecker @@ -100,11 +99,11 @@ class GoogleLoginHintAddon(): else: self.checker = None - def request(self, flow: http.HTTPFlow): + async def request(self, flow: http.HTTPFlow): if self.checker is None: return try: - asyncio.run(self.checker.request(flow)) + await self.checker.request(flow) except Exception as e: print(f"[ERROR] GoogleLoginHint Addon failed: {e}") From cf3bfee0392a6fea0a4e8f5dacb3dfaa1e808208 Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 15 Jun 2025 13:25:43 +0900 Subject: [PATCH 06/14] fix: update proxy test URL to use correct GitHub OAuth endpoint --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf5d5a9..043673f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: sleep 5 # Test proxy functionality - curl --cacert ~/.mitmproxy/mitmproxy-ca-cert.pem -x http://localhost:11080 https://github.com/login/oauth/authorize?client_id=Ov23lixietSCQOHxPvcr&redirect_uri=http%3A%2F%2Flocalhost%3A8787&scope=read%3Auser+user%3Aemail&skip_account_picker=true --silent + curl --cacert ~/.mitmproxy/mitmproxy-ca-cert.pem -x https://github.com/login?client_id=Ov23lixietSCQOHxPvcr&return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3DOv23lixietSCQOHxPvcr%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A8787%26scope%3Dread%253Auser%2Buser%253Aemail%26skip_account_picker%3Dtrue --silent # Clean up kill $APP_PID From c593a92b114b6b90483b99df2ba5aa2eea9fce08 Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 15 Jun 2025 13:27:06 +0900 Subject: [PATCH 07/14] fix: wrap URL in quotes for curl command in CI workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 043673f..1de3732 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: sleep 5 # Test proxy functionality - curl --cacert ~/.mitmproxy/mitmproxy-ca-cert.pem -x https://github.com/login?client_id=Ov23lixietSCQOHxPvcr&return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3DOv23lixietSCQOHxPvcr%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A8787%26scope%3Dread%253Auser%2Buser%253Aemail%26skip_account_picker%3Dtrue --silent + curl --cacert ~/.mitmproxy/mitmproxy-ca-cert.pem -x "https://github.com/login?client_id=Ov23lixietSCQOHxPvcr&return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3DOv23lixietSCQOHxPvcr%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A8787%26scope%3Dread%253Auser%2Buser%253Aemail%26skip_account_picker%3Dtrue" --silent # Clean up kill $APP_PID From 990eb1b643f94f2ba388aa5654047d67e445f8b7 Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 15 Jun 2025 13:28:43 +0900 Subject: [PATCH 08/14] fix: update proxy test URL to use localhost for curl command --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1de3732..db5ffe5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: sleep 5 # Test proxy functionality - curl --cacert ~/.mitmproxy/mitmproxy-ca-cert.pem -x "https://github.com/login?client_id=Ov23lixietSCQOHxPvcr&return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3DOv23lixietSCQOHxPvcr%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A8787%26scope%3Dread%253Auser%2Buser%253Aemail%26skip_account_picker%3Dtrue" --silent + curl --cacert ~/.mitmproxy/mitmproxy-ca-cert.pem -x https://localhost:11080 "https://github.com/login?client_id=Ov23lixietSCQOHxPvcr&return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3DOv23lixietSCQOHxPvcr%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A8787%26scope%3Dread%253Auser%2Buser%253Aemail%26skip_account_picker%3Dtrue" --silent # Clean up kill $APP_PID From b221c4a9e62596607cda4615005b560c9dd396b0 Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 15 Jun 2025 13:29:46 +0900 Subject: [PATCH 09/14] fix: update proxy test to skip SSL verification in CI workflow --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db5ffe5..bf955ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,8 +40,8 @@ jobs: # Wait for application to start sleep 5 - # Test proxy functionality - curl --cacert ~/.mitmproxy/mitmproxy-ca-cert.pem -x https://localhost:11080 "https://github.com/login?client_id=Ov23lixietSCQOHxPvcr&return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3DOv23lixietSCQOHxPvcr%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A8787%26scope%3Dread%253Auser%2Buser%253Aemail%26skip_account_picker%3Dtrue" --silent + # Test proxy functionality (skip SSL verification for testing) + curl --insecure -x https://localhost:11080 "https://github.com/login?client_id=Ov23lixietSCQOHxPvcr&return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3DOv23lixietSCQOHxPvcr%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A8787%26scope%3Dread%253Auser%2Buser%253Aemail%26skip_account_picker%3Dtrue" --silent # Clean up kill $APP_PID From 9a14872964c2be7d5c6359f1bd4ed22b952f69bb Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 15 Jun 2025 13:30:33 +0900 Subject: [PATCH 10/14] fix: update proxy test to use certificate for SSL verification --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf955ec..bfc9c92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,8 +40,8 @@ jobs: # Wait for application to start sleep 5 - # Test proxy functionality (skip SSL verification for testing) - curl --insecure -x https://localhost:11080 "https://github.com/login?client_id=Ov23lixietSCQOHxPvcr&return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3DOv23lixietSCQOHxPvcr%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A8787%26scope%3Dread%253Auser%2Buser%253Aemail%26skip_account_picker%3Dtrue" --silent + # Test proxy functionality + curl --cacert ~/.mitmproxy/mitmproxy-ca-cert.pem -x https://localhost:11080 "https://github.com/login?client_id=Ov23lixietSCQOHxPvcr&return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3DOv23lixietSCQOHxPvcr%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A8787%26scope%3Dread%253Auser%2Buser%253Aemail%26skip_account_picker%3Dtrue" # Clean up kill $APP_PID From 0c7994a52fe8fd38448fd7e70ebb2c6c2b5048cc Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 15 Jun 2025 13:31:31 +0900 Subject: [PATCH 11/14] fix: update proxy test to skip certificate verification --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bfc9c92..4597434 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: sleep 5 # Test proxy functionality - curl --cacert ~/.mitmproxy/mitmproxy-ca-cert.pem -x https://localhost:11080 "https://github.com/login?client_id=Ov23lixietSCQOHxPvcr&return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3DOv23lixietSCQOHxPvcr%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A8787%26scope%3Dread%253Auser%2Buser%253Aemail%26skip_account_picker%3Dtrue" + curl -k -x https://localhost:11080 "https://github.com/login?client_id=Ov23lixietSCQOHxPvcr&return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3DOv23lixietSCQOHxPvcr%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A8787%26scope%3Dread%253Auser%2Buser%253Aemail%26skip_account_picker%3Dtrue" # Clean up kill $APP_PID From 3af57870641369113e9c4072e02d2fa35a15ad92 Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 15 Jun 2025 13:39:16 +0900 Subject: [PATCH 12/14] feat: update CI workflow configuration Update GitHub Actions workflow settings --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4597434..8162bdf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,8 @@ jobs: sleep 5 # Test proxy functionality + sudo cp ~/.mitmproxy/mitmproxy-ca-cert.pem /usr/local/share/ca-certificates/mitmproxy-ca-cert.crt + sudo update-ca-certificates curl -k -x https://localhost:11080 "https://github.com/login?client_id=Ov23lixietSCQOHxPvcr&return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3DOv23lixietSCQOHxPvcr%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A8787%26scope%3Dread%253Auser%2Buser%253Aemail%26skip_account_picker%3Dtrue" # Clean up From ba277ccec10edb5ee1d94be883033689a7297e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=94=EB=83=A5=20=28imnyang=29?= Date: Mon, 16 Jun 2025 22:25:54 +0900 Subject: [PATCH 13/14] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8162bdf..c71b722 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: # Test proxy functionality sudo cp ~/.mitmproxy/mitmproxy-ca-cert.pem /usr/local/share/ca-certificates/mitmproxy-ca-cert.crt sudo update-ca-certificates - curl -k -x https://localhost:11080 "https://github.com/login?client_id=Ov23lixietSCQOHxPvcr&return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3DOv23lixietSCQOHxPvcr%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A8787%26scope%3Dread%253Auser%2Buser%253Aemail%26skip_account_picker%3Dtrue" + curl -k -x https://localhost:11080 "https://github.com/login/oauth/authorize?client_id=Ov23lixietSCQOHxPvcr&redirect_uri=http://localhost:8787&scope=read:user+user:email&response_type=code&code_challenge=abc123&code_challenge_method=S256" # Clean up kill $APP_PID From 5d1624a96aa6a18d1d533ce4a68128a0a8ba54e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=94=EB=83=A5=20=28imnyang=29?= Date: Mon, 16 Jun 2025 22:27:11 +0900 Subject: [PATCH 14/14] Update ci.yml --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c71b722..09915cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,9 @@ jobs: # Test proxy functionality sudo cp ~/.mitmproxy/mitmproxy-ca-cert.pem /usr/local/share/ca-certificates/mitmproxy-ca-cert.crt sudo update-ca-certificates + + mkdir data + echo https://github.com > ./data/target.dump curl -k -x https://localhost:11080 "https://github.com/login/oauth/authorize?client_id=Ov23lixietSCQOHxPvcr&redirect_uri=http://localhost:8787&scope=read:user+user:email&response_type=code&code_challenge=abc123&code_challenge_method=S256" # Clean up