Welcome to NetSec’s documentation!

NetSec

netsec.analyzer.network_monitor(module: SupportedModules, init: bool = True, block: bool = False) NoReturn

Monitor devices connected to the network.

Parameters:
  • module – Module to scan. Currently, supports any network on a Netgear router or At&t networks.

  • init – Takes a boolean value to create a snapshot file or actually monitor the network.

  • block – Takes a boolean value whether to block the intrusive device.

At&t

class netsec.modules.att.Device(dictionary: dict)

Convert dictionary into a device object.

>>> Device
netsec.modules.att.create_snapshot() NoReturn

Creates a snapshot.json which is used to determine the known and unknown devices.

netsec.modules.att.format_key(key: str) str

Format the key to match the Device object.

netsec.modules.att.generate_dataframe() DataFrame

Generate a dataframe using the devices information from router web page.

Returns:

Devices list as a data frame.

Return type:

DataFrame

netsec.modules.att.get_attached_devices() Generator[Device]

Get all devices connected to the router.

Yields:

Generator[Device] – Yields each device information as a Device object.

netsec.modules.att.get_ipaddress() str

Get network id from the current IP address.

netsec.modules.att.run() NoReturn

Trigger to initiate a Network Scan and block the devices that are not present in snapshot.json file.

Netgear

class netsec.modules.netgear.LocalIPScan

Connector to scan devices in the same IP range using Netgear API.

>>> LocalIPScan
allow(device: Union[str, Device]) Optional[Device]

Allows internet access to a device.

Parameters:

device – Takes device name or Device object as an argument.

Returns:

Returns the device object received from get_device_by_name() method.

Return type:

Device

always_allow(device: Device) NoReturn

Allows internet access to a device.

Saves the device name to snapshot.json to not block in the future. Removes the device name from blocked.json if an entry is present.

Parameters:

device – Takes device name or Device object as an argument

block(device: Union[str, Device]) Optional[Device]

Blocks internet access to a device.

Parameters:

device – Takes device name or Device object as an argument.

Returns:

Returns the device object received from get_device_by_name() method.

Return type:

Device

create_snapshot() NoReturn

Creates a snapshot.json which is used to determine the known and unknown devices.

run(block: bool = False) NoReturn

Trigger to initiate a Network Scan and block the devices that are not present in snapshot.json file.

Helper

netsec.modules.helper.notify(msg_dict: List[Dict[str, str]]) NoReturn

Send an email notification when there is a threat.

Parameters:

msg_dict – Dict message to be sent as template.

Models

class netsec.modules.models.DeviceStatus(value)

Device status strings for allow or block.

allow: str = 'Allow'
block: str = 'Block'
class netsec.modules.models.SupportedModules(value)

Supported modules are At&t and Netgear.

att: str = 'At&t'
netgear: str = 'Netgear'

Settings

class netsec.modules.settings.Config

Wrapper for all the environment variables.

blocked: PathLike = 'fileio/blocked.yaml'
gmail_pass: AnyStr = None
gmail_user: AnyStr = None
notification: PathLike = 'fileio/last_notify'
phone: AnyStr = None
recipient: AnyStr = None
router_pass: AnyStr = None
snapshot: PathLike = 'fileio/snapshot.json'

Indices and tables