예제 #1
0
def readFile(hostFile):
	#ns= {'xmlns':"http://schemas.microsoft.com/powershell/2004/04"}
	#open switch list file for reading
	tree = ET.parse(hostFile)
	root = tree.getroot()
	output = []
	structure=root.findall('structure/section')
	source=None
	destin=None
	protocol=None
	packet = root.findall('packet')
	for sec in packet:
		secelem=sec.findall('section')
		if (tools.isNotEqual('ARP',secelem[4].text) and  tools.isNotEqual('LLMNR',secelem[4].text) and tools.isNotEqual('DHCPv6',secelem[4].text) and tools.isNotEqual('ICMPv6',secelem[4].text)):
			output.append((secelem[2].text,secelem[3].text,secelem[4].text ))
	return output
예제 #2
0
def getPortNames(hostFile):
    #open switch list file for reading
    ns = {
        'xmlns': "http://www.iana.org/assignments",
        'id': "service-names-port-numbers"
    }
    tree = ET.parse(hostFile)
    root = tree.getroot()
    output = dict()
    ports = root.findall('xmlns:record', ns)
    for p in ports:
        protocol = nameSpaceFilter('xmlns:protocol', p, ns)
        description = nameSpaceFilter('xmlns:description', p, ns)
        number = nameSpaceFilter('xmlns:number', p, ns)
        name = nameSpaceFilter('xmlns:name', p, ns)
        if (tools.isNotEqual(number, '0') and name != None and number != None):
            output[(number, protocol)] = name
    return output
예제 #3
0

#pprint(set(readFile("..\\data\\wireshark\\goteborg-test.xml")))
#pprint(set(readFile("..\\data\\wireshark\\summary-packets_fixed.xml")))

data = parse_and_remove(
    "F:\\ongoingWork\\ModBusCaps\\unzipped\\converted\\packets_00001_20161115135616.xml",
    'packet/section')

counter = 0
newS = set()
for d in data:
    src = d[0]
    dst = d[1]
    proto = d[2]
    if (tools.isNotEqual('ARP', proto) and tools.isNotEqual('LLMNR', proto)
            and tools.isNotEqual('DHCPv6', proto)
            and tools.isNotEqual('ICMPv6', proto)):
        newS.add(tuple(d))
        counter += 1
print(len(newS))
pprint(newS)
print('All', counter)

####################################################################################################
###Writing the file
####################################################################################################


def store(sourceName, scope, sourceIP, nodeName, data, hash, date, client):
    checkStart = client['metaelement'].fetchByExample(