Ftp 使用Scapy获得重新组装的碎片

Ftp 使用Scapy获得重新组装的碎片,ftp,scapy,Ftp,Scapy,我是Scapy的新手,已经开始使用它来生成FTP流量 我的拓扑:Scapy->Server 我面临的问题是,服务器正在发送碎片数据包,我不知道如何处理它 我的代码: def getFTP(): global pkt mac = Ether(dst=dst, src=src) ip = IPv6(src=sip, dst=dip) s = TCP( sport=sport, dport=dport, flags='S', seq=100,

我是Scapy的新手,已经开始使用它来生成FTP流量

我的拓扑:Scapy->Server

我面临的问题是,服务器正在发送碎片数据包,我不知道如何处理它

我的代码:

def getFTP():
    global pkt

    mac = Ether(dst=dst, src=src)

    ip = IPv6(src=sip, dst=dip)

    s = TCP(
        sport=sport, dport=dport, flags='S', seq=100,
        options=[
            ('MSS', 1460), ('SAckOK', ''),
            ('Timestamp', (5693231, 0)),
            ('NOP', 1), ('WScale', 6)
        ]
    )

    print "sending SYN"

    p = srp(mac / ip / s, iface=eth)

    print "About to send ACK"

    a = p.seq + 1
srp一直在等待数据包,即使我以片段形式接收数据包

def send_auto_ack(packet):
    global pkt
    if packet.haslayer(IP):
            packet.show()
            pckt_src=packet[IP].dst
            pckt_dst=packet[IP].src
            mac=Ether(dst=packet[Ether].src, src=packet[Ether].dst)
            cal_ack=Get_tcp_seg_len(ip_type,packet)
            ip=ip_type(src=pckt_src, dst=pckt_dst)
            tcp=TCP(sport=packet[IP].dport,dport=packet[IP].sport,flags='A',seq=packet[IP].ack,ack=packet[IP].seq+cal_ack)
            packet=mac/ip/tcp
            sendp(packet,iface=eth)

def send_auto_fin_ack(packet):
    global pkt
    if packet.haslayer(IP) and (packet[TCP].flags== 4 or  packet[TCP].flags ==1 or packet[TCP].flags ==17):
            print "Inside auto fin ack subroutine"

            pckt_src=packet[IP].dst
            pckt_dst=packet[IP].src
            mac=Ether(dst=packet[Ether].src, src=packet[Ether].dst)
            cal_ack=Get_tcp_seg_len(ip_type,packet)
            ip=ip_type(src=pckt_src, dst=pckt_dst)          

            tcp=TCP(sport=packet[IP].dport,dport=packet[IP].sport,flags='FA',seq=packet[IP].ack,ack=cal_ack)
            packet=mac/ip/tcp
            sendp(packet,iface=eth)
            print "Sent 1 FIN ACK "
            return True
    return False
def getfullHTTP():
    global pkt
    mac=Ether(dst=dst, src=src)
    ip=ip_type(src=sip, dst=dip)
    s=TCP(sport=sport,dport=dport,flags='S',seq=100)
    p=srp1(mac/ip/s,iface=eth)
    print "Sent SYN"
    if p.haslayer(TCP):
            if ((p.getlayer(TCP).flags==0x12)):
                    print "Received SYN ACK"
                    data ='GET '+url+' HTTP/1.1 \r\nHost: '+dip+'\r\n\r\n'
                    a=p.seq+1
                    packet=TCP(sport=sport,dport=dport,flags='A',seq=101,ack=a)
                    final=mac/ip/packet
                    sendp(final,iface=eth)
                    print"Sent ACK"
                    packet=TCP(sport=sport,dport=dport,flags='PA',seq=101,ack=a)/data
                    final=mac/ip/packet
                    print final.show()
                    sendp(final,iface=eth)

                    print"Sent GET Request"

                    filter1 = "tcp port " +`dport`+" and dst host "+sip+" and src host "+dip+" and !icmp and !arp"
                    print filter1
                    a=sniff(iface=eth,filter=filter1,prn=send_auto_ack,stop_filter=send_auto_fin_ack)
                    #a.show()
                    #a[0].show()
                    if '200' in a[0][Raw].load:
                            print "200 OK is present"

                    else:
                            print "200 OK is not present"
                            tc_fail=1
            else:
                    tc_fail=1
    else:
            tc_fail=1