def __init__(self, **kwargs): if not kwargs: # Just for getting Help. return self.all_fields = kwargs try: self.protocol = self.all_fields['protocol'] except KeyError: self.protocol = "ip" # Defualt L3 protocol. dst = self.all_fields['dst'] if is_v6(dst): self.protocol = "ipv6" try: proto = self.all_fields['proto'] except KeyError as err: print(err, "Must specify proto.") if 'dst' in list(self.all_fields.keys()): self.all_fields['dst'] = str(self.all_fields['dst']) self.l2 = self._eth_header() if self.protocol == 'ip': self.l3 = self._ip_header() elif self.protocol == 'ipv6': self.l3 = self._ip6_header() if proto == 'tcp': self.l4 = self._tcp_header() elif proto == 'udp': self.l4 = self._udp_header() elif proto == 'icmp': self.l4 = self._icmp_header()
def start(self): sport = self.profile.stream.l4.sport self.client = TCPClient(self, sport, debug=5) table = 'ip6tables' if is_v6( self.profile.stream.l3.src) else 'iptables' # Kernal will send RST packet during TCP hand shake before the scapy # sends ACK, So drop RST packets sent by Kernal os.system('%s -A OUTPUT -p tcp --tcp-flags RST RST -s %s -j DROP' % (table, self.profile.stream.l3.src)) # DO TCP Three way Hand Shake self.client.runbg() if isinstance(self.profile, ContinuousSportRange): self.clients = self.start_clients() self._start()
def start(self): sport = self.profile.stream.l4.sport self.client = TCPClient(self, sport, debug=5) table = 'ip6tables' if is_v6(self.profile.stream.l3.src) else 'iptables' # Kernal will send RST packet during TCP hand shake before the scapy # sends ACK, So drop RST packets sent by Kernal os.system( '%s -A OUTPUT -p tcp --tcp-flags RST RST -s %s -j DROP' % (table, self.profile.stream.l3.src)) # DO TCP Three way Hand Shake self.client.runbg() if isinstance(self.profile, ContinuousSportRange): self.clients = self.start_clients() self._start()
def __init__(self, **kwargs): if not kwargs: # Just for getting Help. return self.all_fields = kwargs try: self.protocol = self.all_fields['protocol'] except KeyError: self.protocol = "ip" # Defualt L3 protocol. dst = self.all_fields['dst'] if is_v6(dst): self.protocol = "ipv6" try: proto = self.all_fields['proto'] except KeyError, err: print err, "Must specify proto."