def test_count_repeater(self): repeater = CountRepeater(count=5, sleep_time=self.SLEEP_TIME) connection = MockCountConnection() target = Target(connection, repeater=repeater) target.send(b"This is a test") self.assertEqual(repeater.count, connection.count) self.assertGreaterEqual(connection.second - connection.first, self.SLEEP_TIME) with self.assertRaises(ValueError): CountRepeater(count=0)
def test_time_repeater(self): repeater = TimeRepeater(duration=0.05, sleep_time=self.SLEEP_TIME) connection = MockTimeConnection() target = Target(connection, repeater=repeater) target.send(b"This is a test") self.assertLessEqual(connection.last - connection.first, repeater.duration) self.assertGreaterEqual(connection.second - connection.first, self.SLEEP_TIME) with self.assertRaises(ValueError): TimeRepeater(duration=0)
def main(): arguments = setup_argparse() if arguments.original: data = get_original__pck(arguments.protocol) elif arguments.path: data = get_crashing_pck(arguments.path) else: print("You have to specify a path to the packet to be send or choose to send an original packet") sys.exit() if arguments.host and arguments.port: target = Target( connection=SocketConnection(arguments.host, arguments.port, proto='tcp')) session = Session(target=target, check_data_received_each_request=True, keep_web_open=False) target.open() target.send(data) target.close() else: sendp(data, iface="lo")