first commit
This commit is contained in:
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<%- include('partials/head.ejs') %>
|
||||
</head>
|
||||
<body class="body-box-menu">
|
||||
<div class="wrapper slide-bottom box-menu">
|
||||
<h2>TinyCTF Submissions</h2>
|
||||
<p>Enter a flag! Any flag!</p>
|
||||
<form action="" method="post">
|
||||
|
||||
<% if(error != ''){ %>
|
||||
<span class='form-error'> <%= error %> </span>
|
||||
<% } %>
|
||||
|
||||
<% if(good != ''){ %>
|
||||
<span class='form-good'> <%= good %> </span>
|
||||
<% } %>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Guess</label>
|
||||
<input type="text" name="guess" class="form-control">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" class="btn btn-primary" value="guess">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
THIS IS A TEST
|
||||
@@ -0,0 +1,8 @@
|
||||
<meta charset="UTF-8">
|
||||
<title><%= title %></title>
|
||||
<link rel="stylesheet" type="text/css" href="/public/css/style.css">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||
<style type="text/css">
|
||||
body{ font: 14px sans-serif; color:#000000; }
|
||||
.wrapper{ width: 350px; padding: 20px; }
|
||||
</style>
|
||||
@@ -0,0 +1,59 @@
|
||||
module.exports = {
|
||||
rundashserver: function (bindaddr, bindport, flags, teamname) {
|
||||
|
||||
const bodyParser = require('body-parser');
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const app = express();
|
||||
|
||||
app.use(bodyParser.urlencoded({
|
||||
extended: false
|
||||
}));
|
||||
|
||||
// set the view engine to ejs
|
||||
app.set('view engine', 'ejs');
|
||||
app.set('views', path.join('./services/views'));
|
||||
app.use('/public', express.static(__dirname + '/public'));
|
||||
|
||||
const addr = bindaddr;
|
||||
const port = bindport;
|
||||
|
||||
// set the app to listen on the port
|
||||
app.listen(port, () => {
|
||||
console.log(`Website running at → ${addr}:${port}`);
|
||||
});
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.render('guess',{title:'TinyCTF', error:'', good:''});
|
||||
});
|
||||
|
||||
app.post('/', (req, res) => {
|
||||
if(!req.body.guess){
|
||||
res.render('guess',{title:'TinyCTF', error:'Try harder!', good:''});
|
||||
} else {
|
||||
|
||||
var i = 0;
|
||||
var goodguess = 0;
|
||||
|
||||
do {
|
||||
if(flags[i].flag.trim() == req.body.guess.trim()){
|
||||
var towrite = "("+ teamname +") Got flag: " + flags[i].flag.trim() + " (" + Date.now() + ")";
|
||||
goodguess = 1;
|
||||
|
||||
fs.appendFileSync('correctlog.txt', towrite + '\n');
|
||||
console.log(towrite);
|
||||
}
|
||||
i++;
|
||||
} while (i < flags.length && goodguess != 1);
|
||||
|
||||
if(goodguess){
|
||||
res.render('guess',{title:'TinyCTF', error:'', good:'You got one!'});
|
||||
} else{
|
||||
res.render('guess',{title:'TinyCTF', error:'Try harder!', good:''});
|
||||
}
|
||||
//res.redirect('/');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user