Пример #1
0
def filter(data):
    flag =True;
    uri =data['uri']
    if not filter_uri(uri):
        flag=False;
        send_log.log_error("not match uri %s" % uri)     
    return flag;
Пример #2
0
def send_request(request):
    try:
        response = urllib2.urlopen(request)
        code = response.getcode()
        send_log.log_debug("response code %s" % code)
        if (code == 302):
            redirect_url = response.geturl()
            send_log.log_info("redirect to %s" % redirect_url)
            redirect_request = urllib2.Request(redirect_url)
            response = urllib2.urlopen(redirect_request)
        #print code
    except Exception, e:
        error_str = "send request exception ,%s" % e
        send_log.log_error(error_str)
        pass
Пример #3
0
def main_pcap(p_time, p_data, local_ip, port, resent_ip, count):
    p = dpkt.ethernet.Ethernet(p_data)
    if p.type == dpkt.ethernet.ETH_TYPE_IP:
        ip_data = p.data
        src_ip = '%d.%d.%d.%d' % tuple(map(ord, list(ip_data.src)))
        dst_ip = '%d.%d.%d.%d' % tuple(map(ord, list(ip_data.dst)))
        if ip_data.p == dpkt.ip.IP_PROTO_UDP:
            udp_data = p.data.data
            if udp_data.data:
                try:
                    send_log.log_info("get data: %s" % udp_data.data)
                    data = eval(udp_data.data)
                    httpsend.wapper_httpsend(data, resent_ip, count)
                except Exception, e:
                    error_str = "Capture src_ip %s:local_ip %s:dst_ip %s:exception: %s" % (
                        src_ip, local_ip, dst_ip, e)
                    send_log.log_error(error_str)
                    pass
Пример #4
0
def start():
    if (len(sys.argv) < 3):
        capture_nc = send_config.getConfig("config", 'nc')
        if (not capture_nc):
            print "error not have network card info"
            send_log.log_error("error not have network card info")
            sys.exit(1)
        resent_ip = send_config.getConfig("config", 'resent_ip')
        if (not resent_ip):
            print "error not have resent ip info"
            send_log.log_error("error not have resent ip info")
            sys.exit(1)
        print "Start sender sever network card: %s resent ip: %s" % (
            capture_nc, resent_ip)
        send_log.log_info("Start sender sever network card: %s resent ip: %s" %
                          (capture_nc, resent_ip))
        count = send_config.getConfig("config", 'count')
        port = send_config.getConfig("config", 'port')
        if (count):
            if (port):
                capture_udp.capture(capture_nc, resent_ip, count, int(port))
            else:
                capture_udp.capture(capture_nc, resent_ip, count)
        else:
            capture_udp.capture(capture_nc, resent_ip)
    else:
        capture_nc = sys.argv[1]
        resent_ip = sys.argv[2]
        print "Start sender sever network card: %s resent ip: %s" % (
            capture_nc, resent_ip)
        if (len(sys.argv) == 4):
            count = sys.argv[3]
            capture_udp.capture(capture_nc, resent_ip, count)
        elif (len(sys.argv) == 5):
            count = sys.argv[3]
            port = sys.argv[4]
            capture_udp.capture(capture_nc, resent_ip, count, port)
        else:
            capture_udp.capture(capture_nc, resent_ip)