Exemple #1
0
def dynamic_pcap():
    if request.method == 'POST':
        #temporarily store upload pcap file
        time = int(request.form['time'])

        ft = filter_dynamic.Dynamic_Filter(time=time)
        try:
            data_lists = ft.live_Capture(
            )  #[ARP_Collection, APR_Package, IP_Collection, IP_Package]
        except:
            sys.exit("no package detected")

        ARP_Collection = data_lists[0]
        APR_Package = data_lists[1]
        IP_Collection = data_lists[2]
        IP_Package = data_lists[3]

        #line chart for ARP DELTA Information
        pkt_line_ARP = XY(width=800, height=600, explicit_size=True)
        pkt_line_ARP.title = 'Time delta for ARP'
        for key, list in ARP_Collection.iteritems():
            pkt_line_ARP.add(key, list)
        chart_ARP_Delta = pkt_line_ARP.render()

        # line chart for ARP Package Information
        pkt_line_ARP = XY(width=800, height=600, explicit_size=True)
        pkt_line_ARP.title = 'Package Info for ARP'
        for key, list in APR_Package.iteritems():
            pkt_line_ARP.add(key, list)
        chart_ARP_Package = pkt_line_ARP.render()

        pkt_line_IP = XY(width=800, height=600, explicit_size=True)
        pkt_line_IP.title = 'Time delta for IP'
        for key, list in IP_Collection.iteritems():
            pkt_line_IP.add(key, list)
        chart_IP_Delta = pkt_line_IP.render()

        pkt_line_IP = XY(width=800, height=600, explicit_size=True)
        pkt_line_IP.title = 'Package Info for IP'
        for key, list in IP_Package.iteritems():
            pkt_line_IP.add(key, list)
        chart_IP_Package = pkt_line_IP.render()

        del ft
        html = """{} {} <br/> {} {}""".format(chart_ARP_Package,
                                              chart_ARP_Delta,
                                              chart_IP_Package, chart_IP_Delta)
        return html

    else:
        return current_app.send_static_file('dynamic.html')
Exemple #2
0
def static_pcap():
    if request.method == 'POST':
        #temporarily store upload pcap file
        print request
        traceFile = request.files['file']
        traceFile.save("temporary/temp_pcap_file.pcap")

        ft = filter_static.Static_Filter(
            fileName="temporary/temp_pcap_file.pcap")
        device_traffic_dict = ft.detect_Device()

        #line chart for individual device data sent historys
        pkt_line = XY(width=800, height=600, explicit_size=True)
        pkt_line.title = 'Device Package Curve'
        for key, list in device_traffic_dict.iteritems():
            pkt_line.add(key, list)
        chart = pkt_line.render()

        # bar chart for device data sent summary
        pkt_Bar = Bar(width=800, height=600, explicit_size=True)
        pkt_Bar.title = 'Device Package Sum'
        for key, list in device_traffic_dict.iteritems():
            zipped = map(sum, zip(*list))
            pkt_Bar.add(key, zipped[1])
        pkt_Bar = pkt_Bar.render()

        del ft
        html = """{} {}""".format(chart, pkt_Bar)
        return html

    else:
        return current_app.send_static_file('static.html')
Exemple #3
0
def generateGraph():
    '''
        Function that generates the graph which plots the traffic (packet
        size against time). This allows the client to monitor the traffic
        easily, hence improving the user experience while using the webpage.
        For future works, other properties of the packet object can also be
        plotted on the same axes for more detailed analyses and comparisons.
    '''
    # process pcap and create a pygal chart with packet sizes
    pkt_sizes = []
    cap = pyshark.FileCapture("trace/traffic.pcap", only_summaries=True)

    for packet in cap:  # for each packet in the pygal chart
        # create a point (X,Y) and add it to the list
        # X: the absolute time (in seconds) between the current packet and the first packet
        # Y: the length (in bytes) of the packet
        pkt_sizes.append((float(packet.time), int(packet.length)))

    # create pygal instance
    pkt_size_chart = XY(width=400,
                        height=300,
                        style=LightGreenStyle,
                        explicit_size=True)
    pkt_size_chart.title = 'PACKET SIZES OVER TIME'
    pkt_size_chart.x_title = 'Time (s)'
    pkt_size_chart.y_title = 'Packet Size (bytes)'

    # add points to chart and render html
    pkt_size_chart.add('Size', pkt_sizes)  # graph legend
    chart = pkt_size_chart.render().decode("utf-8")

    return chart
