线上的一个应用,没对外宣传,但似乎有黑客在探测密码了. docker 启动的 mysql,看控制台标准输出,一直在这样,是在暴力破解密码吗?:
2017-11-21T06:09:41.804288Z 122 [Note] Access denied for user 'root'@'121.207.227.164' (using password: YES)
database_1 | 2017-11-21T06:09:43.610338Z 123 [Note] Access denied for user 'root'@'121.207.227.164' (using password: YES)
我已经加过过滤器了,如下:
import javax.servlet.*; import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Enumeration;
/** * / @WebFilter(filterName="sqlAttackFilter",urlPatterns="/") public class SqlAttackFilter implements Filter { @Override public void destroy() { }
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest req=(HttpServletRequest)request;
HttpServletResponse res=(HttpServletResponse)response;
//获得所有请求参数名
Enumeration params = req.getParameterNames();
String sql = "";
while (params.hasMoreElements()) {
//得到参数名
String name = params.nextElement().toString();
//System.out.println("name===========================" + name + "--");
//得到参数对应值
String[] value = req.getParameterValues(name);
for (int i = 0; i < value.length; i++) {
sql = sql + value[i];
}
}
//有 sql 关键字,跳转到 error.html
if (sqlValidate(sql)) {
throw new IOException("--------------------->never put in illegal code");
//String ip = req.getRemoteAddr();
} else {
chain.doFilter(request,response);
}
}
//效验
protected static boolean sqlValidate(String str) {
str = str.toLowerCase();//统一转为小写
String badStr = "'|and|exec|execute|insert|select|delete|update|count|drop|*|%|chr|mid|master|truncate|" +
"char|declare|sitename|net user|xp_cmdshell|;|or|-|+|,|like'|and|exec|execute|insert|create|drop|" +
"table|from|grant|use|group_concat|column_name|" +
"information_schema.columns|table_schema|union|where|select|delete|update|order|by|count|*|" +
"chr|mid|master|truncate|char|declare|or|;|-|--|+|,|like|//|/|%|#";//过滤掉的 sql 关键字,可以手动添加
String[] badStrs = badStr.split("\\|");
for (int i = 0; i < badStrs.length; i++) {
if (str.indexOf(badStrs[i]) >= 0) {
return true;
}
}
return false;
}
@Override
public void init(FilterConfig config) throws ServletException {
}
}
我想知道他是在用什么方式搞的,有什么应对办法?
1
86322989 OP 他的 ip 一直都在变,应该是控制了很多肉鸡.
看物理地址都是内地各省的. 另外,mysql 应该是默认只能 localhost 连接的. 唯一的可能就是 sql 注入了,但我过滤了啊,求告知 |
2
wafm 2017-11-21 14:47:18 +08:00
二次验证,验证码 可以缓解一下
|