How to send a message with ping?
Asked Answered
M

2

13

The Ping command uses an ICMP request as far as I know

So is it possible to send a short text with the ping command right from commandline?

Malina answered 6/8, 2015 at 13:42 Comment(0)
E
17

What about ping -p pattern? Keep in mind that not all of versions of ping support -p option.

You may specify up to 16 ''pad'' bytes to fill out the packet you send. This is useful for diagnosing data-dependent problems in a network. For example, -p ff will cause the sent packet to be filled with all ones.

E.g. ping -p 486920686572652e www.example.com, where 486920686572652e = Hi here.

Einhorn answered 6/8, 2015 at 13:50 Comment(1)
I saw the text decoded in wireshark on my other pc, so it worksMalina
M
5
#!/bin/python3
import sys, subprocess
text = sys.argv[1]
target = sys.argv[2]
if len(text)>16:
    print("Text too long!")
    exit()
enctext = r''.join( hex(ord(c)).split("x")[1] for c in text )
subprocess.check_output(["ping", "-p", enctext, "-c", "1", target])

Maybe this piece of code is helpful for somebody

Malina answered 6/8, 2015 at 14:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.