Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
fuswim
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sysadmin
fuswim
Commits
a1695a1f
Commit
a1695a1f
authored
3 years ago
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove iwlist.py, we don't use it.
parent
317984f1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
55 deletions
+0
-55
iwlist.py
iwlist.py
+0
-55
No files found.
iwlist.py
deleted
100644 → 0
View file @
317984f1
import
re
import
subprocess
cellNumberRe
=
re
.
compile
(
r"^Cell\s+(?P<cellnumber>.+)\s+-\s+Address:\s(?P<mac>.+)$"
)
regexps
=
[
re
.
compile
(
r"^ESSID:\"(?P<essid>.*)\"$"
),
re
.
compile
(
r"^Protocol:(?P<protocol>.+)$"
),
re
.
compile
(
r"^Mode:(?P<mode>.+)$"
),
re
.
compile
(
r"^Frequency:(?P<frequency>[\d.]+) (?P<frequency_units>.+) \(Channel (?P<channel>\d+)\)$"
),
re
.
compile
(
r"^Encryption key:(?P<encryption>.+)$"
),
re
.
compile
(
r"^Quality=(?P<signal_quality>\d+)/(?P<signal_total>\d+)\s+Signal level=(?P<signal_level_dBm>.+) d.+$"
),
re
.
compile
(
r"^Signal level=(?P<signal_quality>\d+)/(?P<signal_total>\d+).*$"
),
]
# Detect encryption type
wpaRe
=
re
.
compile
(
r"IE:\ WPA\ Version\ 1$"
)
wpa2Re
=
re
.
compile
(
r"IE:\ IEEE\ 802\.11i/WPA2\ Version\ 1$"
)
# Runs the comnmand to scan the list of networks.
# Must run as super user.
# Does not specify a particular device, so will scan all network devices.
def
scan
(
interface
=
'wlan0'
):
cmd
=
[
"iwlist"
,
interface
,
"scan"
]
proc
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
points
=
proc
.
stdout
.
read
()
.
decode
(
'utf-8'
)
return
points
# Parses the response from the command "iwlist scan"
def
parse
(
content
):
cells
=
[]
lines
=
content
.
split
(
'
\n
'
)
for
line
in
lines
:
line
=
line
.
strip
()
cellNumber
=
cellNumberRe
.
search
(
line
)
if
cellNumber
is
not
None
:
cells
.
append
(
cellNumber
.
groupdict
())
continue
wpa
=
wpaRe
.
search
(
line
)
if
wpa
is
not
None
:
cells
[
-
1
]
.
update
({
'encryption'
:
'wpa'
})
wpa2
=
wpa2Re
.
search
(
line
)
if
wpa2
is
not
None
:
cells
[
-
1
]
.
update
({
'encryption'
:
'wpa2'
})
for
expression
in
regexps
:
result
=
expression
.
search
(
line
)
if
result
is
not
None
:
if
'encryption'
in
result
.
groupdict
()
:
if
result
.
groupdict
()[
'encryption'
]
==
'on'
:
cells
[
-
1
]
.
update
({
'encryption'
:
'wep'
})
else
:
cells
[
-
1
]
.
update
({
'encryption'
:
'off'
})
else
:
cells
[
-
1
]
.
update
(
result
.
groupdict
())
continue
return
cells
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment