Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guicoelho #6

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 0 additions & 5 deletions wargame/wargame_backend/.env

This file was deleted.

23 changes: 10 additions & 13 deletions wargame/wargame_backend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,24 +322,22 @@ app.get('/vulnerabilidades/novafiltragem/:nome', (request, response) => {

app.get('/executeCat/:filename', (req, res) => {
const filename = req.params.filename;
const command = `/usr/bin/cat ${filename}`;

exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`Erro ao executar o comando: ${error.message}`);
return res.status(500).json({ success: false, message: 'Erro ao executar o comando' });
}
if (!/^[a-zA-Z0-9-_.]+$/.test(filename)) {
return res.status(400).json({ success: false, message: 'Nome de arquivo inválido' });
}

const safePath = `/caminho/seguro/para/arquivos/${filename}`;

if (stderr) {
console.error(`Erro no STDERR: ${stderr}`);
return res.status(500).json({ success: false, message: 'Erro no STDERR do comando' });
fs.readFile(safePath, 'utf8', (error, data) => {
if (error) {
console.error(`Erro ao ler o arquivo: ${error.message}`);
return res.status(500).json({ success: false, message: 'Erro ao ler o arquivo' });
}

console.log(`Comando executado com sucesso: ${stdout}`);
res.json({ success: true, output: stdout });
res.json({ success: true, output: data });
});
});


app.listen(port, () => {
console.log(`Servidor rodando em http://localhost:${port}`);
Expand All @@ -357,5 +355,4 @@ function criarHashSenha(senha, salt) {
return hashSenha;
}


// teste
16 changes: 0 additions & 16 deletions wargame/wargame_backend/node_modules/.bin/color-support

This file was deleted.

17 changes: 0 additions & 17 deletions wargame/wargame_backend/node_modules/.bin/color-support.cmd

This file was deleted.

28 changes: 0 additions & 28 deletions wargame/wargame_backend/node_modules/.bin/color-support.ps1

This file was deleted.

16 changes: 0 additions & 16 deletions wargame/wargame_backend/node_modules/.bin/mime

This file was deleted.

17 changes: 0 additions & 17 deletions wargame/wargame_backend/node_modules/.bin/mime.cmd

This file was deleted.

28 changes: 0 additions & 28 deletions wargame/wargame_backend/node_modules/.bin/mime.ps1

This file was deleted.

16 changes: 0 additions & 16 deletions wargame/wargame_backend/node_modules/.bin/mkdirp

This file was deleted.

17 changes: 0 additions & 17 deletions wargame/wargame_backend/node_modules/.bin/mkdirp.cmd

This file was deleted.

28 changes: 0 additions & 28 deletions wargame/wargame_backend/node_modules/.bin/mkdirp.ps1

This file was deleted.

16 changes: 0 additions & 16 deletions wargame/wargame_backend/node_modules/.bin/node-pre-gyp

This file was deleted.

17 changes: 0 additions & 17 deletions wargame/wargame_backend/node_modules/.bin/node-pre-gyp.cmd

This file was deleted.

28 changes: 0 additions & 28 deletions wargame/wargame_backend/node_modules/.bin/node-pre-gyp.ps1

This file was deleted.

16 changes: 0 additions & 16 deletions wargame/wargame_backend/node_modules/.bin/nopt

This file was deleted.

17 changes: 0 additions & 17 deletions wargame/wargame_backend/node_modules/.bin/nopt.cmd

This file was deleted.

28 changes: 0 additions & 28 deletions wargame/wargame_backend/node_modules/.bin/nopt.ps1

This file was deleted.

16 changes: 0 additions & 16 deletions wargame/wargame_backend/node_modules/.bin/rimraf

This file was deleted.

Loading