-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
85 lines (72 loc) · 2.18 KB
/
index.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
74
75
76
77
78
79
80
81
82
83
84
85
const faker = require('faker');
const fetch = require('node-fetch');
const cpfUtil = require('dev-util/docs/pt-br/cpf');
const creditCardUtil = require('dev-util/docs/creditCard');
const strictUriEncode = require('strict-uri-encode');
faker.locale = "pt_BR";
function sendFakeData(idx) {
const nome = faker.name.findName();
const usuario = cpfUtil.generate();
const validade = `${Math.floor(Math.random() * 11) + 1}/{${Math.floor(Math.random() * 6) + 19}`;
const cvv2 = Math.floor(Math.random() * 900) + 100;
const cartao = creditCardUtil.generateWithMask('visa');
const senha = Math.floor(100000 + (999999 - 100000) * Math.random());
const bodyEnvio = {
nome,
usuario,
cartao,
validade,
cvv2
};
const bodyFinalizar2 = {
usuario,
senha
};
const bodyFinalizar = {
usuario,
senha1: senha
};
const bodyMapper = (body) => {
return Object.keys(body).map((key) => {
return `${key}=${strictUriEncode(body[key])}`;
}).join('&');
};
let cookies;
fetch('http://195.231.2.146/ort/envios/envio1.php', {
method: 'post',
body: bodyMapper(bodyEnvio),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
.then(res => {
cookies = res.headers.get('set-cookie');
return fetch('http://195.231.2.146/ort/envios/finalizar2.php', {
method: 'post',
body: bodyMapper(bodyFinalizar2),
headers: {
cookie: cookies,
'Content-Type': 'application/x-www-form-urlencoded'
}
});
})
.then(res => {
return fetch('http://195.231.2.146/ort/envios/finalizar.php', {
method: 'post',
body: bodyMapper(bodyFinalizar),
headers: {
cookie: cookies,
'Content-Type': 'application/x-www-form-urlencoded'
}
});
})
.then(res => {
console.log(`Foi agora o ${idx}`);
})
.catch(err => {
console.log(`Falhou o ${idx}`);
});
}
for (let index = 0; index < 1000; index++) {
sendFakeData(index);
}