如何使用 ping 发送消息?
How to send a message with ping?
据我所知,Ping 命令使用 ICMP 请求
那么是否可以直接从命令行使用 ping 命令发送短文本?
ping -p pattern
呢?请记住,并非所有 ping
版本都支持 -p
选项。
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.
例如ping -p 486920686572652e www.example.com
,这里是 486920686572652e = 你好。
#!/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])
也许这段代码对某人有帮助
据我所知,Ping 命令使用 ICMP 请求
那么是否可以直接从命令行使用 ping 命令发送短文本?
ping -p pattern
呢?请记住,并非所有 ping
版本都支持 -p
选项。
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.
例如ping -p 486920686572652e www.example.com
,这里是 486920686572652e = 你好。
#!/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])
也许这段代码对某人有帮助