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

2018-05-13 10:17:33 +08:00
 ywgx

我这边接触到的短信服务,有类似情况,实在不理解,那些不断变更请求源 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
1662 次点击
所在节点    程序员
4 条回复
floopy
2018-05-13 10:23:08 +08:00
加个机器识别技弄个验证码输错 3 次或者请求验证码页面次数过多直接 iptables 封杀半小时。个人建议轻喷 233
gamexg
2018-05-13 10:42:29 +08:00
短信轰炸
Event
2018-05-13 10:45:28 +08:00
做短信轰炸器的人抓的吧
opengps
2018-05-14 08:54:15 +08:00
用别人的资源,免费做短信轰炸。
以前乘坐 xx 打车的时候,有个司机看着像是待过局子似的。对一个乘客骂骂咧咧,说是某宝 10 块钱轰炸多少条

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/454418

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX