Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
derv82
GitHub Repository: derv82/wifite2
Path: blob/master/wifite/tools/iwconfig.py
412 views
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
from .dependency import Dependency
5
6
class Iwconfig(Dependency):
7
dependency_required = True
8
dependency_name = 'iwconfig'
9
dependency_url = 'apt-get install wireless-tools'
10
11
12
@classmethod
13
def mode(cls, iface, mode_name):
14
from ..util.process import Process
15
16
pid = Process(['iwconfig', iface, 'mode', mode_name])
17
pid.wait()
18
19
return pid.poll()
20
21
22
@classmethod
23
def get_interfaces(cls, mode=None):
24
from ..util.process import Process
25
26
interfaces = set()
27
iface = ''
28
29
(out, err) = Process.call('iwconfig')
30
for line in out.split('\n'):
31
if len(line) == 0: continue
32
33
if not line.startswith(' '):
34
iface = line.split(' ')[0]
35
if '\t' in iface:
36
iface = iface.split('\t')[0].strip()
37
38
iface = iface.strip()
39
if len(iface) == 0:
40
continue
41
42
if mode is None:
43
interfaces.add(iface)
44
45
if mode is not None and 'Mode:{}'.format(mode) in line and len(iface) > 0:
46
interfaces.add(iface)
47
48
return list(interfaces)
49
50
51