Skip to content

c4man35/netguard

Repository files navigation

NetGuard — Network Security Testing Suite

یک ابزار حرفه‌ای برای تست امنیت سایبری سایت‌ها در شرایط شبکه‌های قدیمی و محدود

Network security testing tool for analyzing website responses to legacy network conditions, IPv6 blocking, bandwidth throttling, and VPN configurations.


🎯 Overview

NetGuard is a comprehensive network security testing suite designed to:

  • Block IPv6 traffic and analyze IPv4-only behavior
  • Throttle bandwidth to 10 KB/s or custom rates
  • Simulate VPN connectivity via WireGuard over IPv4-only tunnels
  • Generate detailed security reports with optimization recommendations
  • Test websites under realistic degraded network conditions

Perfect for:

  • Cybersecurity teams testing website resilience
  • Legacy network environment compatibility testing
  • Performance analysis under poor connectivity
  • Security vulnerability discovery in constrained scenarios

📁 Project Structure

netguard/
├── backend-go/           # Go backend (primary)
│   ├── main.go
│   └── go.mod
├── backend-rust/         # Rust backend (alternative)
│   ├── Cargo.toml
│   ├── src/
│   │   ├── main.rs
│   │   ├── lib.rs
│   │   ├── network.rs
│   │   ├── security.rs
│   │   └── vpn.rs
├── frontend/             # React + Vite frontend
│   ├── src/
│   │   ├── App.jsx
│   │   ├── App.css
│   │   └── main.jsx
│   ├── index.html
│   ├── vite.config.js
│   └── package.json
└── README.md

🚀 Quick Start

Prerequisites

  • Go 1.21+ (for Go backend) — Install
  • Rust 1.70+ (for Rust backend) — Install
  • Node.js 18+ (for frontend) — Install
  • Root/Admin access (for network controls: iptables, tc, dnctl, etc.)

1. Backend Setup (Choose One)

Option A: Go Backend (Recommended)

cd backend-go

# Run directly
go run main.go

# Or build
go build -o netguard-go
./netguard-go

Server runs on: http://localhost:8080

Option B: Rust Backend

cd backend-rust

# Build and run
cargo run --release

# Or build only
cargo build --release
./target/release/netguard-server

Server runs on: http://127.0.0.1:8081

2. Frontend Setup

cd frontend

# Install dependencies
npm install

# Development server
npm run dev
# Opens at http://localhost:3000

# Production build
npm run build

3. Access Application

Open your browser:


🎮 Usage Guide

Network Controls

IPv6 Blocking

Toggle to block all IPv6 traffic and force IPv4-only communication.

Linux:

sudo ip6tables -P INPUT DROP
sudo ip6tables -P OUTPUT DROP

macOS:

sudo pfctl -f /tmp/netguard_pf.conf

Windows:

netsh interface teredo set state disabled

Bandwidth Throttling

Simulate slow networks (10 KB/s default). Uses traffic control:

Linux (tc):

sudo tc qdisc add dev eth0 root htb default 10
sudo tc class add dev eth0 parent 1: classid 1:10 htb rate 80kbit

macOS (dnctl):

sudo dnctl pipe 1 config bw 80Kbit/s

VPN Configuration

  1. Generate: Create WireGuard config for target server
  2. Connect: Activate VPN tunnel
  3. Disconnect: Stop VPN
# Manual WireGuard connection
sudo wg-quick up /tmp/netguard_wg0.conf

Security Testing

Run a test:

  1. Enter target domain (e.g., example.com)
  2. Configure network conditions (IPv6 block, bandwidth limit, VPN)
  3. Click "Start Test"
  4. View detailed security report

Test Results Include:

  • ✅/❌ IPv4 reachability
  • ✅/❌ IPv6 reachability
  • ⏱️ Latency (TCP connect time)
  • 📊 Throughput (KB/s)
  • 🌐 HTTP status code
  • 🔒 Security headers analysis (HSTS, CSP, X-Frame-Options, etc.)
  • 📈 Security score (0-100)
  • 💡 Optimization recommendations

📊 API Endpoints

GET /api/status

Current configuration state and backend OS

Response:

{
  "config": {
    "ipv6_blocked": false,
    "bandwidth_kbps": 10,
    "vpn_enabled": false,
    "vpn_server_ip": "",
    "test_running": false
  },
  "os": "linux",
  "version": "1.0.0"
}

POST /api/ipv6

Block/unblock IPv6

Request:

{ "block": true }

POST /api/bandwidth

Configure bandwidth throttling

Request:

{
  "kbps": 10,
  "enabled": true
}

POST /api/vpn

Generate, connect, or disconnect VPN

Request (generate):

{
  "action": "generate",
  "server_ip": "203.0.113.42",
  "port": 51820,
  "protocol": "wireguard"
}

Request (connect):

{
  "action": "connect",
  "server_ip": "203.0.113.42"
}

POST /api/test

Run security test on target host

Request:

{ "host": "example.com" }

Response:

{
  "timestamp": "2024-01-15T10:30:45Z",
  "target_host": "example.com",
  "ipv6_reachable": false,
  "ipv4_reachable": true,
  "latency_ms": 45.2,
  "throughput_kbps": 234.5,
  "http_status": 200,
  "security_score": 82,
  "recommendations": [
    "✅ All critical security headers present",
    "⚡ Moderate latency (45ms) — consider regional endpoints"
  ]
}

