https://github.com/marcuwynu23/fw
FW is a simple firewall command-line tool written in Go, designed to control the Windows firewall using the netsh command.
https://github.com/marcuwynu23/fw
Last synced: 5 months ago
JSON representation
FW is a simple firewall command-line tool written in Go, designed to control the Windows firewall using the netsh command.
- Host: GitHub
- URL: https://github.com/marcuwynu23/fw
- Owner: marcuwynu23
- Created: 2024-09-18T02:37:56.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-15T08:54:58.000Z (11 months ago)
- Last Synced: 2025-02-17T04:41:31.566Z (9 months ago)
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
FW
FW is a simple firewall command-line tool written in Go, designed to control the Windows firewall using the `netsh` command. This tool allows you to enable or disable the firewall, allow or deny traffic on specific ports, and list firewall rules in a simplified manner (Program Name, Port, Direction).
## Features
- **Enable/Disable Firewall**: Quickly enable or disable the firewall.
- **Allow/Deny Ports**: Add rules to allow or deny traffic on specific ports.
- **List Rules**: Simplified listing of firewall rules showing only Program Name, Port, and Direction.
- **Cross-Platform (Windows)**: Works specifically with Windows using `netsh`.
## Usage
### Running the FW Tool
You can run FW in different modes:
1. **Enable/Disable Firewall**: Control the state of the Windows firewall.
2. **Allow/Deny Ports**: Add rules to allow or block traffic on specific ports.
3. **List Rules**: List the current firewall rules in a simplified format.
4. **Delete Rules**: Remove firewall rules for a specific port.
### Flags
- `enable`: Enable the firewall for all profiles.
- `disable`: Disable the firewall for all profiles.
- `allow [in|out]`: Allow traffic on the specified port (default: inbound).
- `deny [in|out]`: Block traffic on the specified port (default: inbound).
- `delete `: Delete the firewall rule for the specified port.
- `list`: List current firewall rules (Program Name, Port, Direction).
- `status`: Show the current status of the firewall.
### Examples
#### 1. Enabling the Firewall
To enable the firewall on all profiles:
```bash
fw enable
```
#### 2. Disabling the Firewall
To disable the firewall on all profiles:
```bash
fw disable
```
#### 3. Allowing Traffic on a Port
To allow inbound traffic on port `8080`:
```bash
fw allow 8080
```
To allow outbound traffic on port `8080`:
```bash
fw allow 8080 out
```
#### 4. Denying Traffic on a Port
To block inbound traffic on port `22`:
```bash
fw deny 22
```
#### 5. Deleting a Port Rule
To delete a firewall rule for port `8080`:
```bash
fw delete 8080
```
#### 6. Listing Firewall Rules
To list the current firewall rules (showing Program Name, Port, and Direction):
```bash
fw list
```
#### 7. Firewall Status
To check the current firewall status:
```bash
fw status
```
### Usage Example
```bash
$ fw list
Port Direction Program Name
8080 Inbound AllowInboundPort8080
80 Inbound AllowInboundPort80
22 Inbound DenyInboundPort22
```
### How It Works
- **Enabling/Disabling the Firewall**: The tool uses the `netsh advfirewall` command to enable or disable the firewall.
- **Adding/Denying Rules**: It creates rules using the `netsh advfirewall firewall add rule` command for allowing or blocking traffic on specific ports.
- **Listing Rules**: The tool parses the output of the `netsh advfirewall firewall show rule` command to display the relevant firewall rules.
## Supported Platforms
- **Windows**: This tool works on Windows only, as it uses the `netsh` command-line tool to manage the firewall.
## Security Warning
This tool is intended for educational purposes or system administration tasks. Use it responsibly and ensure you have appropriate permissions to modify firewall rules on the system.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.