-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
54 lines (42 loc) · 1.85 KB
/
app.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
import eel
import requests, csv, subprocess
import webbrowser
# set folder
eel.init('source')
# Removing Rules
@eel.expose
def remove_rule():
rule = "netsh advfirewall firewall delete rule name='BadIP'"
subprocess.run(["Powershell", "-Command", rule])
# Adding Inbound Rule
@eel.expose
def inbound_rule():
response = requests.get("https://feodotracker.abuse.ch/downloads/ipblocklist.csv").text
rule = "netsh advfirewall firewall delete rule name= 'BadIP'"
subprocess.run(["Powershell", "-Command", rule])
mycsv = csv.reader(filter(lambda x: not x.startswith("#"), response.splitlines()))
for row in mycsv:
ip = row[1]
if(ip)!=("dst_ip"):
print("Added Rule to block:", ip)
rule = "netsh advfirewall firewall add rule name='BadIP' Dir=In Action=Block RemoteIP=" + ip # Fill Dir= with (Out or In)
subprocess.run(["Powershell", "-Command", rule])
# Adding Outbound Rule
@eel.expose
def outbound_rule():
response = requests.get("https://feodotracker.abuse.ch/downloads/ipblocklist.csv").text
rule = "netsh advfirewall firewall delete rule name= 'BadIP'"
subprocess.run(["Powershell", "-Command", rule])
mycsv = csv.reader(filter(lambda x: not x.startswith("#"), response.splitlines()))
for row in mycsv:
ip = row[1]
if(ip)!=("dst_ip"):
print("Added Rule to block:", ip)
rule = "netsh advfirewall firewall add rule name='BadIP' Dir=Out Action=Block RemoteIP=" + ip # Fill Dir= with (Out or In)
subprocess.run(["Powershell", "-Command", rule])
# Opening Github in external tab.
@eel.expose
def open_github():
webbrowser.open("https://www.github.com/akshayalix/Firewall")
eel.browsers.set_path('chrome', r'C:\Users\alix\AppData\Local\Thorium\Application\thorium.exe')
eel.start('index.html', size=(800, 960), position=(550, 50))