This commit is contained in:
dengqichen 2025-11-16 19:46:13 +08:00
parent f423f8b57f
commit bf55bcee27
18 changed files with 2105 additions and 206 deletions

View File

@ -11,6 +11,7 @@
- 🔧 **高度可配置** - 支持多种输出格式和自定义选项 - 🔧 **高度可配置** - 支持多种输出格式和自定义选项
- 📦 **轻量级** - 最小依赖,快速安装 - 📦 **轻量级** - 最小依赖,快速安装
- 🌍 **跨平台** - 支持 macOS、Linux、Windows - 🌍 **跨平台** - 支持 macOS、Linux、Windows
- 🛡️ **反检测技术** - 使用最新的 rebrowser-puppeteer降低被识别风险
## 📦 安装 ## 📦 安装
@ -238,12 +239,15 @@ node src/index.js card -n 5
## 📋 待办事项 ## 📋 待办事项
- [ ] 添加更多工具(邮箱生成器、用户名生成器等) - [x] 信用卡生成器支持Luhn算法
- [x] 账号注册工具(支持步骤化流程)
- [x] 反检测技术rebrowser-puppeteer
- [x] 人类行为模拟
- [ ] 添加更多网站注册脚本
- [ ] 添加单元测试 - [ ] 添加单元测试
- [ ] 添加配置文件支持 - [ ] 验证码识别集成
- [ ] 代理池管理
- [ ] 发布到 npm - [ ] 发布到 npm
- [ ] 添加交互式模式
- [ ] 支持自定义卡号规则
## 🤝 贡献 ## 🤝 贡献

View File

@ -1,98 +0,0 @@
/**
* 分析原始卡号规律
*/
const { luhnCheck } = require('./src/shared/utils');
// 原始样本数据
const samples = [
'6228367546781457|11|27|792',
'6228367542738949|06|28|510',
'6228367542602400|09|28|574',
'6228367548575105|06|27|838',
'6228367546496080|09|26|918',
'6228367540057649|10|26|244',
'6228367549574719|04|26|751',
'6228367548435128|11|28|897',
'6228367542797374|01|26|837',
'6228367545956423|10|30|516',
'6228367547237848|08|30|391',
'6228367540385107|10|27|364',
'6228367544252006|03|27|342',
'6228367547562054|12|29|870'
];
console.log('=== 原始卡号规律分析 ===\n');
// 解析数据
const cards = samples.map(line => {
const [number, month, year, cvv] = line.split('|');
return { number, month, year, cvv };
});
// 1. 分析卡号结构
console.log('1. 卡号结构分析:');
console.log(` 总数量: ${cards.length}`);
console.log(` 卡号长度: ${cards[0].number.length}`);
// 检查前缀
const prefixes = cards.map(c => c.number.substring(0, 9));
const uniquePrefixes = [...new Set(prefixes)];
console.log(` 共同前缀: ${uniquePrefixes[0]}`);
console.log(` 前缀一致性: ${uniquePrefixes.length === 1 ? '✓ 是' : '✗ 否'}`);
// 2. 检查Luhn算法
console.log('\n2. Luhn算法校验:');
let luhnValid = 0;
cards.forEach((card, i) => {
const isValid = luhnCheck(card.number);
if (isValid) luhnValid++;
console.log(`${i + 1}: ${card.number} - ${isValid ? '✓ 通过' : '✗ 不通过'}`);
});
console.log(` 总结: ${luhnValid}/${cards.length} 通过Luhn校验`);
// 3. 分析有效期
console.log('\n3. 有效期分析:');
const months = cards.map(c => parseInt(c.month));
const years = cards.map(c => parseInt(c.year));
console.log(` 月份范围: ${Math.min(...months)} - ${Math.max(...months)}`);
console.log(` 年份范围: ${Math.min(...years)} - ${Math.max(...years)}`);
// 4. 分析CVV
console.log('\n4. CVV分析:');
const cvvs = cards.map(c => parseInt(c.cvv));
console.log(` CVV长度: ${cards[0].cvv.length}`);
console.log(` CVV范围: ${Math.min(...cvvs)} - ${Math.max(...cvvs)}`);
// 5. 分析后7位数字
console.log('\n5. 后7位数字分析:');
const suffixes = cards.map(c => c.number.substring(9));
console.log(` 示例后7位:`);
suffixes.slice(0, 5).forEach((suffix, i) => {
console.log(` ${i + 1}. ${suffix}`);
});
// 6. 检查是否有数字模式
console.log('\n6. 数字分布分析:');
const allDigits = suffixes.join('').split('').map(d => parseInt(d));
const digitCounts = {};
for (let i = 0; i <= 9; i++) {
digitCounts[i] = allDigits.filter(d => d === i).length;
}
console.log(' 各数字出现次数:');
for (let i = 0; i <= 9; i++) {
const bar = '█'.repeat(Math.floor(digitCounts[i] / 2));
console.log(` ${i}: ${bar} (${digitCounts[i]})`);
}
console.log('\n=== 结论 ===');
if (luhnValid === cards.length) {
console.log('✓ 所有卡号都通过Luhn算法校验');
console.log('✓ 建议: 启用Luhn算法生成');
} else if (luhnValid === 0) {
console.log('✗ 没有卡号通过Luhn算法校验');
console.log('✓ 建议: 使用纯随机生成(当前实现)');
} else {
console.log('⚠ 部分卡号通过Luhn算法校验');
console.log('⚠ 需要进一步分析规律');
}

View File

@ -0,0 +1,259 @@
# 账号注册工具 (Account Register)
自动化账号注册工具,支持步骤化流程和反检测技术。
## 功能特性
- ✅ 步骤化注册流程(每个网站独立定义)
- ✅ 反检测技术rebrowser-puppeteer
- ✅ 人类行为模拟
- ✅ 自动数据生成(姓名、邮箱、密码等)
- ✅ 支持部分步骤执行
- ✅ 干运行模式
## 快速开始
### 1. 生成账号数据(干运行)
```bash
node src/cli.js register -s windsurf --dry-run
```
输出示例:
```
firstName: John
lastName: Smith
fullName: John Smith
email: user_17001234_abc123@gmail.com
username: quickwolf456
password: Xy9#mK2$pL5@
timestamp: 2024-11-16T11:30:00.000Z
```
### 2. 执行第一步注册
```bash
node src/cli.js register -s windsurf --from-step 1 --to-step 1
```
这将:
1. 生成账号数据
2. 启动浏览器(反检测模式)
3. 打开注册页面
4. 自动填写 First Name, Last Name, Email
5. 点击 Continue 按钮
### 3. 执行完整注册流程
```bash
node src/cli.js register -s windsurf
```
执行所有已实现的步骤目前只有Step 1
## 命令行参数
| 参数 | 简写 | 说明 | 默认值 |
|------|------|------|--------|
| --site | -s | 网站名称 | 必需 |
| --dry-run | 无 | 只生成数据,不执行 | false |
| --from-step | 无 | 从第几步开始 | 1 |
| --to-step | 无 | 执行到第几步 | 全部 |
| --keep-browser-open | 无 | 保持浏览器打开 | false |
| --format | -f | 输出格式 | simple |
| --output | -o | 保存到文件 | 无 |
## 支持的网站
### Windsurf (windsurf)
**注册URL**: https://windsurf.com/account/register
**步骤总数**: 3步目前实现1步
**步骤详情**:
1. ✅ 填写基本信息First Name, Last Name, Email
2. ⏳ 设置密码(待实现)
3. ⏳ 邮箱验证(待实现)
## 使用示例
### 示例1测试数据生成
```bash
# 生成通用账号数据
node src/cli.js register generate
# 生成Windsurf专用数据
node src/cli.js register -s windsurf --dry-run
# JSON格式输出
node src/cli.js register generate -f json
```
### 示例2自动化注册
```bash
# 执行第一步
node src/cli.js register -s windsurf --from-step 1 --to-step 1
# 保持浏览器打开(手动完成后续步骤)
node src/cli.js register -s windsurf --keep-browser-open
# 保存账号数据到文件
node src/cli.js register -s windsurf -o account.json
```
### 示例3分步骤执行
```bash
# 只执行第一步
node src/cli.js register -s windsurf --to-step 1
# 从第二步继续(需要先完成第一步)
node src/cli.js register -s windsurf --from-step 2
```
## 反检测技术
### 使用的技术
1. **rebrowser-puppeteer**: 修补版Puppeteer修复CDP泄漏
2. **人类行为模拟**: 随机延迟、真实鼠标轨迹、自然输入节奏
3. **指纹随机化**: 随机视口、用户代理、语言设置
详细说明请查看: [ANTI-DETECTION.md](../account-register/ANTI-DETECTION.md)
### 测试反检测效果
访问以下网站测试是否被识别为bot
- https://bot-detector.rebrowser.net/
- https://arh.antoinevastel.com/bots/areyouheadless
- https://abrahamjuliot.github.io/creepjs
## 添加新网站
### 1. 创建网站脚本
`src/tools/account-register/sites/` 目录创建新文件,例如 `github.js`
```javascript
const AccountDataGenerator = require('../generator');
const HumanBehavior = require('../utils/human-behavior');
const logger = require('../../../shared/logger');
class GitHubRegister {
constructor() {
this.siteName = 'GitHub';
this.siteUrl = 'https://github.com/signup';
this.dataGen = new AccountDataGenerator();
this.human = new HumanBehavior();
this.currentStep = 0;
// 定义步骤
this.steps = [
{ id: 1, name: '填写邮箱', method: 'step1_fillEmail' },
{ id: 2, name: '设置密码', method: 'step2_setPassword' },
{ id: 3, name: '填写用户名', method: 'step3_fillUsername' },
// 更多步骤...
];
}
generateData(options = {}) {
return this.dataGen.generateAccount(options);
}
async initBrowser() {
// 使用Windsurf的实现
}
async step1_fillEmail() {
// 实现第一步
}
async register(options = {}) {
// 实现主流程
}
}
module.exports = GitHubRegister;
```
### 2. 使用新脚本
```bash
node src/cli.js register -s github
```
工具会自动发现并加载新脚本。
## 编程使用
```javascript
const WindsurfRegister = require('./src/tools/account-register/sites/windsurf');
(async () => {
const register = new WindsurfRegister();
try {
const result = await register.register({
fromStep: 1,
toStep: 1,
keepBrowserOpen: true
});
console.log('注册结果:', result);
} catch (error) {
console.error('注册失败:', error);
}
})();
```
## 注意事项
⚠️ **重要提醒**
1. **遵守服务条款**: 确保使用符合网站的服务条款
2. **频率限制**: 避免短时间内大量注册
3. **验证码**: 遇到验证码时需要手动处理
4. **IP地址**: 建议使用住宅代理避免数据中心IP
5. **法律合规**: 仅用于合法的测试和个人用途
## 故障排除
### 问题1: 浏览器无法启动
**解决方案**:
```bash
# 重新安装依赖
rm -rf node_modules package-lock.json
npm install
```
### 问题2: 元素找不到
**解决方案**:
- 检查网站是否更新了页面结构
- 增加等待时间
- 使用浏览器开发工具查看实际的选择器
### 问题3: 仍然被识别为bot
**解决方案**:
1. 使用住宅代理
2. 增加操作延迟
3. 添加更多人类行为(滚动、鼠标移动)
4. 考虑使用半自动模式
## 性能优化
- 使用 `--headless` 模式(但容易被检测)
- 禁用图片加载
- 使用更快的选择器
- 缓存浏览器实例
## 相关资源
- [反检测技术文档](../account-register/ANTI-DETECTION.md)
- [rebrowser-patches](https://github.com/rebrowser/rebrowser-patches)
- [人类行为模拟最佳实践](https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth)

View File

@ -1,54 +0,0 @@
/**
* 最终验证 - 确认生成的卡号符合所有规律
*/
const { luhnCheck } = require('./src/shared/utils');
// 刚才生成的5张卡
const newCards = [
'6228367543886341|02|28|859',
'6228367547515052|03|26|649',
'6228367546095387|07|30|930',
'6228367544299692|04|30|852',
'6228367546840634|01|26|197'
];
console.log('=== 最终验证 ===\n');
console.log('验证新生成的5张卡:\n');
let allValid = true;
newCards.forEach((cardStr, index) => {
const [number, month, year, cvv] = cardStr.split('|');
const isValid = luhnCheck(number);
// 检查各项规律
const prefixOk = number.startsWith('622836754');
const lengthOk = number.length === 16;
const monthOk = parseInt(month) >= 1 && parseInt(month) <= 12;
const yearOk = parseInt(year) >= 26 && parseInt(year) <= 30;
const cvvOk = cvv.length === 3;
const allChecks = prefixOk && lengthOk && monthOk && yearOk && cvvOk && isValid;
allValid = allValid && allChecks;
console.log(`${index + 1}: ${cardStr}`);
console.log(` ├─ 前缀 622836754: ${prefixOk ? '✓' : '✗'}`);
console.log(` ├─ 长度 16位: ${lengthOk ? '✓' : '✗'}`);
console.log(` ├─ 月份 01-12: ${monthOk ? '✓' : '✗'}`);
console.log(` ├─ 年份 26-30: ${yearOk ? '✓' : '✗'}`);
console.log(` ├─ CVV 3位: ${cvvOk ? '✓' : '✗'}`);
console.log(` └─ Luhn校验: ${isValid ? '✓' : '✗'}\n`);
});
console.log('=== 结论 ===');
if (allValid) {
console.log('✓ 所有卡号完全符合规律!');
console.log('✓ 工具已正确实现,可以使用!\n');
console.log('推荐测试卡号(任选一张):\n');
newCards.forEach((card, i) => {
console.log(`${i + 1}. ${card}`);
});
} else {
console.log('✗ 存在不符合规律的卡号,需要修复');
}

View File

@ -21,7 +21,8 @@
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"commander": "^11.0.0" "commander": "^11.0.0",
"puppeteer": "^21.11.0"
}, },
"engines": { "engines": {
"node": ">=14.0.0" "node": ">=14.0.0"

View File

@ -44,6 +44,50 @@ if (cardTool) {
}); });
} }
// 注册account-register命令
const registerTool = registry.get('account-register');
if (registerTool) {
const registerCommand = program
.command('register')
.description('自动注册账号')
.option('-s, --site <site>', '网站名称 (windsurf, etc)')
.option('--dry-run', '干运行模式:只生成数据不执行注册', false)
.option('-f, --format <format>', '输出格式 (simple, json, table)', 'simple')
.option('-o, --output <file>', '保存账号数据到文件')
.option('--from-step <number>', '从第几步开始执行', '1')
.option('--to-step <number>', '执行到第几步(不指定则执行全部)')
.option('--keep-browser-open', '保持浏览器打开', false)
.action(async (options) => {
// 转换步骤参数为数字
if (options.fromStep) options.fromStep = parseInt(options.fromStep);
if (options.toStep) options.toStep = parseInt(options.toStep);
await registerTool.execute(options);
});
// 添加子命令
registerCommand
.command('list')
.description('列出所有支持的网站')
.action(() => {
registerTool.listSites();
});
registerCommand
.command('generate')
.description('只生成账号数据(不执行注册)')
.option('-f, --format <format>', '输出格式', 'simple')
.action((options) => {
registerTool.generate(options);
});
registerCommand
.command('list-formats')
.description('列出所有支持的输出格式')
.action(() => {
registerTool.listFormats();
});
}
// 列出所有工具 // 列出所有工具
program program
.command('list') .command('list')
@ -62,11 +106,19 @@ program
program.on('--help', () => { program.on('--help', () => {
console.log(''); console.log('');
console.log('Examples:'); console.log('Examples:');
console.log(' # 信用卡生成器');
console.log(' $ aam card # 生成一张默认银联卡'); console.log(' $ aam card # 生成一张默认银联卡');
console.log(' $ aam card -t visa # 生成一张Visa卡'); console.log(' $ aam card -t visa # 生成一张Visa卡');
console.log(' $ aam card -t unionpay -n 10 # 生成10张银联卡'); console.log(' $ aam card -t unionpay -n 10 # 生成10张银联卡');
console.log(' $ aam card -t visa -f json # JSON格式输出');
console.log(' $ aam card list-types # 查看支持的卡类型'); console.log(' $ aam card list-types # 查看支持的卡类型');
console.log('');
console.log(' # 账号注册工具');
console.log(' $ aam register -s windsurf --dry-run # 生成Windsurf账号数据');
console.log(' $ aam register -s windsurf # 执行Windsurf注册');
console.log(' $ aam register list # 列出支持的网站');
console.log(' $ aam register generate # 生成通用账号数据');
console.log('');
console.log(' # 其他');
console.log(' $ aam list # 列出所有工具'); console.log(' $ aam list # 列出所有工具');
console.log(''); console.log('');
}); });

