File size: 2,389 Bytes
9579da5
 
 
 
 
 
 
 
 
 
 
 
 
b473a0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b24d62a
b473a0e
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
title: AMLD SQL Injection Demo
emoji: 💻
colorFrom: blue
colorTo: blue
sdk: docker
app_port: 8050
python_version: "3.10"
app_file: Introduction.py
fullWidth: true
pinned: true
---

# AMLD SQL Injection Demo

## Introduction

Welcome to the AMLD SQL Injection Demo by Effixis for AMLD EPFL 2024! This project showcases the risks of SQL injections in web applications, particularly when using Large Language Models (LLMs). The repository includes two demonstrations: Basic SQL Injections and LLM Safeguard.

## Features

- **Basic SQL Injections (`Basic_SQL_Injections.py`):** Demonstrates the risks of direct SQL query generation by LLMs, leading to potential SQL injections.
- **LLM Safeguard (`pages/LLM_safeguard.py`):** Illustrates an advanced setup where an LLM Safeguard is employed to detect and filter out malicious SQL queries.
- **Chinook Database Integration:** Uses the Chinook sample database, representing a digital media store.
- **Interactive Web Interface:** Built with Streamlit, offering a user-friendly interface for interacting with both demonstrations.
- **Database Reset Functionality:** Allows users to reset the database to its original state for repeated tests.

## Installation

1. Clone the repository:
    ```bash
    git clone https://github.com/effixis/shared-amld-sql-injection-demo.git
    ```

2. Navigate to the cloned directory:

    ```bash
    cd shared-amld-sql-injection-demo
    ```

3. Install the required packages:

    Activate your preferred Python environment and install the required packages using the provided `requirements.txt` file. For example, using Conda:

    ```bash
    conda create -n amld-sql-injection-demo
    conda activate amld-sql-injection-demo
    pip install -r requirements.txt
    ```

4. Create a `.env` file in the root directory and set the OpenAI API key:

    ```bash
    echo "OPENAI_API_KEY=enter_your_api_key_here" > .env
    ```

    You can find your API key on the [OpenAI dashboard](https://beta.openai.com/).

## Usage

Run the Streamlit application:

```bash
streamlit run Introduction.py
```

Follow the instructions on the web interface to interact with the application.

## Disclaimer

This demo is for educational purposes to showcase the risk of SQL injections using LLMs. It should not be used for malicious purposes. Users are responsible for any misuse of the tools and information provided.