RUN AS LOCALSYSTEM USER
EDITABLE PARAMETERS:
this script has been scanned with virustotal.com and xcitium verdict cloud.
PYTHON SCRIPT FILE SHA1 VALUE - e71b5b428834251516a889930174c1d4a2f7df2b
JSON FILE SHA1 VALUE - 819f620bb319a776a7e7a00a1ca58ad43e88563f
SSID = ["SSID_1", "SSID_2", "SSID_3"]
Change_or_reverse = "change" # give change or reverse
import os
from subprocess import PIPE, Popen
import ctypes
class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
def __enter__(self):
self.old_value = ctypes.c_long()
self.success = self._disable(ctypes.byref(self.old_value))
def __exit__(self, type, value, traceback):
if self.success:
self._revert(self.old_value)
def ecmd(command, success, error):
with disable_file_system_redirection():
obj = Popen(command, shell = True, stdout = PIPE, stderr = PIPE)
out, err = obj.communicate()
ret=obj.returncode
if ret==0:
if out:
print(out.strip())
print(success)
else:
if err:
print("an error occured: %s"%(err.strip()))
print(error)
else:
print(error)
print("return code: %s"%(ret))
def check(ID_list):
with disable_file_system_redirection():
filters = os.popen("netsh wlan show filters").read()
allow_parse = filters.partition("Allow list on the system (user)")[-1].partition("Block list on the system (group policy)")[0]
NewID_list = []
for ID in ID_list:
if not ID in allow_parse:
NewID_list.append(ID)
else:
print("SSID: %s is already Allowed on this system"%(ID))
deny_parse = filters.partition("Block list on the system (user)")[-1]
flag = 0
if 'SSID: "", Type: Infrastructure' in deny_parse:
flag = 1
return NewID_list, flag
IDs_to_allow, deny_flag = check(SSID)
def add_filters():
IDs_to_allow, deny_flag = check(SSID)
for ID in IDs_to_allow:
allow_command = 'netsh wlan add filter permission=allow ssid="%s" networktype=infrastructure'%(ID)
allow_success = "Successfully allowed the SSID: %s"%(ID)
allow_error = "something went wrong while allowing the SSID: %s"%(ID)
ecmd(allow_command, allow_success, allow_error)
deny_success = "Successfully denied permission for every single SSIDs except the allowed ones"
deny_error = "Failed to deny permission for every single SSIDs except the allowed ones"
if deny_flag == 0:
deny_command = "netsh wlan add filter permission=denyall networktype=infrastructure"
ecmd(deny_command, deny_success, deny_error)
else:
print("already denied permission for every single SSIDs except the allowed ones on this system")
def delete_filters():
with disable_file_system_redirection():
for ID in SSID:
delete_command = 'netsh wlan delete filter permission=allow ssid="%s" networktype=infrastructure'%(ID)
print(os.popen(delete_command).read())
delete_deny_command = 'netsh wlan delete filter permission=denyall networktype=infrastructure'
print(os.popen(delete_deny_command).read())
print("Successfully reversed the settings")
if Change_or_reverse.lower() == "change":
add_filters()
elif Change_or_reverse.lower() == "reverse":
delete_filters()
else:
print("Please check the spelling in the Change_or_reverse variable")
Comments