Commit 35399eb8 by 钱炳权

test

parent 70b1d8e9
......@@ -25,3 +25,55 @@
2024-04-08 14:12:56.793 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 779 ms
2024-04-08 14:12:56.972 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer - Tomcat started on port(s): 8100 (http) with context path ''
2024-04-08 14:12:56.991 [main] INFO com.example.fuzzControll.FuzzControlApplication - Started FuzzControlApplication in 1.299 seconds (JVM running for 2.308)
2024-04-22 14:22:53.375 [main] INFO com.example.fuzzControll.FuzzControlApplication - Starting FuzzControlApplication using Java 11.0.6 on DESKTOP-GDSKRB2 with PID 33664 (D:\code\company\fuzz-backend\fuzz-backend\fuzzbackend\target\classes started by qian in D:\code\company\fuzz-backend\fuzz-backend\fuzzbackend)
2024-04-22 14:22:53.380 [main] INFO com.example.fuzzControll.FuzzControlApplication - The following 1 profile is active: "dev"
2024-04-22 14:22:54.237 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8100 (http)
2024-04-22 14:22:54.242 [main] INFO org.apache.catalina.core.StandardService - Starting service [Tomcat]
2024-04-22 14:22:54.242 [main] INFO org.apache.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.68]
2024-04-22 14:22:54.429 [main] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
2024-04-22 14:22:54.429 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 994 ms
2024-04-22 14:22:54.727 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.PortInUseException: Port 8100 is already in use
2024-04-22 14:22:54.728 [main] INFO org.apache.catalina.core.StandardService - Stopping service [Tomcat]
2024-04-22 14:22:54.738 [main] INFO o.s.b.a.l.ConditionEvaluationReportLoggingListener -
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2024-04-22 14:22:54.748 [main] ERROR o.s.b.diagnostics.LoggingFailureAnalysisReporter -
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 8100 was already in use.
Action:
Identify and stop the process that's listening on port 8100 or configure this application to listen on another port.
2024-04-22 15:18:57.017 [main] INFO com.example.fuzzControll.FuzzControlApplication - Starting FuzzControlApplication using Java 11.0.6 on DESKTOP-GDSKRB2 with PID 14372 (D:\code\company\fuzz-backend\fuzz-backend\fuzzbackend\target\classes started by qian in D:\code\company\fuzz-backend\fuzz-backend\fuzzbackend)
2024-04-22 15:18:57.019 [main] INFO com.example.fuzzControll.FuzzControlApplication - The following 1 profile is active: "dev"
2024-04-22 15:18:57.423 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8100 (http)
2024-04-22 15:18:57.428 [main] INFO org.apache.catalina.core.StandardService - Starting service [Tomcat]
2024-04-22 15:18:57.428 [main] INFO org.apache.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.68]
2024-04-22 15:18:57.468 [main] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
2024-04-22 15:18:57.468 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 429 ms
2024-04-22 15:18:57.630 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.PortInUseException: Port 8100 is already in use
2024-04-22 15:18:57.631 [main] INFO org.apache.catalina.core.StandardService - Stopping service [Tomcat]
2024-04-22 15:18:57.637 [main] INFO o.s.b.a.l.ConditionEvaluationReportLoggingListener -
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2024-04-22 15:18:57.643 [main] ERROR o.s.b.diagnostics.LoggingFailureAnalysisReporter -
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 8100 was already in use.
Action:
Identify and stop the process that's listening on port 8100 or configure this application to listen on another port.
......@@ -6,7 +6,7 @@ import com.example.fuzzControll.conf.KittyProperties;
public class CmdConstent {
static KittyProperties kittyProperties = (KittyProperties)SpringContextUtil.getBean("kittyProperties");
public static final String GET_FILE_NAME = "ls -h ";
public static final String DELETE_FILE = "sudo rm -r ";
public static final String DELETE_FILE = "rm -r ";
public static final String COUNT_FILE = "ls -l | grep \"^-\" | wc -l";
public static final String COUNT_DIR = "ls -l | grep \"^d\" | wc -l";
public static final String RUN_AFLNET = "afl-fuzz -d -i "+kittyProperties.getAflnetPath()+"aflnet/tutorials/live555/in-rtsp -o out-live8 " +
......
package com.example.fuzzControll.controller;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.service.GenerateMethodService;
......@@ -32,6 +34,7 @@ public class TestClassController {
ProtocolTemplateService protocolTemplateService;
@Autowired
VulnerabilityTypeService vulnerabilityTypeService;
/**
* 模板
*/
......@@ -39,52 +42,52 @@ public class TestClassController {
public AjaxResult protocolTemplate(@RequestBody TestEntity testEntity) {
try {
Map<String, List<String>> result = protocolTemplateService.generation(testEntity);
return AjaxResult.success(result==null?"模板文件生成未成功运行":result);
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error(e.getMessage());
return AjaxResult.success(result == null ? "模板文件生成未成功运行!第三方接口可能存在问题。" : result);
} catch (CmdException | FuzzException e) {
log.error(e.getDefaultMessage());
return AjaxResult.error("模板生成失败!系统存在问题。");
}
}
/**
*生成方法
* 生成方法
*/
@RequestMapping(value = "/generate", method = RequestMethod.POST)
public AjaxResult generate(@RequestBody TestEntity testEntity) {
try {
Map<String, List<String>> result = generateMethodService.generation(testEntity);
return AjaxResult.success(result==null?"生成方法未成功运行":result);
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("生成方法使用失败!");
return AjaxResult.success(result == null ? "生成方法未成功运行!第三方接口可能存在问题。" : result);
} catch (CmdException | FuzzException e) {
log.error(e.getDefaultMessage());
return AjaxResult.error("生成方法使用失败!系统存在问题。");
}
}
/**
*变异方法
* 变异方法
*/
@RequestMapping(value = "/mutation", method = RequestMethod.POST)
public AjaxResult mutation(@RequestBody TestEntity testEntity) {
try {
Map<String, List<String>> result = mutationService.generation(testEntity);
return AjaxResult.success(result==null?"mutationTest未成功运行":result);
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("mutationTest失败!");
return AjaxResult.success(result == null ? "mutationTest未成功运行!第三方接口可能存在问题。" : result);
} catch (CmdException | FuzzException e) {
log.error(e.getDefaultMessage());
return AjaxResult.error("mutationTest失败!系统存在问题。");
}
}
/**
*漏洞类型
* 漏洞类型
*/
@RequestMapping(value = "/vulnerabilityType", method = RequestMethod.POST)
public AjaxResult upload(@RequestBody TestEntity testEntity) {
try {
Map<String, List<String>> result = vulnerabilityTypeService.generation(testEntity);
return AjaxResult.success(result==null?"漏洞类型未成功运行":result);
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("漏洞类型测试失败!");
return AjaxResult.success(result == null ? "漏洞类型未成功运行!第三方接口可能存在问题。" : result);
} catch (CmdException | FuzzException e) {
log.error(e.getDefaultMessage());
return AjaxResult.error("漏洞类型测试失败!系统存在问题。");
}
}
}
package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.service.GenerateMethodService;
......@@ -21,10 +22,10 @@ public class GenerateMethodServiceImpl implements GenerateMethodService {
KittyProperties kitty;
@Override
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException {
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException, CmdException {
String cmd = parseParameters(testEntity);
if (cmd.isEmpty()) {
return null;
throw new FuzzException("cmd is null!");
}
return cmdTools.runProgramCmdAndResult(cmd);
}
......
......@@ -2,6 +2,7 @@ package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.MutationConstent;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.service.MutationService;
......@@ -23,10 +24,10 @@ class MutationServiceImpl implements MutationService {
@Override
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException {
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException, CmdException {
String cmd = parseParameters(testEntity);
if (cmd.isEmpty()) {
return null;
throw new FuzzException("cmd is null!");
}
return cmdTools.runProgramCmdAndResult(cmd);
}
......
......@@ -3,6 +3,7 @@ package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.ProtocolConstent;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.service.ProtocolTemplateService;
......@@ -23,9 +24,9 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
KittyProperties kitty;
@Override
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException {
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException, CmdException {
String cmd = parseParameters(testEntity);
if (cmd.isEmpty()) {
if (cmd == null || cmd.equals("")) {
throw new FuzzException("cmd is null!");
}
return cmdTools.runProgramCmdAndResult(cmd);
......@@ -124,12 +125,11 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
case "tcp"://have error
return tcpCmd(testEntity);
default:
log.error("未知协议![{}]", testEntity.getTestClassName());
return null;
//TODO testcase_dos/testcase_rpc/ftp_vuln_reproduce
throw new FuzzException("Unknown protocol!");
//TODO testcase_dos/testcase_rpc/ftp_vuln_reproduce
}
} catch (Exception e) {
throw new FuzzException("Count of params is not match!");
throw new FuzzException("Count of params is not match or unknown protocol!");
}
}
......
......@@ -35,7 +35,7 @@ public class SeedFileServiceImpl implements SeedFileService {
cmdTools.runCmd(CmdConstent.DELETE_FILE + properties.getSeedPath() + "/" + fileName, "delFile");
fileCountAfter = getSeedFileCount("delFile after.");
if (fileCountAfter == fileCountBefore) {
throw new CmdException("Delete unsuccess ! The file has not changed .Attempt to change permissions.");
throw new CmdException("Delete unsuccess ! The file has not changed .Attempt to change permissions or there is no filr to be deleted.");
}
}
......
package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.service.VulnerabilityTypeService;
......@@ -20,8 +21,11 @@ public class VulnerabilityTypeServiceImpl implements VulnerabilityTypeService {
KittyProperties kitty;
@Override
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException {
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException, CmdException {
String cmd = parseParameters(testEntity);
if (cmd.isEmpty()) {
throw new FuzzException("cmd is null!");
}
return cmdTools.runProgramCmdAndResult(cmd);
}
......
......@@ -60,7 +60,7 @@ public class CmdTools {
* 运行需要后台运行cmd
* 将数据存入文件中
*/
public Map<String, List<String>> runProgramCmdAndResult(String cmd) throws FuzzException {
public Map<String, List<String>> runProgramCmdAndResult(String cmd) throws CmdException {
Map<String, List<String>> result = new HashMap();
List<String> out = Collections.synchronizedList(new ArrayList<String>());
List<String> error = Collections.synchronizedList(new ArrayList<String>());
......@@ -70,15 +70,15 @@ public class CmdTools {
printMessageByProgramCmd(process.getErrorStream(), error);
process.waitFor();
} catch (Exception e) {
log.error("aflnet run error!");
throw new FuzzException("run fuzz error !");
e.printStackTrace();
throw new CmdException("run fuzz error !");
}
result.put("out", out);
result.put("error", error);
return result;
}
private List<String> printMessageByProgramCmd(final InputStream input, final List<String> result) throws InterruptedException {
private List<String> printMessageByProgramCmd(final InputStream input, final List<String> result) {
new Thread(new Runnable() {
@Override
public void run() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment