Commit 3f6bd303 by 钱炳权

完善后端异常处理,即使cmd运行但是没有数据写入和修改依旧显示未成功。

parent a73cc0e0
...@@ -101,6 +101,14 @@ ...@@ -101,6 +101,14 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins> </plugins>
......
...@@ -5,7 +5,7 @@ import org.springframework.stereotype.Component; ...@@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
@Component("kittyProperties") @Component("kittyProperties")
@ConfigurationProperties(prefix = "kitty") @ConfigurationProperties(prefix = "kitty")
public class kittyProperties { public class KittyProperties {
String path; String path;
String venvPath; String venvPath;
String methodPath; String methodPath;
......
...@@ -5,7 +5,7 @@ import org.springframework.stereotype.Component; ...@@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
@Component("seedProperties") @Component("seedProperties")
@ConfigurationProperties(prefix = "filepath") @ConfigurationProperties(prefix = "filepath")
public class seedProperties { public class SeedProperties {
String seedPath; String seedPath;
public String getSeedPath() { public String getSeedPath() {
......
package com.example.fuzzControll.constents; package com.example.fuzzControll.constents;
import com.example.fuzzControll.conf.SpringContextUtil; import com.example.fuzzControll.conf.SpringContextUtil;
import com.example.fuzzControll.conf.kittyProperties; import com.example.fuzzControll.conf.KittyProperties;
public class cmdConstent { public class CmdConstent {
static kittyProperties kittyProperties = (kittyProperties)SpringContextUtil.getBean("kittyProperties"); static KittyProperties kittyProperties = (KittyProperties)SpringContextUtil.getBean("kittyProperties");
public static final String GET_FILE_NAME = "ls -h "; public static final String GET_FILE_NAME = "ls -h ";
public static final String DELETE_FILE = "sudo rm -r "; public static final String DELETE_FILE = "sudo 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 " + public static final String RUN_AFLNET = "afl-fuzz -d -i "+kittyProperties.getAflnetPath()+"aflnet/tutorials/live555/in-rtsp -o out-live8 " +
"-x "+kittyProperties.getAflnetPath()+"aflnet/tutorials/live555/rtsp.dict "; "-x "+kittyProperties.getAflnetPath()+"aflnet/tutorials/live555/rtsp.dict ";
public static final String RUN_PING = "ping www.baidu.com"; public static final String RUN_PING = "ping www.baidu.com";
......
package com.example.fuzzControll.constents; package com.example.fuzzControll.constents;
public class mutationConstent { public class MutationConstent {
public static final String TEST_GRANULARITY_BIT_BYTE = "test_granularity_bit_byte.py "; public static final String TEST_GRANULARITY_BIT_BYTE = "test_granularity_bit_byte.py ";
public static final String TEST_MUTATED_LIBS = "test_mutated_libs.py "; public static final String TEST_MUTATED_LIBS = "test_mutated_libs.py ";
public static final String TEST_MUTATION_STRATEGY = "test_mutation_strategy.py "; public static final String TEST_MUTATION_STRATEGY = "test_mutation_strategy.py ";
......
package com.example.fuzzControll.constents; package com.example.fuzzControll.constents;
public class protocolConstent { public class ProtocolConstent {
public static final String ARP = "arp_raw.py "; public static final String ARP = "arp_raw.py ";
public static final String BGP = "bgp_tcp.py "; public static final String BGP = "bgp_tcp.py ";
public static final String DHCP = "dhcp_scapy.py "; public static final String DHCP = "dhcp_scapy.py ";
......
package com.example.fuzzControll.controller; package com.example.fuzzControll.controller;
import com.example.fuzzControll.pojo.vo.AjaxResult; import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.service.getServerMessageService; import com.example.fuzzControll.service.GetServerMessageService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
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;
...@@ -12,9 +12,9 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -12,9 +12,9 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@RestController @RestController
@RequestMapping("/kittyServer") @RequestMapping("/kittyServer")
public class kittyServerMessageController { public class KittyServerMessageController {
@Autowired @Autowired
getServerMessageService getServerMessageService; GetServerMessageService getServerMessageService;
/** /**
* 获取服务器stats信息 * 获取服务器stats信息
*/ */
...@@ -45,7 +45,7 @@ public class kittyServerMessageController { ...@@ -45,7 +45,7 @@ public class kittyServerMessageController {
try { try {
return AjaxResult.success(getServerMessageService.getStages()); return AjaxResult.success(getServerMessageService.getStages());
} catch (Exception e) { } catch (Exception e) {
return AjaxResult.error("stats信息获取失败!"); return AjaxResult.error("stages信息获取失败!");
} }
} }
/** /**
...@@ -56,7 +56,7 @@ public class kittyServerMessageController { ...@@ -56,7 +56,7 @@ public class kittyServerMessageController {
try { try {
return AjaxResult.success(getServerMessageService.getReport()); return AjaxResult.success(getServerMessageService.getReport());
} catch (Exception e) { } catch (Exception e) {
return AjaxResult.error("stats信息获取失败!"); return AjaxResult.error("report信息获取失败!");
} }
} }
} }
package com.example.fuzzControll.controller; package com.example.fuzzControll.controller;
import com.example.fuzzControll.pojo.vo.AjaxResult; import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.service.seedFileService; import com.example.fuzzControll.service.SeedFileService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -16,10 +16,10 @@ import java.util.List; ...@@ -16,10 +16,10 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/seedFile") @RequestMapping("/seedFile")
public class seedFileController { public class SeedFileController {
@Autowired @Autowired
seedFileService service; SeedFileService service;
/** /**
* 种子文件查询接口 * 种子文件查询接口
......
package com.example.fuzzControll.controller; package com.example.fuzzControll.controller;
import com.example.fuzzControll.pojo.vo.AjaxResult; 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.mutationService; import com.example.fuzzControll.service.MutationService;
import com.example.fuzzControll.service.protocolTemplateService; import com.example.fuzzControll.service.ProtocolTemplateService;
import com.example.fuzzControll.service.vulnerabilityTypeService; 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;
...@@ -20,20 +20,20 @@ import java.util.Map; ...@@ -20,20 +20,20 @@ import java.util.Map;
*/ */
@RestController @RestController
@RequestMapping("/testClass") @RequestMapping("/testClass")
public class testClassController { public class TestClassController {
@Autowired @Autowired
generateMethodService generateMethodService; GenerateMethodService generateMethodService;
@Autowired @Autowired
mutationService mutationService; MutationService mutationService;
@Autowired @Autowired
protocolTemplateService protocolTemplateService; ProtocolTemplateService protocolTemplateService;
@Autowired @Autowired
vulnerabilityTypeService vulnerabilityTypeService; VulnerabilityTypeService vulnerabilityTypeService;
/** /**
* 模板 * 模板
*/ */
@RequestMapping(value = "/protocolTemplate", method = RequestMethod.POST) @RequestMapping(value = "/protocolTemplate", method = RequestMethod.POST)
public AjaxResult protocolTemplate(@RequestBody testEntity testEntity) { public AjaxResult protocolTemplate(@RequestBody TestEntity testEntity) {
try { try {
Map<String, List<String>> result = protocolTemplateService.generation(testEntity); Map<String, List<String>> result = protocolTemplateService.generation(testEntity);
return AjaxResult.success(result==null?"模板文件生成未成功运行":result); return AjaxResult.success(result==null?"模板文件生成未成功运行":result);
...@@ -46,7 +46,7 @@ public class testClassController { ...@@ -46,7 +46,7 @@ public class testClassController {
*生成方法 *生成方法
*/ */
@RequestMapping(value = "/generate", method = RequestMethod.POST) @RequestMapping(value = "/generate", method = RequestMethod.POST)
public AjaxResult generate(@RequestBody testEntity testEntity) { public AjaxResult generate(@RequestBody TestEntity testEntity) {
try { try {
Map<String, List<String>> result = generateMethodService.generation(testEntity); Map<String, List<String>> result = generateMethodService.generation(testEntity);
return AjaxResult.success(result==null?"生成方法未成功运行":result); return AjaxResult.success(result==null?"生成方法未成功运行":result);
...@@ -59,7 +59,7 @@ public class testClassController { ...@@ -59,7 +59,7 @@ public class testClassController {
*变异方法 *变异方法
*/ */
@RequestMapping(value = "/mutation", method = RequestMethod.POST) @RequestMapping(value = "/mutation", method = RequestMethod.POST)
public AjaxResult mutation(@RequestBody testEntity testEntity) { public AjaxResult mutation(@RequestBody TestEntity testEntity) {
try { try {
Map<String, List<String>> result = mutationService.generation(testEntity); Map<String, List<String>> result = mutationService.generation(testEntity);
return AjaxResult.success(result==null?"mutationTest未成功运行":result); return AjaxResult.success(result==null?"mutationTest未成功运行":result);
...@@ -72,7 +72,7 @@ public class testClassController { ...@@ -72,7 +72,7 @@ public class testClassController {
*漏洞类型 *漏洞类型
*/ */
@RequestMapping(value = "/vulnerabilityType", method = RequestMethod.POST) @RequestMapping(value = "/vulnerabilityType", method = RequestMethod.POST)
public AjaxResult upload(@RequestBody testEntity testEntity) { public AjaxResult upload(@RequestBody TestEntity testEntity) {
try { try {
Map<String, List<String>> result = vulnerabilityTypeService.generation(testEntity); Map<String, List<String>> result = vulnerabilityTypeService.generation(testEntity);
return AjaxResult.success(result==null?"漏洞类型未成功运行":result); return AjaxResult.success(result==null?"漏洞类型未成功运行":result);
......
package com.example.fuzzControll.controller; package com.example.fuzzControll.controller;
import com.example.fuzzControll.pojo.vo.AjaxResult; import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.cmdStartParams; import com.example.fuzzControll.pojo.vo.CmdStartParams;
import com.example.fuzzControll.service.testService; import com.example.fuzzControll.service.TestService;
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;
...@@ -14,15 +14,15 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -14,15 +14,15 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@RestController @RestController
@RequestMapping("/test") @RequestMapping("/test")
public class testControler { public class TestControler {
@Autowired @Autowired
testService service; TestService service;
/** /**
* 测试启动 * 测试启动
*/ */
@RequestMapping(value = "/testStart", method = RequestMethod.POST) @RequestMapping(value = "/testStart", method = RequestMethod.POST)
public AjaxResult list(@RequestBody final cmdStartParams cmdStartParams) { public AjaxResult list(@RequestBody final CmdStartParams cmdStartParams) {
try { try {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
......
package com.example.fuzzControll.exception;
public class AflnetException extends BaseException{
private static final long serialVersionUID = 1L;
public AflnetException(String defaultMessage) {
super(defaultMessage, "aflnet");
}
}
package com.example.fuzzControll.exception;
/**
* 基础异常
*/
public class BaseException extends RuntimeException{
private static final long serialVersionUID = 1L;
/**
* 错误消息
*/
private String defaultMessage;
/**
* 所属模块
*/
private String module;
public BaseException(String defaultMessage, String module) {
this.defaultMessage = defaultMessage;
this.module = module;
}
}
package com.example.fuzzControll.exception;
/**
* cmd运行异常
*/
public class CmdException extends BaseException{
private static final long serialVersionUID = 1L;
public CmdException(String defaultMessage) {
super(defaultMessage, "cmd");
}
}
package com.example.fuzzControll.exception;
/**
* 文件操作异常
*/
public class FileException extends BaseException{
private static final long serialVersionUID = 1L;
public FileException(String defaultMessage) {
super(defaultMessage, "file");
}
}
package com.example.fuzzControll.exception;
public class FuzzException extends BaseException{
private static final long serialVersionUID = 1L;
public FuzzException(String defaultMessage) {
super(defaultMessage, "fuzz");
}
}
package com.example.fuzzControll.exception;
public class ServerException extends BaseException{
private static final long serialVersionUID = 1L;
public ServerException(String defaultMessage) {
super(defaultMessage, "server");
}
}
...@@ -7,7 +7,7 @@ import lombok.Setter; ...@@ -7,7 +7,7 @@ import lombok.Setter;
@Data @Data
@Getter @Getter
@Setter @Setter
public class cmdStartParams { public class CmdStartParams {
String netinfo; //netInfo String netinfo; //netInfo
String protopcol; //protocol String protopcol; //protocol
int waiting; //usec int waiting; //usec
......
...@@ -7,7 +7,7 @@ import lombok.Setter; ...@@ -7,7 +7,7 @@ import lombok.Setter;
@Data @Data
@Getter @Getter
@Setter @Setter
public class testEntity { public class TestEntity {
String testClassName; String testClassName;
String[] paramJson; String[] paramJson;
} }
...@@ -3,7 +3,7 @@ package com.example.fuzzControll.pojo.vo; ...@@ -3,7 +3,7 @@ package com.example.fuzzControll.pojo.vo;
import lombok.Data; import lombok.Data;
@Data @Data
public class testReturnEntity { public class TestReturnEntity {
String run_time; String run_time;
String cycles_done; String cycles_done;
String last_new_path; String last_new_path;
......
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.testEntity; import com.example.fuzzControll.pojo.vo.TestEntity;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public interface generateMethodService { public interface GenerateMethodService {
Map<String,List<String>> generation(testEntity testEntity); Map<String,List<String>> generation(TestEntity testEntity);
} }
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
import java.util.List; public interface GetServerMessageService {
import java.util.Map;
public interface getServerMessageService {
String getStats(); String getStats();
String getTemplateInfo(); String getTemplateInfo();
......
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.testEntity; import com.example.fuzzControll.pojo.vo.TestEntity;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public interface mutationService { public interface MutationService {
Map<String, List<String>> generation(testEntity testEntity); Map<String, List<String>> generation(TestEntity testEntity);
} }
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.testEntity; import com.example.fuzzControll.pojo.vo.TestEntity;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public interface protocolTemplateService { public interface ProtocolTemplateService {
Map<String,List<String>> generation(testEntity testEntity); Map<String,List<String>> generation(TestEntity testEntity);
} }
...@@ -4,10 +4,11 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -4,10 +4,11 @@ import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
public interface seedFileService { public interface SeedFileService {
public List<String> getSeedFiles(); public List<String> getSeedFiles();
void delFile(String fileName); void delFile(String fileName);
void upload(MultipartFile file); void upload(MultipartFile file);
int getSeedFileCount();
} }
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.cmdStartParams; import com.example.fuzzControll.pojo.vo.CmdStartParams;
public interface testService { public interface TestService {
void testStart(cmdStartParams cmdStartParams); void testStart(CmdStartParams cmdStartParams);
void testStop(); void testStop();
......
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.testEntity; import com.example.fuzzControll.pojo.vo.TestEntity;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public interface vulnerabilityTypeService { public interface VulnerabilityTypeService {
Map<String, List<String>> generation(testEntity testEntity); Map<String, List<String>> generation(TestEntity testEntity);
} }
package com.example.fuzzControll.service.impl; package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.kittyProperties; import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.pojo.vo.testEntity; import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.service.generateMethodService; import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.tools.cmdTools; import com.example.fuzzControll.service.GenerateMethodService;
import com.example.fuzzControll.tools.testTools; import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.TestTools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -14,13 +15,13 @@ import java.util.Map; ...@@ -14,13 +15,13 @@ import java.util.Map;
@Service @Service
@Slf4j @Slf4j
public class generateMethodServiceImpl implements generateMethodService { public class GenerateMethodServiceImpl implements GenerateMethodService {
cmdTools cmdTools = new cmdTools(); CmdTools cmdTools = new CmdTools();
@Autowired @Autowired
kittyProperties kitty; KittyProperties kitty;
@Override @Override
public Map<String, List<String>> generation(testEntity testEntity) { public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException {
String cmd = parseParameters(testEntity); String cmd = parseParameters(testEntity);
if (cmd.isEmpty()) { if (cmd.isEmpty()) {
return null; return null;
...@@ -28,7 +29,7 @@ public class generateMethodServiceImpl implements generateMethodService { ...@@ -28,7 +29,7 @@ public class generateMethodServiceImpl implements generateMethodService {
return cmdTools.runProgramCmdAndResult(cmd); return cmdTools.runProgramCmdAndResult(cmd);
} }
public String parseParameters(testEntity testEntity) { public String parseParameters(TestEntity testEntity) {
switch (testEntity.getTestClassName().toLowerCase()) { switch (testEntity.getTestClassName().toLowerCase()) {
case "foreach": case "foreach":
return cmd(testEntity, "-f"); return cmd(testEntity, "-f");
...@@ -56,8 +57,8 @@ public class generateMethodServiceImpl implements generateMethodService { ...@@ -56,8 +57,8 @@ public class generateMethodServiceImpl implements generateMethodService {
} }
} }
private String cmd(testEntity testEntity, String cmd) { private String cmd(TestEntity testEntity, String cmd) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 5, "generationMethod")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 5, "generationMethod"))
return ""; return "";
String target_host = null; String target_host = null;
String target_port = null; String target_port = null;
......
package com.example.fuzzControll.service.impl; package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.kittyProperties; import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.service.getServerMessageService; import com.example.fuzzControll.exception.ServerException;
import com.example.fuzzControll.service.GetServerMessageService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
...@@ -12,18 +12,13 @@ import org.apache.http.util.EntityUtils; ...@@ -12,18 +12,13 @@ import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j @Slf4j
@Service("getServerMessageService") @Service("getServerMessageService")
public class getServerMessageImpl implements getServerMessageService { public class GetServerMessageImpl implements GetServerMessageService {
@Autowired @Autowired
kittyProperties kitty; KittyProperties kitty;
public String getServerMsg(String messageName) { public String getServerMsg(String messageName) throws ServerException{
switch (messageName) { switch (messageName) {
case "templateInfo": { case "templateInfo": {
HttpGet httpGetTemplateInfo = new HttpGet(kitty.getTemplateInfoHttp()); HttpGet httpGetTemplateInfo = new HttpGet(kitty.getTemplateInfoHttp());
...@@ -32,6 +27,7 @@ public class getServerMessageImpl implements getServerMessageService { ...@@ -32,6 +27,7 @@ public class getServerMessageImpl implements getServerMessageService {
return EntityUtils.toString(templateInfoResponse.getEntity(), "utf-8"); return EntityUtils.toString(templateInfoResponse.getEntity(), "utf-8");
} catch (Exception e) { } catch (Exception e) {
log.error("templateInfo http error!"); log.error("templateInfo http error!");
throw new ServerException("get server templateInfo error !");
} }
} }
case "stats": { case "stats": {
...@@ -41,6 +37,7 @@ public class getServerMessageImpl implements getServerMessageService { ...@@ -41,6 +37,7 @@ public class getServerMessageImpl implements getServerMessageService {
return EntityUtils.toString(statsResponse.getEntity(), "utf-8"); return EntityUtils.toString(statsResponse.getEntity(), "utf-8");
} catch (Exception e) { } catch (Exception e) {
log.error("stats http error!"); log.error("stats http error!");
throw new ServerException("get server stats error !");
} }
} }
case "report": { case "report": {
...@@ -50,6 +47,8 @@ public class getServerMessageImpl implements getServerMessageService { ...@@ -50,6 +47,8 @@ public class getServerMessageImpl implements getServerMessageService {
return EntityUtils.toString(reportResponse.getEntity(), "utf-8"); return EntityUtils.toString(reportResponse.getEntity(), "utf-8");
} catch (Exception e) { } catch (Exception e) {
log.error("report http error!"); log.error("report http error!");
throw new ServerException("get server report error !");
} }
} }
case "stages": { case "stages": {
...@@ -59,6 +58,7 @@ public class getServerMessageImpl implements getServerMessageService { ...@@ -59,6 +58,7 @@ public class getServerMessageImpl implements getServerMessageService {
return EntityUtils.toString(stagesResponse.getEntity(), "utf-8"); return EntityUtils.toString(stagesResponse.getEntity(), "utf-8");
} catch (Exception e) { } catch (Exception e) {
log.error("stages http error!"); log.error("stages http error!");
throw new ServerException("get server stages error !");
} }
} }
default: default:
...@@ -67,22 +67,22 @@ public class getServerMessageImpl implements getServerMessageService { ...@@ -67,22 +67,22 @@ public class getServerMessageImpl implements getServerMessageService {
} }
@Override @Override
public String getStats() { public String getStats() throws ServerException {
return getServerMsg("stats"); return getServerMsg("stats");
} }
@Override @Override
public String getTemplateInfo() { public String getTemplateInfo() throws ServerException{
return getServerMsg("templateInfo"); return getServerMsg("templateInfo");
} }
@Override @Override
public String getStages() { public String getStages() throws ServerException{
return getServerMsg("report"); return getServerMsg("stages");
} }
@Override @Override
public String getReport() { public String getReport() throws ServerException{
return getServerMsg("stages"); return getServerMsg("report");
} }
} }
package com.example.fuzzControll.service.impl; package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.kittyProperties; import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.mutationConstent; import com.example.fuzzControll.constents.MutationConstent;
import com.example.fuzzControll.pojo.vo.testEntity; import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.service.mutationService; import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.tools.cmdTools; import com.example.fuzzControll.service.MutationService;
import com.example.fuzzControll.tools.testTools; import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.TestTools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -15,14 +16,14 @@ import java.util.Map; ...@@ -15,14 +16,14 @@ import java.util.Map;
@Service("mutationService") @Service("mutationService")
@Slf4j @Slf4j
class mutationServiceImpl implements mutationService { class MutationServiceImpl implements MutationService {
cmdTools cmdTools = new cmdTools(); CmdTools cmdTools = new CmdTools();
@Autowired @Autowired
kittyProperties kitty; KittyProperties kitty;
@Override @Override
public Map<String, List<String>> generation(testEntity testEntity) { public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException {
String cmd = parseParameters(testEntity); String cmd = parseParameters(testEntity);
if (cmd.isEmpty()) { if (cmd.isEmpty()) {
return null; return null;
...@@ -30,7 +31,7 @@ class mutationServiceImpl implements mutationService { ...@@ -30,7 +31,7 @@ class mutationServiceImpl implements mutationService {
return cmdTools.runProgramCmdAndResult(cmd); return cmdTools.runProgramCmdAndResult(cmd);
} }
public String parseParameters(testEntity testEntity) { public String parseParameters(TestEntity testEntity) {
switch (testEntity.getTestClassName().toLowerCase()) { switch (testEntity.getTestClassName().toLowerCase()) {
case "bit": case "bit":
return variationGranularityCmd(testEntity, 1); return variationGranularityCmd(testEntity, 1);
...@@ -96,8 +97,8 @@ class mutationServiceImpl implements mutationService { ...@@ -96,8 +97,8 @@ class mutationServiceImpl implements mutationService {
} }
} }
private String distortionLibCmd(testEntity testEntity, int methodNum) { private String distortionLibCmd(TestEntity testEntity, int methodNum) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "distortionLib" + methodNum)) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "distortionLib" + methodNum))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -107,12 +108,12 @@ class mutationServiceImpl implements mutationService { ...@@ -107,12 +108,12 @@ class mutationServiceImpl implements mutationService {
} catch (Exception e) { } catch (Exception e) {
log.error("distortionLib [{}] 参数解析失败!", methodNum); log.error("distortionLib [{}] 参数解析失败!", methodNum);
} }
return kitty.getVenvPath() + " " + kitty.getMutationPath() + mutationConstent.TEST_MUTATED_LIBS + " -g " + methodNum + " -d " + dst_ip + " -p " + dst_port; return kitty.getVenvPath() + " " + kitty.getMutationPath() + MutationConstent.TEST_MUTATED_LIBS + " -g " + methodNum + " -d " + dst_ip + " -p " + dst_port;
} }
private String variationGranularityCmd(testEntity testEntity, int methodNum) { private String variationGranularityCmd(TestEntity testEntity, int methodNum) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "variationGranularity" + methodNum)) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "variationGranularity" + methodNum))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -122,10 +123,10 @@ class mutationServiceImpl implements mutationService { ...@@ -122,10 +123,10 @@ class mutationServiceImpl implements mutationService {
} catch (Exception e) { } catch (Exception e) {
log.error("variationGranularity [{}] 参数解析失败!", methodNum); log.error("variationGranularity [{}] 参数解析失败!", methodNum);
} }
return kitty.getVenvPath() + " " + kitty.getMutationPath() + mutationConstent.TEST_GRANULARITY_BIT_BYTE + " -g " + methodNum + " -d " + dst_ip + " -p " + dst_port; return kitty.getVenvPath() + " " + kitty.getMutationPath() + MutationConstent.TEST_GRANULARITY_BIT_BYTE + " -g " + methodNum + " -d " + dst_ip + " -p " + dst_port;
} }
private String mutationStrategyCmd(testEntity testEntity, int methodNum) { private String mutationStrategyCmd(TestEntity testEntity, int methodNum) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "mutationStrategy" + methodNum)) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "mutationStrategy" + methodNum))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -135,7 +136,7 @@ class mutationServiceImpl implements mutationService { ...@@ -135,7 +136,7 @@ class mutationServiceImpl implements mutationService {
} catch (Exception e) { } catch (Exception e) {
log.error("mutationStrategy [{}] 参数解析失败!", methodNum); log.error("mutationStrategy [{}] 参数解析失败!", methodNum);
} }
return kitty.getVenvPath() + " " + kitty.getMutationPath() + mutationConstent.TEST_MUTATION_STRATEGY + " -g " + methodNum + " -d " + dst_ip + " -p " + dst_port; return kitty.getVenvPath() + " " + kitty.getMutationPath() + MutationConstent.TEST_MUTATION_STRATEGY + " -g " + methodNum + " -d " + dst_ip + " -p " + dst_port;
} }
} }
\ No newline at end of file
package com.example.fuzzControll.service.impl; package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.kittyProperties; import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.protocolConstent; import com.example.fuzzControll.constents.ProtocolConstent;
import com.example.fuzzControll.pojo.vo.testEntity; import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.service.protocolTemplateService; import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.tools.cmdTools; import com.example.fuzzControll.service.ProtocolTemplateService;
import com.example.fuzzControll.tools.testTools; import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.TestTools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -16,13 +17,13 @@ import java.util.Map; ...@@ -16,13 +17,13 @@ import java.util.Map;
@Slf4j @Slf4j
@Service @Service
public class protocolTemplateImpl implements protocolTemplateService { public class ProtocolTemplateImpl implements ProtocolTemplateService {
cmdTools cmdTools = new cmdTools(); CmdTools cmdTools = new CmdTools();
@Autowired @Autowired
kittyProperties kitty; KittyProperties kitty;
@Override @Override
public Map<String, List<String>> generation(testEntity testEntity) { public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException {
String cmd = parseParameters(testEntity); String cmd = parseParameters(testEntity);
if (cmd.isEmpty()) { if (cmd.isEmpty()) {
return null; return null;
...@@ -30,7 +31,7 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -30,7 +31,7 @@ public class protocolTemplateImpl implements protocolTemplateService {
return cmdTools.runProgramCmdAndResult(cmd); return cmdTools.runProgramCmdAndResult(cmd);
} }
public String parseParameters(testEntity testEntity) { public String parseParameters(TestEntity testEntity) {
switch (testEntity.getTestClassName().toLowerCase()) { switch (testEntity.getTestClassName().toLowerCase()) {
case "arp": case "arp":
return arpCmd(testEntity); return arpCmd(testEntity);
...@@ -125,9 +126,10 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -125,9 +126,10 @@ public class protocolTemplateImpl implements protocolTemplateService {
} }
} }
private String tcpCmd(testEntity testEntity) { private String tcpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "tcp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "tcp")){
return ""; return "";
}
String dst_ip = null; String dst_ip = null;
String src_ip = null; String src_ip = null;
try { try {
...@@ -136,12 +138,13 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -136,12 +138,13 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("tcp参数解析失败!"); log.error("tcp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.TCP + " " + dst_ip + " " +src_ip; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.TCP + " " + dst_ip + " " +src_ip;
} }
private String udpCmd(testEntity testEntity) { private String udpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "udp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "udp")){
return ""; return "";
}
String dst_ip = null; String dst_ip = null;
String src_ip = null; String src_ip = null;
try { try {
...@@ -150,11 +153,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -150,11 +153,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("udp参数解析失败!"); log.error("udp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.UDP + " " + dst_ip + " " +src_ip; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.UDP + " " + dst_ip + " " +src_ip;
} }
private String tftpCmd(testEntity testEntity) { private String tftpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "tftp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "tftp"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -164,11 +167,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -164,11 +167,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("tftp参数解析失败!"); log.error("tftp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.TFTP + " " + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.TFTP + " " + dst_ip + " " + dst_port;
} }
private String sharpCmd(testEntity testEntity) { private String sharpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "sharp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "sharp"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -178,11 +181,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -178,11 +181,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("sharp参数解析失败!"); log.error("sharp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.SHARP + " " + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.SHARP + " " + dst_ip + " " + dst_port;
} }
private String netbiosCmd(testEntity testEntity) { private String netbiosCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "netbios")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "netbios"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -192,11 +195,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -192,11 +195,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("netbios参数解析失败!"); log.error("netbios参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.NETBIOS + " --host=" + dst_ip + " --port=" + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.NETBIOS + " --host=" + dst_ip + " --port=" + dst_port;
} }
private String ripCmd(testEntity testEntity) { private String ripCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rip")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rip"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -206,11 +209,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -206,11 +209,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("rip参数解析失败!"); log.error("rip参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.RIP + " --host=" + dst_ip + " --port=" + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.RIP + " --host=" + dst_ip + " --port=" + dst_port;
} }
private String httpsCmd(testEntity testEntity) { private String httpsCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "https")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "https"))
return ""; return "";
String src_ip = null; String src_ip = null;
String src_port = null; String src_port = null;
...@@ -224,11 +227,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -224,11 +227,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("https参数解析失败!"); log.error("https参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.HTTPS + " " + src_ip + " " + src_port+" " + dst_ip+" " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.HTTPS + " " + src_ip + " " + src_port+" " + dst_ip+" " + dst_port;
} }
private String ipsecCmd(testEntity testEntity) { private String ipsecCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "ipsec")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "ipsec"))
return ""; return "";
String src_ip = null; String src_ip = null;
String dst_ip = null; String dst_ip = null;
...@@ -240,11 +243,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -240,11 +243,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("ipsec参数解析失败!"); log.error("ipsec参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.IPSEC + " -s " + src_ip + " -d " + dst_ip+" -b " + bind_ip; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.IPSEC + " -s " + src_ip + " -d " + dst_ip+" -b " + bind_ip;
} }
private String pop3Cmd(testEntity testEntity) { private String pop3Cmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "pop3")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "pop3"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -254,11 +257,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -254,11 +257,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("pop3参数解析失败!"); log.error("pop3参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.POP3 + " --host=" + dst_ip + " --port=" + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.POP3 + " --host=" + dst_ip + " --port=" + dst_port;
} }
private String telnetCmd(testEntity testEntity) { private String telnetCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "telnet")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "telnet"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -268,11 +271,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -268,11 +271,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("telnet参数解析失败!"); log.error("telnet参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.TELNET + " --host=" + dst_ip + " --port=" + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.TELNET + " --host=" + dst_ip + " --port=" + dst_port;
} }
private String ipCmd(testEntity testEntity) { private String ipCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "ip")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "ip"))
return ""; return "";
String dst_mac = null; String dst_mac = null;
String src_mac = null; String src_mac = null;
...@@ -286,11 +289,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -286,11 +289,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("ip参数解析失败!"); log.error("ip参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.IP + " " + dst_mac + " " + src_mac + " " + dst_ip + " " + src_ip; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.IP + " " + dst_mac + " " + src_mac + " " + dst_ip + " " + src_ip;
} }
private String isisCmd(testEntity testEntity) { private String isisCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 1, "isis")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 1, "isis"))
return ""; return "";
String dst_mac = null; String dst_mac = null;
try { try {
...@@ -298,11 +301,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -298,11 +301,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("isis参数解析失败!"); log.error("isis参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.ISIS + " --dst_mac==" + dst_mac; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.ISIS + " --dst_mac==" + dst_mac;
} }
private String ospfCmd(testEntity testEntity) { private String ospfCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ospf")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ospf"))
return ""; return "";
String dst_mac = null; String dst_mac = null;
String dst_ip = null; String dst_ip = null;
...@@ -312,11 +315,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -312,11 +315,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("ospf参数解析失败!"); log.error("ospf参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.OSPF + " --dest_mac=" + dst_mac + " --dest_ip=" + dst_ip; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.OSPF + " --dest_mac=" + dst_mac + " --dest_ip=" + dst_ip;
} }
private String vlanCmd(testEntity testEntity) { private String vlanCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "vlan")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "vlan"))
return ""; return "";
String dts_mac = null; String dts_mac = null;
String src_mac = null; String src_mac = null;
...@@ -326,11 +329,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -326,11 +329,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("vlan参数解析失败!"); log.error("vlan参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.VLAN + " " + dts_mac + " " + src_mac; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.VLAN + " " + dts_mac + " " + src_mac;
} }
private String stpCmd(testEntity testEntity) { private String stpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "stp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "stp"))
return ""; return "";
String src_mac = null; String src_mac = null;
String dts_mac = null; String dts_mac = null;
...@@ -340,11 +343,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -340,11 +343,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("stp参数解析失败!"); log.error("stp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.STP + " -s " + src_mac + " -d " + dts_mac; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.STP + " -s " + src_mac + " -d " + dts_mac;
} }
private String pppoeCmd(testEntity testEntity) { private String pppoeCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "pppoe")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "pppoe"))
return ""; return "";
String dst_mac = null; String dst_mac = null;
String src_mac = null; String src_mac = null;
...@@ -358,17 +361,17 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -358,17 +361,17 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("pppoe参数解析失败!"); log.error("pppoe参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.PPPOE + " " + dst_mac + " " + src_mac + " " + dst_ip + " " + src_ip; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.PPPOE + " " + dst_mac + " " + src_mac + " " + dst_ip + " " + src_ip;
} }
private String pppCmd(testEntity testEntity) { private String pppCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "ppp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "ppp"))
return ""; return "";
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.PPP; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.PPP;
} }
private String mstpCmd(testEntity testEntity) { private String mstpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "mstp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "mstp"))
return ""; return "";
String src_mac = null; String src_mac = null;
String dst_mac = null; String dst_mac = null;
...@@ -378,17 +381,17 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -378,17 +381,17 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("mstp参数解析失败!"); log.error("mstp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.MSTP + " -s " + src_mac + " -d " + dst_mac; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.MSTP + " -s " + src_mac + " -d " + dst_mac;
} }
private String lldpCmd(testEntity testEntity) { private String lldpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "lldp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "lldp"))
return ""; return "";
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.LLDP; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.LLDP;
} }
private String rarpCmd(testEntity testEntity) { private String rarpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rarp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rarp"))
return ""; return "";
String dst_mac = null; String dst_mac = null;
String src_mac = null; String src_mac = null;
...@@ -398,11 +401,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -398,11 +401,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("rarp参数解析失败!"); log.error("rarp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.RARP + " " + dst_mac + " " + src_mac; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.RARP + " " + dst_mac + " " + src_mac;
} }
private String upnpCmd(testEntity testEntity) { private String upnpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "upnp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "upnp"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -412,11 +415,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -412,11 +415,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("upnp参数解析失败!"); log.error("upnp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.UPNP + " " + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.UPNP + " " + dst_ip + " " + dst_port;
} }
private String snmpCmd(testEntity testEntity) { private String snmpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "snmp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "snmp"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -426,11 +429,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -426,11 +429,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("snmp参数解析失败!"); log.error("snmp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.SNMP + " " + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.SNMP + " " + dst_ip + " " + dst_port;
} }
private String ntpCmd(testEntity testEntity) { private String ntpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ntp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ntp"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -440,11 +443,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -440,11 +443,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("ntp参数解析失败!"); log.error("ntp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.NTP + " " + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.NTP + " " + dst_ip + " " + dst_port;
} }
private String nntpCmd(testEntity testEntity) { private String nntpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "nntp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "nntp"))
return ""; return "";
String src_ip = null; String src_ip = null;
String src_port = null; String src_port = null;
...@@ -458,11 +461,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -458,11 +461,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("nntp参数解析失败!"); log.error("nntp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.NNTP + " " + src_ip + " " + src_port + " " + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.NNTP + " " + src_ip + " " + src_port + " " + dst_ip + " " + dst_port;
} }
private String nfsCmd(testEntity testEntity) { private String nfsCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "nfs")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "nfs"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -472,11 +475,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -472,11 +475,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("nfs参数解析失败!"); log.error("nfs参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.NFS + " " + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.NFS + " " + dst_ip + " " + dst_port;
} }
private String sshCmd(testEntity testEntity) { private String sshCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ssh")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ssh"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
try { try {
...@@ -484,11 +487,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -484,11 +487,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("ssh参数解析失败!"); log.error("ssh参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.SSH + " -d " + dst_ip; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.SSH + " -d " + dst_ip;
} }
private String sslCmd(testEntity testEntity) { private String sslCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ssl")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ssl"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -498,11 +501,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -498,11 +501,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("ssl参数解析失败!"); log.error("ssl参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.SSL + " -d " + dst_ip + " -p " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.SSL + " -d " + dst_ip + " -p " + dst_port;
} }
private String smbCmd(testEntity testEntity) { private String smbCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "smb")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "smb"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -512,11 +515,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -512,11 +515,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("smb参数解析失败!"); log.error("smb参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.RPC + " " + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.RPC + " " + dst_ip + " " + dst_port;
} }
private String rpcCmd(testEntity testEntity) { private String rpcCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rpc")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rpc"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -526,11 +529,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -526,11 +529,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("rpc参数解析失败!"); log.error("rpc参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.RPC + " " + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.RPC + " " + dst_ip + " " + dst_port;
} }
private String sipCmd(testEntity testEntity) { private String sipCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "sip")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "sip"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -540,11 +543,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -540,11 +543,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("sip参数解析失败!"); log.error("sip参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.SIP + " -d " + dst_ip + " -p " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.SIP + " -d " + dst_ip + " -p " + dst_port;
} }
private String radiusCmd(testEntity testEntity) { private String radiusCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "radius")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "radius"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -556,11 +559,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -556,11 +559,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("radius参数解析失败!"); log.error("radius参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.RADIUS + " --host=" + dst_ip + " --port=" + dst_port + " --src_host=" + src_ip; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.RADIUS + " --host=" + dst_ip + " --port=" + dst_port + " --src_host=" + src_ip;
} }
private String imapCmd(testEntity testEntity) { private String imapCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "imap")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "imap"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -570,11 +573,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -570,11 +573,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("imap参数解析失败!"); log.error("imap参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.IMAP + " --host=" + dst_ip + " --port=" + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.IMAP + " --host=" + dst_ip + " --port=" + dst_port;
} }
private String igmpv2Cmd(testEntity testEntity) { private String igmpv2Cmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "igmpv2")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "igmpv2"))
return ""; return "";
String src_ip = null; String src_ip = null;
String dst_ip = null; String dst_ip = null;
...@@ -586,11 +589,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -586,11 +589,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("igmpv2参数解析失败!"); log.error("igmpv2参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.IGMPV2 + " -s " + src_ip + " -d " + dst_ip + " -b " + bind_ip; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.IGMPV2 + " -s " + src_ip + " -d " + dst_ip + " -b " + bind_ip;
} }
private String igmpv1Cmd(testEntity testEntity) { private String igmpv1Cmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "igmpv1")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "igmpv1"))
return ""; return "";
String src_ip = null; String src_ip = null;
String dst_ip = null; String dst_ip = null;
...@@ -602,11 +605,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -602,11 +605,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("igmpv1参数解析失败!"); log.error("igmpv1参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.IGMPV1 + " -s " + src_ip + " -d " + dst_ip + " -b " + bind_ip; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.IGMPV1 + " -s " + src_ip + " -d " + dst_ip + " -b " + bind_ip;
} }
private String icmpCmd(testEntity testEntity) { private String icmpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "icmp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "icmp"))
return ""; return "";
String dst_mac = null; String dst_mac = null;
String src_mac = null; String src_mac = null;
...@@ -620,11 +623,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -620,11 +623,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("icmp参数解析失败!"); log.error("icmp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.ICMP + " " + dst_mac + " " + src_mac + " " + dst_ip + " " + src_ip; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.ICMP + " " + dst_mac + " " + src_mac + " " + dst_ip + " " + src_ip;
} }
private String http_dos_qemuCmd(testEntity testEntity) { private String http_dos_qemuCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "http")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "http"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String port = null; String port = null;
...@@ -634,17 +637,17 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -634,17 +637,17 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("http_dos_qemu参数解析失败!"); log.error("http_dos_qemu参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.HTTP_DOS_QUMU + " -d " + dst_ip + " -p " + port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.HTTP_DOS_QUMU + " -d " + dst_ip + " -p " + port;
} }
private String hdlcCmd(testEntity testEntity) { private String hdlcCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "hdlc")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "hdlc"))
return ""; return "";
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.HDLC; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.HDLC;
} }
private String ftpCmd(testEntity testEntity) { private String ftpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ftp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ftp"))
return ""; return "";
String target_host = null; String target_host = null;
String target_port = null; String target_port = null;
...@@ -654,11 +657,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -654,11 +657,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("ftp参数解析失败!"); log.error("ftp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.FTP + target_host + " " + target_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.FTP + target_host + " " + target_port;
} }
private String frpCmd(testEntity testEntity) { private String frpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "frp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "frp"))
return ""; return "";
String target_host = null; String target_host = null;
String target_port = null; String target_port = null;
...@@ -668,11 +671,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -668,11 +671,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("frp参数解析失败!"); log.error("frp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.FRP + target_host + " " + target_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.FRP + target_host + " " + target_port;
} }
private String dnsCmd(testEntity testEntity) { private String dnsCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "dns")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "dns"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -682,11 +685,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -682,11 +685,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("dns参数解析失败!"); log.error("dns参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.DNS + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.DNS + dst_ip + " " + dst_port;
} }
private String dhcpCmd(testEntity testEntity) { private String dhcpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "dhcp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "dhcp"))
return ""; return "";
String dst_ip = null; String dst_ip = null;
String dst_port = null; String dst_port = null;
...@@ -696,11 +699,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -696,11 +699,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("dhcp参数解析失败!"); log.error("dhcp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.DHCP + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.DHCP + dst_ip + " " + dst_port;
} }
private String bgpCmd(testEntity testEntity) { private String bgpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "bgp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "bgp"))
return ""; return "";
String src_ip = null; String src_ip = null;
String src_port = null; String src_port = null;
...@@ -714,11 +717,11 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -714,11 +717,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("bgp参数解析失败!"); log.error("bgp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.BGP + src_ip + " " + src_port + " " + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.BGP + src_ip + " " + src_port + " " + dst_ip + " " + dst_port;
} }
public String arpCmd(testEntity testEntity) { public String arpCmd(TestEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "arp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "arp"))
return ""; return "";
String dst_mac = null; String dst_mac = null;
String src_mac = null; String src_mac = null;
...@@ -728,6 +731,6 @@ public class protocolTemplateImpl implements protocolTemplateService { ...@@ -728,6 +731,6 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error("arp参数解析失败!"); log.error("arp参数解析失败!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.ARP + dst_mac + " " + src_mac; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.ARP + dst_mac + " " + src_mac;
} }
} }
package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.SeedProperties;
import com.example.fuzzControll.constents.CmdConstent;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.exception.FileException;
import com.example.fuzzControll.service.SeedFileService;
import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.FileTools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List;
@Service
public class SeedFileServiceImpl implements SeedFileService {
CmdTools cmdTools = new CmdTools();
FileTools fileTools = new FileTools();
@Autowired
SeedProperties properties;
@Override
public List<String> getSeedFiles() throws CmdException{
return cmdTools.runCmd(CmdConstent.GET_FILE_NAME + properties.getSeedPath());
}
//todo 同步修改可能会出现问题
@Override
public void delFile(String fileName) throws CmdException {
int fileCountBefore = getSeedFileCount();
cmdTools.runCmd(CmdConstent.DELETE_FILE + properties.getSeedPath() + "/" + fileName);
int fileCountAfter = getSeedFileCount();
if(fileCountAfter==fileCountBefore){
throw new CmdException("delete cmd error !The file has not changed.");
}
}
@Override
public void upload(MultipartFile file) throws FileException {
int fileCountBefore = getSeedFileCount();
fileTools.load(file);
int fileCountAfter = getSeedFileCount();
if(fileCountAfter==fileCountBefore){
throw new CmdException("upload file error !The file failed to be submitted.");
}
}
/**
*
* 获取种子文件目录下文件数量
*/
@Override
public int getSeedFileCount() throws CmdException {
List<String> files = cmdTools.runCmd(CmdConstent.GET_FILE_NAME+ properties.getSeedPath());
int count = files.size();
return count;
}
}
package com.example.fuzzControll.service.impl; package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.SpringContextUtil; import com.example.fuzzControll.conf.SpringContextUtil;
import com.example.fuzzControll.conf.kittyProperties; import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.cmdConstent; import com.example.fuzzControll.constents.CmdConstent;
import com.example.fuzzControll.pojo.vo.cmdStartParams; import com.example.fuzzControll.pojo.vo.CmdStartParams;
import com.example.fuzzControll.service.testService; import com.example.fuzzControll.service.TestService;
import com.example.fuzzControll.tools.cmdTools; import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.testControlTools; import com.example.fuzzControll.tools.TestControlTools;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service("testService") @Service("testService")
public class testServiceImpl implements testService { public class TestServiceImpl implements TestService {
kittyProperties kittyProperties = (kittyProperties) SpringContextUtil.getBean("kittyProperties"); KittyProperties kittyProperties = (KittyProperties) SpringContextUtil.getBean("kittyProperties");
cmdTools cmdTools = new cmdTools(); CmdTools cmdTools = new CmdTools();
//todo 不同服务不同端口 //todo 不同服务不同端口
@Override @Override
public void testStart(cmdStartParams cmdStartParams) { public void testStart(CmdStartParams cmdStartParams) {
testControlTools.setIsRunning(true); TestControlTools.setIsRunning(true);
String cmd = cmdTools.parse(cmdStartParams); String cmd = cmdTools.parse(cmdStartParams);
String finalCmd = cmdConstent.RUN_AFLNET + cmd + kittyProperties.getAflnetPath()+"live555/testProgs/testOnDemandRTSPServer 8554"; String finalCmd = CmdConstent.RUN_AFLNET + cmd + kittyProperties.getAflnetPath()+"live555/testProgs/testOnDemandRTSPServer 8554";
cmdTools.runProgramCmd(finalCmd); cmdTools.runProgramCmd(finalCmd);
} }
@Override @Override
public void testStop() { public void testStop() {
testControlTools.setIsRunning(false); TestControlTools.setIsRunning(false);
} }
} }
package com.example.fuzzControll.service.impl; package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.kittyProperties; import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.pojo.vo.testEntity; import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.service.vulnerabilityTypeService; import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.tools.cmdTools; import com.example.fuzzControll.service.VulnerabilityTypeService;
import com.example.fuzzControll.tools.CmdTools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -13,18 +14,18 @@ import java.util.Map; ...@@ -13,18 +14,18 @@ import java.util.Map;
@Slf4j @Slf4j
@Service("vulnerabilityTypeService") @Service("vulnerabilityTypeService")
public class vulnerabilityTypeServiceImpl implements vulnerabilityTypeService { public class VulnerabilityTypeServiceImpl implements VulnerabilityTypeService {
cmdTools cmdTools = new cmdTools(); CmdTools cmdTools = new CmdTools();
@Autowired @Autowired
kittyProperties kitty; KittyProperties kitty;
@Override @Override
public Map<String, List<String>> generation(testEntity testEntity) { public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException {
String cmd = parseParameters(testEntity); String cmd = parseParameters(testEntity);
return cmdTools.runProgramCmdAndResult(cmd); return cmdTools.runProgramCmdAndResult(cmd);
} }
public String parseParameters(testEntity testEntity) { public String parseParameters(TestEntity testEntity) {
switch (testEntity.getTestClassName().toLowerCase()) { switch (testEntity.getTestClassName().toLowerCase()) {
case "array_index_out_of_bounds_vulnerabilit"://have error case "array_index_out_of_bounds_vulnerabilit"://have error
return cmd(testEntity, 0); return cmd(testEntity, 0);
...@@ -56,7 +57,7 @@ public class vulnerabilityTypeServiceImpl implements vulnerabilityTypeService { ...@@ -56,7 +57,7 @@ public class vulnerabilityTypeServiceImpl implements vulnerabilityTypeService {
} }
} }
private String cmd(testEntity testEntity, int kindNum) { private String cmd(TestEntity testEntity, int kindNum) {
return kitty.getVenvPath() + " " + kitty.getVulnerabilityTypePath() + "vul_types_test.py " + kindNum; return kitty.getVenvPath() + " " + kitty.getVulnerabilityTypePath() + "vul_types_test.py " + kindNum;
} }
//todo 还有很多类型要写 //todo 还有很多类型要写
......
package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.seedProperties;
import com.example.fuzzControll.constents.cmdConstent;
import com.example.fuzzControll.service.seedFileService;
import com.example.fuzzControll.tools.cmdTools;
import com.example.fuzzControll.tools.fileTools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Service
public class seedFileServiceImpl implements seedFileService {
cmdTools cmdTools = new cmdTools();
fileTools fileTools = new fileTools();
@Autowired
seedProperties properties;
@Override
public List<String> getSeedFiles() {
return cmdTools.runCmd(cmdConstent.GET_FILE_NAME+properties.getSeedPath());
}
//todo 没有执行结果提示,
@Override
public void delFile(String fileName) {
cmdTools.runCmd(cmdConstent.DELETE_FILE+properties.getSeedPath()+"/"+fileName);
}
@Override
public void upload(MultipartFile file) {
fileTools.load(file);
}
}
...@@ -3,8 +3,10 @@ package com.example.fuzzControll.tools; ...@@ -3,8 +3,10 @@ package com.example.fuzzControll.tools;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.example.fuzzControll.conf.SpringContextUtil; import com.example.fuzzControll.conf.SpringContextUtil;
import com.example.fuzzControll.controller.WebSocket; import com.example.fuzzControll.controller.WebSocket;
import com.example.fuzzControll.pojo.vo.cmdStartParams; import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.pojo.vo.testReturnEntity; import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.CmdStartParams;
import com.example.fuzzControll.pojo.vo.TestReturnEntity;
import java.io.*; import java.io.*;
...@@ -12,14 +14,14 @@ import java.util.*; ...@@ -12,14 +14,14 @@ import java.util.*;
//todo need modify //todo need modify
public class cmdTools { public class CmdTools {
Boolean send = false; Boolean send = false;
WebSocket socket = (WebSocket) SpringContextUtil.getBean("WebSocket"); WebSocket socket = (WebSocket) SpringContextUtil.getBean("WebSocket");
/** /**
* 运行不需要后台运行cmd * 运行不需要后台运行cmd
*/ */
public List<String> runCmd(String cmd) { public List<String> runCmd(String cmd) throws CmdException {
List<String> result = new ArrayList<String>(); List<String> result = new ArrayList<String>();
try { try {
Process process = Runtime.getRuntime().exec(cmd); Process process = Runtime.getRuntime().exec(cmd);
...@@ -27,7 +29,7 @@ public class cmdTools { ...@@ -27,7 +29,7 @@ public class cmdTools {
printMessage(process.getErrorStream(), new ArrayList<String>()); printMessage(process.getErrorStream(), new ArrayList<String>());
process.waitFor(); process.waitFor();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); throw new CmdException("run delete or search cmd error !");
} }
return result; return result;
...@@ -54,7 +56,7 @@ public class cmdTools { ...@@ -54,7 +56,7 @@ public class cmdTools {
* 运行需要后台运行cmd * 运行需要后台运行cmd
* 将数据存入文件中 * 将数据存入文件中
*/ */
public Map<String, List<String>> runProgramCmdAndResult(String cmd) { public Map<String, List<String>> runProgramCmdAndResult(String cmd) throws FuzzException {
Map<String, List<String>> result = new HashMap(); Map<String, List<String>> result = new HashMap();
List<String> out = Collections.synchronizedList(new ArrayList<String>()); List<String> out = Collections.synchronizedList(new ArrayList<String>());
List<String> error = Collections.synchronizedList(new ArrayList<String>()); List<String> error = Collections.synchronizedList(new ArrayList<String>());
...@@ -64,7 +66,7 @@ public class cmdTools { ...@@ -64,7 +66,7 @@ public class cmdTools {
printMessageByProgramCmd(process.getErrorStream(), error); printMessageByProgramCmd(process.getErrorStream(), error);
process.waitFor(); process.waitFor();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); throw new FuzzException("run fuzz error !");
} }
result.put("out", out); result.put("out", out);
result.put("error", error); result.put("error", error);
...@@ -115,8 +117,8 @@ public class cmdTools { ...@@ -115,8 +117,8 @@ public class cmdTools {
Reader reader = new InputStreamReader(input); Reader reader = new InputStreamReader(input);
BufferedReader bf = new BufferedReader(reader); BufferedReader bf = new BufferedReader(reader);
String line = null; String line = null;
testReturnEntity returnEntity = new testReturnEntity(); TestReturnEntity returnEntity = new TestReturnEntity();
while ((line = bf.readLine()) != null && testControlTools.getIsRunning()) { while ((line = bf.readLine()) != null && TestControlTools.getIsRunning()) {
makeReturnEntity(line, returnEntity); makeReturnEntity(line, returnEntity);
if (send) { if (send) {
String data = JSONObject.toJSONString(returnEntity); String data = JSONObject.toJSONString(returnEntity);
...@@ -125,7 +127,7 @@ public class cmdTools { ...@@ -125,7 +127,7 @@ public class cmdTools {
} }
} }
private testReturnEntity makeReturnEntity(String line, testReturnEntity returnEntity) { private TestReturnEntity makeReturnEntity(String line, TestReturnEntity returnEntity) {
if (line.contains("run time")) { if (line.contains("run time")) {
send = false; send = false;
int run_time = line.indexOf(":"); int run_time = line.indexOf(":");
...@@ -215,7 +217,7 @@ public class cmdTools { ...@@ -215,7 +217,7 @@ public class cmdTools {
return returnEntity; return returnEntity;
} }
public String parse(cmdStartParams cmdStartParams) { public String parse(CmdStartParams cmdStartParams) {
StringBuilder cmd = new StringBuilder(); StringBuilder cmd = new StringBuilder();
if (cmdStartParams.getNetinfo() != "") { if (cmdStartParams.getNetinfo() != "") {
cmd.append(" -N " + cmdStartParams.getNetinfo()); cmd.append(" -N " + cmdStartParams.getNetinfo());
......
package com.example.fuzzControll.tools; package com.example.fuzzControll.tools;
import com.example.fuzzControll.conf.SpringContextUtil; import com.example.fuzzControll.conf.SpringContextUtil;
import com.example.fuzzControll.conf.seedProperties; import com.example.fuzzControll.conf.SeedProperties;
import com.example.fuzzControll.exception.FileException;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
...@@ -9,10 +10,13 @@ import java.io.BufferedOutputStream; ...@@ -9,10 +10,13 @@ import java.io.BufferedOutputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
public class fileTools { public class FileTools {
seedProperties properties = (seedProperties) SpringContextUtil.getBean("seedProperties"); SeedProperties properties = (SeedProperties) SpringContextUtil.getBean("seedProperties");
public void load(MultipartFile file) { public void load(MultipartFile file) throws FileException {
if (file==null){
throw new FileException("upload file is null !");
}
try (InputStream inputStream = file.getInputStream(); try (InputStream inputStream = file.getInputStream();
FileOutputStream outputStream = new FileOutputStream(properties.getSeedPath() + "/" + file.getOriginalFilename());) { FileOutputStream outputStream = new FileOutputStream(properties.getSeedPath() + "/" + file.getOriginalFilename());) {
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
...@@ -24,7 +28,7 @@ public class fileTools { ...@@ -24,7 +28,7 @@ public class fileTools {
bufferedOutputStream.write(buffer, 0, bytesRead); bufferedOutputStream.write(buffer, 0, bytesRead);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); throw new FileException("write file error !");
} }
} }
......
package com.example.fuzzControll.tools; package com.example.fuzzControll.tools;
//todo 对ip等增加正则判断 //todo 对ip等增加正则判断
public class regularTools { public class RegularTools {
} }
package com.example.fuzzControll.tools; package com.example.fuzzControll.tools;
public class testControlTools { public class TestControlTools {
private static Boolean isRunning; private static Boolean isRunning;
public static Boolean getIsRunning() { public static Boolean getIsRunning() {
...@@ -8,6 +8,6 @@ public class testControlTools { ...@@ -8,6 +8,6 @@ public class testControlTools {
} }
public static void setIsRunning(Boolean isRunning) { public static void setIsRunning(Boolean isRunning) {
testControlTools.isRunning = isRunning; TestControlTools.isRunning = isRunning;
} }
} }
...@@ -3,7 +3,7 @@ package com.example.fuzzControll.tools; ...@@ -3,7 +3,7 @@ package com.example.fuzzControll.tools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class testTools { public class TestTools {
public static boolean paramsLenghtTest(int paramsLen,int needParamsLen,String name){ public static boolean paramsLenghtTest(int paramsLen,int needParamsLen,String name){
Boolean isOk = paramsLen==needParamsLen; Boolean isOk = paramsLen==needParamsLen;
if(!isOk){ if(!isOk){
......
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