Skip to content

Dhakshi03/ip_access_manager

Repository files navigation

Python License

IP Access Manager

A Python-based cybersecurity automation tool for managing IP allow lists in restricted networks. The tool validates IP addresses, removes restricted IPs, generates audit logs, creates timestamped backups, and supports verbose and dry-run execution.

Overview

In security-sensitive environments such as healthcare organizations, access to restricted resources must be carefully controlled. This project automates the maintenance of IP allow lists by removing unauthorized or restricted IP addresses while maintaining audit trails and backups.

The tool is designed with secure scripting practices commonly used in security operations and system administration.

Features

  • Validate IPv4 and IPv6 addresses
  • Remove restricted IPs from allow lists
  • Detect and remove invalid IP addresses
  • Generate timestamped audit logs
  • Create timestamped backups before modification
  • Support verbose mode for detailed execution logs
  • Support dry-run mode to preview changes safely
  • Generate execution summaries
  • Command-line interface using argparse
  • Robust exception handling

Project Structure

ip-access-manager/
│
├── ip_access_manager.py
├── allow.txt
├── remove.txt
├── README.md
├── LICENSE
├── .gitignore
├── log.txt              # Generated during execution
└── backups/             # Generated during execution

Requirements

  • Python 3.8 or higher

No external dependencies are required. The project uses only Python's standard library.

Usage

Normal Execution

python ip_access_manager.py sample_allowed_ips.txt sample_remove_ips.txt

Verbose Mode

Displays detailed execution information.

python ip_access_manager.py sample_allowed_ips.txt sample_remove_ips.txt -v

Dry Run Mode

Previews all changes without modifying any files.

python ip_access_manager.py sample_allowed_ips.txt sample_remove_ips.txt --dry-run

Verbose + Dry Run

python ip_access_manager.py sample_allowed_ips.txt sample_remove_ips.txt -v --dry-run

Input Files

allow.txt

Contains IP addresses currently permitted to access restricted resources.

Example:

192.168.1.10
192.168.1.20
10.0.0.1
172.16.0.5

remove.txt

Contains IP addresses that must be removed from the allow list.

Example:

192.168.1.20
10.0.0.1

Output

During execution, the tool:

  1. Validates all IP addresses
  2. Removes invalid IPs
  3. Removes restricted IPs from the allow list
  4. Creates timestamped backups
  5. Updates the allow list
  6. Records actions in an audit log
  7. Generates a summary report

Example summary:

================= Summary =================
Dry Run               : No
Initial allowed IPs   : 14
Initial restricted IPs: 6
Invalid IPs           : 4
Removed IPs           : 4
Remaining IPs         : 8
Files Modified        : Yes
Backup created        : Yes
Log file updated      : log.txt

Demonstration

Verbose Mode with Dry Run

The following screenshot shows the tool running in verbose mode with dry-run enabled. No files are modified, and the tool displays the actions that would have been performed.

Dry Run Verbose


Generated Logs and Updated Allow List

The tool maintains audit logs with timestamps and updates the allow list after processing.

Logs and Allow List


Verbose Execution

Verbose mode provides detailed information about each operation, including invalid IP removal and restricted IP filtering.

Verbose Execution


Timestamped Backups

Before modifying any files, timestamped backups are automatically created to ensure recoverability.

Backups

Audit Logging

All modifications and validation failures are recorded in log.txt with timestamps.

Example:

2026-08-07 14:32:10 Removed IP address: 192.168.1.20
2026-08-07 14:32:15 Invalid IP address found in allow list: abc.def.ghi.jkl

Backup System

Before modifying any files, the tool automatically creates timestamped backups:

backups/
├── backup_allow_list_20260807_143210.txt
└── backup_restricted_list_20260807_143210.txt

This ensures recoverability and preserves historical records.

Security Features

  • Input validation using the ipaddress module
  • Audit logging for traceability
  • Backup creation before modification
  • Safe dry-run execution
  • Exception handling for reliability

Future Enhancements

  • Support CIDR ranges
  • Export logs in CSV format
  • Interactive command-line mode
  • Firewall API integration
  • User authentication and role-based access

Author

Dhakshitha Deivanai

B.Tech CSE (Cyber Security)

License

This project is licensed under the MIT License.

About

Python-based IP allow-list management tool with validation, audit logging, backups, verbose mode, and dry-run support.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors