KSC Open API
Kaspersky Security Center API description
int ScanDiapasons::AddDiapason ( params  pInfo,
[out] params  pInvalidIntervals 
)

Add new diapason with specified attributes.

Adds new diapason with the specified attributes (see List of network diapason attributes). Error occurs if at least one of intervals/subnet intersects with any of existing intervals/subnets. Following attributes are required.

  • "KLDPNS_DN"
  • "KLDPNS_LF"
  • "KLDPNS_ScanEnabled"
  • "KLDPNS_ILS"

If at least one of diapasons intersects with any of existing diapasons or is invalid then 0 is returned and such interval is added to "KLDPNS_ILS" array in pInvalidIntervals.

Parameters:
pInfo(params) container with diapason attributes (see List of network diapason attributes)
[out]pInvalidIntervals(params) Intervals which were not added to diapason due to intersections or if they were invalid
Returns:
(int) id of new diapason
See also:
List of network diapason attributes

See also Python code with use of KlAkOAPI Python package below:

            server = KlAkOAPI.AdmServer.KlAkAdmServer.Create("https://ksc.example.com:13299", "username", "password")
            oScanDiapasons = KlAkOAPI.ScanDiapasons.KlAkScanDiapasons(server)
            strSubnet = "172.17.14.0/24"
            vecStrings = strSubnet.split('/')
            # convert subnet
            nMaskBits = int(vecStrings[1])
            nMask = socket.htonl((0xffffffff << (32 - nMaskBits)) & 0xffffffff)
            nIp = int.from_bytes(socket.inet_aton(vecStrings[0]), byteorder='little')
            nIp &= nMask
            # prepare params
            oPars = KlAkOAPI.Params.KlAkParams({})
            oPars.AddString("KLDPNS_DN", 'MyTestSubnet')
            oPars.AddArray("KLDPNS_ILS", [KlAkOAPI.Params.paramParams({"KLDPNS_IL_ISSUBNET": True, "KLDPNS_IL_MASKORLOW": KlAkOAPI.Params.paramInt(nMask), "KLDPNS_IL_SUBNETORHI": KlAkOAPI.Params.paramInt(nIp)})])
            oPars.AddInt("KLDPNS_LF", 3600*8)
            oPars.AddBool("KLDPNS_ScanEnabled", False)
            # add subnet
            idDiapason = oScanDiapasons.AddDiapason(oPars).RetVal()
            
See also:
Sample. Creating ip subnets based on AD Site and Services.