-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e53aefe
commit c5232e2
Showing
15 changed files
with
423 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"useTabs": false, | ||
"tabWidth": 4, | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
// const mark | ||
// const mark | ||
|
||
|
||
module.exports = {} | ||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
const fs = require('fs') | ||
const fs = require('fs'); | ||
module.exports = (basedir, name) => { | ||
const appDir = basedir + '/profiles/' + name; | ||
const initFile = appDir + '/init.yaml'; | ||
const templatesDir = appDir + '/templates'; | ||
const resourcesDir = templatesDir + '/resources'; | ||
|
||
//check if the directory is available | ||
if (!fs.existsSync(appDir)) { console.log("Error: Directory: `"+appDir+"` not exists"); process.exit(1); } | ||
if (!fs.existsSync(initFile)) { console.log("Error: Init file: `"+initFile+"` not exists"); process.exit(1); } | ||
if (!fs.existsSync(templatesDir)) { console.log("Error: Template directory: `"+appDir+"` not exists"); process.exit(1); } | ||
if (!fs.existsSync(resourcesDir)) { console.log("Error: Template Resources directory: `"+appDir+"` not exists"); process.exit(1); } | ||
|
||
//check if the directory is available | ||
if (!fs.existsSync(appDir)) { | ||
console.log('Error: Directory: `' + appDir + '` not exists'); | ||
process.exit(1); | ||
} | ||
if (!fs.existsSync(initFile)) { | ||
console.log('Error: Init file: `' + initFile + '` not exists'); | ||
process.exit(1); | ||
} | ||
if (!fs.existsSync(templatesDir)) { | ||
console.log('Error: Template directory: `' + appDir + '` not exists'); | ||
process.exit(1); | ||
} | ||
if (!fs.existsSync(resourcesDir)) { | ||
console.log( | ||
'Error: Template Resources directory: `' + appDir + '` not exists' | ||
); | ||
process.exit(1); | ||
} | ||
|
||
return { | ||
name, | ||
initFile, | ||
templatesDir, | ||
resourcesDir | ||
} | ||
} | ||
|
||
|
||
resourcesDir, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
const fs = require('fs') | ||
const fs = require('fs'); | ||
const yaml = require('js-yaml'); | ||
|
||
const defaultConfig = { | ||
port:3000, | ||
headers: {} | ||
} | ||
port: 3000, | ||
headers: {}, | ||
}; | ||
|
||
module.exports = (app) => { | ||
try { | ||
let config = yaml.load(fs.readFileSync(app.initFile, 'utf8')); | ||
app.logger.info('Config -> loading main config') | ||
app.logger.info('Config -> loading main config'); | ||
return config; | ||
} catch (e) { | ||
app.logger.error('Config -> loading main config failed, make sure init.yaml is exists and have correct values') | ||
app.logger.error('Config -> Falling back to default config') | ||
app.logger.error( | ||
'Config -> loading main config failed, make sure init.yaml is exists and have correct values' | ||
); | ||
app.logger.error('Config -> Falling back to default config'); | ||
return defaultConfig; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
const randomizer = require('../randomizer') | ||
|
||
const randomizer = require('../randomizer'); | ||
|
||
module.exports = (http) => { | ||
//add couple of fake cookies | ||
//list of cookies to implement | ||
//list of cookies to implement | ||
let cookie_set = { | ||
key: randomizer.faker.internet.domainWord(), | ||
value: randomizer.faker.git.commitSha() | ||
} | ||
value: randomizer.faker.git.commitSha(), | ||
}; | ||
|
||
http.use(function(req, res, next) { | ||
http.use(function (req, res, next) { | ||
//if not exists create it | ||
if(!req.cookies || !req.cookies[cookie_set.key]){ | ||
if (!req.cookies || !req.cookies[cookie_set.key]) { | ||
res.cookie(cookie_set.key, cookie_set.value, { | ||
httpOnly: true | ||
}) | ||
next() | ||
return | ||
httpOnly: true, | ||
}); | ||
next(); | ||
return; | ||
} | ||
|
||
if(req.cookies && req.cookies[cookie_set.key] != cookie_set.value){ | ||
if (req.cookies && req.cookies[cookie_set.key] != cookie_set.value) { | ||
//cookie manipulated | ||
req.session.isMalicious = true | ||
req.session.isMalicious = true; | ||
} | ||
|
||
//all good | ||
next() | ||
next(); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,31 @@ | ||
const fs = require('fs') | ||
const randomizer = require('../randomizer') | ||
const fs = require('fs'); | ||
const randomizer = require('../randomizer'); | ||
|
||
module.exports = (http) => { | ||
|
||
let files = { | ||
".env": randomizer.fakeIt(fs.readFileSync(__dirname + '/files/dotenv', {encoding: 'utf-8'})), | ||
"readme.txt": randomizer.fakeIt(fs.readFileSync(__dirname + '/files/readme.txt', {encoding: 'utf-8'})), | ||
"changelog.txt": randomizer.fakeIt(fs.readFileSync(__dirname + '/files/changelog.txt', {encoding: 'utf-8'})) | ||
'.env': randomizer.fakeIt( | ||
fs.readFileSync(__dirname + '/files/dotenv', { | ||
encoding: 'utf-8', | ||
}) | ||
), | ||
'readme.txt': randomizer.fakeIt( | ||
fs.readFileSync(__dirname + '/files/readme.txt', { | ||
encoding: 'utf-8', | ||
}) | ||
), | ||
'changelog.txt': randomizer.fakeIt( | ||
fs.readFileSync(__dirname + '/files/changelog.txt', { | ||
encoding: 'utf-8', | ||
}) | ||
), | ||
}; | ||
|
||
|
||
|
||
for (const route in files) { | ||
const content = files[route]; | ||
http.get("/"+route, (req,res) => { | ||
req.session.isMalicious = true | ||
res.set('Content-Type', 'text/plain') | ||
res.status(500).send(content) | ||
const content = files[route]; | ||
http.get('/' + route, (req, res) => { | ||
req.session.isMalicious = true; | ||
res.set('Content-Type', 'text/plain'); | ||
res.status(500).send(content); | ||
}); | ||
} | ||
|
||
|
||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
const fs = require('fs') | ||
const randomizer = require('../randomizer') | ||
const fs = require('fs'); | ||
const randomizer = require('../randomizer'); | ||
|
||
module.exports = (http) => { | ||
let robotsTxt = fs.readFileSync(__dirname + '/files/robots.txt', { | ||
encoding: 'utf-8', | ||
}); | ||
robotsTxt = randomizer.fakeIt(robotsTxt); | ||
|
||
let robotsTxt = fs.readFileSync(__dirname + '/files/robots.txt', {encoding: 'utf-8'}); | ||
robotsTxt = randomizer.fakeIt(robotsTxt) | ||
|
||
http.get('/robots.txt', (req,res) => { | ||
http.get('/robots.txt', (req, res) => { | ||
let content = robotsTxt; | ||
res.set('Content-Type', 'text/plain') | ||
res.set('Content-Type', 'text/plain'); | ||
res.send(content); | ||
}) | ||
}); | ||
|
||
http.get('/[cd]/*', (req,res) => { | ||
http.get('/[cd]/*', (req, res) => { | ||
//if accessed, this request is malicious | ||
req.session.isMalicious = true | ||
res.status(500).send("Internal Server Error") | ||
}) | ||
} | ||
req.session.isMalicious = true; | ||
res.status(500).send('Internal Server Error'); | ||
}); | ||
}; |
Oops, something went wrong.