-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable_filter.py
80 lines (64 loc) · 1.78 KB
/
table_filter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import iptc
#10.8.59.206
#192.168.5.113 -> rule.src = "149.154.167.91/149.154.167.91"
table = iptc.Table(iptc.Table.FILTER)
# Engelleme
rule = iptc.Rule()
rule.in_interface = "wlp4s0"
rule.src = "149.154.167.91/149.154.167.91"
rule.dst = "192.168.5.113"
rule.protocol = "tcp"
match = iptc.Match(rule, "tcp")
target = iptc.Target(rule, "DROP")
rule.add_match(match)
rule.target = target
chain = iptc.Chain(iptc.Table(iptc.Table.FILTER), "INPUT")
chain.insert_rule(rule)
'''
rule = iptc.Rule()
rule.in_interface = "wlp4s0"
rule.src = "192.168.118.128"
rule.dst = "104.244.42.8"
rule.protocol = "tcp"
match = iptc.Match(rule, "tcp")
target = iptc.Target(rule, "REJECT")
rule.add_match(match)
rule.target = target
chain = iptc.Chain(iptc.Table(iptc.Table.FILTER), "OUTPUT")
chain.insert_rule(rule)
'''
# telegram: 149.154.167.91
'''
rule = iptc.Rule()
rule.in_interface = "wlp4s0"
rule.src = "52.0.0.0/52.255.255.255"
rule.dst = "0.0.0.0/255.255.255.255"
rule.protocol = "tcp"
match = iptc.Match(rule, "tcp")
rule.add_match(match)
match = iptc.Match(rule, "iprange")
match.src_range = "52.0.0.0-52.255.255.255"
match.dst_range = "10.8.59.206"
rule.add_match(match)
target = iptc.Target(rule, "DROP")
rule.target = target
chain = iptc.Chain(iptc.Table(iptc.Table.FILTER), "INPUT")
chain.insert_rule(rule)
'''
'''
rule = iptc.Rule()
rule.in_interface = "wlp4s0"
rule.src = "149.0.0.0/149.255.255.255"
rule.dst = "0.0.0.0/255.255.255.255"
rule.protocol = "tcp"
match = iptc.Match(rule, "tcp")
rule.add_match(match)
match = iptc.Match(rule, "iprange")
match.src_range = "149.0.0.0-149.255.255.255"
match.dst_range = "10.8.59.206-10.255.255.255"
rule.add_match(match)
target = iptc.Target(rule, "DROP")
rule.target = target
chain = iptc.Chain(iptc.Table(iptc.Table.FILTER), "INPUT")
chain.insert_rule(rule)
'''