
A comprehensive browser extension (.xpi) malware scanner which checks for many common malware tricks like:, credential-stealers obfuscation tactics, steganography, base64 payloads, zip-tricks, remote-code execution, polyglot tricks, meta data tricks in an attempt to give the analysist information about where deeper analysis is needed.
Firefox 확장 프로그램 파일(.xpi)을 분석하여 악성 코드, 난독화, 숨겨진 페이로드, 스테가노그래피 등 확장 프로그램 검토 팀을 우회하는 데 사용되는 기술을 탐지하는 명령줄 도구입니다.
extension-scanner.py는 Firefox 확장 프로그램을 열어 내부의 모든 파일에 대해 일련의 보안 검사를 수행합니다. 그런 다음 심각도별로 정렬된 결과를 색상 코드로 구분된 보고서로 생성합니다.
CRITICAL — 거의 확실히 악성; 즉시 조사 필요HIGH — 강력히 의심됨; 주의 깊은 검토 필요MEDIUM — 잠재적 위험; 문맥에 따라 검토LOW — 경미한 우려; 정보 제공INFO — 메타데이터 (해시, 파일 크기 등)python3.11, python3.12 또는 python3.13**python3-venv** - 가상 환경 사용 시 필요가상 환경 사용:
sudo apt install python3 python3-venv
git clone https://github.com/ernos/extension-scanner.git
cd extension-scanner
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
**python3-numpy** - 스테가노그래피에 권장, 시스템 전체 설치 (그렇지 않으면 pip install -r requirements.txt)git clone https://github.com/ernos/extension-scanner.git
cd extension-scanner
chmod +x extension-scanner.py
mkdir -p ~/.local/share/bin
ln -s $PWD/extension-scanner.py ~/.local/share/bin/extension-scanner
# Required for LSB steganography analysis (optional but recommended)
pip install pillow numpy
# OPTION 1. Only for current user:
# Enable bash completions for simpler use (TAB for autocompleting commands)
mkdir -p ~/.local/share/bash-completion/completions
cp extension-scanner-completions ~/.local/share/bash-completion/completions
echo "source ~/.local/share/bash-completion/completions/extension-scanner-completions" >> ~/.bashrc
# OPTION 2. Enable completions globally for all users (Should be auto-sourced from your .bashrc)
cp extension-scanner-completions /usr/share/bash-completion/completions
Pillow/NumPy가 설치되지 않아도 도구는 계속 실행됩니다 — LSB 및 픽셀 엔트로피 검사는 단순히 건너뛰고 경고가 출력됩니다.
usage: xpiscanner [-h] [--update-blocklist] [--min-severity {CRITICAL,HIGH,MEDIUM,LOW,INFO}] [--json] [--compact] [-v] [-m] [--scans CHECK [CHECK ...]]
[targets ...]
Firefox Extension Scanner - Scans XPI files for security risks and malware indicators
positional arguments:
targets One or more XPI files or directories containing XPIs to analyze
options:
-h, --help show this help message and exit
--update-blocklist, --update, -u
Fetch fresh domain blocklists from URLhaus and Peter Lowe's list, merge with the bundled snapshot, and saves to
/home/peb/projects/Firefox-Extensions/extension-scanner/blocklist.json. Exits after updating.
--min-severity {CRITICAL,HIGH,MEDIUM,LOW,INFO}
Minimum severity to display (CRITICAL, HIGH, MEDIUM, LOW, INFO; default: INFO)
--json Output results as JSON instead of formatted text
--compact, -c Print each finding on 1-2 lines instead of the default 3-line format
-v, --verbose Enable verbose output: show additional context for findings
-m, --manifest Show full extension manifest for each target
--scans, -s CHECK [CHECK ...]
Limit analysis to specific check types. Choices: anti-analysis, api-abuse, credentials, cross-file,
file-meta, hidden-elements, obfuscation, payloads, permissions, polyglot, remote-code,
signatures, steganography, time-bomb, zip-tricks. Omit to run all checks (default).
extension-scanner.py — Analyze Firefox (and other browsers) extension XPI files for security risks and malware indicators.
Read README.md for information on how to interpret findings, limitations, and best practices for use.
This tool is intended for security researchers, analysts, and advanced users who want to perform a
comprehensive static analysis of browser extensions. It should work well for other browsers as well,
but this has only been tested on firefox.
Usage:
python3 extension-scanner.py [OPTIONS] targets...
Targets can be individual .xpi files or directories containing .xpi files. Use glob patterns (e.g. *.xpi) for convenience.
Available check types:
permissions Dangerous/broad manifest permissions and CSP issues
remote-code Background pages or service workers loaded from remote URLs
obfuscation eval/atob/encoding tricks, suspicious URLs, high-entropy strings
payloads Base64-encoded blobs decoded and scanned for executables/scripts
steganography PNG appended data (auto-decoded via base64/zlib/gzip), unknown chunks, LSB channel analysis
credentials Hardcoded API keys, tokens, passwords, private keys, IP addresses
file-meta Magic bytes, double extensions, suspicious filenames, file entropy
polyglot Files valid in two formats simultaneously (e.g. HTML+ZIP)
zip-tricks Path traversal, null bytes, duplicate entries, ZIP comments
cross-file HTML class tokens cross-referenced against JS localStorage keys
signatures Known strings from confirmed malicious extension families (qingcaila, YTMP4, etc.)
api-abuse Browser API calls indicating data theft or exfiltration (cookies, tabs, history, keylogger, clipboard, executeScript)
hidden-elements Invisible iframes, zero-dimension element injection, tracking pixels (new Image().src)
time-bomb Long-delay setTimeout, Date.now() gates, localStorage install-date checks, Math.random() gates
anti-analysis navigator.webdriver, zero-size window, bare debugger statement, performance.now() timing
Examples:
python3 extension-scanner.py extension.xpi
python3 extension-scanner.py *.xpi
python3 extension-scanner.py /path/to/extensions/
python3 extension-scanner.py a.xpi b.xpi --min-severity HIGH
python3 extension-scanner.py ext.xpi --scans obfuscation payloads
python3 extension-scanner.py ext.xpi --s steganography zip-tricks file-meta
python3 extension-scanner.py ext.xpi --verbose
python3 extension-scanner.py --update-blocklist
python3 extension-scanner.py --manifest
Tips:
- Make sure to source scanner-completions.sh from your .bashrc or .zshrc to enable tab completion for --scans categories and target file paths.
- Use --min-severity to focus on the most critical findings first.
- Use --scans to limit the analysis to specific categories of checks if you're looking for something specific or want to speed up the scan.
- Review the full manifest with --manifest for context on permissions, content scripts, and other extension metadata that can help interpret findings.
- Regularly update the blocklist with --update-blocklist to ensure the latest malicious domains are included in the checks.
Credits:
Developed by Ernos @ https://www.yourdev.net
Email: max at yourdev.net
GitHub: https://www.github.com/ernos/extension-scanner
════════════════════════════════════════════════════════════════════════════
XPI ANALYZER — example.xpi
════════════════════════════════════════════════════════════════════════════
Overall verdict: HIGH RISK
Findings: 1 CRITICAL 3 HIGH 2 MEDIUM 1 LOW
── CRITICAL ────────────────────────────────────────────────────────────
[CRITICAL ] [JS_OBFUSCATION] content.js
eval() call — can execute arbitrary code from strings
Evidence: var x = eval(atob("dmFyIGE9MTs…"))
── HIGH ────────────────────────────────────────────────────────────────
[HIGH ] [PERMISSION] manifest.json
Dangerous permission: 'nativeMessaging' — Can spawn native OS …
Evidence: permissions: ['nativeMessaging', 'storage', '<all_urls>']
…
여러 파일을 분석할 때, 개별 보고서 후에 모든 확장 프로그램을 나란히 보여주는 비교 테이블이 출력됩니다.
| 코드 | 의미 |
|---|---|
0 | CRITICAL 또는 HIGH 발견 사항 없음 |
1 | 최소 하나의 HIGH 발견 사항 |
2 | 최소 하나의 CRITICAL 발견 사항 |
CI 파이프라인 또는 셸 스크립트에서 쉽게 사용할 수 있습니다:
python3 extension-scanner.py extension.xpi --min-severity HIGH
if [ $? -eq 2 ]; then echo "CRITICAL issues found!"; fi
HIGH 발견 사항으로 나타날 수 있습니다.Maximilian Cornett
https://www.yourdev.net https://www.github.com/ernos
GNU General Public License - 이 도구는 보안 연구 및 방어적 분석 목적으로만 사용됩니다.
| 카테고리 | 검사 내용 |
|---|
| 권한 | 위험하거나 지나치게 광범위한 권한 (nativeMessaging, <all_urls>, debugger, desktopCapture 등) |
| 콘텐츠 보안 정책 | CSP의 unsafe-inline, unsafe-eval, 원격 스크립트 소스 |
| JavaScript 난독화 | eval(), atob(), Function() 생성자 남용, 16진수 이스케이프 시퀀스, split/join/reverse 재조립, 인코딩된 문자열 리터럴, 문자열 인수를 사용하는 setTimeout |
| 의심스러운 URL | 하드코딩된 외부 도메인을 known-bad (블록리스트 적중 → HIGH), unknown (허용 목록에 없음 → MEDIUM), known-good (허용 목록 → 표시 안 함)으로 분류합니다. --update-blocklist를 실행하여 URLhaus 및 Peter Lowe의 목록에서 도메인 블록리스트를 업데이트합니다. |
| 자격 증명 및 비밀 | 하드코딩된 API 키, 토큰 (AWS, GitHub, Slack, Google), 비밀번호, 개인 키, IP 주소 |
| Base64 페이로드 | 포함된 base64 blob을 디코딩하고 실행 파일, 스크립트, 네트워크 코드를 검사합니다 |
| PNG 스테가노그래피 | PNG IEND 뒤에 추가된 데이터를 감지하고 트레일러를 자동으로 디코딩합니다 (base64, zlib, gzip 및 조합); 디코딩된 페이로드는 재귀적으로 JS 난독화, 자격 증명, 의심스러운 URL을 검사합니다. 또한 알 수 없는 청크 유형, LSB 채널 이상, 비정상적으로 높은 픽셀 엔트로피를 감지합니다. |
| 파일 메타데이터 | 실행 파일의 매직 바이트 감지 (.exe, .elf, .dylib), 이중 확장자 (예: photo.png.js), 의심스러운 파일 이름 (keylog, miner, wallet) |
| 폴리글롯 파일 | 두 형식에서 동시에 유효한 파일 (예: HTML + ZIP) |
| ZIP 트릭 | 경로 탐색 항목, 파일 이름의 널 바이트, 파서를 속일 수 있는 중복 항목, 페이로드를 포함한 ZIP 주석 |
| 원격 코드 | 원격 URL에서 로드된 백그라운드 페이지 또는 서비스 워커 |
| 높은 엔트로피 | 의심스러울 정도로 높은 엔트로피를 가진 파일 또는 문자열 리터럴 (암호화되거나 압축된 페이로드) |
| API 남용 | 데이터 도난 또는 유출을 나타내는 브라우저 확장 API 호출: cookies.getAll({}), tabs.query({}), history.search, 키보드 리스너, 클립보드 읽기, 동적 함수를 사용한 scripting.executeScript. 동일 파일에서 데이터 수집 호출과 아웃바운드 네트워크 전송이 함께 나타나면 CRITICAL로 상향합니다. |
| 숨겨진 요소 | DOM에 주입된 동적으로 생성된 보이지 않는 iframe (display:none, 크기 0) — 무음 제휴 핑 또는 C2 채널. 외부 URL을 가리키는 new Image().src를 통한 추적 픽셀 |
| 타임 밤 | 지연 시간 ≥ 5분인 setTimeout/setInterval; Date.now() 산술 게이트; 첫 실행 후 며칠 후에 동작을 활성화하는 localStorage 설치 날짜 확인; 페이지 로드의 일부에서만 실행되는 Math.random() 임계값 게이트 |
| 안티 분석 | navigator.webdriver 확인; 너비/높이가 0인 창 비교; 단독 debugger 문; 타이밍 기반 샌드박스 탐지에 사용되는 performance.now() 산술 |
| 플래그 | 설명 |
|---|
--update-blocklist | URLhaus 및 Peter Lowe의 광고/악성 서버 목록에서 최신 도메인 목록을 가져와 번들 스냅샷과 병합하고 스크립트 옆에 blocklist.json에 저장합니다. 업데이트 후 종료됩니다. |
targets | 하나 이상의 .xpi 파일 또는 디렉터리 |
--min-severity | 출력 필터: CRITICAL, HIGH, MEDIUM, LOW, INFO (기본값: INFO) |
--json | 사람이 읽을 수 있는 보고서 대신 JSON 문서로 결과 출력 |
--verbose 또는 -v | manifest.json 내용을 출력하고 의심스러운 패턴 주변의 코드 5줄 정도를 포함합니다 |
--checks | 특정 검사 카테고리만 스캔 (아래 참조) |
| 사용 가능한 검사 카테고리 | 카테고리 내 검사 설명 |
|---|
| permissions | 위험하거나 광범위한 매니페스트 권한 및 CSP 문제 |
| remote-code | 원격 URL에서 로드된 백그라운드 페이지 또는 서비스 워커 |
| obfuscation | eval/atob/인코딩 트릭, 의심스러운 URL, 높은 엔트로피 문자열 |
| payloads | Base64로 인코딩된 blob을 디코딩하고 실행 파일/스크립트 검사 |
| steganography | PNG 추가 데이터, 알 수 없는 청크, LSB 채널 분석 |
| credentials | 하드코딩된 API 키, 토큰, 비밀번호, 개인 키, IP 주소 |
| file-meta | 매직 바이트, 이중 확장자, 의심스러운 파일 이름, 파일 엔트로피 |
| polyglot | 두 형식에서 동시에 유효한 파일 (예: HTML+ZIP) |
| zip-tricks | 경로 탐색, 널 바이트, 중복 항목, ZIP 주석 |
| cross-file | JS localStorage 키와 상호 참조된 HTML 클래스 토큰 |
| api-abuse | 데이터 도난 또는 유출을 나타내는 브라우저 API 호출 (cookies, tabs, history, keyboard, clipboard). 동일 파일에 수집 + 네트워크 전송이 나타나면 CRITICAL. |
| hidden-elements | 보이지 않는 iframe 주입 및 추적 픽셀. iframe이 숨겨져 있고 DOM에 추가되면 HIGH. |
| time-bomb | 긴 지연 setTimeout, Date.now() 산술 게이트, localStorage 설치 날짜, Math.random() 임계값. |
| anti-analysis | navigator.webdriver, 크기 0 창, 단독 debugger 문, performance.now() 산술. |