def plot(filename):
    pkt_arr = []
    cap = pyshark.FileCapture(filename, only_summaries=True)

    pkt_arr.append((1, 0.0))

    print(cap)
    for packet in cap:
        # Create a plot point where (x=protocol, y=bytes)
        pkt_arr.append((int(packet.no), float(packet.time)))

    print(pkt_arr)

    # Create pygal instance
    pkt_size_chart = XY(width=600,
                        height=400,
                        style=LightGreenStyle,
                        explicit_size=True)
    pkt_size_chart.title = 'Packets Analysis'

    pkt_size_chart.add('Time v/s No', pkt_arr)
    chart = pkt_size_chart.render()

    #print(chart)
    html = """{}""".format(chart)
    return html
Exemple #5
0
def captured_dynamic_pcap():
    if request.method == 'POST':
        traceFile = request.files['file']
        data_lists = json.load(traceFile)

        ARP_Collection = data_lists[0]
        APR_Package = data_lists[1]
        IP_Collection = data_lists[2]
        IP_Package = data_lists[3]

        # line chart for ARP DELTA Information
        pkt_line_ARP = XY(width=800, height=600, explicit_size=True)
        pkt_line_ARP.title = 'Time delta for ARP'
        for key, list in ARP_Collection.iteritems():
            pkt_line_ARP.add(key, list)
        chart_ARP_Delta = pkt_line_ARP.render()

        # line chart for ARP Package Information
        pkt_line_ARP = XY(width=800, height=600, explicit_size=True)
        pkt_line_ARP.title = 'Package Info for ARP'
        for key, list in APR_Package.iteritems():
            pkt_line_ARP.add(key, list)
        chart_ARP_Package = pkt_line_ARP.render()

        pkt_line_IP = XY(width=800, height=600, explicit_size=True)
        pkt_line_IP.title = 'Time delta for IP'
        for key, list in IP_Collection.iteritems():
            pkt_line_IP.add(key, list)
        chart_IP_Delta = pkt_line_IP.render()

        pkt_line_IP = XY(width=800, height=600, explicit_size=True)
        pkt_line_IP.title = 'Package Info for IP'
        for key, list in IP_Package.iteritems():
            pkt_line_IP.add(key, list)
        chart_IP_Package = pkt_line_IP.render()

        html = """{} {} <br/> {} {}""".format(chart_ARP_Package,
                                              chart_ARP_Delta,
                                              chart_IP_Package, chart_IP_Delta)
        return html

    else:
        return current_app.send_static_file('captured_dynamic.html')
def drawGraph():
    xy = XY(stroke=False)
    xy.title = 'Correlation'
    xy.add('A', [(0, 0), (.1, .2), (.3, .1), (.5, 1), (.8, .6), (1, 1.08),
                 (1.3, 1.1), (2, 3.23), (2.43, 2)])
    xy.add('B', [(.1, .15), (.12, .23), (.4, .3), (.6, .4), (.21, .21),
                 (.5, .3), (.6, .8), (.7, .8)])
    xy.add('C', [(.05, .01), (.13, .02), (1.5, 1.7), (1.52, 1.6), (1.8, 1.63),
                 (1.5, 1.82), (1.7, 1.23), (2.1, 2.23), (2.3, 1.98)])
    xy.render_to_png('mygraph.png')
    xy.render_in_browser()
Exemple #7
0
def plot(filename):
    pkt_sizes = []
    cap = pyshark.FileCapture(filename, only_summaries=True)
    for packet in cap:
        # Create a plot point where (x=time, y=bytes)
        pkt_sizes.append((float(packet.time), int(packet.length)))
    # Create pygal instance
    pkt_size_chart = XY(width=400, height=300, style=LightGreenStyle, explicit_size=True)
    pkt_size_chart.title = 'Packet Sizes'
    # Add points to chart and render chart html
    pkt_size_chart.add('Size', pkt_sizes)
    chart = pkt_size_chart.render()
    print(chart)
    html = """{}""".format(chart)
    return html 
def plot(filename):
    pkt_sizes = []
    cap = pyshark.FileCapture(filename, only_summaries=True)
    # cap = pyshark.FileCapture(filename)
    for packet in cap:

        #print(type(packet.time))
        l = float(packet.time)
        pkt_sizes.append((float(packet.start), float(packet.time)))

    pkt_size_chart = XY(width=600,
                        height=500,
                        style=LightGreenStyle,
                        explicit_size=True)
    pkt_size_chart.title = 'DNS response time'

    pkt_size_chart.add('Time', pkt_sizes)
    chart = pkt_size_chart.render()
    print(chart)
    html = """{}""".format(chart)
    return html