(WebInfo wi,String strcontent)
| 329 | * 匹配包头信息和服务器html信息,获取服务器名和服务器版本 |
| 330 | * */ |
| 331 | public static void strName(WebInfo wi,String strcontent) throws IOException { |
| 332 | if(!strcontent.isEmpty()){ |
| 333 | BufferedReader br =new BufferedReader(new InputStreamReader(new ByteArrayInputStream(strcontent.getBytes(Charset.forName("utf-8"))))); |
| 334 | String line; |
| 335 | String[] items; |
| 336 | StringBuffer strbuf = new StringBuffer(); |
| 337 | while ((line = br.readLine())!=null){ |
| 338 | String reg = "Server:\\s(\\D*)(\\s|\\/|\\*)(.*)"; |
| 339 | String reg1 = "Server:\\s(\\D*)"; |
| 340 | String[] result =RegCheck(line,reg); |
| 341 | if(result.length>0){ |
| 342 | //System.out.println("result.length:"+result.length); |
| 343 | wi.http_server = result[1]; |
| 344 | wi.http_server_version = result[3]; |
| 345 | if(wi.http_server==null){ |
| 346 | wi.http_server=""; |
| 347 | } |
| 348 | if(wi.http_server.contains("*")){ |
| 349 | wi.http_server = ""; |
| 350 | wi.isServerCrypto = true; |
| 351 | } |
| 352 | } |
| 353 | if(line.contains("Set-Cookie")){ |
| 354 | String[] arr=line.split(":",2); |
| 355 | for(String str:arr){ |
| 356 | if(!str.equals("Set-Cookie")){ |
| 357 | wi.set_Cookie = str; |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | if(line.contains("X-Powered-By")){ |
| 362 | String[] arr=line.split(":",2); |
| 363 | for(String str:arr){ |
| 364 | if(!str.equals("X-Powered-By")){ |
| 365 | wi.X_Powered_By= str; |
| 366 | } |
| 367 | } |
| 368 | } |
| 369 | // //检测主体中的服务器版本信息 |
| 370 | if (matcherChar(line, "Apache")&&wi.http_server.isEmpty()){ |
| 371 | wi.http_server = "Apache"; |
| 372 | } |
| 373 | if (matcherChar(line, "Nginx")&&wi.http_server.isEmpty()){ |
| 374 | wi.http_server = "Nginx"; |
| 375 | } |
| 376 | if (matcherChar(line, "Lighttpd ")&&wi.http_server.isEmpty()){ |
| 377 | wi.http_server = "Lighttpd"; |
| 378 | } |
| 379 | if (matcherChar(line, "IIS ")&&wi.http_server.isEmpty()){ |
| 380 | wi.http_server = "IIS "; |
| 381 | } |
| 382 | if (matcherChar(line, "WebSphere")&&wi.http_server.isEmpty()){ |
| 383 | wi.http_server = "WebSphere"; |
| 384 | } |
| 385 | if (matcherChar(line, "Weblogic")&&wi.http_server.isEmpty()){ |
| 386 | wi.http_server = "WebSphere"; |
| 387 | } |
| 388 | if (matcherChar(line, "Boa")&&wi.http_server.isEmpty()){ |
no test coverage detected