|
KSC Open API
Kaspersky Security Center API description
|
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.
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.
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()
|