This repository has been archived by the owner on Aug 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Providers
David Fernández Aldana edited this page Aug 27, 2016
·
14 revisions
Providers suggest to the system how to proceed depending on the OUI (vendor part of the BSSID) of the AP in two ways:
- Possible WPS pins.
- Possible tools that can generate the WPS pins.
- Offline: no internet is required, the whole database is directly builtin in the class file.
- Online: internet is required
-
Queryable: a single OUI is checked at a time when the
generate
action is executed. -
Downloadable: the whole database is downloaded when the
update_db
action is executed.
- Create a new Python in the directory showed by the table named
name.py
where the name is the provider name in lowercase. - Import the libraries as needed (try to not use any external dependency), you may use:
-
requests
to do HTTP(S) requests. -
pyquery
to parse (X)HTML responses. -
netaddr
to parse and manipulate BSSID's.
- Create a class named
ProviderName
where the Name is the provider name in StudlyCaps subclassing the class showed by the table. - Implement the function showed by the table.
i. Create a new var to store the ProviderResults
(if it is not a online queryable provider)
ii. For each result fetched create a new ProviderResult
using the following constructor:
def __init__(self, starting_mac: str, tools=None, pins=None)
where:
* `starting_mac`: the first 6 hex digits (_case insensitive_) of the mac (_without separator_).
* `tools`: list of strings of the tools identifiers (_see [`tools/list.py`](/luskaner/wps-dict/blob/master/wps_dict/wps_dict/tools/list.py) for the possible values_ that are the dict keys).
* `pins`: list of strings of 8 digit pins (_whether the checksum is valid does not matter_).
and add it to the ProviderResults
(if it is not a online queryable provider) using the following method:
def add(self, provider_result: ProviderResult) -> None
iii. Return ProviderResults
or ProviderResult
where appropriate.
- Add a dictionary key to the
list.py
file in the subfolder shown by the table, where the key is the provider's name and the value isname.ProviderName
where the name is obviously the provider's name.
Type | Directory | Base class | Function signature |
Offline | offline |
DumpProviderBase (core/base.py) |
def load_all() -> ProviderResults |
Online (downloadable) |
online/ downloadable |
||
Online (queryable) |
online/ queryable |
OnlineQueryableProviderBase (online/queryable/core/base.py) |
def load(mac: EUI) -> ProviderResult |
builtin provider located in offline/builtin.py
:
from ..core.base import DumpProviderBase
from ...providers.core.results import ProviderResult, ProviderResults
class ProviderBuiltin(DumpProviderBase):
@staticmethod
def load_all() -> ProviderResults:
results = ProviderResults()
results.add(ProviderResult('123456', pins=['12345678']))
return results
Provider listing (in this case the offline ones) located in offline/list.py
:
from . import *
offline_providers = {
'builtin': builtin.ProviderBuiltin,
}