Skip to content

Commit d825795

Browse files
committed
Start repository
0 parents  commit d825795

2,637 files changed

Lines changed: 482294 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bolt/prompt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
For all designs I ask you to make, have them be beautiful, not cookie cutter. Make webpages that are fully featured and worthy for production.
2+
3+
By default, this template supports JSX syntax with Tailwind CSS classes, React hooks, and Lucide React for icons. Do not install other packages for UI themes, icons, etc unless absolutely necessary or I request them.
4+
5+
Use icons from lucide-react for logos.

.gitignore

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
__pycache__/
2+
*.py[cod]
3+
*$py.class
4+
5+
# Distribution / packaging
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
*.egg-info/
20+
.installed.cfg
21+
*.egg
22+
23+
# PyInstaller
24+
*.manifest
25+
*.spec
26+
27+
# Unit test / coverage reports
28+
htmlcov/
29+
.tox/
30+
.coverage
31+
.coverage.*
32+
.cache
33+
nosetests.xml
34+
coverage.xml
35+
*.cover
36+
.hypothesis/
37+
.pytest_cache/
38+
39+
# Environments
40+
.env
41+
.venv
42+
env/
43+
venv/
44+
ENV/
45+
env.bak/
46+
venv.bak/
47+
48+
# IDE
49+
.vscode/
50+
.idea/
51+
*.swp
52+
*.swo
53+
*~
54+
55+
# OS
56+
.DS_Store
57+
.DS_Store?
58+
._*
59+
.Spotlight-V100
60+
.Trashes
61+
ehthumbs.db
62+
Thumbs.db
63+
64+
# Streamlit
65+
.streamlit/
66+
67+
# Exports
68+
exports/
69+
*.json
70+
*.png
71+
*.csv
72+
*.graphml
73+
74+
# Logs
75+
*.log
76+
logs/

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM python:3.11-slim
2+
3+
# Install system dependencies
4+
RUN apt-get update && apt-get install -y \
5+
nmap \
6+
gcc \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
# Set working directory
10+
WORKDIR /app
11+
12+
# Copy requirements and install Python dependencies
13+
COPY requirements.txt .
14+
RUN pip install --no-cache-dir -r requirements.txt
15+
16+
# Copy application code
17+
COPY . .
18+
19+
# Create non-root user for security
20+
RUN useradd --create-home --shell /bin/bash app \
21+
&& chown -R app:app /app
22+
USER app
23+
24+
# Expose Streamlit port
25+
EXPOSE 8501
26+
27+
# Health check
28+
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
29+
30+
# Set environment variables
31+
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
32+
ENV STREAMLIT_SERVER_PORT=8501
33+
ENV STREAMLIT_SERVER_HEADLESS=true
34+
35+
# Run the application
36+
CMD ["streamlit", "run", "webapp/app.py", "--server.address=0.0.0.0", "--server.port=8501", "--server.headless=true"]

