Protocon是一个以套接字为中心的框架,通过简单的发送和接收脚本快速构建连接。
项目描述
Protocon是一个以套接字为中心的框架,通过简单的发送和接收命令快速构建连接。类似于socat,具有美观的十六进制输出和更多发送/接收自动化控制。
安装
Protocon需要Python 3.4+,可以通过pip命令安装:python3 -m pip install protocon。
示例用法
手动模式
启动Protocon需要一个target_url参数,它描述要打开的套接字类型和连接到的端点。Protocon将切换到交互式控制台,其中包含各种发送和接收数据的命令。
user@localhost:~$ ./protocon tcp://github.com:22 [*] Loaded 4 connection drivers [+] Initialized protocon engine v1.0 at 2017-12-22 08:13:09 [+] Connected to: tcp://github.com:22 pro > # this is a comment pro > # next we're going to receive all the data we can read in 1 second pro > recv_time 1 [*] RX: 22 bytes (CRC: 0xd533) 0000 53 53 48 2d 32 2e 30 2d 6c 69 62 73 73 68 5f 30 SSH-2.0-libssh_0 0010 2e 37 2e 30 0d 0a .7.0.. pro > exit
脚本模式
启动Protocon时,可以指定一个或多个包含命令的资源文件,并将按顺序执行。
user@localhost:~$ ./protocon udp://8.8.8.8:53 examples/dns_query.txt [*] Loaded 4 connection drivers [+] Initialized protocon engine v1.0 at 2017-12-22 08:26:28 [+] Connected to: udp://8.8.8.8:53 encoding - was: utf-8 now: hex [*] TX: 55 bytes (CRC: 0xa139) 0000 37 49 01 20 00 01 00 00 00 00 00 01 03 77 77 77 7I. .........www 0010 06 67 6f 6f 67 6c 65 03 63 6f 6d 00 00 01 00 01 .google.com..... 0020 00 00 29 10 00 00 00 00 00 00 0c 00 0a 00 08 4e ..)............N 0030 c1 3b 36 79 86 a5 d5 .;6y... [*] RX: 59 bytes (CRC: 0x5210) 0000 37 49 81 80 00 01 00 01 00 00 00 01 03 77 77 77 7I...........www 0010 06 67 6f 6f 67 6c 65 03 63 6f 6d 00 00 01 00 01 .google.com..... 0020 c0 0c 00 01 00 01 00 00 00 57 00 04 ac d9 06 e4 .........W...... 0030 00 00 29 02 00 00 00 00 00 00 00 ..)........ [*] The connection has been closed
有关资源文件的更多示例,请参阅示例目录。
target_url 示例
ether://eth0/?type=0x86dd&src=00:0c:29:84:05:fd&dst=33:33:00:00:00:01 null: serial:///dev/ttyUSB0?baudrate=9600&bytesize=8&parity=N&stopbits=1 ssl://1.2.3.4:123 ssl4://5.6.7.8:567 ssl6://[fe80::800:27ff:fe00:10]:4444/?ip6-scope-id=eth0 tcp://1.2.3.4:123 tcp4://0.0.0.0:123/?type=server tcp6://[fe80::800:27ff:fe00:10]:4444/?ip6-scope-id=eth0 udp://1.2.3.4:123 udp4://1.2.3.4:123/?size=8192
数据扩展
用户传递的数据(如 send 和 recv_until 命令的参数)将使用基本转义序列进行展开。此外,这些序列可以通过在前面加上 \ 来转义。
序列 |
描述 |
---|---|
\\ |
字面反斜杠 |
\n |
换行 |
\r |
回车 |
\t |
制表符 |
\x00 |
字面字节 0x00 |
${var} |
名为 var 的变量 |
变量
展开支持使用 ${var} 插入的变量。以下变量是自动定义的。
变量名 |
描述 |
---|---|
url.host |
URL的主机部分 |
url.password |
URL的密码部分 |
url.port |
URL的端口号部分 |
url.scheme |
URL的方案部分 |
url.username |
URL的用户名部分 |
致谢
Spencer McIntyre - zeroSteiner (@zeroSteiner)
项目详情
关闭
protocon-1.4.0.tar.gz 的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 16297ec86a7e4899f320e14afadd7d638130dfd16268f39754040328f1af33bc |
|
MD5 | 2fb7b007024be872e47c0af91dfada9e |
|
BLAKE2b-256 | a423e6ce513c3f8910c08c6c93ec8b9aa154bd5565b4ffa9e0e64725ab51c7e1 |