Skip to content

Instantly share code, notes, and snippets.

@Osb0rn3
Created December 20, 2023 16:11
Show Gist options
  • Save Osb0rn3/e3fd7bd61a69fc668d18d946f05763b9 to your computer and use it in GitHub Desktop.
Save Osb0rn3/e3fd7bd61a69fc668d18d946f05763b9 to your computer and use it in GitHub Desktop.
const express = require('express');
const fs = require('fs').promises;
const axios = require('axios');
const app = express();
const port = 3000;
app.get('/request', async (req, res) => {
const url = req.query?.url || '';
if (url.match(new RegExp('^http(s)?:\/\/[a-zA-Z0-9]+\.voorivex\.academy$'))) {
try {
const response = await axios.get(url);
if (response.data?.message == 'under-my-command') {
res.send(await fs.readFile('/flag', 'utf-8'))
}
} catch (error) {
res.status(500).json({ error: 'Error fetching data from the url' });
}
} else {
res.status(400).json({ error: 'Invalid url' });
}
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
@anorouzi
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment