forked from kaakaww/vuln_node_express
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrapdb.js
60 lines (55 loc) · 1.61 KB
/
bootstrapdb.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
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('./db/vulny.db');
db.serialize(function () {
db.run('CREATE TABLE item (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name NVARCHAR(1024) NOT NULL, description TEXT)', function (err) {
if (err) {
console.error(err);
} else {
const itemTbl = db.prepare('INSERT INTO item VALUES (null, ?, ?)', function (err) {
if (err) {
console.error(err)
}
});
for (var i = 0; i < 3; i++) {
itemTbl.run('item-' + i, 'item-' + i + ' is the great item evar');
}
itemTbl.finalize(function (err) {
if (err) {
console.error(err)
} else {
db.close(function (err) {
if (err) {
console.error(err)
}
});
}
});
}
});
db.run('CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, username NVARCHAR(1024) NOT NULL, password TEXT NOT NULL)', function (err) {
if (err) {
console.error(err);
} else {
const userTbl = db.prepare('INSERT INTO user VALUES (null, ?, ?)', function (err) {
if (err) {
console.error(err)
}
});
userTbl.run('admin', 'S3cr37P@$$w0rD!');
userTbl.run('user1', 'bad_password');
userTbl.run('user2', 'worse');
userTbl.run('user3', 'fail');
userTbl.finalize(function (err) {
if (err) {
console.error(err)
} else {
db.close(function (err) {
if (err) {
console.error(err)
}
});
}
});
}
});
});