-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpp.js
More file actions
131 lines (117 loc) · 3.83 KB
/
Copy pathpp.js
File metadata and controls
131 lines (117 loc) · 3.83 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
var phantomfs = require('fs');
var casper = require('casper').create();
var config = require('./config.js');
var ccArr = [];
var userData = '';
var user = {
email : '',
password : '',
firstname : '',
lastname : '',
street : '',
city : 'San Francisco',
state : 'CA',
zip : '94112',
phone : '',
cc: '',
exp: '',
cvv: ''
}
var randomUserUrl = 'https://randomuser.me/api/?nat=us';
casper.start(config.target_url, function() {
this.viewport(1920, 1080);
this.userAgent(config.useragent);
userData = this.evaluate(function(wsurl) {
return JSON.parse(__utils__.sendAJAX(wsurl, 'GET', null, false));
}, {wsurl: randomUserUrl});
var array = phantomfs.read(config.target_file).split("\n");
for(i in array) {
// console.log(array[i]);
var line = array[i].trim();
if(line.length > 0){
ccArr.push(line.split(','));
}
}
// console.log(JSON.stringify(ccArr));
var content = '';
var idx = undefined;
for(i in ccArr) {
for(j in ccArr[i]) {
if(j > 0) content = content + ',';
content = content + ccArr[i][j];
}
if(ccArr[i][3] != 'true' && idx === undefined) {
// console.log('found unused line at ' + i);
idx = i;
content = content + ',true';
}
if(ccArr[i] != undefined){
content = content + '\n';
}
}
phantomfs.write(config.target_file, content, 'w');
if(idx === undefined){
console.log('no valid lines found');
} else {
user.cc = ccArr[i][0];
user.exp = ccArr[i][2];
user.cvv = ccArr[i][1];
}
});
casper.then(function(){
user.email = userData.results[0].user.username + config.email_domain;
user.password = config.password;
user.firstname = userData.results[0].user.name.first;
user.lastname = userData.results[0].user.name.last;
user.street = userData.results[0].user.location.street;
//user.phone = (userData.results[0].user.phone.replace(/\D/g,''));
user.phone = userData.results[0].user.phone.replace('-',' ');
//test
// console.log(JSON.stringify(user));
});
casper.then(function() {
this.capture('1.png');
this.wait(1989, function then(){
this.fillSelectors('form.proceed', {
'input[name="email"]': user.email,
'input[name="password"]': user.password,
'input[name="confirmPassword"]': user.password
}, true);
});
});
casper.then(function(){
this.wait(1989, function then(){
this.capture('2.png');
this.fillSelectors('form.proceed', {
'input[name="firstName"]': user.firstname,
'input[name="lastName"]': user.lastname,
'input[name="address1"]': user.street,
'input[name="city"]': user.city,
'select[name="state"]': user.state,
'input[name="zip"]': user.zip,
'input[name="phoneNumber"]': user.phone,
'input[name="terms"]': true, //"checked"?
}, true);
});
});
casper.then(function(){
this.wait(1989, function then(){
this.capture('3.png');
this.fillSelectors('form.proceed', {
'input[name="cardNumber"]': user.cc,
'input[name="expiryDate"]': user.exp,
'input[name="csc"]': user.cvv,
'input[name="address1"]': user.street,
'input[name="city"]': user.city,
'select[name="state"]': user.state,
'input[name="zip"]': user.zip,
}, true);
});
});
casper.then(function(){
console.log(user.email);
this.wait(1989, function then(){
this.capture('4.png');
});
});
casper.run();