Просмотр исходного кода

Adding Readmes and the setting up wireguard folders

Jose Rodriguez Rios 3 недель назад
Родитель
Сommit
dd8ba6f4d4

+ 12
- 1
README.md Просмотреть файл

@@ -1,3 +1,14 @@
1 1
 # NVSRCO
2 2
 
3
-Lightweight Vulnerability Scanner for Resourced-constrained Organizations 
3
+**NVSRCO** stands for **Network Vulnerability Scanner for Resource-Constrained Organizations**. This project aims to provide an affordable network security assessment tool tailored for environments with limited technical or financial resources.
4
+
5
+## Overview
6
+
7
+NVSRCO automates the discovery of network devices, scanning of ports, and identification of vulnerabilities using OpenVAS. Results are compiled into CSVs and visualized through an interactive web dashboard.
8
+
9
+## Features
10
+- OpenVAS integration for deep vulnerability assessments
11
+- Periodic scan scheduling with Python
12
+- Interactive Dash web UI for non-technical users
13
+- Docker-based OpenVAS setup for ease of deployment
14
+- Automated host discovery and port scanning

+ 125
- 0
Scanner/README.md Просмотреть файл

@@ -0,0 +1,125 @@
1
+# Network Vulnerability Scanner Automation
2
+
3
+This project provides a automated system for discovering network hosts, scanning for open ports, assessing vulnerabilities using OpenVAS (GVM), and displaying results in a web dashboard. It supports manual, Docker-based, and virtual machine deployment.
4
+
5
+---
6
+
7
+## Project Structure
8
+
9
+```
10
+project/
11
+├── Host_Discovery/
12
+│   ├── networkdiscovery.py
13
+│   ├── portscanner.py
14
+├── Vulnerability_Scanner/
15
+│   ├── createTargets.py
16
+│   ├── taskmaker.py
17
+│   ├── starttask.py
18
+│   ├── getreports.py
19
+│   ├── generate_reports.py
20
+├── WebApp/
21
+│   ├── webapp.py
22
+├── data/                # Stores active_hosts.csv, scan results, reports
23
+├── scheduler.py         # Python task scheduler
24
+├── docker-compose.yml   # For OpenVAS container
25
+├── install_docker.sh    # Setup script for Docker on Ubuntu
26
+├── setup_manual.sh      # Installs system and Python dependencies
27
+```
28
+
29
+---
30
+
31
+## Setup (Manual, Ubuntu Linux)
32
+
33
+### 1. Run the Setup Script
34
+
35
+```bash
36
+chmod +x setup_manual.sh
37
+sudo ./setup_manual.sh
38
+```
39
+
40
+### 2. Activate the Virtual Environment
41
+
42
+```bash
43
+source venv/bin/activate
44
+```
45
+
46
+---
47
+
48
+## Setup (Docker)
49
+
50
+### 1. Install Docker
51
+
52
+```bash
53
+chmod +x install_docker.sh
54
+./install_docker.sh
55
+```
56
+
57
+### 2. Start OpenVAS Container
58
+
59
+```bash
60
+cd openvas-docker
61
+sudo docker compose up -d
62
+```
63
+
64
+### 3. Check Logs
65
+
66
+```bash
67
+docker compose logs -f openvas
68
+```
69
+
70
+You should see `GVMD is running` and `Healthchecks completed with no issues`.
71
+
72
+---
73
+
74
+## Automation (Python Scheduler)
75
+
76
+### Run the Scheduler
77
+
78
+```bash
79
+sudo ./venv/bin/python scheduler.py
80
+```
81
+
82
+This does the following:
83
+
84
+- Every hour:
85
+  - Runs `networkdiscovery.py`
86
+  - Then `portscanner.py` if hosts were found
87
+- Every 11 hours:
88
+  - Runs OpenVAS scan scripts (`createTargets.py` to `generate_reports.py`)
89
+
90
+---
91
+
92
+## Web Dashboard
93
+
94
+After scans, run:
95
+
96
+```bash
97
+cd WebApp
98
+./venv/bin/python webapp.py
99
+```
100
+
101
+Then go to:
102
+
103
+```
104
+http://localhost:8050
105
+```
106
+
107
+Tabs include:
108
+
109
+- Overview (timeline, port stats, IP tracking)
110
+- Vulnerability Analysis (interactive treemap)
111
+- Port Heatmap (binary heatmap)
112
+
113
+---
114
+
115
+## Requirements
116
+
117
+- Ubuntu 22.04+ or 24.04
118
+- Python 3.8+
119
+- Docker Engine & Compose
120
+
121
+---
122
+
123
+## Author
124
+
125
+Jose Emmanuel Rodriguez Rios

+ 10
- 0
VPN/Wireguard client Docker/Dockerfile Просмотреть файл

@@ -0,0 +1,10 @@
1
+FROM ubuntu:20.04
2
+
3
+RUN apt-get update && \
4
+    apt-get install -y wireguard iproute2 iptables && \
5
+    apt-get clean
6
+
7
+COPY entrypoint.sh /entrypoint.sh
8
+RUN chmod +x /entrypoint.sh
9
+
10
+ENTRYPOINT ["/entrypoint.sh"]

+ 52
- 0
VPN/Wireguard client Docker/README.md Просмотреть файл

@@ -0,0 +1,52 @@
1
+# WireGuard VPN Client in Docker
2
+
3
+This is a side module for a broader project focused on network vulnerability scanning. It enables remote scanning by establishing a **reverse VPN tunnel** between the remote client and the central scanner.
4
+
5
+The containerized WireGuard client connects securely to the main scanner’s server, making the remote network accessible for scanning — as if the scanner were directly connected to it.
6
+
7
+---
8
+
9
+## Features
10
+
11
+- Automatically generates a WireGuard key pair (if not present)
12
+- Accepts configuration via Docker environment variables
13
+- Enables NAT and IP forwarding for reverse tunneling
14
+- Runs with `network_mode: host` to provide full LAN visibility
15
+- Lightweight and easy to deploy on Linux systems
16
+
17
+---
18
+
19
+##  Setup Instructions
20
+
21
+### 1. Configure Your `docker-compose.yml`
22
+
23
+Edit the environment section and replace placeholders with actual values:
24
+
25
+```yaml
26
+WG_ADDRESS: "10.0.0.2/24"
27
+WG_SERVER_PUBLIC_KEY: "YOUR_REAL_PUBLIC_KEY_HERE"
28
+WG_SERVER_ENDPOINT: "YOUR.SERVER.IP.HERE:51820"
29
+WG_ALLOWED_IPS: "0.0.0.0/0"
30
+WG_KEEPALIVE: "25"
31
+WG_IFACE: "enp0s3"  # Replace with your actual network interface
32
+```
33
+
34
+### 3. Build and Start the Container
35
+
36
+```bash
37
+sudo docker-compose build
38
+sudo docker-compose up -d
39
+```
40
+
41
+### 4. Check Logs
42
+
43
+```bash
44
+sudo docker logs wireguard-client
45
+```
46
+You should see:
47
+
48
+    The public key of the client
49
+
50
+    Confirmation of the wg0 interface being created
51
+
52
+    No config syntax errors

+ 23
- 0
VPN/Wireguard client Docker/docker-compose.yml Просмотреть файл

@@ -0,0 +1,23 @@
1
+version: '3.8'
2
+
3
+services:
4
+  wireguard-client:
5
+    build: .
6
+    container_name: wireguard-client
7
+    privileged: true
8
+    cap_add:
9
+      - NET_ADMIN
10
+    environment:
11
+      WG_ADDRESS: "10.0.0.2/24"
12
+      WG_SERVER_PUBLIC_KEY: "YOUR_REAL_PUBLIC_KEY_HERE"
13
+      WG_SERVER_ENDPOINT: "YOUR.SERVER.IP.HERE:51820"
14
+      WG_ALLOWED_IPS: "0.0.0.0/0"
15
+      WG_KEEPALIVE: "25"
16
+      WG_IFACE: "enp0s3"
17
+    volumes:
18
+      - wg-keys:/etc/wireguard/keys
19
+    network_mode: host
20
+    restart: unless-stopped
21
+
22
+volumes:
23
+  wg-keys:

+ 41
- 0
VPN/Wireguard client Docker/entrypoint.sh Просмотреть файл

@@ -0,0 +1,41 @@
1
+#!/bin/bash
2
+
3
+set -e
4
+
5
+echo "[*] Starting VPN Agent..."
6
+
7
+WG_CONF="/etc/wireguard/wg0.conf"
8
+WG_KEY_DIR="/etc/wireguard/keys"
9
+mkdir -p $WG_KEY_DIR
10
+
11
+# Generate keypair if not exist
12
+if [ ! -f "$WG_KEY_DIR/privatekey" ]; then
13
+    echo "[*] Generating WireGuard keypair..."
14
+    umask 077
15
+    wg genkey | tee "$WG_KEY_DIR/privatekey" | wg pubkey > "$WG_KEY_DIR/publickey"
16
+fi
17
+
18
+PRIVATE_KEY=$(cat "$WG_KEY_DIR/privatekey")
19
+
20
+cat > $WG_CONF <<EOF
21
+[Interface]
22
+PrivateKey = ${PRIVATE_KEY}
23
+Address = ${WG_ADDRESS}
24
+PostUp = iptables -t nat -A POSTROUTING -o ${WG_IFACE} -j MASQUERADE
25
+PostDown = iptables -t nat -D POSTROUTING -o ${WG_IFACE} -j MASQUERADE
26
+
27
+[Peer]
28
+PublicKey = ${WG_SERVER_PUBLIC_KEY}
29
+Endpoint = ${WG_SERVER_ENDPOINT}
30
+AllowedIPs = ${WG_ALLOWED_IPS}
31
+PersistentKeepalive = ${WG_KEEPALIVE}
32
+EOF
33
+
34
+echo "[✓] Public Key for registration:"
35
+cat "$WG_KEY_DIR/publickey"
36
+
37
+echo 1 > /proc/sys/net/ipv4/ip_forward
38
+
39
+wg-quick up wg0
40
+
41
+tail -f /dev/null

+ 68
- 0
VPN/Wireguard setup bash scripts/README-wireguard-final.md Просмотреть файл

