Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
:param target: IP or hostname of the remote device
:type target: str
:param payload_provider: An iterable list of payloads to send
:type payload_provider: PayloadProvider
:param timeout: Timeout that will apply to all ping messages, in seconds
:type timeout: int
:param socket_options: Options to specify for the network.Socket
:type socket_options: tuple
:param seed_id: The first ICMP packet ID to use
:type seed_id: Union[None, int]
:param verbose: Flag to enable verbose mode, defaults to False
:type verbose: bool
:param output: File where to write verbose output, defaults to stdout
:type output: file"""
self.socket = network.Socket(target, 'icmp', source=None, options=socket_options)
self.provider = payload_provider
self.timeout = timeout
self.responses = ResponseList(verbose=verbose, output=output)
self.seed_id = seed_id
if self.seed_id is None:
self.seed_id = os.getpid() & 0xFFFF
:param out: Stream to which redirect the verbose output
:type out: stream
:return: List with the result of each ping
:rtype: executor.ResponseList"""
provider = payload_provider.Repeat(b'', 0)
if size and size > 0:
if not payload:
payload = random_text(size)
provider = payload_provider.Repeat(payload, count)
elif sweep_start and sweep_end and sweep_end >= sweep_start:
if not payload:
payload = random_text(sweep_start)
provider = payload_provider.Sweep(payload, sweep_start, sweep_end)
options = ()
if df:
options = network.Socket.DONT_FRAGMENT
comm = executor.Communicator(target, provider, timeout, socket_options=options, verbose=verbose, output=out)
comm.run()
return comm.responses