GET /api/logs

Fetch system logs

GET /api/results

Fetch all test results


🔒 Security Headers Analyzed

  • Strict-Transport-Security (HSTS)
  • Content-Security-Policy (CSP)
  • X-Frame-Options
  • X-Content-Type-Options
  • Referrer-Policy
  • Permissions-Policy
  • X-XSS-Protection

🛠️ Platform Support

Feature Linux macOS Windows
IPv6 Blocking ✅ ip6tables ✅ pfctl ✅ netsh
Bandwidth Limit ✅ tc ✅ dnctl ✅ PowerShell
VPN (WireGuard) ✅ wg-quick ✅ wg-quick ✅ WireGuard App
HTTP Testing
DNS Lookup

⚙️ Advanced Configuration

Custom WireGuard Peer

Edit /tmp/netguard_wg0.conf after generation:

[Peer]
PublicKey = <server-public-key>
Endpoint = 203.0.113.42:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25

Using Rust Backend Instead of Go

Change API endpoint in frontend/src/App.jsx:

const API_BASE = 'http://127.0.0.1:8081/api'; // Rust

Bandwidth Limit Profiles

Create profiles in backend:

  • 3G (2010): ~0.5 MB/s = 500 KB/s
  • 2G (2005): ~20 KB/s
  • Dial-up (1995): ~5 KB/s
  • Legacy: 10 KB/s (default)

📈 Performance Recommendations

Based on security test results:

Issue Recommendation
Low throughput Enable gzip/brotli compression, minify assets, use HTTP/2
High latency Use CDN, edge caching, regional endpoints
Missing headers Add security headers via web server or reverse proxy
Server errors Debug backend, improve error handling, add monitoring
IPv6 exposed Configure firewall rules, disable IPv6 if not needed

🔧 Troubleshooting

"Permission denied" on IPv6 blocking

# Go backend must run as root
sudo go run main.go

# Or set capabilities
sudo setcap cap_net_admin=ep ./netguard-go

API unreachable from frontend

Check CORS headers. Go backend includes CORS; Rust backend has .layer(CorsLayer::permissive()).

WireGuard fails to connect

  • Ensure /tmp/netguard_wg0.conf is readable
  • Verify server IP is reachable: ping <server-ip>
  • Check firewall: sudo ufw allow 51820/udp

High CPU usage during bandwidth limiting

Traffic control is CPU-intensive. Consider:

  • Reducing test frequency
  • Using lower bandwidth limits
  • Testing off-peak hours

📝 Example Workflow

1. Configure Network Conditions:
   ├─ Enable IPv6 blocking
   ├─ Set bandwidth to 10 KB/s
   └─ (Optional) Configure VPN

2. Target Security Test:
   ├─ Enter: example.com
   └─ Click: Start Test

3. Review Results:
   ├─ Security Score: 82/100
   ├─ Headers Missing: CSP
   ├─ Latency: 45ms
   └─ Throughput: 234 KB/s

4. Get Recommendations:
   ├─ Add Content-Security-Policy header
   ├─ Enable HSTS preload
   ├─ Optimize asset delivery
   └─ Deploy to CDN for latency reduction

🎯 Use Cases

Academic Research

Test website compliance with security standards under degraded conditions.

Penetration Testing

Discover vulnerabilities in error handling, timeouts, and network edge cases.

Performance Optimization

Identify bottlenecks and asset optimization opportunities.

Legacy Environment Testing

Validate website functionality for users on older networks (2G/3G).

VPN Analysis

Test application behavior through encrypted IPv4-only tunnels.


📦 Dependencies

Go Backend

  • Standard library (net, http, os/exec, crypto)
  • Cross-platform (Linux, macOS, Windows)
  • No external dependencies

Rust Backend

  • tokio - async runtime
  • axum - web framework
  • reqwest - HTTP client
  • serde - JSON serialization
  • chrono - timestamps

Frontend

  • react 18.2
  • react-dom 18.2
  • axios - HTTP client
  • lucide-react - icons
  • vite - build tool

📄 License

NetGuard © 2024 — Educational & Professional Use


🤝 Contributing

Contributions welcome! Areas for enhancement:

  • Additional VPN protocols (OpenVPN, IKEv2)
  • Real-time network graphs
  • Load testing integration
  • Custom test scenarios
  • Mobile app (React Native)

📞 Support

For issues or questions:

  1. Check logs in the Logs tab
  2. Verify API endpoint connectivity
  3. Ensure root/admin privileges for network controls
  4. Review backend console output 5.support: https://t.me/goholiclover

donation:

1.btc:bc1qpdsmktdtkueqeq6u77t67qndm75kkmm2wl80ec 2.eth:0xc0f3759FA67fF8e46ba8EDf6f345Bd7B110c8368 3.tron:TS2Zm5WAyicFsoRBoFWHEn8hWqoyw5kPho

🔐 NetGuard v1.0.0

Built with Go, Rust, React, and ❤️ for cybersecurity professionals with help of ai

About

NetGuard v1.0.0 : is a project to test server in harsh condition it tests how Will your server/website will react in harsh condition its blocking ipv6 and start a vpn and lower speed to 10kB/s

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors