Commit 708a64ec authored by 金枪银矛小霸王's avatar 金枪银矛小霸王 Committed by Medicean

Add English word random variable (#211)

* Add English word random variable

1、新增随机英语单词变量
2、修改 boundary 的生成方法

* Update base.js

解决从数组里取到重复数据的可能

* Update form_data.js

还是改回来吧。突然觉得没什么必要

* Update base.js

更正算法

* Update base.js
parent 1dcd2eed
This diff is collapsed.
/**
* 中国蚁剑::核心模块::基础函数库
* 开写:2016/04/12
* 更新:-
* 更新:2019/09/02 (@Ch1ngg)
* 作者:蚁逅 <https://github.com/antoor>
*/
'use strict';
......@@ -9,6 +9,8 @@
const iconv = require('iconv-lite');
const NodeRSA = require('node-rsa');
const fs = require('fs');
const words = require('../../modules/words');
class Base {
......@@ -22,7 +24,7 @@ class Base {
opts['encode'] = opts['encode'] || 'utf8';
opts['encoder'] = opts['encoder'] || 'default';
this.__opts__ = opts;
this['__encoder__'] = {
/**
* 默认编码器
......@@ -81,6 +83,16 @@ class Base {
} catch (e) {}
return key;
}
getRandomVariable(array) {
var tmp = [];
while (tmp.length < 6) {
let v = array[Math.ceil(Math.random() * array.length - 1)];
tmp.indexOf(v) === -1 && tmp.push(v);
}
return tmp;
}
/**
* 返回参数列表
......@@ -88,18 +100,22 @@ class Base {
*/
argv() {
// 生成一个随机的变量名
let random = () => `0x${ (Math.random() + Math.random())
.toString(16)
.substr(2)}`;
// 返回六个随机变量名数组
return [
random(),
random(),
random(),
random(),
random(),
random()
];
let random;
if(this.__opts__.otherConf["use-random-variable"] == 1){
//random = () => `${words.randomWords[parseInt(Math.random() * words.randomWords.length)]}`;//从word.js随机返回单词
return this.getRandomVariable(words.randomWords);
}else{
random = () => `${(Math.random() + Math.random()).toString(16).substr(2)}`; // 返回六个随机变量名数组
return [
random(),
random(),
random(),
random(),
random(),
random()
];
}
}
/**
......@@ -279,9 +295,7 @@ class Base {
encoding = encoding != "unknown" ?
encoding :
this.__opts__['encode'];
let text = antSword
.Decodes
.decode(buff, encoding);
let text = antSword.Decodes.decode(buff, encoding);
return res({
'encoding': encoding || "",
'text': text,
......@@ -311,6 +325,7 @@ class Base {
chunkStepMin: (this.__opts__['otherConf'] || {})['chunk-step-byte-min'] || 2,
chunkStepMax: (this.__opts__['otherConf'] || {})['chunk-step-byte-max'] || 3,
useMultipart: (this.__opts__['otherConf'] || {})['use-multipart'] === 1,
useRandomVariable: (this.__opts__['otherConf'] || {})['use-random-variable'] === 1,
timeout: parseInt((this.__opts__['otherConf'] || {})['request-timeout']),
headers: (this.__opts__['httpConf'] || {})['headers'] || {},
body: (this.__opts__['httpConf'] || {})['body'] || {}
......@@ -362,6 +377,7 @@ class Base {
chunkStepMin: (this.__opts__['otherConf'] || {})['chunk-step-byte-min'] || 2,
chunkStepMax: (this.__opts__['otherConf'] || {})['chunk-step-byte-max'] || 3,
useMultipart: (this.__opts__['otherConf'] || {})['use-multipart'] === 1,
useRandomVariable: (this.__opts__['otherConf'] || {})['use-random-variable'] === 1,
timeout: parseInt((this.__opts__['otherConf'] || {})['request-timeout']),
headers: (this.__opts__['httpConf'] || {})['headers'] || {},
body: (this.__opts__['httpConf'] || {})['body'] || {}
......@@ -371,4 +387,4 @@ class Base {
}
// export default Base;
module.exports = Base;
\ No newline at end of file
module.exports = Base;
......@@ -176,6 +176,7 @@ module.exports = {
otherConf: {
nohttps: 'Ignore HTTPS certificate',
usemultipart: 'Use Multipart send payload',
userandomvariable:'Use random English word variables',
chunk: {
title: 'Chunked Transfer (Experimentally)',
usechunk: 'Use Chunked send payload.',
......
......@@ -178,6 +178,7 @@ module.exports = {
otherConf: {
nohttps: '忽略HTTPS证书',
usemultipart: '使用 Multipart 发包',
userandomvariable: '使用随机英文单词变量',
chunk: {
title: '分块传输(实验性功能)',
usechunk: '开启分块传输发包',
......
......@@ -177,6 +177,7 @@ module.exports = {
otherConf: {
nohttps: '忽略HTTPS證書',
usemultipart: '使用 Multipart 發包',
userandomvariable: '使用隨機英文單詞變量',
chunk: {
title: '分塊傳輸(實驗性功能)',
usechunk: '開啟分塊傳輸發包',
......
......@@ -177,6 +177,7 @@ module.exports = {
otherConf: {
nohttps: '忽略HTTPS證書',
usemultipart: '使用 Multipart 發包',
userandomvariable:'使用隨機英文單詞變量',
chunk: {
title: '分塊傳輸(實驗性功能)',
usechunk: '開啟分塊傳輸發包',
......
......@@ -445,6 +445,7 @@ class Form {
const opt = Object.assign({}, {
'ignore-https': 0,
'use-multipart': 0,
'use-random-variable': 0,
'use-chunk': 0,
'chunk-step-byte-min': 2,
'chunk-step-byte-max': 3,
......@@ -470,7 +471,12 @@ class Form {
name: 'ignore-https',
label: LANG['list']['otherConf']['nohttps'],
checked: opt['ignore-https'] === 1
}, {
},{
type: "checkbox",
name: 'use-random-variable',
label: LANG['list']['otherConf']['userandomvariable'],
checked: opt['use-random-variable'] === 1
},{
type: "checkbox",
name: 'use-multipart',
label: LANG['list']['otherConf']['usemultipart'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment