jump to navigation

หยุด bittorent ด้วย Linux firewall January 26, 2009

Posted by admin in : Linux, บทความ , trackback

utorrent

การบล็อค Bittorrent ในตอนนี้สามารถที่จะเป็นไปได้แล้ว ด้วยการใช้ IpTables และ Rope

เครื่อง Client ที่ใช้ Bittorrent อาจจะใช้โปรแกรมของค่ายต่าง ๆ ที่ประกอบด้วย : the original “Bittorrent”, ABC, Azureus, BitManager, eDonkey2000, Rufus, BitComet, BitLord, BitSpirit, BitTornedo, Burst!, G3 Torrent, Shareza, TorrentStorm, XBT Client, Bits on wheels, Tomato Torrent, ctorrent, Qtorrent and rtorrent โดยรายละเอียดของ Client เหล่านี้สามารถดูได้ที่

http://a.scarywater.net/torrent/clients/
หรือ ที่นี่ครับ.

ในการควบคุมทราฟฟิกจะขึ้นอยู่กับนโยบายของคุณ  คุณอาจจะต้องการบ่งชี้ (identify) ทราฟฟิกของเครือข่ายเมื่อมีคนใช้ Bittorrent ดาวน์โหลดหนัง, TV episodes, และ album tracks ฯลฯ ด้วยการจำกัด (restrict) หรือไม่ก็บล็อคหรือเสริมด้วยการใช้ QoS หรือ rules  โดย IpTables และ Rope บน Linux นั้นได้จัดให้มีเครือมือสำหรับการบล็อคการดาวน์โหลดโดยใช้ Bittorrent ตามนโยบายขององค์กรของคุณตามที่ต้องการ
ซึ่ง Bittorrent Protocol สามารถที่จะถูกบ่งชี้ (identified) ได้ง่าย (การประยุกต์ QoS policies, ลิ้นบังคับ : throttle,หรือการบันทึก log ของทรากฟิกหรือด้วยการบล็อกทั้งหมด) ด้วยการใช้ IpTables, Scriptable Rope match module และสคริปต์ Bittorrent.rope  เมื่อได้ติดตั้ง Rope ไว้ใน Linux kernel แ้ล้ว ก็สามารถใช้สคริปต์ค้นหาโปรโตคอล Bittorrent ด้วยการตรวจสอบแพ็กเก็ต TCP/IP แบบละเอียด, การบ่งชี้แพ็กเก็ตสองชนิดที่แตกต่าง (distinct packet) โดยอาศัยข้อมูลที่บรรจุมา
กฎของ IpTables จำเป็นต้องใ้ช้ลอจิกต่อไปนี้บน Linux Firewall

iptables -A FORWARD -p tcp -m rope –script bittorrent -j DROP

ข้อมูลของ Rope ที่ประกอบด้วยการดาวน์โหลด  การติดตั้งโมดูลและการใ้ช้งานสคริปท์ สามารถดูได้จาก http://www.lowth.com/rope/Rope  ส่วนข้อมูล IpTables ดูได้จาก http://www.netfilter.org/  และสคริปต์ของ bittorrent.rope ดูได้จาก http://www.lowth.com/rope/attach/BlockingBittorrent/bittorrent.rope

เราจะจำแนกหรือรู้จักโปรโตคอลได้อย่างไร
โปรโตคอลจะมีการ setup packet ในรูปแบบคล้ายกับรูปต่อไปนี้ (there’s a binary dump of this in the file bittorrent.pkt1.bin).

