Skip to content

Commit e7eaa0b

Browse files
committed
Linting
1 parent 8f968ab commit e7eaa0b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

wsuks/helpers/arpspoofer.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from ipaddress import ip_address, IPv4Network
22
import logging
3+
from pathlib import Path
34
import sys
45
import time
56
import traceback
@@ -106,20 +107,17 @@ def check_spoofIp_subnet(self, targetIp, spoofIp):
106107
def enable_ip_forwarding(self):
107108
"""Enable IP forwarding if the the spoofed IP address is not in the same subnet as the host."""
108109
# Read ip_fowarding setting and enable it if necessary
109-
with open("/proc/sys/net/ipv4/ip_forward") as f:
110-
self.ip_forwarding = f.read().strip()
110+
self.ip_forwarding = Path("/proc/sys/net/ipv4/ip_forward").read_text().strip()
111111

112112
if self.ip_forwarding == "0":
113113
self.logger.warning("IP fowarding not enabled, enabling now")
114-
with open("/proc/sys/net/ipv4/ip_forward", "w") as f:
115-
f.write("1")
114+
Path("/proc/sys/net/ipv4/ip_forward").write_text("1")
116115

117116
def disable_ip_forwarding(self):
118117
"""Disable IP forwarding if it was enabled before."""
119118
if self.ip_forwarding == "0":
120119
self.logger.warning("Restoring: Disabling IP fowarding")
121-
with open("/proc/sys/net/ipv4/ip_forward", "w") as f:
122-
f.write("0")
120+
Path("/proc/sys/net/ipv4/ip_forward").write_text("0")
123121

124122
def start(self, targetIp, spoofIp):
125123
"""

0 commit comments

Comments
 (0)