Ejemplo n.º 1
0
import pymongo

from netaddr import *
from collections import deque
from net_functions import *
from find_route import findRouteIPTable, findRouteEIGRP

import common
import backend
import config
import time

db = pymongo.Connection(config.db_host, config.db_port)[config.db_name]
collection = db["snmp_raw"]
timestamp = sorted(collection.distinct("timestamp"), reverse=True)[0]

for router in collection.find({"type": "ipCidrRoute", "timestamp": timestamp}).distinct("ip_src"):
	findRouteIPTable(router, ip2int("0.0.0.0"))

gateways = collection.find({"type": "ipCidrRoute", "ip_dst": 0, "timestamp": timestamp}).distinct("ip_gtw")
gateways = set(gateways)

gateways_found = set()
for gateway in gateways:
	if collection.find({"ipAdEntAddr": gateway}).count() > 0:
		gateways_found.add(gateway)
gateways -= gateways_found

for gateway in gateways:
	print int2ip(gateway)
Ejemplo n.º 2
0
begin = time.time()
last = begin

f = open('check_report.txt', 'w')

f_not_found = open('flows_not_found.txt', 'w')
f_incoming = open('flows_incoming.txt', 'w')
f_outgoing = open('flows_outgoing.txt', 'w')
f_intra = open('flows_intra.txt', 'w')
f_forward = open('flows_forward.txt', 'w')
f_invisible = open('flows_invisible.txt', 'w')

for flow in result[0]:
	
	ip_table = findRouteIPTable((flow["sourceIPv4Address"]), (flow["destinationIPv4Address"]), observationPoint = ["130.198.1.1", "130.198.1.2"], verbose = True, useDefaultGatewayIncoming = "130.198.1.1", useDefaultGatewayOutgoing = True)
	if ip_table > 0:
		kind = "this text is not supposed to be ever printed"
		if ip_table == 1:
			routes_invisible = routes_invisible + 1
			f_invisible.write("%s -> %s (intra)\n" % (int2ip(flow["sourceIPv4Address"]), int2ip(flow["destinationIPv4Address"])))
			kind = "intra"
		elif ip_table == 3:
			routes_invisible = routes_invisible + 1
			f_invisible.write("%s -> %s (incoming)\n" % (int2ip(flow["sourceIPv4Address"]), int2ip(flow["destinationIPv4Address"])))
			kind = "incoming"
		elif ip_table == 4:
			routes_invisible = routes_invisible + 1
			f_invisible.write("%s -> %s (outgoing)\n" % (int2ip(flow["sourceIPv4Address"]), int2ip(flow["destinationIPv4Address"])))
			kind = "outgoing"
		elif ip_table == 6: