]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
ipp2p: bittorrent commands
authorTomasz Tomkowiak <bloodman@gmail.com>
Tue, 26 Jan 2010 03:16:00 +0000 (06:16 +0300)
committerJan Engelhardt <jengelh@medozas.de>
Sun, 28 Feb 2010 16:25:49 +0000 (17:25 +0100)
After testing I decide to write my patch to bittorrent GET commands
from xt_ipp2p.c because old procedure is useless for modified and/or
private trackers.

BTW: info_hash may be 3rd argument, passkey (private trackers) may be
1st argument (or not) etc. so we need to search.

doc/changelog.txt
extensions/xt_ipp2p.c

index c1eda166d031369d38c58e3d4e3c687b0fa915c0..4761bea104c9a2392f53633879d270e7fdf75143 100644 (file)
@@ -1,6 +1,7 @@
 
 HEAD
 ====
+- ipp2p: updated bittorent command recognition
 
 
 Xtables-addons 1.23 (February 24 2010)
index 44c6573b7d07cd48164580c188745a051dc6e9fe..a94c2d2955a588aa540fb07a8eb0ef601b4f7b9d 100644 (file)
@@ -505,19 +505,18 @@ search_bittorrent(const unsigned char *payload, const unsigned int plen)
                if (payload[0] == 0x13)
                        if (memcmp(payload + 1, "BitTorrent protocol", 19) == 0)
                                return IPP2P_BIT * 100;
-
                /*
-                * get tracker commandos, all starts with GET /
-                * then it can follow: scrape| announce
-                * and then ?hash_info=
+                * Any tracker command starts with GET / then *may be* some file on web server
+                * (e.g. announce.php or dupa.pl or whatever.cgi or NOTHING for tracker on root dir)
+                * but *must have* one (or more) of strings listed below (true for scrape and announce)
                 */
                if (memcmp(payload, "GET /", 5) == 0) {
-                       /* message scrape */
-                       if (memcmp(payload + 5, "scrape?info_hash=", 17) == 0)
+                       if (HX_memmem(payload, plen, "info_hash=", 9) != NULL)
                                return IPP2P_BIT * 100 + 1;
-                       /* message announce */
-                       if (memcmp(payload + 5, "announce?info_hash=", 19) == 0)
+                       if (HX_memmem(payload, plen, "peer_id=", 8) != NULL)
                                return IPP2P_BIT * 100 + 2;
+                       if (HX_memmem(payload, plen, "passkey=", 8) != NULL)
+                               return IPP2P_BIT * 100 + 4;
                }
        } else {
                /* bitcomet encryptes the first packet, so we have to detect another