README.md

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# Network Topology Mapper
2+
3+
A lightweight network topology mapping application built with Python and Streamlit that discovers network hosts and visualizes network topology using interactive D3.js graphs.
4+
5+
## Features
6+
7+
- **Network Discovery**: Scan subnets using Nmap to discover live hosts
8+
- **Interactive Visualization**: D3.js force-directed network graphs with zoom and drag
9+
- **Multiple Scan Types**: Support for ping, TCP, and SYN scanning methods
10+
- **Host Classification**: Automatically classify hosts as gateways, servers, workstations, or printers
11+
- **Export Options**: Export topology data as JSON, PNG, GraphML, or CSV formats
12+
- **Containerized Deployment**: Docker support for easy deployment
13+
- **Responsive UI**: Clean Streamlit interface with real-time updates
14+
15+
## Quick Start
16+
17+
### Using Docker (Recommended)
18+
19+
1. Clone the repository:
20+
```bash
21+
git clone <repository-url>
22+
cd network-topology-mapper
23+
```
24+
25+
2. Build and run with Docker Compose:
26+
```bash
27+
docker-compose up --build
28+
```
29+
30+
3. Open your browser and navigate to `http://localhost:8501`
31+
32+
### Local Installation
33+
34+
1. Install system dependencies:
35+
```bash
36+
# Ubuntu/Debian
37+
sudo apt-get update && sudo apt-get install nmap
38+
39+
# macOS
40+
brew install nmap
41+
```
42+
43+
2. Install Python dependencies:
44+
```bash
45+
pip install -r requirements.txt
46+
```
47+
48+
3. Run the application:
49+
```bash
50+
streamlit run webapp/app.py
51+
```
52+
53+
## Usage
54+
55+
1. **Enter Network Subnet**: Input your target network in CIDR notation (e.g., `192.168.1.0/24`)
56+
57+
2. **Select Scan Type**:
58+
- **Ping Scan**: Fast host discovery using ICMP
59+
- **TCP Scan**: More thorough scanning with port detection
60+
- **SYN Scan**: Stealth scanning (requires root privileges)
61+
62+
3. **Start Scan**: Click "Start Network Scan" to begin discovery
63+
64+
4. **View Results**: Interactive network topology will be displayed with:
65+
- Color-coded nodes based on host types
66+
- Connections between hosts
67+
- Detailed host information in sidebar
68+
69+
5. **Export Data**: Use export options to save topology in various formats
70+
71+
## Architecture
72+
73+
```
74+
├── discovery/ # Network scanning modules
75+
│ ├── __init__.py
76+
│ └── nmap_scan.py # Nmap wrapper for network discovery
77+
├── graph/ # Topology building modules
78+
│ ├── __init__.py
79+
│ └── topology_builder.py # NetworkX graph construction
80+
├── webapp/ # Streamlit web interface
81+
│ ├── __init__.py
82+
│ ├── app.py # Main Streamlit application
83+
│ └── d3_component.html # D3.js visualization component
84+
├── utils/ # Utility modules
85+
│ ├── __init__.py
86+
│ └── exporters.py # Export functionality
87+
├── requirements.txt # Python dependencies
88+
├── Dockerfile # Container configuration
89+
└── docker-compose.yml # Multi-container setup
90+
```
91+
92+
## Host Classification
93+
94+
The application automatically classifies discovered hosts:
95+
96+
- **Gateway** (Red): Typically .1 or .254 addresses, network gateways
97+
- **Server** (Teal): Hosts with common service ports (22, 80, 443, etc.)
98+
- **Workstation** (Blue): Standard client computers
99+
- **Printer** (Green): Devices with printing service ports
100+
101+
## Security Considerations
102+
103+
- **Root Privileges**: SYN scanning requires root/administrator privileges
104+
- **Network Permissions**: Ensure you have permission to scan target networks
105+
- **Firewall Rules**: Some scans may be blocked by firewalls
106+
- **Rate Limiting**: Large networks may take time to scan completely
107+
108+
## Export Formats
109+
110+
- **JSON**: Complete topology data with metadata
111+
- **PNG**: Static network diagram image
112+
- **GraphML**: Compatible with Gephi, Cytoscape, and other graph tools
113+
- **CSV**: Separate files for nodes and connections
114+
115+
## Configuration
116+
117+
### Environment Variables
118+
119+
- `STREAMLIT_SERVER_ADDRESS`: Server bind address (default: 0.0.0.0)
120+
- `STREAMLIT_SERVER_PORT`: Server port (default: 8501)
121+
- `STREAMLIT_SERVER_HEADLESS`: Run in headless mode (default: true)
122+
123+
### Docker Network Modes
124+
125+
For network scanning to work properly in Docker:
126+
- Use `network_mode: host` for full network access
127+
- Add `NET_ADMIN` and `NET_RAW` capabilities
128+
- Consider security implications of privileged containers
129+
130+
## Troubleshooting
131+
132+
### Common Issues
133+
134+
1. **"Command not found: nmap"**
135+
- Install nmap system package
136+
- Ensure nmap is in system PATH
137+
138+
2. **"Permission denied" errors**
139+
- Run with sudo for SYN scans
140+
- Use ping or TCP scans for unprivileged scanning
141+
142+
3. **No hosts discovered**
143+
- Verify network subnet is correct
144+
- Check firewall settings
145+
- Try different scan types
146+
147+
4. **Slow scanning**
148+
- Use ping scan for faster results
149+
- Reduce subnet size
150+
- Check network latency
151+
152+
## Contributing
153+
154+
1. Fork the repository
155+
2. Create a feature branch
156+
3. Make changes with tests
157+
4. Submit a pull request
158+
159+
## License
160+
161+
This project is licensed under the MIT License - see the LICENSE file for details.
162+
163+
## Dependencies
164+
165+
- **Streamlit**: Web application framework
166+
- **NetworkX**: Graph manipulation and analysis
167+
- **python-nmap**: Python wrapper for nmap
168+
- **D3.js**: Interactive data visualization
169+
- **Matplotlib**: Static graph rendering
170+
- **Pandas**: Data manipulation
171+
172+
## Roadmap
173+
174+
- [ ] Real-time network monitoring
175+
- [ ] SNMP integration for device details
176+
- [ ] Network performance metrics
177+
- [ ] Custom styling themes
178+
- [ ] API endpoint for automation
179+
- [ ] Multi-subnet scanning
180+
- [ ] Historical topology comparison

discovery/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Discovery module for network scanning

0 commit comments

Comments
 (0)