99 lines
3.2 KiB
JavaScript
99 lines
3.2 KiB
JavaScript
/**
|
|
* 分析原始卡号规律
|
|
*/
|
|
|
|
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('⚠ 需要进一步分析规律');
|
|
}
|