线上的一个应用,没对外宣传,但似乎有黑客在探测密码了. 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 {
}
}
我想知道他是在用什么方式搞的,有什么应对办法?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.