V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
ywgx
V2EX  ›  程序员

看到有网友分享吐槽云上网络带宽资源的问题,也反馈一个短信资源情况

  •  
  •   ywgx · 2018-05-13 10:17:33 +08:00 · 1615 次点击
    这是一个创建于 2168 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我这边接触到的短信服务,有类似情况,实在不理解,那些不断变更请求源 IP,变更电话号码刷短信资源的,他们动机是什么?

    我唯一能想到的就是经济利益,还是有点不可思议啊

    不知道有没有遇到同样情况的?

    目前我这边解决方法也非常简单实用:OpenResty + Redis 解决

    1. 获取请求源 IP 和 POST 数据
    2. 对上面 POST 数据(内包含电话号码信息),17200s 超过 5 次,返回 403,Redis 记录过期时间
    3. 对上面源 IP 记录 Redis,比如 86400s 超过 128 次(主要考虑校园网这种统一出口,太小有误拦截,大部分请求在上面 POST 信息就拦截了),返回 403,Redis 记录过期时间
    local redis = require "resty.redis"
    local cache = redis.new()
    cache.connect(cache,'127.0.0.1','6379')
    local resp_body = ngx.req.get_body_data() or "-"
    local headers=ngx.req.get_headers()  
    local ip=headers["X-REAL-IP"] or headers["X_FORWARDED_FOR"] or ngx.var.remote_addr or "-"
    function split( _str, seperator)    
        local pos, arr = 0, {}    
        for st, sp in function() return string.find( _str, seperator, pos, true ) end do    
          table.insert(arr, string.sub(_str, pos, st-1 ))    
          pos = sp + 1    
        end    
        table.insert(arr, string.sub( _str, pos))    
        return arr    
    end   
    if string.find(resp_body,"phone") then
            cache:incr(resp_body)
            cache:expire(resp_body,17200)
            if tonumber(cache:get(resp_body)) > 4 then
                    ngx.exit(403)
            end
    end
    local sip = split(ip,",")[1]
    if split(sip,".")[1] == "10" then
            return
    end
    cache:incr(sip)
    cache:expire(sip,86400)
    if tonumber(cache:get(sip)) > 128 then
            ngx.exit(403)
    end
    return
    
    4 条回复    2018-05-14 08:54:15 +08:00
    floopy
        1
    floopy  
       2018-05-13 10:23:08 +08:00 via iPhone
    加个机器识别技弄个验证码输错 3 次或者请求验证码页面次数过多直接 iptables 封杀半小时。个人建议轻喷 233
    gamexg
        2
    gamexg  
       2018-05-13 10:42:29 +08:00
    短信轰炸
    Event
        3
    Event  
       2018-05-13 10:45:28 +08:00
    做短信轰炸器的人抓的吧
    opengps
        4
    opengps  
       2018-05-14 08:54:15 +08:00
    用别人的资源,免费做短信轰炸。
    以前乘坐 xx 打车的时候,有个司机看着像是待过局子似的。对一个乘客骂骂咧咧,说是某宝 10 块钱轰炸多少条
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2587 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 01:42 · PVG 09:42 · LAX 18:42 · JFK 21:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.