Giter Club home page Giter Club logo

bpl's Introduction

BPL - Binary Processing Language

Build Status Go Report Card GitHub release Coverage Status GoDoc

快速入门

了解 BPL 最快的方式是学习 qbpl 和 qbplproxy 两个实用程序:

qbpl

qbpl 可用来分析任意的文件格式。使用方法如下:

qbpl [-p <protocol>.bpl -o <output>.log] <file>

多数情况下,你不需要指定 -p <protocol>.bpl 参数,我们根据文件后缀来确定应该使用何种 protocol 来解析这个文件。例如:

qbpl 1.gif

不过为了让 qbpl 能够找到所有的 protocols,我们需要先安装:

make install # 这将将所有的bpl文件拷贝到 ~/.qbpl/formats/

qbplproxy

qbplproxy 可用来分析服务器和客户端之间的网络包。它通过代理要分析的服务,让客户端请求自己来分析请求包和返回包。使用方式如下:

qbplproxy -h <listenIp:port> -b <backendIp:port> [-p <protocol>.bpl -f <filter> -o <output>.log]

其中,<listenIp:port> 是 qbplproxy 自身监听的IP和端口,<backendIp:port> 是原始的服务。-f <filter> 是过滤条件,这个条件通过 BPL_FILTER 全局变量传递到 bpl 中。

多数情况下,你不需要指定 -p <protocol>.bpl 参数,qbplproxy 程序可以根据你监听的端口来猜测网络协议。例如:

mongod --port 37017
qbplproxy -h localhost:27017 -b localhost:37017

我们会依据端口 27017 知道你要分析的是 mongodb 的网络协议。

BPL 文法

请参见 BPL 文法

网络协议研究

RTMP 协议

格式描述:

测试:

  1. 启动一个 rtmp server,让其监听 1936 端口(而不是默认的 1935 端口)。比如我们可以用 node-rtsp-rtmp-server
git clone [email protected]:iizukanao/node-rtsp-rtmp-server.git
cd node-rtsp-rtmp-server
修改 config.coffee,将:
  * rtmpServerPort: 1935 改为 rtmpServerPort: 1936;
  * serverPort: 80 改为 serverPort: 8080(这样就不用 sudo 来运行了)
coffee server.coffee
  1. 启动 qbplproxy:
qbplproxy -h localhost:1935 -b localhost:1936 -p formats/rtmp.bpl | tee rtmp.log
  1. 推流:
ffmpeg -re -i test.m4v -c:v copy -c:a copy -f flv rtmp://localhost/live/123
  1. 播流:

在 Mac 下可以考虑用 VLC Player,打开网址 rtmp://localhost/live/123 进行播放即可。

  1. 选择性查看

有时候我们并不希望看到所有的信息,rtmp.bpl 支持以 flashVer 作为过滤条件。如:

qbplproxy -f 'flashVer=LNX 9,0,124,2' -h localhost:1935 -b localhost:1936 -p formats/rtmp.bpl | tee <output>.log

或者我们直接用 reqMode(用来区分是推流publish还是播流play) 来过滤。如:

qbplproxy -f 'reqMode=play' -h localhost:1935 -b localhost:1936 -p formats/rtmp.bpl | tee <output>.log

这样就可以只捕获 VLC Player 的播流过程了。

当然,其实还有一个不用过滤条件的办法:就是让推流直接推到 rtmp server,但是播流请求发到 qbplproxy。

FLV 协议

格式描述:

测试:

  1. 启动一个 rtmp/flv server,让其监听 1935/8135 端口。

  2. 启动 qbplproxy:

qbplproxy -h localhost:8888 -b localhost:8135 -p formats/flv.bpl | tee flv.log
  1. 推流:
ffmpeg -re -i test.m4v -c:v copy -c:a copy -f flv rtmp://localhost/live/123
  1. 播流:

在 Mac 下可以考虑用 VLC Player,打开网址 http://localhost:8888/live/123.flv 进行播放即可。

WebRTC 协议

格式描述:

MongoDB 协议

格式描述:

测试:

  1. 启动 MongoDB,让其监听 37017 端口(而不是默认的 27017 端口):
./mongod --port 37017 --dbpath ~/data/db
  1. 启动 qbplproxy:
qbplproxy -h localhost:27017 -b localhost:37017 -p formats/mongo.bpl | tee mongo.log
  1. 使用 MongoDB,比如通过 mongo shell 操作:
./mongo

文件格式研究

MongoDB binlog 格式

TODO

MySQL binlog 格式

TODO

HLS TS 格式

格式描述:

测试:TODO

FLV 格式

格式描述:

测试:TODO

MP4 格式

格式描述:

测试:

qbpl -p formats/mp4.bpl <example>.mp4

GIF 格式

格式描述:

测试:

qbpl -p formats/gif.bpl formats/1.gif

bpl's People

Contributors

dependabot[bot] avatar xushiwei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bpl's Issues

wuffs?

Google 前一阵子也搞了一个相当类似的东西,也是 Go 实现的,这个项目除了集成 qlang 之外还有什么优势?(比如学习曲线之类?)

不可变 let?

spec 里 let x = y 总能成功,不够函数式,可能导致写出 bug 而不自知。

参考一些其他语言,加入一旦赋值就不可改变的 let 绑定如何?没有看具体实现,也许实现上做进 qlang 会更好。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.