@@ -0,0 +1,68 @@
1
+# WireGuard VPN Setup Scripts
2
+
3
+These scripts automate the installation and configuration of a WireGuard-based VPN setup for a network vulnerability scanner project. They include:
4
+
5
+- A **client setup script** to establish a reverse tunnel from a remote site
6
+- A **server setup script** for the central scanner to receive connections
7
+
8
+---
9
+
10
+## 📡 VPN Client Setup (`setup-wireguard-client.sh`)
11
+
12
+This script installs WireGuard on a remote machine, generates keys, and sets up a reverse tunnel to the scanner server using the WireGuard protocol.
13
+
14
+### 🔧 Configuration
15
+
16
+Before running, edit the following values inside the script:
17
+
18
+- `WG_ADDRESS`: IP address of the client in the VPN (e.g., `10.0.0.2/24`)
19
+- `WG_SERVER_PUBLIC_KEY`: Public key of the server
20
+- `WG_SERVER_ENDPOINT`: IP and port of the server (e.g., `192.0.2.1:51820`)
21
+- `WG_ALLOWED_IPS`: Use `0.0.0.0/0` to tunnel all traffic through the VPN
22
+- `WG_IFACE`: Network interface used for NAT (e.g., `enp0s3`)
23
+
24
+### ▶️ Usage
25
+
26
+```bash
27
+chmod +x setup-wireguard-client.sh
28
+sudo ./setup-wireguard-client.sh
29
+```
30
+
31
+---
32
+
33
+## 🛡 VPN Server Setup (`setup-wireguard-server-no-postup.sh`)
34
+
35
+This script installs WireGuard on the central scanning server, generates a keypair, and configures it to accept connections from clients.
36
+
37
+### 🔧 Configuration
38
+
39
+Before running, edit the script:
40
+
41
+- `WG_ADDRESS`: Server IP in the VPN (e.g., `10.0.0.1/32`)
42
+- `WG_LISTEN_PORT`: Port to listen on (e.g., `123`)
43
+- `WG_PEER_PUBLIC_KEY`: Public key of the client
44
+- `WG_ALLOWED_IPS`: Must include the client's tunnel IP (e.g., `10.0.0.2/32`) and any **internal subnets** the server needs to access through the client (e.g., `192.168.0.0/24`)
45
+
46
+### ▶️ Usage
47
+
48
+```bash
49
+chmod +x setup-wireguard-server-no-postup.sh
50
+sudo ./setup-wireguard-server-no-postup.sh
51
+```
52
+
53
+---
54
+
55
+## Notes
56
+
57
+- Ensure the client's real internal subnets are listed in `AllowedIPs` on the server.
58
+- You can connect multiple clients by repeating the `[Peer]` block in the server’s config.
59
+- Keys are stored under `/etc/wireguard/`. Do not expose them publicly.
60
+- You need to exchange public keys from scanner to client and vice versa to put in the conf file
61
+
62
+### 🛠 Useful Commands
63
+
64
+```bash
65
+wg show                   # Show the status of WireGuard connection
66
+sudo wg-quick down wg0    # Bring down the VPN
67
+sudo wg-quick up wg0      # Bring up the VPN
68
+```

+ 68
- 0
VPN/Wireguard setup bash scripts/README-wireguard.md Просмотреть файл

@@ -0,0 +1,68 @@
1
+# WireGuard VPN Setup Scripts
2
+
3
+These scripts automate the installation and configuration of a WireGuard-based VPN setup for a network vulnerability scanner project. They include:
4
+
5
+- A **client setup script** to establish a reverse tunnel from a remote site
6
+- A **server setup script** for the central scanner to receive connections
7
+
8
+---
9
+
10
+##  VPN Client Setup (`setup-wireguard-client.sh`)
11
+
12
+This script installs WireGuard on a remote machine, generates keys, and sets up a reverse tunnel to the scanner server using the WireGuard protocol.
13
+
14
+###  Configuration
15
+
16
+Before running, edit the following values inside the script:
17
+
18
+- `WG_ADDRESS`: IP address of the client in the VPN (e.g., `10.0.0.2/24`)
19
+- `WG_SERVER_PUBLIC_KEY`: Public key of the server
20
+- `WG_SERVER_ENDPOINT`: IP and port of the server (e.g., `192.0.2.1:51820`)
21
+- `WG_ALLOWED_IPS`: Use `0.0.0.0/0` to tunnel all traffic through the VPN
22
+- `WG_IFACE`: Network interface used for NAT (e.g., `enp0s3`)
23
+
24
+###  Usage
25
+
26
+```bash
27
+chmod +x setup-wireguard-client.sh
28
+sudo ./setup-wireguard-client.sh
29
+```
30
+
31
+---
32
+
33
+##  VPN Server Setup (`setup-wireguard-server-no-postup.sh`)
34
+
35
+This script installs WireGuard on the central scanning server, generates a keypair, and configures it to accept connections from clients.
36
+
37
+###  Configuration
38
+
39
+Before running, edit the script:
40
+
41
+- `WG_ADDRESS`: Server IP in the VPN (e.g., `10.0.0.1/32`)
42
+- `WG_LISTEN_PORT`: Port to listen on (e.g., `123`)
43
+- `WG_PEER_PUBLIC_KEY`: Public key of the client
44
+- `WG_ALLOWED_IPS`: Must include the client's tunnel IP (e.g., `10.0.0.2/32`) and any **internal subnets** the server needs to access through the client (e.g., `192.168.0.0/24`)
45
+
46
+###  Usage
47
+
48
+```bash
49
+chmod +x setup-wireguard-server-no-postup.sh
50
+sudo ./setup-wireguard-server-no-postup.sh
51
+```
52
+
53
+---
54
+
55
+## Notes
56
+
57
+- Ensure the client's real internal subnets are listed in `AllowedIPs` on the server.
58
+- You can connect multiple clients by repeating the `[Peer]` block in the server’s config.
59
+- Keys are stored under `/etc/wireguard/`. Do not expose them publicly.
60
+- You need to exchange public keys from scanner to client and vice versa to put in the conf file which in both it in /etc/wireguard/${WG_INTERFACE}.conf depending on what you put as the wg_interface.
61
+
62
+###  Useful Commands
63
+
64
+```bash
65
+sudo wg show                   # Show the status of WireGuard connection
66
+sudo wg-quick down wg0    # Bring down the VPN
67
+sudo wg-quick up wg0      # Bring up the VPN
68
+```

+ 64
- 0
VPN/Wireguard setup bash scripts/setup-wireguard-client.sh Просмотреть файл

@@ -0,0 +1,64 @@
1
+#!/bin/bash
2
+
3
+set -e
4
+
5
+# === CONFIGURATION ===
6
+WG_INTERFACE="wg0"
7
+WG_ADDRESS="10.0.0.2/24"
8
+WG_PRIVATE_KEY_PATH="/etc/wireguard/privatekey"
9
+WG_PUBLIC_KEY_PATH="/etc/wireguard/publickey"
10
+WG_CONF_PATH="/etc/wireguard/${WG_INTERFACE}.conf"
11
+WG_SERVER_PUBLIC_KEY="YOUR_REAL_PUBLIC_KEY_HERE"
12
+WG_SERVER_ENDPOINT="YOUR.SERVER.IP.HERE:51820"
13
+WG_ALLOWED_IPS="0.0.0.0/0"
14
+WG_KEEPALIVE=25
15
+WG_IFACE="enp0s3"  # Replace with your outbound interface name
16
+
17
+# === INSTALL WIREGUARD ===
18
+echo " Installing WireGuard..."
19
+sudo apt-get update
20
+sudo apt-get install -y wireguard
21
+
22
+# === GENERATE KEYS ===
23
+echo " Generating WireGuard keys..."
24
+sudo mkdir -p /etc/wireguard
25
+sudo chmod 700 /etc/wireguard
26
+
27
+if [ ! -f "$WG_PRIVATE_KEY_PATH" ]; then
28
+  umask 077
29
+  wg genkey | sudo tee "$WG_PRIVATE_KEY_PATH" | wg pubkey | sudo tee "$WG_PUBLIC_KEY_PATH"
30
+else
31
+  echo "] Private key already exists. Skipping key generation."
32
+fi
33
+
34
+PRIVATE_KEY=$(sudo cat "$WG_PRIVATE_KEY_PATH")
35
+
36
+# === WRITE CONFIG FILE ===
37
+echo " Writing WireGuard config to $WG_CONF_PATH..."
38
+sudo tee "$WG_CONF_PATH" > /dev/null <<EOF
39
+[Interface]
40
+PrivateKey = ${PRIVATE_KEY}
41
+Address = ${WG_ADDRESS}
42
+PostUp = iptables -t nat -A POSTROUTING -o ${WG_IFACE} -j MASQUERADE
43
+PostDown = iptables -t nat -D POSTROUTING -o ${WG_IFACE} -j MASQUERADE
44
+
45
+[Peer]
46
+PublicKey = ${WG_SERVER_PUBLIC_KEY}
47
+Endpoint = ${WG_SERVER_ENDPOINT}
48
+AllowedIPs = ${WG_ALLOWED_IPS}
49
+PersistentKeepalive = ${WG_KEEPALIVE}
50
+EOF
51
+
52
+sudo chmod 600 "$WG_CONF_PATH"
53
+
54
+# === ENABLE IP FORWARDING ===
55
+echo " Enabling IP forwarding..."
56
+sudo sysctl -w net.ipv4.ip_forward=1
57
+echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf > /dev/null
58
+
59
+# === START THE TUNNEL ===
60
+echo " Starting WireGuard interface ${WG_INTERFACE}..."
61
+sudo wg-quick up "${WG_INTERFACE}"
62
+
63
+echo " WireGuard VPN client is up and connected."
64
+

