爱意满满的作品展示区。
faicker

分享自己写的两个 iptables module, http_redirect 和 xor

  •  
  •   faicker · Sep 2, 2017 · 3683 views
    This topic created in 3174 days ago, the information mentioned may be changed or developed.

    把以前学习 netfilter 时写的两个 module 发出来。

    http_redirect

    • 类似于 reject,不过是用的 http 302 重定向。
    • github 链接 ipt_httpredirect

    xor

    • 对指定的 tcp/udp 连接的 payload 用 key-byte 进行 xor 操作。
    • github 链接 ipt_xor

    感谢

    8 replies    2017-10-24 14:21:17 +08:00
    newworld
        1
    newworld  
       Sep 2, 2017
    顶贴 以示鼓励 哈哈哈
    faicker
        2
    faicker  
    OP
       Sep 4, 2017
    @newworld 谢谢
    muziling
        3
    muziling  
       Sep 4, 2017
    用了这个,是否输入 www.baidu.com 就能自动打开 www.bing.com
    faicker
        4
    faicker  
    OP
       Sep 4, 2017
    @muziling 可以,匹配了 www.baidu.com 后直接回个 302 response 做重定向到 www.bing.com
    类似于连接公共 WIFI 时,重定向到一个认证页面。不过这个可以用 TPROXY 模块。
    muziling
        5
    muziling  
       Sep 4, 2017
    @faicker
    tproxy 是这样用吗?
    iptables -t mangle -A PREROUTING -d [百度 IP] -p tcp -m tcp --dport 80 -j TPROXY --on-port 80 --on-ip [bing ip] --tproxy-mark 0x1/0x1
    faicker
        6
    faicker  
    OP
       Sep 4, 2017
    @muziling 不是,tproxy 是 ip 层面的,相当于可以修改目的 ip,目的端口,然后把这个包送过去。
    我的这个是 http 层面的。
    acess
        7
    acess  
       Oct 22, 2017
    有问题:没重算 checksum。
    如果和 nat 配合用就会出错,比如 TCP 重置、丢包之类的。
    faicker
        8
    faicker  
    OP
       Oct 24, 2017
    @acess
    是的。要考虑网卡是否能做 checksum,如果不能的话,就要自己计算。准备改为如果不是 CHECKSUM_PARTIAL,就计算 checksum。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5640 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 59ms · UTC 08:35 · PVG 16:35 · LAX 01:35 · JFK 04:35
    ♥ Do have faith in what you're doing.