BusinessUnit Module

Purpose of BusinessUnit

The BusinessUnit object is the backbone of portscan, it structures the data needed for a business unit to exist, handles reading of input, creates ScanObjects, handles concurrency of scans, and parses output.

Using BusinessUnit

Most modules while callable by the user are integrated into BusinessUnit. An example workflow is given below.

from portscan import BusinessUnit

# create a BusinessUnit object with required arugments
BU = BusinessUnit.BusinessUnit('test_Business', '.')

# populate data structures by reading in config files
BU.ReadPorts()
BU.ReadBase()

# Trigger the nmap scans
BU.Scan()

# Collect all nmap data and write to file
BU.Collect()

BusinessUnit methods

class portscan.businessunit.BusinessUnit(p_name, p_path, p_verbose='', p_org='')
__init__(p_name, p_path, p_verbose='', p_org='')

BusinessUnit Class Constructor.

Variables:
  • businessUnit – (string) Description: BusinessUnit name
  • path – (string) Description: Path to top-level config directory
  • verbose – (string) Description: Verbose information provided to BusinessUnit
  • org – (string) Description: Organization the BusinessUnit belongs to
  • machineCount – (int) Description: The number of unique hosts being scanned
  • emails – (list) Description: List of emails read from the {}.conf file
  • stats – (dict) Dictionary of stats generated by the scan
  • outfile – (string) Description: Path to generated report
CheckDeps()

Private Method that depends on self.path existing in the object.

Collect(buisness_path='')

Calls ParseOutput to collect all output into a readable csv. Generates HTML Generation and Uploading to DropBox.

ParseOutput(buisness_path='')

Parse and assemble human readable csv report of all nmap results.

ReadBase()

Parse and store networks, subnets, ranges, and individual IP’s for scanning from ports_baseline_{business_unit}.conf.

ReadPorts()

Parse and store general ports from ports_bad_{business_unit}.

Scan()

Execute scanning commands held in ScanObjects. Uses forking and waits on PID returns.