+ 63
- 0
VPN/Wireguard setup bash scripts/setup-wireguard-server.sh Просмотреть файл

@@ -0,0 +1,63 @@
1
+#!/bin/bash
2
+
3
+set -e
4
+
5
+# === CONFIGURATION ===
6
+WG_INTERFACE="wg0"
7
+WG_ADDRESS="10.0.0.1/32"
8
+WG_LISTEN_PORT="123"
9
+WG_PRIVATE_KEY_PATH="/etc/wireguard/privatekey"
10
+WG_PUBLIC_KEY_PATH="/etc/wireguard/publickey"
11
+WG_CONF_PATH="/etc/wireguard/${WG_INTERFACE}.conf"
12
+WG_PEER_PUBLIC_KEY="YOUR_CLIENT_PUBLIC_KEY_HERE"
13
+
14
+# IMPORTANT: Add all IP subnets that exist on the client-side LANs
15
+WG_ALLOWED_IPS="136.145.187.0/24, 10.0.0.2/32, 192.168.0.0/24"
16
+WG_KEEPALIVE=25
17
+
18
+# === INSTALL WIREGUARD ===
19
+echo " Installing WireGuard..."
20
+sudo apt-get update
21
+sudo apt-get install -y wireguard
22
+
23
+# === GENERATE SERVER KEYS ===
24
+echo "Generating WireGuard server keys..."
25
+sudo mkdir -p /etc/wireguard
26
+sudo chmod 700 /etc/wireguard
27
+
28
+if [ ! -f "$WG_PRIVATE_KEY_PATH" ]; then
29
+  umask 077
30
+  wg genkey | sudo tee "$WG_PRIVATE_KEY_PATH" | wg pubkey | sudo tee "$WG_PUBLIC_KEY_PATH"
31
+else
32
+  echo " Private key already exists. Skipping key generation."
33
+fi
34
+
35
+PRIVATE_KEY=$(sudo cat "$WG_PRIVATE_KEY_PATH")
36
+
37
+# === WRITE CONFIG ===
38
+echo " Writing server config to $WG_CONF_PATH..."
39
+sudo tee "$WG_CONF_PATH" > /dev/null <<EOF
40
+[Interface]
41
+PrivateKey = ${PRIVATE_KEY}
42
+Address = ${WG_ADDRESS}
43
+ListenPort = ${WG_LISTEN_PORT}
44
+
45
+[Peer]
46
+PublicKey = ${WG_PEER_PUBLIC_KEY}
47
+AllowedIPs = ${WG_ALLOWED_IPS}
48
+PersistentKeepalive = ${WG_KEEPALIVE}
49
+EOF
50
+
51
+sudo chmod 600 "$WG_CONF_PATH"
52
+
53
+# === ENABLE IP FORWARDING ===
54
+echo "Enabling IP forwarding..."
55
+sudo sysctl -w net.ipv4.ip_forward=1
56
+echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf > /dev/null
57
+
58
+# === START WIREGUARD SERVER ===
59
+echo "Starting WireGuard interface ${WG_INTERFACE}..."
60
+sudo wg-quick up "${WG_INTERFACE}"
61
+
62
+echo "WireGuard server is now running and listening on port ${WG_LISTEN_PORT}."
63
+echo "IMPORTANT: Make sure AllowedIPs includes all subnets from the client's local networks!"