Commit 13284f0d by 钱炳权

24/4/2 reconsitution

parent 4f11b8a8
...@@ -14,6 +14,15 @@ public class kittyProperties { ...@@ -14,6 +14,15 @@ public class kittyProperties {
String statsHttp; String statsHttp;
String stagesHttp; String stagesHttp;
String reportHttp; String reportHttp;
String mutationPath;
public String getMutationPath() {
return mutationPath;
}
public void setMutationPath(String mutationPath) {
this.mutationPath = mutationPath;
}
public String getTemplateInfoHttp() { public String getTemplateInfoHttp() {
return templateInfoHttp; return templateInfoHttp;
......
package com.example.fuzzControll.constents;
public class mutationConstent {
public static final String GET_FILE_NAME = "ls -h ";
}
...@@ -7,6 +7,9 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -7,6 +7,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/**
* kitty服务器信息
*/
@RestController @RestController
@RequestMapping("/kittyServer") @RequestMapping("/kittyServer")
public class kittyServerMessageController { public class kittyServerMessageController {
......
package com.example.fuzzControll.controller;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.service.getServerMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/mutation")
public class mutationController {
@Autowired
getServerMessageService getServerMessageService;
@RequestMapping(value = "/mutation", method = RequestMethod.POST)
public AjaxResult getStats() {
try {
return AjaxResult.success(getServerMessageService.getStats());
} catch (Exception e) {
return AjaxResult.error("mutationTest失败!");
}
}
}
package com.example.fuzzControll.controller;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.testEntity;
import com.example.fuzzControll.service.protocolTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/protocolTemplate")
public class protocolTemplatController {
@Autowired
protocolTemplateService protocolTemplateService;
/**
* seeFileUpload
*/
@RequestMapping(value = "/generation", method = RequestMethod.POST)
public AjaxResult upload(@RequestBody testEntity testEntity) {
try {
return AjaxResult.success(protocolTemplateService.generation(testEntity));
} catch (Exception e) {
return AjaxResult.error("模板文件生成失败!");
}
}
}
...@@ -11,6 +11,9 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -11,6 +11,9 @@ import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
/**
* aflnet种子文件
*/
@RestController @RestController
@RequestMapping("/seedFile") @RequestMapping("/seedFile")
public class seedFileController { public class seedFileController {
......
...@@ -4,35 +4,73 @@ import com.example.fuzzControll.pojo.vo.AjaxResult; ...@@ -4,35 +4,73 @@ import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.testEntity; import com.example.fuzzControll.pojo.vo.testEntity;
import com.example.fuzzControll.service.generateMethodService; import com.example.fuzzControll.service.generateMethodService;
import com.example.fuzzControll.service.getServerMessageService; import com.example.fuzzControll.service.getServerMessageService;
import com.example.fuzzControll.service.protocolTemplateService;
import com.example.fuzzControll.service.vulnerabilityTypeService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/**
* 不同类型的测试方法
*/
@RestController @RestController
@RequestMapping("/testClass") @RequestMapping("/testClass")
public class testClassController { public class testClassController {
@Autowired @Autowired
generateMethodService service; generateMethodService generateMethodService;
@Autowired @Autowired
getServerMessageService getServerMessageService; getServerMessageService getServerMessageService;
@Autowired
protocolTemplateService protocolTemplateService;
@Autowired
vulnerabilityTypeService vulnerabilityTypeService;
/**
* 模板
*/
@RequestMapping(value = "/protocolTemplate", method = RequestMethod.POST)
public AjaxResult protocolTemplate(@RequestBody testEntity testEntity) {
try {
return AjaxResult.success(protocolTemplateService.generation(testEntity));
} catch (Exception e) {
return AjaxResult.error("模板文件生成失败!");
}
}
/**
*生成方法
*/
@RequestMapping(value = "/generate", method = RequestMethod.POST) @RequestMapping(value = "/generate", method = RequestMethod.POST)
public AjaxResult upload(@RequestBody testEntity testEntity) { public AjaxResult generate(@RequestBody testEntity testEntity) {
try { try {
return AjaxResult.success(service.generation(testEntity)); return AjaxResult.success(generateMethodService.generation(testEntity));
} catch (Exception e) { } catch (Exception e) {
return AjaxResult.error("变异方法使用失败!"); return AjaxResult.error("变异方法使用失败!");
} }
} }
/**
*变异方法
*/
@RequestMapping(value = "/mutation", method = RequestMethod.POST) @RequestMapping(value = "/mutation", method = RequestMethod.POST)
public AjaxResult getStats() { public AjaxResult mutation() {
try { try {
return AjaxResult.success(getServerMessageService.getStats()); return AjaxResult.success(getServerMessageService.getStats());
} catch (Exception e) { } catch (Exception e) {
return AjaxResult.error("mutationTest失败!"); return AjaxResult.error("mutationTest失败!");
} }
} }
/**
*漏洞类型
*/
@RequestMapping(value = "/vulnerabilityType", method = RequestMethod.POST)
public AjaxResult upload(@RequestBody testEntity testEntity) {
try {
return AjaxResult.success(vulnerabilityTypeService.generation(testEntity));
} catch (Exception e) {
return AjaxResult.error("漏洞类型测试失败!");
}
}
} }
...@@ -9,6 +9,9 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -9,6 +9,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/**
* aflnet测试控制
*/
@RestController @RestController
@RequestMapping("/test") @RequestMapping("/test")
public class testControler { public class testControler {
......
package com.example.fuzzControll.controller;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.testEntity;
import com.example.fuzzControll.service.vulnerabilityTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/vulnerabilityType")
public class vulnerabilityTypeController {
@Autowired
vulnerabilityTypeService service;
@RequestMapping(value = "/generate", method = RequestMethod.POST)
public AjaxResult upload(@RequestBody testEntity testEntity) {
try {
return AjaxResult.success(service.generation(testEntity));
} catch (Exception e) {
return AjaxResult.error("漏洞类型测试失败!");
}
}
}
package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.kittyProperties;
import com.example.fuzzControll.pojo.vo.testEntity;
import com.example.fuzzControll.service.mutationService;
import com.example.fuzzControll.tools.cmdTools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service("mutationService")
@Slf4j
public class mutationServiceImpl implements mutationService {
cmdTools cmdTools = new cmdTools();
@Autowired
kittyProperties kitty;
@Override
public Map<String,List<String>> generation(testEntity testEntity) {
String cmd = parseParameters(testEntity);
return cmdTools.runProgramCmdAndResult(cmd);
}
public String parseParameters(testEntity testEntity) {
switch (testEntity.getTestClassName().toLowerCase()) {
case "foreach":
return foreachCmd(testEntity);
default:
log.error("未知变异方法![{}]", testEntity.getTestClassName());
return null;
}
}
private String foreachCmd(testEntity testEntity) {
String target_host = null;
String target_port = null;
String s1 = null;
String s2 = null;
String s3 = null;
try {
target_host = testEntity.getParamJson()[0];
target_port = testEntity.getParamJson()[1];
s1 = testEntity.getParamJson()[2];
s2 = testEntity.getParamJson()[3];
s3 = testEntity.getParamJson()[4];
} catch (Exception e) {
log.error("http_dos_qemu参数解析失败!");
}
return kitty.getVenvPath() + " " + kitty.getMutationPath() + "generate_method_test.py -f " + s1 + " " + s2 + " " + s3+" --host="+target_host+" --port="+target_port;
}
//todo 还有很多生成方法
}
package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.testEntity;
import java.util.List;
import java.util.Map;
public interface mutationService {
Map<String, List<String>> generation(testEntity testEntity);
}
...@@ -21,7 +21,8 @@ kitty: ...@@ -21,7 +21,8 @@ kitty:
venvPath: "/home/qbq/fuzz50/kitty/venv/bin/python" venvPath: "/home/qbq/fuzz50/kitty/venv/bin/python"
methodPath: "/home/qbq/fuzz50/kitty/2020test/"#kitty下变异方法路径 methodPath: "/home/qbq/fuzz50/kitty/2020test/"#kitty下变异方法路径
vulnerabilityTypePath: "/home/qbq/fuzz50/kitty/2020test/"#kitty下漏洞类型python路径 vulnerabilityTypePath: "/home/qbq/fuzz50/kitty/2020test/"#kitty下漏洞类型python路径
mutationPath: "/home/qbq/fuzz50/kitty/2020test/"
templateInfoHttp: "http://127.0.0.1:26001/api/template_info.json"#模板信息请求链接 templateInfoHttp: "http://127.0.0.1:26001/api/template_info.json"#模板信息请求链接
statsHttp: "http://127.0.0.1:26001/api/stats.json"#运行时数据 statsHttp: "http://127.0.0.1:26001/api/stats.json"#运行时数据
stagesHttp: "http://127.0.0.1:26001/api/stages.json"# stagesHttp: "http://127.0.0.1:26001/api/stages.json"#
reportHttp: "http://127.0.0.1:26001/api/report"# reportHttp: "http://127.0.0.1:26001/api/report"#
\ No newline at end of file
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