Skip to content

Commit

Permalink
Added better regex to detect wireless interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostop14 committed Apr 25, 2021
1 parent 451fa65 commit ec85800
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions wirelessengine.py
Expand Up @@ -495,7 +495,7 @@ def convertUnknownToString(ssid):
def getInterfaces(printResults=False):
result = subprocess.run(['iwconfig'], stdout=subprocess.PIPE,stderr=subprocess.DEVNULL)
wirelessResult = result.stdout.decode('UTF-8')
p = re.compile('^(.*?) IEEE', re.MULTILINE)
p = re.compile('^(w.*?) .*', re.MULTILINE)
tmpInterfaces = p.findall(wirelessResult)

retVal = []
Expand All @@ -512,16 +512,6 @@ def getInterfaces(printResults=False):
if (printResults):
print("Error: No wireless interfaces found.")

p = re.compile('^(.*?) unassociated', re.MULTILINE)
tmpInterfaces = p.findall(wirelessResult)
if (len(tmpInterfaces) > 0):
for curInterface in tmpInterfaces:
tmpStr=curInterface.replace(' ','')
retVal.append(tmpStr)
# debug
if (printResults):
print(tmpStr)

return retVal

def getMonitoringModeInterfaces(printResults=False):
Expand Down

0 comments on commit ec85800

Please sign in to comment.