Skip to content
Back to skills

Wechat Miniprogram Pentesting

BSecurity

WeChat mini-program: wxapkg unpack, API surface, crypto

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 29, 2026
developmentjavascriptpythonrustgojavashellbashnodeawstesting

Works with

  • cli
  • api

Security analysis

B84/100
  • criticalDownloads and executes remote scripts — classic supply chain attack
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 3 files and shows the line behind each finding

Scanned November 29, 2026

npx -y skills add blackfoxxx/kestrel --skill wechat-miniprogram-pentesting --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Wechat Miniprogram Pentesting?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Wechat Miniprogram Pentesting
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/blackfoxxx-wechat-miniprogram-pentesting/badge)](https://www.skillsdirectory.com/skills/blackfoxxx-wechat-miniprogram-pentesting)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: wechat-miniprogram-pentesting
description: "WeChat mini-program: wxapkg unpack, API surface, crypto"
metadata:
  tags: "wechat,mini-program,wxapkg,miniprogram,wechat-security,applet,javascript,wx-api,reversing"
  category: mobile

---

# WeChat Mini Program Security Testing Methodology

> **Core idea**: Mini Programs run in a JavaScript sandbox, but their business logic, API endpoints, and signing secrets are all in the decompiled source. It's essentially web security + JavaScript source audit.

## Deep Reference

- wxapkg decompilation detailed workflow, obfuscated code handling → [references/miniprogram-decompile.md](references/miniprogram-decompile.md)
- API authentication bypass and traffic capture details → [references/miniprogram-api-testing.md](references/miniprogram-api-testing.md)

---

## Phase 0: Mini Program Package Acquisition

### Method 1: Android Phone Extraction (Recommended)

```bash
# Precondition: rooted Android phone with WeChat installed
adb shell

# Scan for .wxapkg files
find /data/data/com.tencent.mm/ -name "*.wxapkg" 2>/dev/null
# Common locations:
# /data/data/com.tencent.mm/MicroMsg/<hash>/appbrand/pkg/

# Or use PC's WeChat storage location (documents synced)
find /sdcard/tencent/ -name "*.wxapkg" 2>/dev/null

# Pull to PC
adb pull /data/data/com.tencent.mm/MicroMsg/<hash>/appbrand/pkg/ ./wxapkg/
```

### Method 2: iOS Device Extraction

```bash
# Requires jailbroken iOS device
# WeChat storage path:
# /var/mobile/Containers/Data/Application/<UUID>/Library/WechatPrivate/<hash>/appbrand/pkg/

ssh root@device
find /var/mobile/Containers/Data/Application/ -path "*/appbrand/pkg/*.wxapkg" 2>/dev/null
scp root@device:/path/to/*.wxapkg ./
```

### Method 3: PC WeChat (Windows/macOS)

```bash
# Windows storage path
# C:\Users\<Username>\Documents\WeChat Files\WeChat Files\<WechatID>\Applet\<AppID>\

# macOS
# ~/Library/Containers/com.tencent.xinWeChat/Data/Library/Application Support/com.tencent.xinWeChat/

# File structure: __APP__.wxapkg is the main package, sub-packages are numbered separately
```

### Obtain AppID

```bash
# AppID starts with wx, 18 characters, e.g. wx1234567890abcdef
# Method 1: visible in app info page
# Method 2: appears in decompiled source
# Method 3: check in WeChat DevTools
```

---

## Phase 1: Package Decompilation

### wxapkg Decompilation Tools

```bash
# Method 1: unveilr (supports encrypted packages, recommended)
# npm install -g unveilr
# Or use npx
npx unveilr com.tencent.mm-*.wxapkg -o output/

# Method 2: wxappUnpacker (classic but older)
git clone https://github.com/qwerty472123/wxappUnpacker
npm install
node wuWxapkg.js path/to/app.wxapkg

# Method 3: CrackMinApp (supports sub-packages)
# python3 unpack.py path/to/app.wxapkg output/

# Method 4: wxUnpacker (online version)
# Online tool: https://github.com/ls-projects/miniprogram-decompiler
```

### Decompiled Source Structure

```
output/
├── app.js           # App logic, global configuration, initialization
├── app.json         # Page routing configuration
├── app.wxss         # Global styles
├── pages/           # Page source code
│   ├── index/
│   │   ├── index.js     # Page logic (key audit target)
│   │   ├── index.wxml   # Page template
│   │   └── index.wxss   # Page styles
│   └── ...
├── utils/           # Utilities (often includes signature/crypto logic)
│   ├── request.js       # Network request encapsulation (key audit target)
│   └── common.js        # Common functions
└── miniprogram_npm/ # npm packages
```

---

## Phase 2: Static Code Audit

### Sensitive Information Leakage

```bash
# 1. Hardcoded credentials / keys
grep -rn "password\|passwd\|secret\|api_key\|apiKey\|appSecret\|privateKey" output/ --include="*.js"
grep -rn "ACCESS_KEY\|SecretId\|SecretKey\|ak\|sk" output/ --include="*.js"

# 2. Sensitive business data
grep -rn "phone\|mobile\|idcard\|id_card\|bankcard" output/ --include="*.js"

# 3. Backend API addresses
grep -rn "baseUrl\|baseURL\|host\|url\|api" output/ --include="*.js" | grep -i "http"
grep -rn "wx\.request" output/ --include="*.js"

# 4. Signing keys and algorithms
grep -rn "sign\|signature\|md5\|sha1\|hmac\|aes\|encrypt" output/ --include="*.js"

# 5. Admin interfaces / test interfaces
grep -rn "admin\|test\|debug\|mock" output/ --include="*.js"

# 6. Debug switches
grep -rn "debug\|isDebug\|isDev\|isDevelopment" output/ --include="*.js"
```

### app.json — Page Route Analysis

```bash
# View all page routes
cat output/app.json | python3 -m json.tool

# Focus on:
# 1. Admin pages (admin/ manage/ backstage/)
# 2. Payment pages
# 3. User privilege management pages
# 4. usingComponents — third-party components
```

### Request Encapsulation Analysis

```bash
# Find request encapsulation layer
grep -rn "wx\.request" output/utils/ --include="*.js" -l
cat output/utils/request.js

# Audit points:
# 1. How is the signature generated?
# 2. Is token placed in header/body/URL parameter?
# 3. Are there Authorization fields?
# 4. Is there certificate pinning?
```

### Authentication Logic Analysis

```bash
# Login flow
grep -rn "login\|token\|openid\|session_key\|auth" output/ --include="*.js" | head -50

# Sensitive operations
grep -rn "admin\|payment\|transfer\|withdraw\|balance" output/ --include="*.js"
```

---

## Phase 3: Traffic Capture and Analysis

### Capture Environment Setup

```
Traffic capture options?
├─ Android phone + Burp
│   ├─ Set WiFi proxy → Burp
│   ├─ Install Burp CA certificate to device (Android 7+ requires trusting user CA)
│   └─ WeChat itself may use certificate pinning for some interfaces (mitm-proxy might help)
├─ PC WeChat (recommended — easier certificate trust)
│   ├─ Set system proxy → Burp
│   └─ PC WeChat trusts system CA by default
└─ Mitmproxy + mitmweb
    └─ mitmproxy --mode transparent (transparent proxy mode)
```

### PC WeChat Proxy Setup

```bash
# Windows: set system proxy
# Settings → Network & Internet → Proxy → Manual proxy setup

# macOS: set system proxy
networksetup -setwebproxy Wi-Fi 127.0.0.1 8080
networksetup -setsecurewebproxy Wi-Fi 127.0.0.1 8080
# Install Burp CA to system keychain and trust it
```

### Mini Program Certificate Pinning Check

If traffic cannot be captured, it might be certificate pinning:

```bash
# Check in decompiled source
grep -rn "domain\|certificate\|ssl\|tls\|fingerprint" output/ --include="*.js"

# Check whether wx.request has sslVerify: false setting
grep -rn "sslVerify" output/ --include="*.js"
```

---

## Phase 4: API Authentication Bypass

### Common Authentication Mechanisms

| Authentication Type | Description | Bypass Strategy |
|--------------------|-------------|-----------------|
| Session Token | JWT / custom token | Try replay, tampering |
| Signature (Sign) | HMAC-SHA256 / MD5 | Extract key from decompiled source, forge |
| OpenID | WeChat user unique identifier | Fixed, cannot change |
| wx.login Code | One-time, 5-minute expiry | Normally cannot replay |
| Custom login token | Often JWT or UUID | Try replay / brute force |

### Signature Bypass

After decompiling, find the signing logic in source code:

```javascript
// Common signing patterns
// Pattern 1: sorted parameters + secret key MD5
function sign(params, secret) {
  let str = Object.keys(params)
    .sort()
    .map(k => `${k}=${params[k]}`)
    .join('&') + `&key=${secret}`;
  return md5(str).toUpperCase();
}

// Pattern 2: timestamp + nonce + body HMAC
function generateSign(timestamp, nonce, body, secret) {
  return hmacSha256(`${timestamp}\n${nonce}\n${body}`, secret);
}
```

After extracting the signing logic:

```python
# Forge signature using Python
import hashlib, hmac, json

secret = "extracted_secret_key"
params = {"user_id": "victim", "action": "transfer", "amount": 100}
# Reconstruct signature using decompiled algorithm
sorted_params = sorted(params.items())
sign_str = "&".join(f"{k}={v}" for k, v in sorted_params) + f"&key={secret}"
sign = hashlib.md5(sign_str.encode()).hexdigest().upper()
```

### Unauthorized Access Testing

```bash
# 1. Test accessing high-privilege interface without token
curl -X GET "https://api.target.com/admin/users"

# 2. Use low-privilege account token to access high-privilege interface
curl -H "Authorization: Bearer low_priv_token" "https://api.target.com/admin/delete?id=1"

# 3. Horizontal privilege escalation — access other users' data
curl -H "Authorization: Bearer my_token" "https://api.target.com/user/data?user_id=other_user_id"

# 4. Parameter tampering
curl -d '{"user_id": "admin", "role": "admin"}' "https://api.target.com/profile/update"
```

---

## Phase 5: Frontend Logic Bypass

### Client-Side Access Control Bypass

```javascript
// In decompiled source, find page access control
// App.js or specific page
onShow() {
  if (!this.data.isAdmin) {
    wx.navigateTo({url: '/pages/index/index'});  // redirect to home
    return;
  }
  // Admin-only operations...
}
```

After decompiling, directly construct navigateTo parameters to visit admin pages:

```javascript
// In WeChat DevTools console
wx.navigateTo({url: '/pages/admin/admin'})
// Or direct URL access
wx.reLaunch({url: '/pages/admin/admin?bypass=1'})
```

### Modifying Decompiled Source

```bash
# Repack after modifying decompiled source
# 1. Modify JS logic (e.g., remove privilege checks)
vim output/pages/admin/admin.js
# Comment out or remove: if (!isAdmin) return;

# 2. Repack (not currently supported by all tools — use WeChat DevTools)
# Method: Import decompiled project into WeChat DevTools for real-time debugging
```

### WeChat DevTools Debugging

```
1. Open WeChat Web DevTools
2. Select "Existing Mini Program project"
3. Import decompiled source directory
4. Use console to modify variables and call functions in real-time
5. No repack needed — debug directly in development environment
```

---

## Phase 6: Common Vulnerabilities

### Sensitive Data in Cloud Storage

```bash
# Mini Programs often use Tencent Cloud COS, check for unprotected file addresses
# Pattern: in decompiled source find COS/OSS/S3 URLs
grep -rn "cos\.ap\|myqcloud\|oss\.aliyuncs\|s3\.amazonaws" output/ --include="*.js"
grep -rn "downloadFile\|uploadFile\|wx\.downloadFile" output/ --include="*.js"
```

### SSRF via wx.request

```bash
# If wx.request URL is user-controlled → SSRF
grep -rn "url.*this\.data\|url.*event\|url.*params" output/ --include="*.js" | grep "wx\.request"
```

### Stored XSS via wx.navigateTo / webview

```bash
# Mini Programs can embed web pages via WebView
grep -rn "web-view\|webview\|navigateTo" output/ --include="*.wxml"
grep -rn "WebviewURL\|webUrl\|src" output/ --include="*.js"
# If URL is user-controlled → XSS
```

### IDOR (Insecure Direct Object Reference)

Common ID increment / UUID brute force:

```bash
# Enumerate user data
for i in {1..1000}; do
  curl -s -H "Authorization: Bearer token" \
    "https://api.target.com/user/profile?user_id=$i" | python3 -m json.tool
done
```

### Payment Logic Bypass

```bash
# 1. Modify amount
{"price": 0.01, "product_id": "premium_item"}

# 2. Order replay (use completed order ID to get product again)
{"order_id": "completed_order_id", "action": "deliver"}

# 3. Coupon abuse
{"coupon_code": "TEST100", "product_id": "any"}
```

---

## Notes

- WeChat Mini Programs are essentially a web application embedded in WeChat's container
- The underlying runtime is WeChat's custom JavaScript engine (JsCore on iOS, V8 on Android)
- wx.request does not go through the system's HTTP layer, so capturing traffic may require transparency proxies
- WeChat DevTools is essential for debugging decompiled source
- Mini Program packages have size limits — complex apps use sub-packages; each needs to be decompiled separately
- Some mini programs use code obfuscation (variable name mangling etc.) — may require manual deobfuscation
- WeChat API (wx.*) calls are native calls, not HTTP, and cannot be intercepted

Files in this skill

  • SKILL.md11.8 KB
  • references/miniprogram-source-audit.md4.6 KB
  • references/wxapkg-unpacking.md3.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.