0×0000    4500   006c   40b4   4000   8006   4506   c0a8   0066                 E..l@.@…E….f
0×0010    c41e   efa4   0729    1ae2  b65b   7e40   bc89  e335                 …..)…[~@…5
0×0020    5019   ffff       cf93     0000  1342    6974   546f   7272                 P……..BitTorr
0×0030    656e   7420   7072    6f74   6f63    6f6c     0000   0000                 ent.protocol….
0×0040    0000   0000   9f42     6ffd    f801    3595    2350   0ed8                 …..Bo…5.#P..
0×0050    7aae  aae8   5c54    8c45  2d41   5a32   3230   302d                z…\T.E-AZ2200-
0×0060    7a59   5044   324e    644f   5852   784e                                      zYPD2NdOXRxN

สคริปต์ bittorrent.rope บ่งชี้ (identify) แพ็กเก็ตอันนี้ด้วยการพิสูจน์ (verifying) ต่อไปนี้

  • The data starts with the hex character 0×13
  • Then comes the string “BitTorrent protocol”
  • Then 8 null characters
  • Then 20 characters we dont check
  • Then 20 “printable” (non-space) characters
  • Then the end of the packet.
  • ชนิดของแพ็กเก็ตอันที่สองถูกใช้สำหรับการเิริ่มต้น (initiate) ดาวน์โหลดซึ่งจะคล้ายกับรูปถัดไป (there’s a dump of this one in bittorrent.pkt2.bin).

    0×0000   4500  011e  5aa4  4000  8006   fd67  c0a8  0066      E…Z.@….g…f
    0×0010   43a9  9d16  0821   1f92  d3ec  1a63  2d74  9795     C….!…..c-t..
    0×0020   5018  ffff      94f3    0000  4745  5420  2f73   6372      P…….GET./scr
    0×0030   6170  653f   696e   666f   5f68   6173  683d  2539     ape?info_hash=%9
    0×0040   4642  6f25   4644   2546  3825  3031  3525  3935      FBo%FD%F8%015%95
    0×0050   2532  3350  2530   4525  4438  7a25  4145  2541     %23P%0E%D8z%AE%A
    0×0060   4125  4538  2535   4354  2538  4345  2048  5454     A%E8%5CT%8CE.HTT
    0×0070   502f   312e  310d   0a55 7365  722d  4167  656e     P/1.1..User-Agen
    0×0080   743a  2041  7a75   7265 7573  2032  2e32  2e30     t:.Azureus.2.2.0
    0×0090   2e30  0d0a  4163   6365 7074  2d45  6e63  6f64     .0..Accept-Encod
    0×00a0   696e  673a  2067   7a69 700d  0a48 6f73    743a    ing:.gzip..Host:
    0×00b0   2074  7261  6e73   616d 7269  742e  6e65  743a    .transamrit.net:
    0×00c0   3830  3832  0d0a   4163 6365  7074  3a20  7465     8082..Accept:.te
    0×00d0   7874  2f68   746d   6c2c 2069  6d61  6765  2f67     xt/html,.image/g
    0×00e0   6966  2c20  696d   6167 652f   6a70  6567  2c20    if,.image/jpeg,.
    0×00f0    2a3b  2071  3d2e   322c 202a  2f2a  3b20  713d    *;.q=.2,.*/*;.q=
    0×0100   2e32  0d0a  436f    6e6e 6563  7469  6f6e  3a20    .2..Connection:.
    0×0110   6b65  6570  2d61   6c69 7665  0d0a  0d0a              keep-alive….

     

    สคริปต์ี้บ่งชี้ (identify) แพ็กเก็ตอันนี้โดยใช้กฎเกณฑ์ดังต่อไปนี้ :

    The data starts with “GET /” followed by “scrape” or “announce”.
    -Next comes the string “?info_hash=”.
    -The end of the first text line in the packet contains “HTTP/1.1″
    -The string “Accept-Encoding: gzip” is found later in the packet
    -The packet ends with the string “\r\n\r\n”.
    -All characters in the data payload are “ASCII” ones (as defined by isascii).

    ดาวน์โหลดไฟล์
    ดาวน์โหลดไฟล์ได้จาก 3 link ต่อไปนี้

    ดาวน์โหลดไฟล์
    ดาวน์โหลดไฟล์ได้จาก 3 link ต่อไปนี้

    ### ผมเชื่อว่าหลายองค์กรน่าจะเจอปัญหาในการโหลด บิตของเหล่าพนักงานจอมดาวโหลดทั้งหลาย ถ้ายังไง admin ก็ลองนำไปทดลองดูนะครับ ###

    ชอชอบคุณบทความดีๆจาก http://www.itwizard.info 

    แบ่งปันข่าวสารให้เพื่อนๆ:
    • Digg
    • Google
    • Facebook
    • Technorati
    • Live
    • TwitThis
    • YahooMyWeb

    Comments

    Sorry comments are closed for this entry