Merge pull request #13 from j93es/feat/sensitive-data

Docs 수정 및 Sensitive Data 기능 추가
This commit is contained in:
암냥 2025-06-20 22:03:49 +09:00 committed by GitHub
commit 4f0097049c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 87 additions and 18 deletions

View file

@ -5,7 +5,7 @@ ANONYMIZED_TELEMETRY=false
GOOGLE_API_KEY=
# 권장 (다른 모델로 교체 가능) [다른 모델로 교체시 성능 보장 불가]
GOOGLE_MODEL=gemini-2.5-flash-preview-05-20
#GOOGLE_PLANNER_MODEL=gemini-2.5-flash-preview-05-20
GOOGLE_PLANNER_MODEL=gemini-2.5-flash-preview-05-20
# min(INITIAL_BACKOFF * (2 ** try_cnt), MAX_BACKOFF)만큼 API가 실패시 대기합니다.
INITIAL_BACKOFF=60

1
.gitignore vendored
View file

@ -12,6 +12,7 @@ oauth_providers.csv
.venv
.env
.sensitive.json
log_*.log
domains.txt

10
.sensitive.example.json Normal file
View file

@ -0,0 +1,10 @@
{
"*.google.com": {
"x_username": "bot.imnya.ng@gmail.com",
"x_password": "some.google.password"
},
"github.com": {
"x_username": "imnyang-bot",
"x_password": "some.github.password"
}
}

3
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"rust-analyzer.initializeStopped": true
}

View file

@ -1,18 +1,17 @@
# 참고하면 좋을만한 것
- [ ] 일부 웹사이트는 사용자의 언어에 따라 OAuth 옵션을 바꾸기도 합니다.
- [ ] https://docs.browser-use.com/customize/custom-functions
# 환경 설정
이 프로젝트는 [uv](https://docs.astral.sh/uv/getting-started/installation/)라는 Python 패키지 관리자를 사용하여 설정해야합니다.
요구 사항
- [uv](https://docs.astral.sh/uv/getting-started/installation/) - Python Package Manager Written by Rust
- [oauth-backend](https://github.com/j93es/oauth-backend)
- [Google Chrome](https://www.google.com/intl/ko_kr/chrome/)
또한 [oauth-backend](https://github.com/j93es/oauth-backend)가 설정되길 권장합니다.
> 프록시를 사용한다면 이 가이드에 따라 인증서 또한 설정되어야만 합니다.
---
> [oauth-backend](https://github.com/j93es/oauth-backend) 프록시를 사용한다면 이 가이드에 따라 인증서 또한 설정되어야만 합니다.
>
> 그렇지 않으면 실행되지 않습니다.
>
> 윈도우 환경에서는 `sudo certutil -addstore root mitmproxy-ca-cert.cer`로 인증합니다.
> 윈도우 환경에서는 `sudo certutil -addstore root mitmproxy-ca-cert.cer`로 인증합니다.
>
> Sudo가 활성화되어있지 않은 환경에서는 관리자로 상향된 쉘에서 실행합니다.
>
@ -31,11 +30,18 @@ uv sync
venv와 패키지가 설치가 됩니다.
---
~~browser_use가 Playwright에 대한 의존성이 있어 브라우저 설치가 필요합니다~~
스텔스 기능 때문에 Chrome이 필요합니다.
스텔스 기능 때문에 Google Chrome이 필요합니다.
만약 설치가 되어 있지 않다면
```
playwright install chrome
```
---
다음과 같은 명령어로 실행합니다.
```sh
@ -46,26 +52,52 @@ Environment는 .env.example에 따라 설정되어야합니다.
.env.example을 .env로 복사하여서 사용해주세요.
# 쿠키와 로컬 스토리지 설정 방법
# 로그인 방안
## 쿠키와 로컬 스토리지 설정 방법 (추천)
![1](./docs/image.png)
```sh
uv run playwright open https://google.com/ --save-storage=./data/storage_state.json
```
위 명령어를 실행하면 playwright Browser가 하나 열리는데 여기서 원하는 프로바이더를 모두 로그인 한 후에 브라우저를 정상적으로 닫으면 ./data/storage_state.json 경로에 쿠키, 로컬스토리지를 저장한 파일이 생성됩니다.
## Browser Use에게 직접 로그인 요청 (선택)
<details>
위에 쿠키와 로컬스토리지 설정 방법과 혼용해서 사용가능합니다.
`.sensitive.example.json``.sensitive.json`으로 복사해서
안에 있는 예시 내용을 참고해서 작성해주시면 됩니다.
더 자세한 내용은
[Sensitive Data - Browser Use](https://docs.browser-use.com/customize/sensitive-data)를 참고하시면 좋을 것 같습니다.
[Sensitive Data - Browser Use](https://docs.browser-use.com/customize/sensitive-data)에서도 권장하지 않는 방법인만큼 애매하긴 하지만 쿠키와 로컬 스토리지를 저장하기 어려운 경우나 일부 flow에서 접근이 어려운 경우 사용해주세요.
</details>
# 실행
```sh
# domains.txt 받기
curl "https://f.imnya.ng/.whs/tp-domains/data/domains/latest.txt" -o domains.txt
domains.txt는 실행시 자동으로 다운로드 됩니다.
```sh
curl "https://f.imnya.ng/.whs/tp-domains/data/domains/latest.txt" -o domains.txt
```
```sh
# ./run.sh {domains.txt 시작 줄} {domains.txt 끝 줄} {HTML 검사 Skip}
./run.sh 12540 13000 False
```
```pwsh
# domains.txt 받기
curl "https://f.imnya.ng/.whs/tp-domains/data/domains/latest.txt" -o domains.txt
# ./run.ps1 {domains.txt 시작 줄} {domains.txt 끝 줄} {HTML 검사 Skip}
./run.ps1 12540 13000 False
```
# 참고하면 좋을만한 것
- [ ] 일부 웹사이트는 사용자의 언어에 따라 OAuth 옵션을 바꾸기도 합니다.
- [ ] https://docs.browser-use.com/customize/custom-functions

BIN
docs/image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View file

@ -0,0 +1,21 @@
# read json file .sensitive.json
import json
import os
def GetSensitiveData():
"""
Reads sensitive data from a .sensitive.json file in the current directory.
Returns:
dict: A dictionary containing the sensitive data.
"""
file_path = os.path.join(os.getcwd(), '.sensitive.json')
if not os.path.exists(file_path):
return None
with open(file_path, 'r') as file:
sensitive_data = json.load(file)
return sensitive_data

View file

@ -20,6 +20,7 @@ from lib.utils.backend_client import notify_backend
from lib.utils.browser_use import model
from lib.utils.browser_use.clean_resources import clean_resources
from lib.utils.browser_use.func import setup_storage_state
from lib.utils.browser_use.sensitive_data import GetSensitiveData
from lib.utils.config import BACKEND_URL, GOOGLE_MODEL, GOOGLE_PLANNER_MODEL
from lib.utils.is_html import is_html_url
from lib.utils.read_txt import read_lines_between
@ -114,6 +115,7 @@ async def scan_one_url(url: str, skip_html_check: bool = False):
agent = Agent(
browser_session=session,
initial_actions=initial_actions,
sensitive_data=GetSensitiveData(),
task=(
"Navigate to the login page, identify all OAuth provider buttons (excluding Passkey), "
"and for each one: click the button, follow the full OAuth login flow as far as possible "
@ -176,7 +178,7 @@ async def scan_one_url(url: str, skip_html_check: bool = False):
print("-" * 50)
# CSV에 저장 (append)
csv_file = "./oauth_providers.csv"
csv_file = "./data/oauth_providers.csv"
file_exists = os.path.isfile(csv_file)
with open(csv_file, "a", newline="", encoding="utf-8") as f:
writer = csv.writer(f)

View file

@ -3,7 +3,7 @@
$PYTHON_SCRIPT = "main.py"
# 도메인 목록 파일 경로 (Python 스크립트 실행 시 -f 옵션에 전달)
$DOMAIN_FILE = "./domains.txt"
$DOMAIN_FILE = "./data/domains.txt"
# ─────────────
# https://f.imnya.ng/.whs/tp-domains/data/domains/latest.txt

2
run.sh
View file

@ -2,7 +2,7 @@
# ── 설정 부분 ──
PYTHON_SCRIPT="main.py"
DOMAIN_FILE="./domains.txt"
DOMAIN_FILE="./data/domains.txt"
# ─────────────
curl "https://f.imnya.ng/.whs/tp-domains/data/domains/latest.txt" -o $DOMAIN_FILE