mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
update readme and formatting
This commit is contained in:
319
README.md
319
README.md
@ -230,6 +230,325 @@ $ ifconfig | jc --ifconfig -p
|
||||
}
|
||||
]
|
||||
```
|
||||
### iptables
|
||||
```
|
||||
$ sudo iptables -L -t nat | jc --iptables -p
|
||||
[
|
||||
{
|
||||
"chain": "PREROUTING",
|
||||
"rules": [
|
||||
{
|
||||
"target": "PREROUTING_direct",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere"
|
||||
},
|
||||
{
|
||||
"target": "PREROUTING_ZONES_SOURCE",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere"
|
||||
},
|
||||
{
|
||||
"target": "PREROUTING_ZONES",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere"
|
||||
},
|
||||
{
|
||||
"target": "DOCKER",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere",
|
||||
"options": "ADDRTYPE match dst-type LOCAL"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"chain": "INPUT",
|
||||
"rules": []
|
||||
},
|
||||
{
|
||||
"chain": "OUTPUT",
|
||||
"rules": [
|
||||
{
|
||||
"target": "OUTPUT_direct",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere"
|
||||
},
|
||||
{
|
||||
"target": "DOCKER",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"source": "anywhere",
|
||||
"destination": "!loopback/8",
|
||||
"options": "ADDRTYPE match dst-type LOCAL"
|
||||
}
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
```
|
||||
```
|
||||
$ sudo iptables -vnL -t filter | jc --iptables -p
|
||||
[
|
||||
{
|
||||
"chain": "INPUT",
|
||||
"rules": [
|
||||
{
|
||||
"pkts": "1571",
|
||||
"bytes": "3394K",
|
||||
"target": "ACCEPT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0",
|
||||
"options": "ctstate RELATED,ESTABLISHED"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "ACCEPT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "lo",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "711",
|
||||
"bytes": "60126",
|
||||
"target": "INPUT_direct",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "711",
|
||||
"bytes": "60126",
|
||||
"target": "INPUT_ZONES_SOURCE",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "711",
|
||||
"bytes": "60126",
|
||||
"target": "INPUT_ZONES",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "DROP",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0",
|
||||
"options": "ctstate INVALID"
|
||||
},
|
||||
{
|
||||
"pkts": "710",
|
||||
"bytes": "60078",
|
||||
"target": "REJECT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0",
|
||||
"options": "reject-with icmp-host-prohibited"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"chain": "FORWARD",
|
||||
"rules": [
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "DOCKER-ISOLATION",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "DOCKER",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "docker0",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "ACCEPT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "docker0",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0",
|
||||
"options": "ctstate RELATED,ESTABLISHED"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "ACCEPT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "docker0",
|
||||
"out": "!docker0",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "ACCEPT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "docker0",
|
||||
"out": "docker0",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "ACCEPT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0",
|
||||
"options": "ctstate RELATED,ESTABLISHED"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "ACCEPT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "lo",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "FORWARD_direct",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "FORWARD_IN_ZONES_SOURCE",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "FORWARD_IN_ZONES",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "FORWARD_OUT_ZONES_SOURCE",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "FORWARD_OUT_ZONES",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "DROP",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0",
|
||||
"options": "ctstate INVALID"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "REJECT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0",
|
||||
"options": "reject-with icmp-host-prohibited"
|
||||
}
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
```
|
||||
### ls
|
||||
```
|
||||
$ ls -l /bin | jc --ls -p
|
||||
|
@ -7,6 +7,7 @@ jc changelog
|
||||
- Add lsblk parser
|
||||
- Add mount parser
|
||||
- Add uname parser
|
||||
- Add iptables parser
|
||||
|
||||
20191021 v0.6.4
|
||||
- Flatten netstat parser output
|
||||
|
@ -7,6 +7,321 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo iptables -L -t nat | jc --iptables -p
|
||||
[
|
||||
{
|
||||
"chain": "PREROUTING",
|
||||
"rules": [
|
||||
{
|
||||
"target": "PREROUTING_direct",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere"
|
||||
},
|
||||
{
|
||||
"target": "PREROUTING_ZONES_SOURCE",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere"
|
||||
},
|
||||
{
|
||||
"target": "PREROUTING_ZONES",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere"
|
||||
},
|
||||
{
|
||||
"target": "DOCKER",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere",
|
||||
"options": "ADDRTYPE match dst-type LOCAL"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"chain": "INPUT",
|
||||
"rules": []
|
||||
},
|
||||
{
|
||||
"chain": "OUTPUT",
|
||||
"rules": [
|
||||
{
|
||||
"target": "OUTPUT_direct",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere"
|
||||
},
|
||||
{
|
||||
"target": "DOCKER",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"source": "anywhere",
|
||||
"destination": "!loopback/8",
|
||||
"options": "ADDRTYPE match dst-type LOCAL"
|
||||
}
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ sudo iptables -vnL -t filter | jc --iptables -p
|
||||
[
|
||||
{
|
||||
"chain": "INPUT",
|
||||
"rules": [
|
||||
{
|
||||
"pkts": "1571",
|
||||
"bytes": "3394K",
|
||||
"target": "ACCEPT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0",
|
||||
"options": "ctstate RELATED,ESTABLISHED"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "ACCEPT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "lo",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "711",
|
||||
"bytes": "60126",
|
||||
"target": "INPUT_direct",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "711",
|
||||
"bytes": "60126",
|
||||
"target": "INPUT_ZONES_SOURCE",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "711",
|
||||
"bytes": "60126",
|
||||
"target": "INPUT_ZONES",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "DROP",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0",
|
||||
"options": "ctstate INVALID"
|
||||
},
|
||||
{
|
||||
"pkts": "710",
|
||||
"bytes": "60078",
|
||||
"target": "REJECT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0",
|
||||
"options": "reject-with icmp-host-prohibited"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"chain": "FORWARD",
|
||||
"rules": [
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "DOCKER-ISOLATION",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "DOCKER",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "docker0",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "ACCEPT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "docker0",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0",
|
||||
"options": "ctstate RELATED,ESTABLISHED"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "ACCEPT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "docker0",
|
||||
"out": "!docker0",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "ACCEPT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "docker0",
|
||||
"out": "docker0",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "ACCEPT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0",
|
||||
"options": "ctstate RELATED,ESTABLISHED"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "ACCEPT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "lo",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "FORWARD_direct",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "FORWARD_IN_ZONES_SOURCE",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "FORWARD_IN_ZONES",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "FORWARD_OUT_ZONES_SOURCE",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "FORWARD_OUT_ZONES",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "DROP",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0",
|
||||
"options": "ctstate INVALID"
|
||||
},
|
||||
{
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "REJECT",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "*",
|
||||
"out": "*",
|
||||
"source": "0.0.0.0/0",
|
||||
"destination": "0.0.0.0/0",
|
||||
"options": "reject-with icmp-host-prohibited"
|
||||
}
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
"""
|
||||
|
||||
|
||||
@ -29,7 +344,6 @@ def parse(data):
|
||||
parsed_line = line.split()
|
||||
|
||||
state.chain['chain'] = parsed_line[1]
|
||||
# state.chain['references'] = parsed_line[2].lstrip('(').rstrip(')').split()[0]
|
||||
state.chain['rules'] = []
|
||||
|
||||
continue
|
||||
|
Reference in New Issue
Block a user