@@ -80,6 +80,15 @@ def __check_if_linux(self) -> None:
8080 if "linux" not in sys .platform :
8181 raise UnsupportedOS ("You need a Linux distro to run this program" )
8282
83+ def __ip4f (self ) -> None :
84+ subprocess .call (shlex .split ("sysctl -w net.ipv4.ip_forward=0" ))
85+ 86+ def __icmp (self ) -> None :
87+ subprocess .call (shlex .split ("sysctl -w net.ipv4.icmp_echo_ignore_all=1" ))
88+ 89+ def __mtp (self ) -> None :
90+ subprocess .call (shlex .split ("sysctl -w net.ipv4.tcp_mtu_probing=1" ))
91+ 8392 def __sel (self , en : int ) -> bool :
8493 if bool (shutil .which ("setenforce" )) is not False :
8594 subprocess .call (shlex .split ("setenforce {}" .format (en )))
@@ -136,7 +145,8 @@ def __set_iptables_rules(self, torid: int, tport: int = None,
136145 /usr/sbin/iptables -A OUTPUT -d $NET -j ACCEPT
137146 done
138147 /usr/sbin/iptables -A OUTPUT -m owner --uid-owner {torid} -j ACCEPT
139- /usr/sbin/iptables -A OUTPUT -j REJECT""" .format (
148+ /usr/sbin/iptables -A OUTPUT -j REJECT
149+ """ .format (
140150 torid = torid ,
141151 tport = tport if tport is not None else 9040 ,
142152 nontor = nontor
@@ -159,15 +169,19 @@ def __torrc_file(self, tport: int) -> str:
159169 # THIS FILE IS GENERATED BY
160170 # DARKNET.PY
161171 AvoidDiskWrites 1
162- GeoIPFile /usr/local/share/tor/geoip
163- GeoIPv6File /usr/local/share/tor/geoip6
172+ SocksPort 127.0.0.1:9050 IsolateDestAddr IsolateDestPort
173+ SocksPort 127.0.0.1:9150 IsolateSOCKSAuth KeepAliveIsolateSOCKSAuth
174+ ControlPort 9052
175+ ControlListenAddress 127.0.0.1
164176 VirtualAddrNetworkIPv4 10.0.0.0/10
165177 AutomapHostsOnResolve 1
178+ AutomapHostsSuffixes .exit,.onion
166179 ExcludeNodes {{AU}}, {{CA}}, {{US}}, {{NZ}}, {{GB}}, {{DK}}, {{FR}}, {{NL}}, {{NO}}, {{BE}}, {{DE}}, {{IT}}, {{ES}}, {{SE}}
167180 NodeFamily {{AU}}, {{CA}}, {{US}}, {{NZ}}, {{GB}}, {{DK}}, {{FR}}, {{NL}}, {{NO}}, {{BE}}, {{DE}}, {{IT}}, {{ES}}, {{SE}}
168181 StrictNodes 1
169182 TransPort {tport} IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
170183 DNSPort 5353
184+ WarnPlaintextPorts 23,109,110,143
171185 """ .format (
172186 tport = tport if tport is not None else 9040
173187 )
@@ -179,18 +193,18 @@ def __check_if_root(self) -> None:
179193
180194 @property
181195 def __random_mac_address (self ) -> str :
182- return "02:00:00:%2x:%2x:%2x " % (random .randint (0 , 255 ), random .randint (0 , 255 ), random .randint (0 , 255 ))
196+ return "02:00:00:%02x:%02x:%02x " % (random .randint (0 , 255 ), random .randint (0 , 255 ), random .randint (0 , 255 ))
183197
184198 def __change_mac_addr (self , interfaces : list ) -> None :
185199 print ("{} Changing MAC Addresses..." .format (self ._timer ))
186200 for interface in interfaces :
187201 print ("{} Changing: {}" .format (self ._timer , interface ))
188- subprocess .call (shlex .split ("/bin /ip link set {} down" .format (interface )))
202+ subprocess .call (shlex .split ("/sbin /ip link set {} down" .format (interface )))
189203 time .sleep (5 )
190204 macaddr = self .__random_mac_address
191- subprocess .call (shlex .split ("/bin /ip link set {} address {}" .format (interface , macaddr )))
205+ subprocess .call (shlex .split ("/sbin /ip link set {} address {}" .format (interface , macaddr )))
192206 time .sleep (5 )
193- subprocess .call (shlex .split ("/bin /ip link set {} up" .format (interface )))
207+ subprocess .call (shlex .split ("/sbin /ip link set {} up" .format (interface )))
194208 print ("{} MAC Addresses changed for interface: {} => {} " .format (self ._timer , interface , macaddr ))
195209 print ("{} Reloading Network Manager" .format (self ._timer ))
196210 subprocess .call (shlex .split ("systemctl reload NetworkManager" ))
@@ -272,7 +286,7 @@ def start(self, torid: int, torrc: str = None, port: int = None) -> None:
272286
273287 def stop (self ) -> None :
274288 print ("{} STOPPING darknet.py" .format (self ._timer ), end = " " )
275- print ("{} Flushing Firewall, resetting to default:\n " .format (self ._timer ), end = " " )
289+ print ("\n {} Flushing Firewall, resetting to default:\n " .format (self ._timer ), end = " " )
276290 flush = self .__unset_iptables_rules ()
277291 _ = subprocess .check_output (flush , shell = True )
278292 print ("[done]" )
@@ -294,7 +308,11 @@ def run(self, args) -> None:
294308 torrc = args .torrc
295309 port = args .port
296310 if args .start is True :
297- print ("[{}] Checking for SELinux" .format (self ._timer ))
311+ print ("Hardering System..." )
312+ self .__ip4f ()
313+ self .__icmp ()
314+ self .__mtp ()
315+ print ("{} Checking for SELinux" .format (self ._timer ))
298316 print ("SELinux Disabled Temporarily" ) if self .__sel (0 ) else print ("SELinux not Found!" )
299317 if args .torid is not None :
300318 torid = args .torid
@@ -303,7 +321,11 @@ def run(self, args) -> None:
303321 time .sleep (1 )
304322 self .start (torid = torid , torrc = args .torrc , port = port )
305323 if args .stealth is True :
306- print ("[{}] Checking for SELinux" .format (self ._timer ))
324+ print ("Hardering System..." )
325+ self .__ip4f ()
326+ self .__icmp ()
327+ self .__mtp ()
328+ print ("{} Checking for SELinux" .format (self ._timer ))
307329 print ("SELinux Disabled Temporarily" ) if self .__sel (0 ) else print ("SELinux not Found!" )
308330 if args .torid is not None :
309331 torid = args .torid
@@ -319,6 +341,7 @@ def run(self, args) -> None:
319341 self .stop ()
320342 print ("[{}] Checking for SELinux..." .format (self ._timer ))
321343 print ("SELinux Enabled" ) if self .__sel (1 ) else print ("SELinux not Found!" )
344+ print ("darknet.py disabled. You may need to Restart your Machine to Revert some changes!" )
322345
323346
324347if __name__ == "__main__" :
0 commit comments