判断webserver服务器
识别逻辑: 通过构造错误404页面的返回值识别
protected HttpURLRequest requests = new HttpURLRequest();
//通过404判断webSERVER
try {
String page404 = requests.url("http://"+this.target.concat("/asdasdsad")).get().body();
for (WEBServer web : WEBServer.values()) {
if (!web.getKeywords().isEmpty())
{
if (StringUtils.containsAny(page404,web.getKeywords().toArray(new String[]{}))){
task.getResult().getSystemInfo().setWebServer(web);
}
}
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
public enum WEBServer {
RESIN("Resin"),
IIS8("class=\"content-container\"><fieldset>"),
IIS6("go.microsoft.com/fwlink/?linkid="),
IIS7("Internet Information Services 7","background-color:#555555;}","<h3>您要查找的资源可能已被删除","<div id=\"header\"><h1>服务器错误</h1></div>"),
NGINX("nginx/"),
TOMCAT("Apache Tomcat"),
APACHE("The requested URL","Apache/"),
WEBLOGIC("Hypertext Transfer Protocol","From RFC 2068","unavailable and has no forwarding address"),
OTHER;
private List<String> keywords = new ArrayList<>();
WEBServer() {
}
WEBServer(String ... text) {
for (String s : text) {
keywords.add(s);
}
}
public List<String> getKeywords() {
return keywords;
}
}