def mutate(self, packets): numseg = self.numseg position = self.position # Not enough segments, Syn or Ack, return if ( utils.check_length(numseg, packets) or utils.check_syn(packets[numseg - 1]) or utils.check_ack(packets[numseg - 1]) ): return packets forged = packets[numseg - 1].copy() forged = utils.tcp_bad_payload(forged) # calculate and modify chksum forged.chksum = scapy.checksum(forged) + 1 """il frammento manipolato dovrebbe essere preso per buono da snort -k notcp ma scartato da host vittima. """ # insert forged segment if position == "after": packets.insert(numseg, forged) elif position == "before": packets.insert(numseg - 1, forged) # last position is for original packet, not the forged one!!!! elif position == "last": packets.append(packets[numseg - 1]) del (packets[numseg - 1]) packets.insert(numseg - 1, forged) return packets
def mutate(self, packets): result = [] numseg = self.numseg timer = self.timer #Not enough segments, Syn or Ack, return if utils.check_length(numseg, packets) or utils.check_syn(packets[numseg-1]) or utils.check_ack(packets[numseg-1]): return packets forged = packets[numseg-1].copy() forged = utils.tcp_bad_payload(forged, utils.NOPAYLOAD) forged.flags = 'R' #calculate and modify chksum forged.chksum = scapy.checksum(forged)+1 packets.insert(numseg-1, forged) packets[numseg].timeout = timer return packets