View react-cache.ts
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
import objectHash from "object-hash"; | |
const cacheTimeout = 60 * 60 * 1000 | |
let store: Record<string, unknown> = {}; | |
export function cache<A extends unknown[], B = unknown>( | |
fn: (...args: A) => Promise<B>, | |
key?: string // optional key for guaranteed uniqueness | |
) { |
View audit-file-filtering.js
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
const formidable = require("formidable"); | |
const path = require("path"); | |
const smallest = 100; | |
const largest = 10 * 1000 * 1000; | |
const bannedExtensions = [".js", ".html", ".txt", ".exe", ".rtf", ".vbs", ".zip"]; | |
const bannedMimeTypes = [ | |
"text/plain", | |
"text/html", | |
"text/css", |
View file-scan-api.js
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
const nvt = require('node-virustotal'); // read more https://www.npmjs.com/package/node-virustotal | |
const fs = require('fs'); | |
const crypto = require("crypto"); | |
app.post('/upload', async (req, res) => { | |
const randomId = crypto.randomBytes(16).toString("hex"); | |
const filePath = __dirname + "/uploads/" + randomId; | |
const writeStream = fs.createWriteStream(filePath); | |
writeStream.on('finish', () => { | |
try { |
View scan-request-directly.js
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
const fs = require('fs'); | |
const NodeClam = require('clamscan'); | |
// specify socket or TCP connection. read more at https://www.npmjs.com/package/clamscan#scanStream | |
const clamscan = new NodeClam().init({ | |
clamdscan: { | |
socket: '/var/run/clamd.scan/clamd.sock', | |
host: '127.0.0.1', | |
port: 3310, |
View convert-upload-to-file.js
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
const fs = require('fs'); | |
const crypto = require("crypto"); | |
app.post('/upload', async (req, res) => { | |
const randomId = crypto.randomBytes(16).toString("hex"); | |
const filePath = __dirname + "/uploads/" + randomId; | |
const writeStream = fs.createWriteStream(filePath); | |
writeStream.on('finish', () => { | |
const { is_infected, viruses } = await scanFile(filePath); | |
if (!is_infected) { |
View script.html
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
<script> | |
alert("I am a malicious file"); | |
</script> |
View eicar.txt
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
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H* |
View csrf.html
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
<html> | |
<body> | |
<button onclick="aml()">test aml</button> | |
<button onclick="eurazeo()">test eurazio</button> | |
<script> | |
history.pushState("", "", "/"); | |
</script> | |
<script> | |
function submitRequest(url) { | |
var xhr = new XMLHttpRequest(); |
View server-virus-scanning.js
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
const NodeClam = require('clamscan'); | |
module.exports = async function scanFile(filePath) { | |
console.log(`Attempting virus scan for ${filePath}`); | |
const clamscan = await new NodeClam().init({ | |
remove_infected: true, | |
debug_mode: false, | |
scan_recursively: false, |
NewerOlder