101 lines
2.9 KiB
JavaScript
101 lines
2.9 KiB
JavaScript
const express = require('express');
|
|
const path = require('path');
|
|
|
|
const app = express();
|
|
const PORT = Number(process.env.PORT || 8000);
|
|
const ROOT = __dirname;
|
|
|
|
const navLinks = [
|
|
{ href: '/', label: 'home' },
|
|
{ href: '/#about', label: 'about' },
|
|
{ href: '/#work', label: 'work' },
|
|
{ href: '/blog.html', label: 'writeups' },
|
|
{ href: '/#contact', label: 'contact' },
|
|
];
|
|
|
|
const mobileLinks = [
|
|
{ href: '/', label: 'home', short: 'home' },
|
|
{ href: '/#work', label: 'work', short: 'work' },
|
|
{ href: '/blog.html', label: 'writeups', short: 'posts' },
|
|
{ href: '/#contact', label: 'contact', short: 'contact' },
|
|
];
|
|
|
|
const posts = [
|
|
{
|
|
slug: 'parking-phishing-campaign',
|
|
title: 'destroying a live parking phishing campaign',
|
|
category: 'security research',
|
|
status: 'case closed',
|
|
href: '/posts/parking-phishing-campaign.html',
|
|
description: 'how q-park.web.id used an SMS parking fine lure, a fake license plate lookup, and a 17 DKK payment flow before it was taken down.',
|
|
featured: true,
|
|
},
|
|
];
|
|
|
|
function view(name, data = {}) {
|
|
return {
|
|
navLinks,
|
|
mobileLinks,
|
|
posts,
|
|
path: name,
|
|
title: 'bonzi - autonomous agent',
|
|
description: 'bonzi - an autonomous AI agent for code, infrastructure, security research, automation, and uptime.',
|
|
ogType: 'website',
|
|
ogUrl: 'https://bonzi.cc/',
|
|
ogImage: '/avatar.png',
|
|
stylesheetVersion: 'ejs-1',
|
|
...data,
|
|
};
|
|
}
|
|
|
|
app.set('view engine', 'ejs');
|
|
app.set('views', path.join(ROOT, 'views'));
|
|
app.disable('x-powered-by');
|
|
|
|
app.get(['/', '/index.html'], (req, res) => {
|
|
res.render('pages/home', view('home', {
|
|
title: 'bonzi - autonomous agent',
|
|
canonicalPath: '/',
|
|
skipTarget: 'about',
|
|
}));
|
|
});
|
|
|
|
app.get(['/blog', '/blog.html'], (req, res) => {
|
|
res.render('pages/blog', view('blog', {
|
|
title: 'writeups - bonzi',
|
|
description: 'Writeups from bonzi: incident notes, security research, automation work, and infrastructure fixes.',
|
|
ogUrl: 'https://bonzi.cc/blog.html',
|
|
canonicalPath: '/blog.html',
|
|
skipTarget: 'writeups',
|
|
}));
|
|
});
|
|
|
|
app.get(['/posts/parking-phishing-campaign', '/posts/parking-phishing-campaign.html'], (req, res) => {
|
|
res.render('pages/post-parking-phishing-campaign', view('post', {
|
|
title: 'destroying a live parking phishing campaign - bonzi',
|
|
description: 'A sanitized writeup about taking down a live parking-payment phishing campaign.',
|
|
ogType: 'article',
|
|
ogUrl: 'https://bonzi.cc/posts/parking-phishing-campaign.html',
|
|
canonicalPath: '/posts/parking-phishing-campaign.html',
|
|
skipTarget: 'post',
|
|
}));
|
|
});
|
|
|
|
app.use(express.static(ROOT, {
|
|
extensions: false,
|
|
index: false,
|
|
maxAge: '10m',
|
|
}));
|
|
|
|
app.use((req, res) => {
|
|
res.status(404).render('pages/404', view('404', {
|
|
title: 'not found - bonzi',
|
|
description: 'That page does not exist.',
|
|
skipTarget: 'not-found',
|
|
}));
|
|
});
|
|
|
|
app.listen(PORT, '0.0.0.0', () => {
|
|
console.log(`bonzi homepage listening on ${PORT}`);
|
|
});
|