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 * 开写:2016/04/12
* 更新:- * 更新:2019/09/02 (@Ch1ngg)
* 作者:蚁逅 <https://github.com/antoor> * 作者:蚁逅 <https://github.com/antoor>
*/ */
'use strict'; 'use strict';
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
const iconv = require('iconv-lite'); const iconv = require('iconv-lite');
const NodeRSA = require('node-rsa'); const NodeRSA = require('node-rsa');
const fs = require('fs'); const fs = require('fs');
const words = require('../../modules/words');
class Base { class Base {
...@@ -82,16 +84,29 @@ class Base { ...@@ -82,16 +84,29 @@ class Base {
return key; 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;
}
/** /**
* 返回参数列表 * 返回参数列表
* @return {array} [arg1, arg2, arg3..] * @return {array} [arg1, arg2, arg3..]
*/ */
argv() { argv() {
// 生成一个随机的变量名 // 生成一个随机的变量名
let random = () => `0x${ (Math.random() + Math.random()) let random;
.toString(16)
.substr(2)}`; 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 [ return [
random(), random(),
random(), random(),
...@@ -101,6 +116,7 @@ class Base { ...@@ -101,6 +116,7 @@ class Base {
random() random()
]; ];
} }
}
/** /**
* 字符串格式化处理 * 字符串格式化处理
...@@ -279,9 +295,7 @@ class Base { ...@@ -279,9 +295,7 @@ class Base {
encoding = encoding != "unknown" ? encoding = encoding != "unknown" ?
encoding : encoding :
this.__opts__['encode']; this.__opts__['encode'];
let text = antSword let text = antSword.Decodes.decode(buff, encoding);
.Decodes
.decode(buff, encoding);
return res({ return res({
'encoding': encoding || "", 'encoding': encoding || "",
'text': text, 'text': text,
...@@ -311,6 +325,7 @@ class Base { ...@@ -311,6 +325,7 @@ class Base {
chunkStepMin: (this.__opts__['otherConf'] || {})['chunk-step-byte-min'] || 2, chunkStepMin: (this.__opts__['otherConf'] || {})['chunk-step-byte-min'] || 2,
chunkStepMax: (this.__opts__['otherConf'] || {})['chunk-step-byte-max'] || 3, chunkStepMax: (this.__opts__['otherConf'] || {})['chunk-step-byte-max'] || 3,
useMultipart: (this.__opts__['otherConf'] || {})['use-multipart'] === 1, useMultipart: (this.__opts__['otherConf'] || {})['use-multipart'] === 1,
useRandomVariable: (this.__opts__['otherConf'] || {})['use-random-variable'] === 1,
timeout: parseInt((this.__opts__['otherConf'] || {})['request-timeout']), timeout: parseInt((this.__opts__['otherConf'] || {})['request-timeout']),
headers: (this.__opts__['httpConf'] || {})['headers'] || {}, headers: (this.__opts__['httpConf'] || {})['headers'] || {},
body: (this.__opts__['httpConf'] || {})['body'] || {} body: (this.__opts__['httpConf'] || {})['body'] || {}
...@@ -362,6 +377,7 @@ class Base { ...@@ -362,6 +377,7 @@ class Base {
chunkStepMin: (this.__opts__['otherConf'] || {})['chunk-step-byte-min'] || 2, chunkStepMin: (this.__opts__['otherConf'] || {})['chunk-step-byte-min'] || 2,
chunkStepMax: (this.__opts__['otherConf'] || {})['chunk-step-byte-max'] || 3, chunkStepMax: (this.__opts__['otherConf'] || {})['chunk-step-byte-max'] || 3,
useMultipart: (this.__opts__['otherConf'] || {})['use-multipart'] === 1, useMultipart: (this.__opts__['otherConf'] || {})['use-multipart'] === 1,
useRandomVariable: (this.__opts__['otherConf'] || {})['use-random-variable'] === 1,
timeout: parseInt((this.__opts__['otherConf'] || {})['request-timeout']), timeout: parseInt((this.__opts__['otherConf'] || {})['request-timeout']),
headers: (this.__opts__['httpConf'] || {})['headers'] || {}, headers: (this.__opts__['httpConf'] || {})['headers'] || {},
body: (this.__opts__['httpConf'] || {})['body'] || {} body: (this.__opts__['httpConf'] || {})['body'] || {}
......
...@@ -176,6 +176,7 @@ module.exports = { ...@@ -176,6 +176,7 @@ module.exports = {
otherConf: { otherConf: {
nohttps: 'Ignore HTTPS certificate', nohttps: 'Ignore HTTPS certificate',
usemultipart: 'Use Multipart send payload', usemultipart: 'Use Multipart send payload',
userandomvariable:'Use random English word variables',
chunk: { chunk: {
title: 'Chunked Transfer (Experimentally)', title: 'Chunked Transfer (Experimentally)',
usechunk: 'Use Chunked send payload.', usechunk: 'Use Chunked send payload.',
......
...@@ -178,6 +178,7 @@ module.exports = { ...@@ -178,6 +178,7 @@ module.exports = {
otherConf: { otherConf: {
nohttps: '忽略HTTPS证书', nohttps: '忽略HTTPS证书',
usemultipart: '使用 Multipart 发包', usemultipart: '使用 Multipart 发包',
userandomvariable: '使用随机英文单词变量',
chunk: { chunk: {
title: '分块传输(实验性功能)', title: '分块传输(实验性功能)',
usechunk: '开启分块传输发包', usechunk: '开启分块传输发包',
......
...@@ -177,6 +177,7 @@ module.exports = { ...@@ -177,6 +177,7 @@ module.exports = {
otherConf: { otherConf: {
nohttps: '忽略HTTPS證書', nohttps: '忽略HTTPS證書',
usemultipart: '使用 Multipart 發包', usemultipart: '使用 Multipart 發包',
userandomvariable: '使用隨機英文單詞變量',
chunk: { chunk: {
title: '分塊傳輸(實驗性功能)', title: '分塊傳輸(實驗性功能)',
usechunk: '開啟分塊傳輸發包', usechunk: '開啟分塊傳輸發包',
......
...@@ -177,6 +177,7 @@ module.exports = { ...@@ -177,6 +177,7 @@ module.exports = {
otherConf: { otherConf: {
nohttps: '忽略HTTPS證書', nohttps: '忽略HTTPS證書',
usemultipart: '使用 Multipart 發包', usemultipart: '使用 Multipart 發包',
userandomvariable:'使用隨機英文單詞變量',
chunk: { chunk: {
title: '分塊傳輸(實驗性功能)', title: '分塊傳輸(實驗性功能)',
usechunk: '開啟分塊傳輸發包', usechunk: '開啟分塊傳輸發包',
......
...@@ -445,6 +445,7 @@ class Form { ...@@ -445,6 +445,7 @@ class Form {
const opt = Object.assign({}, { const opt = Object.assign({}, {
'ignore-https': 0, 'ignore-https': 0,
'use-multipart': 0, 'use-multipart': 0,
'use-random-variable': 0,
'use-chunk': 0, 'use-chunk': 0,
'chunk-step-byte-min': 2, 'chunk-step-byte-min': 2,
'chunk-step-byte-max': 3, 'chunk-step-byte-max': 3,
...@@ -470,7 +471,12 @@ class Form { ...@@ -470,7 +471,12 @@ class Form {
name: 'ignore-https', name: 'ignore-https',
label: LANG['list']['otherConf']['nohttps'], label: LANG['list']['otherConf']['nohttps'],
checked: opt['ignore-https'] === 1 checked: opt['ignore-https'] === 1
}, { },{
type: "checkbox",
name: 'use-random-variable',
label: LANG['list']['otherConf']['userandomvariable'],
checked: opt['use-random-variable'] === 1
},{
type: "checkbox", type: "checkbox",
name: 'use-multipart', name: 'use-multipart',
label: LANG['list']['otherConf']['usemultipart'], 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