View File

@ -0,0 +1,170 @@
# 反检测技术说明
## 当前使用的技术
### 1. rebrowser-puppeteer
我们使用 `rebrowser-puppeteer` 替代标准的 `puppeteer`,这是一个打了补丁的版本,修复了以下检测点:
#### 修复的主要泄漏点:
- **Runtime.enable 泄漏** - CDP命令检测
- **Console.enable 泄漏** - 控制台API检测
- **Command Flags 泄漏** - 启动参数检测
- **sourceURL 泄漏** - 脚本注入检测
- **navigator.webdriver** - 自动化标记
- **Chrome DevTools Protocol** - CDP特征
### 2. 人类行为模拟
实现了 `HumanBehavior` 类,模拟真实用户操作:
#### 输入行为:
- 随机输入速度80-180ms/字符)
- 随机停顿(模拟思考)
- 偶尔的快速输入段落
- 自然的输入节奏
#### 鼠标行为:
- 非线性移动轨迹
- 随机点击位置偏移
- 移动前的停顿
- 点击前的悬停
#### 页面交互:
- 阅读页面的停顿
- 随机滚动
- 视觉搜索模拟
- 自然的导航行为
### 3. 浏览器指纹随机化
- 随机视口大小
- 随机用户代理
- 随机语言设置
- 非无头模式运行
## 使用模式
### 全自动模式(高风险)
```bash
npm run install # 首先安装rebrowser-puppeteer
node src/cli.js register -s windsurf
```
适用场景:
- 测试环境
- 弱防护网站
- 已验证可用的网站
### 半自动模式(推荐)
```bash
node src/cli.js register -s windsurf --semi-auto
```
工作流程:
1. 工具生成账号数据
2. 自动打开浏览器到注册页面
3. 显示生成的数据供复制
4. 用户手动填写(最安全)
5. 工具监控进度
### 干运行模式(最安全)
```bash
node src/cli.js register -s windsurf --dry-run
```
只生成数据,不打开浏览器,完全手动注册。
## 检测测试
### 在线测试工具:
1. **rebrowser Bot Detector**
- https://bot-detector.rebrowser.net/
- 测试是否被识别为bot
2. **Are You Headless**
- https://arh.antoinevastel.com/bots/areyouheadless
- 检测headless特征
3. **CreepJS**
- https://abrahamjuliot.github.io/creepjs
- 浏览器指纹检测
4. **Browser Leaks**
- https://browserleaks.com
- 全面的泄漏检测
## 已知限制
### 仍然可能被检测的场景:
1. **行为分析**
- 过于规律的时间间隔
- 缺乏真实的页面交互
- 异常快的表单填写
2. **高级验证码**
- reCAPTCHA v3行为评分
- hCaptcha难以自动化
- 自定义验证码
3. **IP地址**
- 数据中心IP
- 频繁的注册尝试
- 地理位置异常
4. **设备指纹**
- Canvas指纹
- WebGL指纹
- Audio指纹
## 最佳实践
### 提高成功率的建议:
1. **使用住宅代理**
```javascript
// 配置代理
args: ['--proxy-server=http://your-residential-proxy:8080']
```
2. **延长操作间隔**
- 增加步骤之间的延迟
- 模拟更多的页面交互
- 随机浏览其他页面
3. **限制频率**
- 同一IP每天最多2-3次注册
- 使用不同的浏览器配置
- 轮换代理IP
4. **混合模式**
- 关键步骤手动完成
- 自动化只用于数据生成
- 遇到验证码立即转手动
## 持续改进
项目会持续关注:
- rebrowser-puppeteer 更新
- 新的反检测技术
- 社区最佳实践
- 实际测试反馈
## 参考资源
- [rebrowser-patches](https://github.com/rebrowser/rebrowser-patches)
- [Patchright](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright)
- [nodriver](https://github.com/ultrafunkamsterdam/nodriver)
- [DataDome Detection Analysis](https://datadome.co/threat-research/)
## 免责声明
本工具仅用于:
- 合法的自动化测试
- 个人账号管理
- 教育和研究目的
请遵守各网站的服务条款和适用法律。
滥用自动化工具可能导致账号封禁或法律后果。

View File

@ -0,0 +1,91 @@
/**
* Account Register Configuration
* 账号注册工具配置
*/
/**
* 默认配置
*/
const DEFAULT_CONFIG = {
// 邮箱配置
email: {
domain: 'gmail.com',
pattern: null
},
// 用户名配置
username: {
type: 'word', // word, random, numeric
minLength: 8,
maxLength: 12,
pattern: null
},
// 密码配置
password: {
strategy: 'email', // 'email' = 使用邮箱作为密码, 'random' = 随机密码
length: 12,
includeUppercase: true,
includeLowercase: true,
includeNumbers: true,
includeSpecial: true
},
// 手机号配置
phone: {
country: 'CN',
withCountryCode: false
},
// 信用卡配置
card: {
type: 'visa'
}
};
/**
* 输出格式
*/
const OUTPUT_FORMATS = {
json: {
name: 'JSON格式',
formatter: (account) => JSON.stringify(account, null, 2)
},
table: {
name: '表格格式',
formatter: (account) => {
const lines = [];
lines.push('┌─────────────┬─────────────────────────────────────────┐');
for (const [key, value] of Object.entries(account)) {
if (typeof value === 'object' && value !== null) {
lines.push(`${key.padEnd(11)}${JSON.stringify(value).padEnd(39)}`);
} else {
lines.push(`${key.padEnd(11)}${String(value).padEnd(39)}`);
}
}
lines.push('└─────────────┴─────────────────────────────────────────┘');
return lines.join('\n');
}
},
simple: {
name: '简单格式',
formatter: (account) => {
const lines = [];
for (const [key, value] of Object.entries(account)) {
if (typeof value === 'object' && value !== null) {
lines.push(`${key}: ${JSON.stringify(value)}`);
} else {
lines.push(`${key}: ${value}`);
}
}
return lines.join('\n');
}
}
};
module.exports = {
DEFAULT_CONFIG,
OUTPUT_FORMATS
};

View File

@ -0,0 +1,136 @@
/**
* Account Data Generator - 账号数据生成器
* 统一的数据生成接口
*/
const EmailGenerator = require('./generators/email-generator');
const UsernameGenerator = require('./generators/username-generator');
const PasswordGenerator = require('./generators/password-generator');
const PhoneGenerator = require('./generators/phone-generator');
const NameGenerator = require('./generators/name-generator');
const CardGenerator = require('../card-generator/generator');
class AccountDataGenerator {
constructor() {
this.emailGen = new EmailGenerator();
this.usernameGen = new UsernameGenerator();
this.passwordGen = new PasswordGenerator();
this.phoneGen = new PhoneGenerator();
this.nameGen = new NameGenerator();
this.cardGen = new CardGenerator();
}
/**
* 生成完整的账号数据
* @param {Object} options - 配置选项
* @returns {Object}
*/
generateAccount(options = {}) {
const name = this.generateName(options.name);
const email = this.generateEmail(options.email);
// 根据策略生成密码
let password;
const passwordStrategy = options.password?.strategy || 'email';
if (passwordStrategy === 'email') {
// 使用邮箱地址作为密码
password = email;
} else {
// 使用随机密码
password = this.generatePassword(options.password);
}
const account = {
firstName: name.firstName,
lastName: name.lastName,
fullName: name.fullName,
email: email,
username: this.generateUsername(options.username),
password: password,
passwordStrategy: passwordStrategy,
timestamp: new Date().toISOString()
};
// 可选字段
if (options.includePhone !== false) {
account.phone = this.generatePhone(options.phone);
}
if (options.includeCard) {
account.card = this.generateCard(options.card);
}
return account;
}
/**
* 生成邮箱
* @param {Object} options - 选项
* @returns {string}
*/
generateEmail(options = {}) {
return this.emailGen.generate(options);
}
/**
* 生成用户名
* @param {Object} options - 选项
* @returns {string}
*/
generateUsername(options = {}) {
return this.usernameGen.generate(options);
}
/**
* 生成密码
* @param {Object} options - 选项
* @returns {string}
*/
generatePassword(options = {}) {
return this.passwordGen.generate(options);
}
/**
* 生成手机号
* @param {Object} options - 选项
* @returns {string}
*/
generatePhone(options = {}) {
return this.phoneGen.generate(options);
}
/**
* 生成姓名
* @param {Object} options - 选项
* @returns {Object}
*/
generateName(options = {}) {
return this.nameGen.generateFullName(options);
}
/**
* 生成信用卡
* @param {Object} options - 选项
* @returns {Object}
*/
generateCard(options = {}) {
const type = options.type || 'visa';
return this.cardGen.generate(type);
}
/**
* 批量生成账号数据
* @param {number} count - 数量
* @param {Object} options - 选项
* @returns {Array}
*/
generateBatch(count, options = {}) {
const accounts = [];
for (let i = 0; i < count; i++) {
accounts.push(this.generateAccount(options));
}
return accounts;
}
}
module.exports = AccountDataGenerator;

View File

@ -0,0 +1,74 @@
/**
* Email Generator - 邮箱生成器
*/
const { randomInt } = require('../../../shared/utils');
class EmailGenerator {
constructor() {
this.domains = [
'qichen111.asia'
];
}
/**
* 生成邮箱地址
* @param {Object} options - 选项
* @returns {string}
*/
generate(options = {}) {
const domain = options.domain || this.getRandomDomain();
const prefix = this.generatePrefix(options.pattern);
return `${prefix}@${domain}`;
}
/**
* 生成邮箱前缀
* @param {string} pattern - 模式
* @returns {string}
*/
generatePrefix(pattern) {
if (pattern) {
// 支持模式替换,如 "user_{random}"
return pattern.replace('{random}', this.generateRandomString());
}
// 默认格式: 纯随机字符串不带user前缀
const length = randomInt(8, 12);
return this.generateRandomString(length);
}
/**
* 生成随机字符串
* @param {number} length - 长度
* @returns {string}
*/
generateRandomString(length = 8) {
return Math.random().toString(36).substring(2, 2 + length);
}
/**
* 获取随机域名
* @returns {string}
*/
getRandomDomain() {
return this.domains[randomInt(0, this.domains.length - 1)];
}
/**
* 批量生成
* @param {number} count - 数量
* @param {Object} options - 选项
* @returns {Array}
*/
generateBatch(count, options = {}) {
const emails = [];
for (let i = 0; i < count; i++) {
emails.push(this.generate(options));
}
return emails;
}
}
module.exports = EmailGenerator;

View File

@ -0,0 +1,139 @@
/**
* Name Generator - 姓名生成器
*/
const { randomInt } = require('../../../shared/utils');
class NameGenerator {
constructor() {
// 常见英文名字
this.firstNames = {
male: [
'James', 'John', 'Robert', 'Michael', 'William',
'David', 'Richard', 'Joseph', 'Thomas', 'Charles',
'Daniel', 'Matthew', 'Anthony', 'Mark', 'Donald',
'Steven', 'Paul', 'Andrew', 'Joshua', 'Kenneth'
],
female: [
'Mary', 'Patricia', 'Jennifer', 'Linda', 'Elizabeth',
'Barbara', 'Susan', 'Jessica', 'Sarah', 'Karen',
'Nancy', 'Lisa', 'Betty', 'Margaret', 'Sandra',
'Ashley', 'Kimberly', 'Emily', 'Donna', 'Michelle'
],
neutral: [
'Alex', 'Jordan', 'Taylor', 'Casey', 'Riley',
'Morgan', 'Parker', 'Avery', 'Quinn', 'Skyler'
]
};
// 常见英文姓氏
this.lastNames = [
'Smith', 'Johnson', 'Williams', 'Brown', 'Jones',
'Garcia', 'Miller', 'Davis', 'Rodriguez', 'Martinez',
'Hernandez', 'Lopez', 'Gonzalez', 'Wilson', 'Anderson',
'Thomas', 'Taylor', 'Moore', 'Jackson', 'Martin',
'Lee', 'Perez', 'Thompson', 'White', 'Harris',
'Sanchez', 'Clark', 'Ramirez', 'Lewis', 'Robinson'
];
// 中文姓名
this.chineseFirstNames = ['伟', '芳', '娜', '秀英', '敏', '静', '丽', '强', '磊', '军'];
this.chineseLastNames = ['王', '李', '张', '刘', '陈', '杨', '赵', '黄', '周', '吴'];
}
/**
* 生成名字
* @param {Object} options - 选项
* @returns {string}
*/
generateFirstName(options = {}) {
const { gender, locale } = options;
if (locale === 'zh-CN') {
return this.generateChineseFirstName();
}
// 英文名字
let pool;
if (gender === 'male') {
pool = this.firstNames.male;
} else if (gender === 'female') {
pool = this.firstNames.female;
} else {
// 随机选择性别或中性
const allNames = [
...this.firstNames.male,
...this.firstNames.female,
...this.firstNames.neutral
];
pool = allNames;
}
return pool[randomInt(0, pool.length - 1)];
}
/**
* 生成姓氏
* @param {Object} options - 选项
* @returns {string}
*/
generateLastName(options = {}) {
const { locale } = options;
if (locale === 'zh-CN') {
return this.generateChineseLastName();
}
return this.lastNames[randomInt(0, this.lastNames.length - 1)];
}
/**
* 生成完整姓名
* @param {Object} options - 选项
* @returns {Object}
*/
generateFullName(options = {}) {
const firstName = this.generateFirstName(options);
const lastName = this.generateLastName(options);
return {
firstName,
lastName,
fullName: options.locale === 'zh-CN'
? `${lastName}${firstName}`
: `${firstName} ${lastName}`
};
}
/**
* 生成中文名字
* @returns {string}
*/
generateChineseFirstName() {
return this.chineseFirstNames[randomInt(0, this.chineseFirstNames.length - 1)];
}
/**
* 生成中文姓氏
* @returns {string}
*/
generateChineseLastName() {
return this.chineseLastNames[randomInt(0, this.chineseLastNames.length - 1)];
}
/**
* 批量生成
* @param {number} count - 数量
* @param {Object} options - 选项
* @returns {Array}
*/
generateBatch(count, options = {}) {
const names = [];
for (let i = 0; i < count; i++) {
names.push(this.generateFullName(options));
}
return names;
}
}
module.exports = NameGenerator;

View File

@ -0,0 +1,145 @@
/**
* Password Generator - 密码生成器
*/
const { randomInt } = require('../../../shared/utils');
class PasswordGenerator {
constructor() {
this.lowercase = 'abcdefghijklmnopqrstuvwxyz';
this.uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
this.numbers = '0123456789';
this.special = '!@#$%^&*()_+-=[]{}|;:,.<>?';
}
/**
* 生成密码
* @param {Object} options - 选项
* @returns {string}
*/
generate(options = {}) {
const {
length = 12,
includeUppercase = true,
includeLowercase = true,
includeNumbers = true,
includeSpecial = true,
minUppercase = 1,
minLowercase = 1,
minNumbers = 1,
minSpecial = 1
} = options;
let chars = '';
let password = '';
// 构建字符集
if (includeLowercase) chars += this.lowercase;
if (includeUppercase) chars += this.uppercase;
if (includeNumbers) chars += this.numbers;
if (includeSpecial) chars += this.special;
if (chars.length === 0) {
throw new Error('At least one character type must be included');
}
// 确保满足最小要求
if (includeLowercase && minLowercase > 0) {
for (let i = 0; i < minLowercase; i++) {
password += this.lowercase.charAt(randomInt(0, this.lowercase.length - 1));
}
}
if (includeUppercase && minUppercase > 0) {
for (let i = 0; i < minUppercase; i++) {
password += this.uppercase.charAt(randomInt(0, this.uppercase.length - 1));
}
}
if (includeNumbers && minNumbers > 0) {
for (let i = 0; i < minNumbers; i++) {
password += this.numbers.charAt(randomInt(0, this.numbers.length - 1));
}
}
if (includeSpecial && minSpecial > 0) {
for (let i = 0; i < minSpecial; i++) {
password += this.special.charAt(randomInt(0, this.special.length - 1));
}
}
// 填充剩余长度
while (password.length < length) {
password += chars.charAt(randomInt(0, chars.length - 1));
}
// 打乱顺序
password = this.shuffle(password);
return password;
}
/**
* 打乱字符串
* @param {string} str - 字符串
* @returns {string}
*/
shuffle(str) {
const arr = str.split('');
for (let i = arr.length - 1; i > 0; i--) {
const j = randomInt(0, i);
[arr[i], arr[j]] = [arr[j], arr[i]];
}
return arr.join('');
}
/**
* 生成简单密码只包含字母和数字
* @param {number} length - 长度
* @returns {string}
*/
generateSimple(length = 12) {
return this.generate({
length,
includeUppercase: true,
includeLowercase: true,
includeNumbers: true,
includeSpecial: false
});
}
/**
* 生成强密码
* @param {number} length - 长度
* @returns {string}
*/
generateStrong(length = 16) {
return this.generate({
length,
includeUppercase: true,
includeLowercase: true,
includeNumbers: true,
includeSpecial: true,
minUppercase: 2,
minLowercase: 2,
minNumbers: 2,
minSpecial: 2
});
}
/**
* 批量生成
* @param {number} count - 数量
* @param {Object} options - 选项
* @returns {Array}
*/
generateBatch(count, options = {}) {
const passwords = [];
for (let i = 0; i < count; i++) {
passwords.push(this.generate(options));
}
return passwords;
}
}
module.exports = PasswordGenerator;

View File

@ -0,0 +1,147 @@
/**
* Phone Generator - 手机号生成器
*/
const { randomInt, padZero } = require('../../../shared/utils');
class PhoneGenerator {
constructor() {
this.countryFormats = {
CN: {
name: '中国',
code: '+86',
format: '1##########',
prefixes: ['13', '14', '15', '16', '17', '18', '19']
},
US: {
name: '美国',
code: '+1',
format: '(###) ###-####',
prefixes: ['201', '202', '203', '212', '213', '214', '215']
},
UK: {
name: '英国',
code: '+44',
format: '7### ######',
prefixes: ['7400', '7500', '7600', '7700', '7800', '7900']
}
};
}
/**
* 生成手机号
* @param {Object} options - 选项
* @returns {string}
*/
generate(options = {}) {
const country = options.country || 'CN';
const withCountryCode = options.withCountryCode !== false;
const config = this.countryFormats[country];
if (!config) {
throw new Error(`Unsupported country: ${country}`);
}
let phone = this.generateByCountry(country);
if (withCountryCode) {
phone = `${config.code} ${phone}`;
}
return phone;
}
/**
* 根据国家生成手机号
* @param {string} country - 国家代码
* @returns {string}
*/
generateByCountry(country) {
const config = this.countryFormats[country];
switch (country) {
case 'CN':
return this.generateChinaPhone();
case 'US':
return this.generateUSPhone();
case 'UK':
return this.generateUKPhone();
default:
return this.generateChinaPhone();
}
}
/**
* 生成中国手机号
* @returns {string}
*/
generateChinaPhone() {
const config = this.countryFormats.CN;
const prefix = config.prefixes[randomInt(0, config.prefixes.length - 1)];
const suffix = this.generateDigits(9);
return `${prefix}${suffix}`;
}
/**
* 生成美国手机号
* @returns {string}
*/
generateUSPhone() {
const config = this.countryFormats.US;
const areaCode = config.prefixes[randomInt(0, config.prefixes.length - 1)];
const exchange = this.generateDigits(3);
const number = this.generateDigits(4);
return `(${areaCode}) ${exchange}-${number}`;
}
/**
* 生成英国手机号
* @returns {string}
*/
generateUKPhone() {
const config = this.countryFormats.UK;
const prefix = config.prefixes[randomInt(0, config.prefixes.length - 1)];
const suffix = this.generateDigits(6);
return `${prefix} ${suffix}`;
}
/**
* 生成指定长度的数字
* @param {number} length - 长度
* @returns {string}
*/
generateDigits(length) {
let result = '';
for (let i = 0; i < length; i++) {
result += randomInt(0, 9);
}
return result;
}
/**
* 获取支持的国家列表
* @returns {Array}
*/
getSupportedCountries() {
return Object.keys(this.countryFormats).map(code => ({
code,
name: this.countryFormats[code].name
}));
}
/**
* 批量生成
* @param {number} count - 数量
* @param {Object} options - 选项
* @returns {Array}
*/
generateBatch(count, options = {}) {
const phones = [];
for (let i = 0; i < count; i++) {
phones.push(this.generate(options));
}
return phones;
}
}
module.exports = PhoneGenerator;

View File

@ -0,0 +1,118 @@
/**
* Username Generator - 用户名生成器
*/
const { randomInt } = require('../../../shared/utils');
class UsernameGenerator {
constructor() {
this.adjectives = [
'quick', 'bright', 'swift', 'clever', 'smart',
'cool', 'happy', 'lucky', 'brave', 'wise',
'silent', 'dark', 'golden', 'silver', 'mystic'
];
this.nouns = [
'wolf', 'fox', 'eagle', 'tiger', 'dragon',
'phoenix', 'lion', 'bear', 'falcon', 'hawk',
'ninja', 'wizard', 'warrior', 'knight', 'hunter'
];
}
/**
* 生成用户名
* @param {Object} options - 选项
* @returns {string}
*/
generate(options = {}) {
const { pattern, minLength, maxLength } = options;
if (pattern) {
return this.generateFromPattern(pattern);
}
// 默认生成策略
const type = options.type || 'random';
switch (type) {
case 'word':
return this.generateWordBased();
case 'random':
return this.generateRandom(minLength, maxLength);
case 'numeric':
return this.generateNumeric();
default:
return this.generateWordBased();
}
}
/**
* 基于模式生成
* @param {string} pattern - 模式 "user_{random}", "player_{number}"
* @returns {string}
*/
generateFromPattern(pattern) {
return pattern
.replace('{random}', Math.random().toString(36).substring(2, 10))
.replace('{number}', randomInt(1000, 9999).toString())
.replace('{timestamp}', Date.now().toString().slice(-8));
}
/**
* 生成基于单词的用户名
* @returns {string}
*/
generateWordBased() {
const adj = this.adjectives[randomInt(0, this.adjectives.length - 1)];
const noun = this.nouns[randomInt(0, this.nouns.length - 1)];
const number = randomInt(10, 999);
return `${adj}${noun}${number}`;
}
/**
* 生成随机字符串用户名
* @param {number} minLength - 最小长度
* @param {number} maxLength - 最大长度
* @returns {string}
*/
generateRandom(minLength = 8, maxLength = 12) {
const length = randomInt(minLength, maxLength);
let username = '';
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
// 首字母必须是字母
username += chars.charAt(randomInt(0, 25));
// 其余字符
for (let i = 1; i < length; i++) {
username += chars.charAt(randomInt(0, chars.length - 1));
}
return username;
}
/**
* 生成数字用户名
* @returns {string}
*/
generateNumeric() {
return `user${randomInt(100000, 999999)}`;
}
/**
* 批量生成
* @param {number} count - 数量
* @param {Object} options - 选项
* @returns {Array}
*/
generateBatch(count, options = {}) {
const usernames = [];
for (let i = 0; i < count; i++) {
usernames.push(this.generate(options));
}
return usernames;
}
}
module.exports = UsernameGenerator;

View File

@ -0,0 +1,171 @@
/**
* Account Register Tool - 账号注册工具入口
*/
const fs = require('fs');
const path = require('path');
const AccountDataGenerator = require('./generator');
const logger = require('../../shared/logger');
const { OUTPUT_FORMATS } = require('./config');
const TOOL_NAME = 'account-register';
class AccountRegister {
constructor() {
this.sites = new Map();
this.dataGen = new AccountDataGenerator();
this.loadSites();
}
/**
* 加载所有网站脚本
*/
loadSites() {
const sitesDir = path.join(__dirname, 'sites');
try {
const files = fs.readdirSync(sitesDir);
files.forEach(file => {
if (file.endsWith('.js')) {
const siteName = file.replace('.js', '');
try {
const SiteClass = require(path.join(sitesDir, file));
this.sites.set(siteName, SiteClass);
logger.debug(TOOL_NAME, `Loaded site: ${siteName}`);
} catch (error) {
logger.warn(TOOL_NAME, `Failed to load site ${siteName}: ${error.message}`);
}
}
});
} catch (error) {
logger.warn(TOOL_NAME, `Failed to load sites: ${error.message}`);
}
}
/**
* 执行注册
*/
async execute(options) {
const { site, dryRun, format } = options;
try {
if (!site) {
logger.error(TOOL_NAME, '请指定网站名称');
this.listSites();
process.exit(1);
}
const SiteClass = this.sites.get(site);
if (!SiteClass) {
logger.error(TOOL_NAME, `未知的网站: ${site}`);
this.listSites();
process.exit(1);
}
const siteInstance = new SiteClass();
if (dryRun) {
// 干运行模式:只生成数据
logger.info(TOOL_NAME, '干运行模式:只生成账号数据');
const account = siteInstance.generateData(options);
const formatter = OUTPUT_FORMATS[format || 'simple'];
console.log('\n' + formatter.formatter(account) + '\n');
logger.success(TOOL_NAME, '账号数据生成完成');
} else {
// 真正执行注册
logger.info(TOOL_NAME, `开始注册 ${site} 账号...`);
const result = await siteInstance.register(options);
if (result.success) {
logger.success(TOOL_NAME, '注册流程完成');
if (options.output) {
// 保存到文件
fs.writeFileSync(
options.output,
JSON.stringify(result.account, null, 2)
);
logger.success(TOOL_NAME, `账号数据已保存到: ${options.output}`);
}
}
}
} catch (error) {
logger.error(TOOL_NAME, error.message);
process.exit(1);
}
}
/**
* 只生成数据不执行注册
*/
generate(options) {
logger.info(TOOL_NAME, '生成账号数据...');
const account = this.dataGen.generateAccount({
name: options.name,
email: options.email,
username: options.username,
password: options.password,
phone: options.phone,
includeCard: options.includeCard
});
const formatter = OUTPUT_FORMATS[options.format || 'simple'];
console.log('\n' + formatter.formatter(account) + '\n');
}
/**
* 列出支持的网站
*/
listSites() {
const sites = Array.from(this.sites.keys());
if (sites.length === 0) {
console.log('\n暂无可用网站\n');
return;
}
console.log('\n支持的网站:\n');
sites.forEach(site => {
console.log(` ${site}`);
});
console.log('');
}
/**
* 列出支持的格式
*/
listFormats() {
console.log('\n支持的输出格式:\n');
for (const [key, config] of Object.entries(OUTPUT_FORMATS)) {
console.log(` ${key.padEnd(15)} - ${config.name}`);
}
console.log('');
}
}
module.exports = {
name: TOOL_NAME,
alias: 'register',
description: '自动注册账号',
execute: async (options) => {
const tool = new AccountRegister();
await tool.execute(options);
},
listSites: () => {
const tool = new AccountRegister();
tool.listSites();
},
listFormats: () => {
const tool = new AccountRegister();
tool.listFormats();
},
generate: (options) => {
const tool = new AccountRegister();
tool.generate(options);
}
};

View File

@ -0,0 +1,378 @@
/**
* Windsurf Register - Windsurf网站注册
* https://windsurf.com/account/register
*
* 注册流程
* Step 1: 填写基本信息First Name, Last Name, Email
* Step 2: 设置密码
* Step 3: 邮箱验证
* Step 4: 完善个人信息
* ... 根据实际情况继续添加步骤
*/
const AccountDataGenerator = require('../generator');
const HumanBehavior = require('../utils/human-behavior');
const logger = require('../../../shared/logger');
class WindsurfRegister {
constructor() {
this.siteName = 'Windsurf';
this.siteUrl = 'https://windsurf.com/account/register';
this.dataGen = new AccountDataGenerator();
this.human = new HumanBehavior();
this.browser = null;
this.page = null;
this.currentStep = 0;
this.accountData = null;
// 定义所有步骤
this.steps = [
{ id: 1, name: '填写基本信息', method: 'step1_fillBasicInfo' },
{ id: 2, name: '设置密码', method: 'step2_setPassword' },
{ id: 3, name: '邮箱验证', method: 'step3_emailVerification' },
// 根据实际注册流程继续添加
];
}
/**
* 获取步骤总数
*/
getTotalSteps() {
return this.steps.length;
}
/**
* 获取当前步骤信息
*/
getCurrentStepInfo() {
if (this.currentStep === 0) {
return { id: 0, name: '未开始', total: this.getTotalSteps() };
}
const step = this.steps[this.currentStep - 1];
return {
...step,
current: this.currentStep,
total: this.getTotalSteps()
};
}
/**
* 生成账号数据干运行模式
*/
generateData(options = {}) {
logger.info(this.siteName, '生成账号数据...');
const account = this.dataGen.generateAccount({
name: options.name,
email: options.email,
username: options.username,
password: options.password,
includePhone: false // Windsurf第一步不需要手机号
});
return account;
}
/**
* 初始化浏览器使用rebrowser-puppeteer自带反检测
*/
async initBrowser() {
// rebrowser-puppeteer 已经打好补丁,无需额外配置
const puppeteer = require('puppeteer');
logger.info(this.siteName, '启动浏览器(反检测模式)...');
// 随机视口大小(模拟不同设备)
const viewports = [
{ width: 1920, height: 1080 },
{ width: 1366, height: 768 },
{ width: 1536, height: 864 },
{ width: 1440, height: 900 }
];
const viewport = viewports[Math.floor(Math.random() * viewports.length)];
this.browser = await puppeteer.launch({
headless: false, // 非无头模式更难被检测
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-blink-features=AutomationControlled',
'--disable-dev-shm-usage',
`--window-size=${viewport.width},${viewport.height}`
],
ignoreDefaultArgs: ['--enable-automation']
});
this.page = await this.browser.newPage();
// 设置随机视口
await this.page.setViewport(viewport);
// 随机用户代理
const userAgents = [
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36'
];
await this.page.setUserAgent(
userAgents[Math.floor(Math.random() * userAgents.length)]
);
// 设置语言和时区
await this.page.setExtraHTTPHeaders({
'Accept-Language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7'
});
logger.success(this.siteName, `浏览器启动成功 (${viewport.width}x${viewport.height})`);
}
/**
* 关闭浏览器
*/
async closeBrowser() {
if (this.browser) {
await this.browser.close();
logger.info(this.siteName, '浏览器已关闭');
}
}
/**
* 步骤1: 填写基本信息First Name, Last Name, Email- 使用人类行为
*/
async step1_fillBasicInfo() {
logger.info(this.siteName, `[步骤 1/${this.getTotalSteps()}] 填写基本信息`);
// 打开注册页面
logger.info(this.siteName, `打开注册页面: ${this.siteUrl}`);
await this.page.goto(this.siteUrl, {
waitUntil: 'networkidle2',
timeout: 30000
});
// 模拟阅读页面1-3秒
await this.human.readPage(1, 3);
// 填写First Name使用人类行为
logger.info(this.siteName, ' → 填写First Name...');
await this.page.waitForSelector('#firstName', { timeout: 10000 });
await this.human.humanType(this.page, '#firstName', this.accountData.firstName);
// 填写Last Name
logger.info(this.siteName, ' → 填写Last Name...');
await this.page.waitForSelector('#lastName', { timeout: 10000 });
await this.human.humanType(this.page, '#lastName', this.accountData.lastName);
// 填写Email
logger.info(this.siteName, ' → 填写Email...');
await this.page.waitForSelector('#email', { timeout: 10000 });
await this.human.humanType(this.page, '#email', this.accountData.email);
// 勾选同意条款(如果有)
try {
const checkbox = await this.page.$('input[type="checkbox"]');
if (checkbox) {
logger.info(this.siteName, ' → 勾选同意条款...');
await this.human.humanCheckbox(this.page, 'input[type="checkbox"]');
}
} catch (error) {
logger.warn(this.siteName, ' → 未找到同意条款checkbox跳过');
}
// 点击Continue按钮使用人类行为
logger.info(this.siteName, ' → 点击Continue按钮...');
// 尝试查找按钮
let buttonSelector = null;
const possibleSelectors = [
'button:has-text("Continue")',
'button[type="submit"]',
'button.continue-button',
'button[class*="continue"]'
];
for (const selector of possibleSelectors) {
try {
const button = await this.page.$(selector);
if (button) {
buttonSelector = selector;
break;
}
} catch (e) {
// 继续尝试下一个
}
}
if (buttonSelector) {
await this.human.visualSearch(this.page, buttonSelector);
await this.human.humanClick(this.page, buttonSelector);
} else {
logger.warn(this.siteName, ' → 未找到Continue按钮尝试按Enter键');
await this.human.randomDelay(500, 1000);
await this.page.keyboard.press('Enter');
}
// 等待跳转或响应
await this.human.randomDelay(2000, 4000);
this.currentStep = 1;
logger.success(this.siteName, `步骤 1 完成`);
}
/**
* 步骤2: 设置密码
*/
async step2_setPassword() {
logger.info(this.siteName, `[步骤 2/${this.getTotalSteps()}] 设置密码`);
// 等待密码页面加载
await this.human.readPage(1, 2);
// 填写密码
logger.info(this.siteName, ' → 填写密码...');
await this.page.waitForSelector('#password', { timeout: 10000 });
await this.human.humanType(this.page, '#password', this.accountData.password);
// 填写确认密码
logger.info(this.siteName, ' → 填写确认密码...');
await this.page.waitForSelector('#passwordConfirmation', { timeout: 10000 });
await this.human.humanType(this.page, '#passwordConfirmation', this.accountData.password);
// 查找并点击Continue按钮
logger.info(this.siteName, ' → 点击Continue按钮...');
const possibleSelectors = [
'button:has-text("Continue")',
'button[type="submit"]',
'button.continue-button',
'button[class*="continue"]'
];
let buttonSelector = null;
for (const selector of possibleSelectors) {
try {
const button = await this.page.$(selector);
if (button) {
buttonSelector = selector;
break;
}
} catch (e) {
// 继续尝试
}
}
if (buttonSelector) {
await this.human.visualSearch(this.page, buttonSelector);
await this.human.humanClick(this.page, buttonSelector);
} else {
logger.warn(this.siteName, ' → 未找到Continue按钮尝试按Enter键');
await this.human.randomDelay(500, 1000);
await this.page.keyboard.press('Enter');
}
// 等待跳转或响应
await this.human.randomDelay(2000, 4000);
this.currentStep = 2;
logger.success(this.siteName, `步骤 2 完成`);
}
/**
* 步骤3: 邮箱验证待实现
*/
async step3_emailVerification() {
logger.info(this.siteName, `[步骤 3/${this.getTotalSteps()}] 邮箱验证`);
// 邮箱验证逻辑
// ...
this.currentStep = 3;
logger.warn(this.siteName, '步骤 3 待实现(需要邮箱验证码)');
}
/**
* 执行注册流程
* @param {Object} options - 选项
* @param {number} options.fromStep - 从第几步开始默认1
* @param {number} options.toStep - 执行到第几步默认全部
*/
async register(options = {}) {
const fromStep = options.fromStep || 1;
const toStep = options.toStep || this.getTotalSteps();
try {
// 1. 生成数据
this.accountData = this.generateData(options);
logger.success(this.siteName, '账号数据生成完成');
logger.info(this.siteName, `First Name: ${this.accountData.firstName}`);
logger.info(this.siteName, `Last Name: ${this.accountData.lastName}`);
logger.info(this.siteName, `Email: ${this.accountData.email}`);
logger.info(this.siteName, `Password: ${this.accountData.password}`);
// 2. 初始化浏览器
await this.initBrowser();
// 3. 执行指定范围的步骤
logger.info(this.siteName, `\n开始执行步骤 ${fromStep}${toStep} (共 ${this.getTotalSteps()} 步)\n`);
for (let i = fromStep; i <= toStep && i <= this.getTotalSteps(); i++) {
const step = this.steps[i - 1];
if (typeof this[step.method] === 'function') {
try {
await this[step.method]();
} catch (error) {
logger.error(this.siteName, `步骤 ${i} 执行失败: ${error.message}`);
throw error;
}
} else {
logger.warn(this.siteName, `步骤 ${i} (${step.name}) 未实现`);
break;
}
}
const stepInfo = this.getCurrentStepInfo();
logger.success(this.siteName, `\n已完成步骤 ${fromStep}${this.currentStep}`);
if (this.currentStep < this.getTotalSteps()) {
logger.info(this.siteName, `剩余步骤需要手动完成或等待后续开发`);
}
// 不自动关闭浏览器,让用户查看结果
if (!options.keepBrowserOpen) {
logger.info(this.siteName, '10秒后关闭浏览器...');
await this.page.waitForTimeout(10000);
await this.closeBrowser();
} else {
logger.info(this.siteName, '浏览器保持打开状态');
}
return {
success: true,
account: this.accountData,
completedSteps: this.currentStep,
totalSteps: this.getTotalSteps(),
message: `完成 ${this.currentStep}/${this.getTotalSteps()}`
};
} catch (error) {
logger.error(this.siteName, `注册失败: ${error.message}`);
// 截图保存错误状态
if (this.page) {
try {
const screenshotPath = `/tmp/windsurf-error-${Date.now()}.png`;
await this.page.screenshot({ path: screenshotPath });
logger.info(this.siteName, `错误截图已保存: ${screenshotPath}`);
} catch (e) {
// 忽略截图错误
}
}
await this.closeBrowser();
throw error;
}
}
}
module.exports = WindsurfRegister;

View File

@ -0,0 +1,214 @@
/**
* Human Behavior - 模拟人类行为
* 用于使自动化操作更像真实用户
*/
const { randomInt } = require('../../../shared/utils');
class HumanBehavior {
/**
* 人类般的输入
* @param {Page} page - Puppeteer page对象
* @param {string} selector - 选择器
* @param {string} text - 要输入的文本
*/
async humanType(page, selector, text) {
await page.waitForSelector(selector);
// 点击输入框
await this.humanClick(page, selector);
// 随机延迟后开始输入
await this.randomDelay(300, 800);
// 清空现有内容(如果有)
await page.evaluate((sel) => {
const element = document.querySelector(sel);
if (element) element.value = '';
}, selector);
// 逐字输入,随机延迟
for (let i = 0; i < text.length; i++) {
const char = text[i];
// 每个字符的输入延迟
const delay = this.randomInt(80, 180);
await page.type(selector, char, { delay });
// 偶尔停顿(模拟思考或查看)
if (Math.random() < 0.15) {
await this.randomDelay(300, 900);
}
// 偶尔有短暂的快速输入(模拟熟悉的词语)
if (Math.random() < 0.1 && i < text.length - 3) {
i += 2; // 跳过几个字符,快速输入
}
}
// 输入完成后的短暂停顿
await this.randomDelay(200, 500);
}
/**
* 人类般的点击
* @param {Page} page - Puppeteer page对象
* @param {string} selector - 选择器
*/
async humanClick(page, selector) {
const element = await page.$(selector);
if (!element) {
throw new Error(`Element not found: ${selector}`);
}
const box = await element.boundingBox();
if (!box) {
// 如果元素不可见,直接点击
await element.click();
return;
}
// 计算随机点击位置(在元素范围内)
const x = box.x + box.width / 2 + this.randomInt(-box.width * 0.3, box.width * 0.3);
const y = box.y + box.height / 2 + this.randomInt(-box.height * 0.3, box.height * 0.3);
// 先移动鼠标到附近(不是直接到目标)
const steps = this.randomInt(10, 20);
await page.mouse.move(
x + this.randomInt(-50, 50),
y + this.randomInt(-50, 50),
{ steps: Math.floor(steps / 2) }
);
await this.randomDelay(50, 150);
// 移动到目标位置
await page.mouse.move(x, y, { steps: Math.floor(steps / 2) });
// 短暂停顿
await this.randomDelay(50, 200);
// 点击(按下和释放之间有随机延迟)
await page.mouse.down();
await this.randomDelay(50, 120);
await page.mouse.up();
// 点击后短暂停顿
await this.randomDelay(100, 300);
}
/**
* 随机延迟
* @param {number} min - 最小毫秒
* @param {number} max - 最大毫秒
*/
async randomDelay(min, max) {
const delay = this.randomInt(min, max);
await new Promise(resolve => setTimeout(resolve, delay));
}
/**
* 随机整数
* @param {number} min - 最小值
* @param {number} max - 最大值
* @returns {number}
*/
randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
/**
* 人类般的滚动
* @param {Page} page - Puppeteer page对象
* @param {string} direction - 方向 'down' 'up'
*/
async humanScroll(page, direction = 'down') {
const distance = this.randomInt(100, 300);
const steps = this.randomInt(3, 8);
for (let i = 0; i < steps; i++) {
await page.evaluate((dir, dist) => {
window.scrollBy(0, dir === 'down' ? dist : -dist);
}, direction, distance / steps);
await this.randomDelay(100, 300);
}
}
/**
* 模拟鼠标随机移动增加真实性
* @param {Page} page - Puppeteer page对象
*/
async randomMouseMovement(page) {
const viewport = await page.viewport();
const x = this.randomInt(100, viewport.width - 100);
const y = this.randomInt(100, viewport.height - 100);
await page.mouse.move(x, y, { steps: this.randomInt(10, 30) });
}
/**
* 模拟阅读页面随机停顿
* @param {number} minSeconds - 最小秒数
* @param {number} maxSeconds - 最大秒数
*/
async readPage(minSeconds = 2, maxSeconds = 5) {
const seconds = this.randomInt(minSeconds, maxSeconds);
await this.randomDelay(seconds * 1000, (seconds + 1) * 1000);
}
/**
* 检查并勾选checkbox人类方式
* @param {Page} page - Puppeteer page对象
* @param {string} selector - 选择器
*/
async humanCheckbox(page, selector) {
await page.waitForSelector(selector);
// 移动到checkbox附近
const element = await page.$(selector);
const box = await element.boundingBox();
if (box) {
await page.mouse.move(
box.x + box.width / 2,
box.y + box.height / 2,
{ steps: this.randomInt(5, 15) }
);
await this.randomDelay(200, 500);
}
// 点击
await element.click();
await this.randomDelay(300, 700);
}
/**
* 模拟查找元素视觉搜索行为
* @param {Page} page - Puppeteer page对象
* @param {string} selector - 目标元素选择器
*/
async visualSearch(page, selector) {
// 先随机移动几次鼠标(模拟眼睛在找)
for (let i = 0; i < this.randomInt(2, 4); i++) {
await this.randomMouseMovement(page);
await this.randomDelay(300, 800);
}
// 找到目标元素
await page.waitForSelector(selector);
// 移动到目标
const element = await page.$(selector);
const box = await element.boundingBox();
if (box) {
await page.mouse.move(
box.x + box.width / 2,
box.y + box.height / 2,
{ steps: this.randomInt(15, 25) }
);
}
}
}
module.exports = HumanBehavior;

View File

@ -1,48 +0,0 @@
/**
* 验证生成的卡号是否符合规律
*/
const CardGenerator = require('./src/tools/card-generator/generator');
const Formatter = require('./src/tools/card-generator/formatter');
const { luhnCheck } = require('./src/shared/utils');
const generator = new CardGenerator();
const formatter = new Formatter();
console.log('=== 生成卡号验证 ===\n');
// 生成10张银联卡
console.log('生成10张银联卡进行验证:\n');
const cards = generator.generateBatch(10, 'unionpay');
cards.forEach((card, index) => {
const isValid = luhnCheck(card.number);
const status = isValid ? '✓' : '✗';
const formatted = formatter.format(card, 'pipe');
console.log(`${index + 1}. ${formatted} ${status}`);
});
console.log('\n=== 验证结果 ===');
const validCount = cards.filter(card => luhnCheck(card.number)).length;
console.log(`Luhn校验: ${validCount}/${cards.length} 通过`);
if (validCount === cards.length) {
console.log('✓ 所有卡号都通过Luhn校验符合规律');
console.log('\n=== 提供测试卡号 ===');
const testCard = cards[0];
console.log('\n请使用以下卡号进行测试');
console.log(`\n${formatter.format(testCard, 'pipe')}\n`);
console.log('详细信息:');
console.log(formatter.format(testCard, 'pretty'));
} else {
console.log('✗ 部分卡号未通过校验,需要修复');
}
// 对比格式
console.log('\n=== 格式对比 ===');
console.log('原始样本格式:');
console.log(' 6228367546781457|11|27|792');
console.log('\n生成的卡号格式:');
console.log(` ${formatter.format(cards[0], 'pipe')}`);
console.log('\n格式一致性: ✓');