Exemplo n.º 1
0
    def getPlotData(self, plottype, plotfilename, doubleaxis, converty,
                    converty2, normalized, desvest):
        exdata = ExtractData(plottype, plotfilename, doubleaxis, desvest)
        #xdata, ydata, xdata2, ydata2
        plotdata = exdata.get_data()

        #print("convert; ", converty, " ", converty2)

        #TODO: smoothing data

        if converty:
            for i in range(len(plotdata[1])):
                plotdata[1][i] = np.array(
                    plotdata[1][i]).astype(float) * float(converty)

        if converty2:
            for i in range(len(plotdata[3])):
                plotdata[3][i] = np.array(
                    plotdata[3][i]).astype(float) * float(converty2)

        if normalized == "Normalized by max":
            for i in range(len(plotdata[1])):
                maxvalue = max(plotdata[1][i])
                for j in range(len(plotdata[1][i])):
                    plotdata[1][i][j] = plotdata[1][i][j] / maxvalue
        elif normalized == "Normalized by first":
            for i in range(len(plotdata[1])):
                firstvalue = plotdata[1][i][0]
                for j in range(len(plotdata[1][i])):
                    plotdata[1][i][j] = plotdata[1][i][j] / firstvalue

        return plotdata
Exemplo n.º 2
0
def main():
    print("Please enter Company Number")
    companyNumberInput = input()
    searchCompanyByNumber = SearchCompanyByNumber()
    companyNumberSearchResult = searchCompanyByNumber.searchByCompanyNumber(companyNumberInput)
    dataExtractedFromCompanyNumberSearchResult = ExtractData()
    extractedData = dataExtractedFromCompanyNumberSearchResult.extractInformationFromCompanyNumberSearch(companyNumberSearchResult)
    print(extractedData)
Exemplo n.º 3
0
def callback(header, data):
    src_ip = None
    dst_ip = None
    src_port = None
    dst_port = None
    layer4Type = ""
    output = ""
    payloadSize = 0
    extract = ExtractData()

    # Parse packet
    decoder = ImpactDecoder.EthDecoder()
    packet = decoder.decode(data)

    # Parse IP packet inside ethernet one
    iphdr = packet.child()

    if isinstance(iphdr, IP):
        # Parse TCP packet inside IP one
        hdr = iphdr.child()

        if isinstance(hdr, TCP) or isinstance(hdr, UDP):
            if isinstance(hdr, TCP):
                layer4Type = "TCP"
                # Only look at SYN packets, not ACK ones
                if hdr.get_SYN() and not hdr.get_ACK():
                    # Get src and dest IPs
                    src_ip = iphdr.get_ip_src()
                    dst_ip = iphdr.get_ip_dst()
                    src_port = hdr.get_th_dport()
                    dst_port = hdr.get_th_sport()
                    payloadSize = hdr.get_size() - hdr.get_header_size()
            elif isinstance(hdr, UDP):
                layer4Type = "UDP"
                # Get src and dest IPs
                src_ip = iphdr.get_ip_src()
                dst_ip = iphdr.get_ip_dst()
                src_port = hdr.get_th_dport()
                dst_port = hdr.get_th_sport()
                payloadSize = hdr.get_size() - hdr.get_header_size()

                # Results are printed
            output = "(%s) Connection attempted from: %s:%s to: %s:%s\n" % (
                layer4Type,
                src_ip,
                src_port,
                dst_ip,
                dst_port,
            )
            if payloadSize != 0:
                output += "\nPayload size: %d\n----%s----\n----\n" % (payloadSize, hdr.get_data_as_string())
            print output

        if src_ip and dst_ip:
            extract.writeToFile("packetOutput.txt", output, "a")
    else:
        print "\nIP header doesn't exist.\n"
        iphdr = None
Exemplo n.º 4
0
def callback(header, data):
    src_ip = None
    dst_ip = None
    src_port = None
    dst_port = None
    layer4Type = ""
    output = ""
    payloadSize = 0
    extract = ExtractData()

    #Parse packet
    decoder = ImpactDecoder.EthDecoder()
    packet = decoder.decode(data)

    #Parse IP packet inside ethernet one
    iphdr = packet.child()

    if isinstance(iphdr, IP):
        #Parse TCP packet inside IP one
        hdr = iphdr.child()

        if isinstance(hdr, TCP) or isinstance(hdr, UDP):
            if isinstance(hdr, TCP):
                layer4Type = "TCP"
                #Only look at SYN packets, not ACK ones
                if hdr.get_SYN() and not hdr.get_ACK():
                    #Get src and dest IPs
                    src_ip = iphdr.get_ip_src()
                    dst_ip = iphdr.get_ip_dst()
                    src_port = hdr.get_th_dport()
                    dst_port = hdr.get_th_sport()
                    payloadSize = hdr.get_size() - hdr.get_header_size()
            elif isinstance(hdr, UDP):
                layer4Type = "UDP"
                #Get src and dest IPs
                src_ip = iphdr.get_ip_src()
                dst_ip = iphdr.get_ip_dst()
                src_port = hdr.get_th_dport()
                dst_port = hdr.get_th_sport()
                payloadSize = hdr.get_size() - hdr.get_header_size()

            #Results are printed
            output = "(%s) Connection attempted from: %s:%s to: %s:%s\n" % (
                layer4Type, src_ip, src_port, dst_ip, dst_port)
            if (payloadSize != 0):
                output += "\nPayload size: %d\n----%s----\n----\n" % (
                    payloadSize, hdr.get_data_as_string())
            print output

        if (src_ip and dst_ip):
            extract.writeToFile("packetOutput.txt", output, "a")
    else:
        print "\nIP header doesn't exist.\n"
        iphdr = None
Exemplo n.º 5
0
from extractdata import ExtractData

extract = ExtractData()
extract.runAttack()