-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflood.js
73 lines (59 loc) · 1.65 KB
/
flood.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const cpf = require('gerador-validador-cpf')
const faker = require('faker')
const axios = require('axios')
const emptyArray = (length) => [...new Array(length)]
const randomInteger = () => parseInt(Math.random() * 10)
const fillWithIntegers = (list) => list.map(randomInteger)
const randomIntegerString = (length) => {
return fillWithIntegers(emptyArray(length)).join('')
}
const randomPhoneNumber = () => faker.helpers.replaceSymbolWithNumber('##+#-####-####')
const totallyLegitHeaders = () => {
return {
'User-Agent': faker.internet.userAgent(),
'Content-Type': 'application/x-www-form-urlencoded'
}
}
function * totallyLegitRunData () {
yield {
usuario: faker.internet.userName().toLowerCase(),
senha: faker.internet.password(),
step: 'passo1'
}
yield {
cpf: cpf.generate(),
senha1: randomIntegerString(6),
telefone: randomPhoneNumber(),
step: 'passo2'
}
}
const postOptions = () => {
return {
baseURL: 'http://atualizar-cadastro.info',
headers: totallyLegitHeaders()
}
}
const logRequestStart = (postData) => {
console.log('Starting request...')
console.log(JSON.stringify(postData))
}
const logRequestEnd = (response) => {
console.log(`Done: ${response.status}`)
}
const requestForData = async (data) => {
logRequestStart(data)
const response = await axios.post('/Seguranca/', data, postOptions())
logRequestEnd(response)
}
const singleRun = async () => {
for (const postData of totallyLegitRunData()) {
await requestForData(postData)
}
}
(async function infiniteFlood () {
let tries = 0
while (true) {
console.log(`session number ${++tries}`)
await singleRun()
}
})()