git ssb

0+

cel / sslh



Commit 66f85dc608a67e113b5436f258a8b1b27bfc13c4

Merge pull request #51 from cernekee/adb

Add builtin handler for Android Debug Bridge (ADB) protocol
yrutschle committed on 6/10/2015, 7:26:55 AM
Parent: 7c35ef8528d47b97894a6495275b57dc1ae3f8c7
Parent: 3469f56012c5311187dbded8d102d1a11ec4cf3c

Files changed

probe.cchanged
probe.cView
@@ -32,8 +32,9 @@
3232 static int is_tinc_protocol(const char *p, int len, struct proto*);
3333 static int is_xmpp_protocol(const char *p, int len, struct proto*);
3434 static int is_http_protocol(const char *p, int len, struct proto*);
3535 static int is_tls_protocol(const char *p, int len, struct proto*);
36+static int is_adb_protocol(const char *p, int len, struct proto*);
3637 static int is_true(const char *p, int len, struct proto* proto) { return 1; }
3738
3839 /* Table of protocols that have a built-in probe
3940 */
@@ -45,8 +46,9 @@
4546 { "xmpp", NULL, NULL, is_xmpp_protocol },
4647 { "http", NULL, NULL, is_http_protocol },
4748 { "ssl", NULL, NULL, is_tls_protocol },
4849 { "tls", NULL, NULL, is_tls_protocol },
50+ { "adb", NULL, NULL, is_adb_protocol },
4951 { "anyprot", NULL, NULL, is_true }
5052 };
5153
5254 static struct proto *protocols;
@@ -223,8 +225,24 @@
223225 */
224226 return p[0] == 0x16 && p[1] == 0x03 && ( p[2] >= 0 && p[2] <= 0x03);
225227 }
226228
229+static int is_adb_protocol(const char *p, int len, struct proto *proto)
230+{
231+ if (len < 30)
232+ return PROBE_AGAIN;
233+
234+ /* The initial ADB host->device packet has a command type of CNXN, and a
235+ * data payload starting with "host:". Note that current versions of the
236+ * client hardcode "host::" (with empty serialno and banner fields) but
237+ * other clients may populate those fields.
238+ *
239+ * We aren't checking amessage.data_length, under the assumption that
240+ * a packet >= 30 bytes long will have "something" in the payload field.
241+ */
242+ return !memcmp(&p[0], "CNXN", 4) && !memcmp(&p[24], "host:", 5);
243+}
244+
227245 static int regex_probe(const char *p, int len, struct proto *proto)
228246 {
229247 regex_t **probe = proto->data;
230248 regmatch_t pos = { 0, len };

Built with git-ssb-web