Commit 33db74cf by 钱炳权

Merge branch 'master' into 'dev'

Master

See merge request !2
parents 970ef118 0745a33d
......@@ -16,3 +16,12 @@
2024-04-01 14:46:12.978 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 461 ms
2024-04-01 14:46:13.162 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer - Tomcat started on port(s): 8100 (http) with context path ''
2024-04-01 14:46:13.169 [main] INFO com.example.fuzzControll.FuzzControlApplication - Started FuzzControlApplication in 0.849 seconds (JVM running for 1.322)
2024-04-08 14:12:55.975 [main] INFO com.example.fuzzControll.FuzzControlApplication - Starting FuzzControlApplication using Java 11.0.6 on DESKTOP-GDSKRB2 with PID 27760 (D:\code\company\fuzz-backend\fuzz-backend\fuzzbackend\target\classes started by qian in D:\code\company\fuzz-backend\fuzz-backend\fuzzbackend)
2024-04-08 14:12:55.989 [main] INFO com.example.fuzzControll.FuzzControlApplication - The following 1 profile is active: "dev"
2024-04-08 14:12:56.567 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8100 (http)
2024-04-08 14:12:56.573 [main] INFO org.apache.catalina.core.StandardService - Starting service [Tomcat]
2024-04-08 14:12:56.573 [main] INFO org.apache.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.68]
2024-04-08 14:12:56.793 [main] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
2024-04-08 14:12:56.793 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 779 ms
2024-04-08 14:12:56.972 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer - Tomcat started on port(s): 8100 (http) with context path ''
2024-04-08 14:12:56.991 [main] INFO com.example.fuzzControll.FuzzControlApplication - Started FuzzControlApplication in 1.299 seconds (JVM running for 2.308)
......@@ -22,6 +22,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.5.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......@@ -51,11 +52,6 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.31</version>
</dependency>
<dependency>
......@@ -86,31 +82,35 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<source>11</source>
<target>11</target>
<encoding>UTF-8</encoding>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.example.fuzzControll.AflnetControlApplication</mainClass>
<skip>true</skip>
</configuration>
<version>2.6.13</version>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
</build>
......
......@@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
@Component("kittyProperties")
@ConfigurationProperties(prefix = "kitty")
public class kittyProperties {
public class KittyProperties {
String path;
String venvPath;
String methodPath;
......@@ -15,6 +15,15 @@ public class kittyProperties {
String stagesHttp;
String reportHttp;
String mutationPath;
String aflnetPath;
public String getAflnetPath() {
return aflnetPath;
}
public void setAflnetPath(String aflnetPath) {
this.aflnetPath = aflnetPath;
}
public String getMutationPath() {
return mutationPath;
......
......@@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
@Component("seedProperties")
@ConfigurationProperties(prefix = "filepath")
public class seedProperties {
public class SeedProperties {
String seedPath;
public String getSeedPath() {
......
package com.example.fuzzControll.constents;
import com.example.fuzzControll.conf.SpringContextUtil;
import com.example.fuzzControll.conf.KittyProperties;
public class CmdConstent {
static KittyProperties kittyProperties = (KittyProperties)SpringContextUtil.getBean("kittyProperties");
public static final String GET_FILE_NAME = "ls -h ";
public static final String DELETE_FILE = "sudo rm -r ";
public static final String 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 " +
"-x "+kittyProperties.getAflnetPath()+"aflnet/tutorials/live555/rtsp.dict ";
public static final String RUN_PING = "ping www.baidu.com";
}
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_MUTATED_LIBS = "test_mutated_libs.py ";
public static final String TEST_MUTATION_STRATEGY = "test_mutation_strategy.py ";
......
package com.example.fuzzControll.constents;
public class protocolConstent {
public class ProtocolConstent {
public static final String ARP = "arp_raw.py ";
public static final String BGP = "bgp_tcp.py ";
public static final String DHCP = "dhcp_scapy.py ";
......
package com.example.fuzzControll.constents;
public class cmdConstent {
public static final String GET_FILE_NAME = "ls -h ";
public static final String DELETE_FILE = "sudo rm -r ";
public static final String RUN_AFLNET = "afl-fuzz -d -i /home/qbq/aflnet/tutorials/live555/in-rtsp -o out-live8 " +
"-x /home/qbq/aflnet/tutorials/live555/rtsp.dict ";
public static final String RUN_PING = "ping www.baidu.com";
}
package com.example.fuzzControll.controller;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.service.getServerMessageService;
import com.example.fuzzControll.service.GetServerMessageService;
import lombok.extern.slf4j.Slf4j;
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;
import java.util.Arrays;
/**
* kitty服务器信息
*/
@RestController
@RequestMapping("/kittyServer")
public class kittyServerMessageController {
@Slf4j
public class KittyServerMessageController {
@Autowired
getServerMessageService getServerMessageService;
GetServerMessageService getServerMessageService;
/**
* 获取服务器stats信息
*/
......@@ -23,6 +27,7 @@ public class kittyServerMessageController {
try {
return AjaxResult.success(getServerMessageService.getStats());
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("stats信息获取失败!");
}
}
......@@ -34,6 +39,7 @@ public class kittyServerMessageController {
try {
return AjaxResult.success(getServerMessageService.getTemplateInfo());
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("templateInfo信息获取失败!");
}
}
......@@ -45,7 +51,8 @@ public class kittyServerMessageController {
try {
return AjaxResult.success(getServerMessageService.getStages());
} catch (Exception e) {
return AjaxResult.error("stats信息获取失败!");
log.error(e.getMessage());
return AjaxResult.error("stages信息获取失败!");
}
}
/**
......@@ -56,7 +63,8 @@ public class kittyServerMessageController {
try {
return AjaxResult.success(getServerMessageService.getReport());
} catch (Exception e) {
return AjaxResult.error("stats信息获取失败!");
log.error(e.getMessage());
return AjaxResult.error("report信息获取失败!");
}
}
}
package com.example.fuzzControll.controller;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.service.seedFileService;
import com.example.fuzzControll.service.SeedFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -9,17 +10,19 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.util.Arrays;
import java.util.List;
/**
* aflnet种子文件
*/
@Slf4j
@RestController
@RequestMapping("/seedFile")
public class seedFileController {
public class SeedFileController {
@Autowired
seedFileService service;
SeedFileService service;
/**
* 种子文件查询接口
......@@ -30,6 +33,7 @@ public class seedFileController {
try {
files = service.getSeedFiles();
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("种子文件获取失败!");
}
return AjaxResult.success(files);
......@@ -43,6 +47,7 @@ public class seedFileController {
try {
service.delFile(fileName);
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("种子文件删除失败!");
}
return AjaxResult.success("种子文件删除成功!");
......@@ -55,6 +60,7 @@ public class seedFileController {
try {
service.upload(file);
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("种子文件upload失败!");
}
return AjaxResult.success("种子文件upload成功!");
......
package com.example.fuzzControll.controller;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.testEntity;
import com.example.fuzzControll.service.generateMethodService;
import com.example.fuzzControll.service.mutationService;
import com.example.fuzzControll.service.protocolTemplateService;
import com.example.fuzzControll.service.vulnerabilityTypeService;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.service.GenerateMethodService;
import com.example.fuzzControll.service.MutationService;
import com.example.fuzzControll.service.ProtocolTemplateService;
import com.example.fuzzControll.service.VulnerabilityTypeService;
import lombok.extern.slf4j.Slf4j;
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;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 不同类型的测试方法
*/
@Slf4j
@RestController
@RequestMapping("/testClass")
public class testClassController {
public class TestClassController {
@Autowired
generateMethodService generateMethodService;
GenerateMethodService generateMethodService;
@Autowired
mutationService mutationService;
MutationService mutationService;
@Autowired
protocolTemplateService protocolTemplateService;
ProtocolTemplateService protocolTemplateService;
@Autowired
vulnerabilityTypeService vulnerabilityTypeService;
VulnerabilityTypeService vulnerabilityTypeService;
/**
* 模板
*/
@RequestMapping(value = "/protocolTemplate", method = RequestMethod.POST)
public AjaxResult protocolTemplate(@RequestBody testEntity testEntity) {
public AjaxResult protocolTemplate(@RequestBody TestEntity testEntity) {
try {
Map<String, List<String>> result = protocolTemplateService.generation(testEntity);
return AjaxResult.success(result==null?"模板文件生成未成功运行":result);
} catch (Exception e) {
return AjaxResult.error("模板文件生成失败!");
log.error(e.getMessage());
return AjaxResult.error(e.getMessage());
}
}
......@@ -46,11 +50,12 @@ public class testClassController {
*生成方法
*/
@RequestMapping(value = "/generate", method = RequestMethod.POST)
public AjaxResult generate(@RequestBody testEntity testEntity) {
public AjaxResult generate(@RequestBody TestEntity testEntity) {
try {
Map<String, List<String>> result = generateMethodService.generation(testEntity);
return AjaxResult.success(result==null?"生成方法未成功运行":result);
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("生成方法使用失败!");
}
}
......@@ -59,11 +64,12 @@ public class testClassController {
*变异方法
*/
@RequestMapping(value = "/mutation", method = RequestMethod.POST)
public AjaxResult mutation(@RequestBody testEntity testEntity) {
public AjaxResult mutation(@RequestBody TestEntity testEntity) {
try {
Map<String, List<String>> result = mutationService.generation(testEntity);
return AjaxResult.success(result==null?"mutationTest未成功运行":result);
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("mutationTest失败!");
}
}
......@@ -72,11 +78,12 @@ public class testClassController {
*漏洞类型
*/
@RequestMapping(value = "/vulnerabilityType", method = RequestMethod.POST)
public AjaxResult upload(@RequestBody testEntity testEntity) {
public AjaxResult upload(@RequestBody TestEntity testEntity) {
try {
Map<String, List<String>> result = vulnerabilityTypeService.generation(testEntity);
return AjaxResult.success(result==null?"漏洞类型未成功运行":result);
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("漏洞类型测试失败!");
}
}
......
package com.example.fuzzControll.controller;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.cmdStartParams;
import com.example.fuzzControll.service.testService;
import com.example.fuzzControll.pojo.vo.CmdStartParams;
import com.example.fuzzControll.service.TestService;
import lombok.extern.slf4j.Slf4j;
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;
import java.util.Arrays;
/**
* aflnet测试控制
*/
@Slf4j
@RestController
@RequestMapping("/test")
public class testControler {
public class TestControler {
@Autowired
testService service;
TestService service;
/**
* 测试启动
*/
@RequestMapping(value = "/testStart", method = RequestMethod.POST)
public AjaxResult list(@RequestBody cmdStartParams cmdStartParams) {
public AjaxResult list(@RequestBody final CmdStartParams cmdStartParams) {
try {
new Thread(new Runnable() {
@Override
public void run() {
log.info("aflnet start!");
service.testStart(cmdStartParams);
}
}).start();
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("测试启动失败!");
}
return AjaxResult.success("测试启动成功!");
......@@ -44,6 +50,7 @@ public class testControler {
try {
service.testStop();
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("测试停止失败!");
}
return AjaxResult.success("测试停止成功!");
......
package com.example.fuzzControll.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.websocket.*;
......@@ -14,17 +15,18 @@ import java.util.concurrent.ConcurrentHashMap;
*/
@Component("WebSocket")
@ServerEndpoint("/websocket/testResult/{name}")
@Slf4j
public class WebSocket {
private Session session; //与某个客户端连接对话,通过此对客户端发送消息
private static final ConcurrentHashMap<String, WebSocket> WEBSOCKET_CONCURRENTHASHMAP = new ConcurrentHashMap<>(); //存放所有连接的客户端
private static final ConcurrentHashMap<String, WebSocket> WEBSOCKET_CONCURRENTHASHMAP = new ConcurrentHashMap<String, WebSocket>(); //存放所有连接的客户端
@OnOpen
public void onOpen(Session session, @PathParam(value = "name") String name) {
this.session = session; //默认客户端,没有重名
WEBSOCKET_CONCURRENTHASHMAP.put(name, this);
System.out.println("【webSocket连接成功】当前连接人数为:" + WEBSOCKET_CONCURRENTHASHMAP.size() + ",此人为:" + name);
log.info("Websocket is connected! The man is {}.There are {} people in the connection ",name,WEBSOCKET_CONCURRENTHASHMAP.size());
}
......@@ -40,8 +42,7 @@ public class WebSocket {
}
}
System.out.println("【webSocket退出成功】当前连接人数为:" + WEBSOCKET_CONCURRENTHASHMAP.size());
log.info("Websocket is closed! There are {} people in the connection ",WEBSOCKET_CONCURRENTHASHMAP.size());
}
@OnError
......@@ -93,7 +94,6 @@ public class WebSocket {
public void appointSending(String sender, String name, String message) {
try {
// WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(sender + ":" + message);
WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(message);
......
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() {
}
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() {
}
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;
@Data
@Getter
@Setter
public class cmdStartParams {
public class CmdStartParams {
String netinfo; //netInfo
String protopcol; //protocol
int waiting; //usec
......
......@@ -7,7 +7,7 @@ import lombok.Setter;
@Data
@Getter
@Setter
public class testEntity {
public class TestEntity {
String testClassName;
String[] paramJson;
}
......@@ -3,7 +3,7 @@ package com.example.fuzzControll.pojo.vo;
import lombok.Data;
@Data
public class testReturnEntity {
public class TestReturnEntity {
String run_time;
String cycles_done;
String last_new_path;
......
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.Map;
public interface generateMethodService {
Map<String,List<String>> generation(testEntity testEntity);
public interface GenerateMethodService {
Map<String,List<String>> generation(TestEntity testEntity);
}
package com.example.fuzzControll.service;
import java.util.List;
import java.util.Map;
public interface getServerMessageService {
public interface GetServerMessageService {
String getStats();
String getTemplateInfo();
......
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.Map;
public interface mutationService {
Map<String, List<String>> generation(testEntity testEntity);
public interface MutationService {
Map<String, List<String>> generation(TestEntity testEntity);
}
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.Map;
public interface protocolTemplateService {
Map<String,List<String>> generation(testEntity testEntity);
public interface ProtocolTemplateService {
Map<String,List<String>> generation(TestEntity testEntity);
}
......@@ -4,10 +4,11 @@ import org.springframework.web.multipart.MultipartFile;
import java.util.List;
public interface seedFileService {
public interface SeedFileService {
public List<String> getSeedFiles();
void delFile(String fileName);
void upload(MultipartFile file);
int getSeedFileCount(String msg);
}
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();
......
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.Map;
public interface vulnerabilityTypeService {
Map<String, List<String>> generation(testEntity testEntity);
public interface VulnerabilityTypeService {
Map<String, List<String>> generation(TestEntity testEntity);
}
package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.kittyProperties;
import com.example.fuzzControll.pojo.vo.testEntity;
import com.example.fuzzControll.service.generateMethodService;
import com.example.fuzzControll.tools.cmdTools;
import com.example.fuzzControll.tools.testTools;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.service.GenerateMethodService;
import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.TestTools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -14,13 +15,13 @@ import java.util.Map;
@Service
@Slf4j
public class generateMethodServiceImpl implements generateMethodService {
cmdTools cmdTools = new cmdTools();
public class GenerateMethodServiceImpl implements GenerateMethodService {
CmdTools cmdTools = new CmdTools();
@Autowired
kittyProperties kitty;
KittyProperties kitty;
@Override
public Map<String, List<String>> generation(testEntity testEntity) {
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException {
String cmd = parseParameters(testEntity);
if (cmd.isEmpty()) {
return null;
......@@ -28,7 +29,7 @@ public class generateMethodServiceImpl implements generateMethodService {
return cmdTools.runProgramCmdAndResult(cmd);
}
public String parseParameters(testEntity testEntity) {
public String parseParameters(TestEntity testEntity) {
switch (testEntity.getTestClassName().toLowerCase()) {
case "foreach":
return cmd(testEntity, "-f");
......@@ -56,8 +57,8 @@ public class generateMethodServiceImpl implements generateMethodService {
}
}
private String cmd(testEntity testEntity, String cmd) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 5, "generationMethod"))
private String cmd(TestEntity testEntity, String cmd) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 5, "generationMethod"))
return "";
String target_host = null;
String target_port = null;
......
package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.kittyProperties;
import com.example.fuzzControll.service.getServerMessageService;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.exception.ServerException;
import com.example.fuzzControll.service.GetServerMessageService;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
......@@ -12,16 +12,11 @@ import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service("getServerMessageService")
public class getServerMessageImpl implements getServerMessageService {
public class GetServerMessageImpl implements GetServerMessageService {
@Autowired
kittyProperties kitty;
KittyProperties kitty;
public String getServerMsg(String messageName) {
switch (messageName) {
......@@ -31,7 +26,7 @@ public class getServerMessageImpl implements getServerMessageService {
CloseableHttpResponse templateInfoResponse = httpClient.execute(httpGetTemplateInfo);) {
return EntityUtils.toString(templateInfoResponse.getEntity(), "utf-8");
} catch (Exception e) {
log.error("templateInfo http error!");
throw new ServerException("get server templateInfo error !");
}
}
case "stats": {
......@@ -40,7 +35,7 @@ public class getServerMessageImpl implements getServerMessageService {
CloseableHttpResponse statsResponse = httpClient.execute(httpGetStats);) {
return EntityUtils.toString(statsResponse.getEntity(), "utf-8");
} catch (Exception e) {
log.error("stats http error!");
throw new ServerException("get server stats error !");
}
}
case "report": {
......@@ -49,7 +44,8 @@ public class getServerMessageImpl implements getServerMessageService {
CloseableHttpResponse reportResponse = httpClient.execute(httpGetStats);) {
return EntityUtils.toString(reportResponse.getEntity(), "utf-8");
} catch (Exception e) {
log.error("report http error!");
throw new ServerException("get server report error !");
}
}
case "stages": {
......@@ -58,7 +54,7 @@ public class getServerMessageImpl implements getServerMessageService {
CloseableHttpResponse stagesResponse = httpClient.execute(httpGetStats);) {
return EntityUtils.toString(stagesResponse.getEntity(), "utf-8");
} catch (Exception e) {
log.error("stages http error!");
throw new ServerException("get server stages error !");
}
}
default:
......@@ -72,17 +68,17 @@ public class getServerMessageImpl implements getServerMessageService {
}
@Override
public String getTemplateInfo() {
public String getTemplateInfo() throws ServerException{
return getServerMsg("templateInfo");
}
@Override
public String getStages() {
return getServerMsg("report");
public String getStages() throws ServerException{
return getServerMsg("stages");
}
@Override
public String getReport() {
return getServerMsg("stages");
public String getReport() throws ServerException{
return getServerMsg("report");
}
}
package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.kittyProperties;
import com.example.fuzzControll.constents.mutationConstent;
import com.example.fuzzControll.pojo.vo.testEntity;
import com.example.fuzzControll.service.mutationService;
import com.example.fuzzControll.tools.cmdTools;
import com.example.fuzzControll.tools.testTools;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.MutationConstent;
import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.service.MutationService;
import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.TestTools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -15,14 +16,14 @@ import java.util.Map;
@Service("mutationService")
@Slf4j
class mutationServiceImpl implements mutationService {
cmdTools cmdTools = new cmdTools();
class MutationServiceImpl implements MutationService {
CmdTools cmdTools = new CmdTools();
@Autowired
kittyProperties kitty;
KittyProperties kitty;
@Override
public Map<String, List<String>> generation(testEntity testEntity) {
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException {
String cmd = parseParameters(testEntity);
if (cmd.isEmpty()) {
return null;
......@@ -30,7 +31,7 @@ class mutationServiceImpl implements mutationService {
return cmdTools.runProgramCmdAndResult(cmd);
}
public String parseParameters(testEntity testEntity) {
public String parseParameters(TestEntity testEntity) {
switch (testEntity.getTestClassName().toLowerCase()) {
case "bit":
return variationGranularityCmd(testEntity, 1);
......@@ -96,8 +97,8 @@ class mutationServiceImpl implements mutationService {
}
}
private String distortionLibCmd(testEntity testEntity, int methodNum) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "distortionLib" + methodNum))
private String distortionLibCmd(TestEntity testEntity, int methodNum) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "distortionLib" + methodNum))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -107,12 +108,12 @@ class mutationServiceImpl implements mutationService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "variationGranularity" + methodNum))
private String variationGranularityCmd(TestEntity testEntity, int methodNum) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "variationGranularity" + methodNum))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -122,10 +123,10 @@ class mutationServiceImpl implements mutationService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "mutationStrategy" + methodNum))
private String mutationStrategyCmd(TestEntity testEntity, int methodNum) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "mutationStrategy" + methodNum))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -135,7 +136,7 @@ class mutationServiceImpl implements mutationService {
} catch (Exception e) {
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;
import com.example.fuzzControll.conf.kittyProperties;
import com.example.fuzzControll.constents.protocolConstent;
import com.example.fuzzControll.pojo.vo.testEntity;
import com.example.fuzzControll.service.protocolTemplateService;
import com.example.fuzzControll.tools.cmdTools;
import com.example.fuzzControll.tools.testTools;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.ProtocolConstent;
import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.service.ProtocolTemplateService;
import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.TestTools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -16,118 +17,127 @@ import java.util.Map;
@Slf4j
@Service
public class protocolTemplateImpl implements protocolTemplateService {
cmdTools cmdTools = new cmdTools();
public class ProtocolTemplateImpl implements ProtocolTemplateService {
CmdTools cmdTools = new CmdTools();
@Autowired
kittyProperties kitty;
KittyProperties kitty;
@Override
public Map<String, List<String>> generation(testEntity testEntity) {
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException {
String cmd = parseParameters(testEntity);
if (cmd.isEmpty()) {
return null;
throw new FuzzException("cmd is null!");
}
return cmdTools.runProgramCmdAndResult(cmd);
}
public String parseParameters(testEntity testEntity) {
switch (testEntity.getTestClassName().toLowerCase()) {
case "arp":
return arpCmd(testEntity);
case "bgp":
return bgpCmd(testEntity);
case "dhcp":
return dhcpCmd(testEntity);
case "dns":
return dnsCmd(testEntity);
case "frp":
return frpCmd(testEntity);
case "ftp":
return ftpCmd(testEntity);
case "hdlc":
return hdlcCmd(testEntity);
case "http_dos_qemu":
return http_dos_qemuCmd(testEntity);
case "icmp"://need long time
return icmpCmd(testEntity);
case "igmpv1":
return igmpv1Cmd(testEntity);
case "igmpv2":
return igmpv2Cmd(testEntity);
case "imap"://cant run with error
return imapCmd(testEntity);
case "radius":
return radiusCmd(testEntity);
case "sip":
return sipCmd(testEntity);
case "rpc":
return rpcCmd(testEntity);
case "smb":
return smbCmd(testEntity);
case "ssl"://cant run with error
return sslCmd(testEntity);
case "ssh"://cant run with error
return sshCmd(testEntity);
case "nfs"://cant run with error
return nfsCmd(testEntity);
case "nntp"://cant run with error
return nntpCmd(testEntity);
case "ntp"://cant run with error
return ntpCmd(testEntity);
case "snmp"://cant run with error
return snmpCmd(testEntity);
case "upnp"://cant run with error
return upnpCmd(testEntity);
case "rarp":
return rarpCmd(testEntity);
case "lldp"://longtime
return lldpCmd(testEntity);
case "mstp"://longtime
return mstpCmd(testEntity);
case "ppp"://cant run with error
return pppCmd(testEntity);
case "pppoe"://longtime
return pppoeCmd(testEntity);
case "stp"://longtime
return stpCmd(testEntity);
case "vlan"://longtime cant get result
return vlanCmd(testEntity);
case "ospf"://longtime
return ospfCmd(testEntity);
case "isis"://have error
return isisCmd(testEntity);
case "ip"://have error
return ipCmd(testEntity);
case "telnet"://have error
return telnetCmd(testEntity);
case "pop3"://have error
return pop3Cmd(testEntity);
case "ipsec"://have error
return ipsecCmd(testEntity);
case "https"://have error
return httpsCmd(testEntity);
case "rip"://longtime
return ripCmd(testEntity);
case "netbios"://have error
return netbiosCmd(testEntity);
case "sharp":
return sharpCmd(testEntity);
case "tftp"://have error
return tftpCmd(testEntity);
case "udp":
return udpCmd(testEntity);
case "tcp"://have error
return tcpCmd(testEntity);
default:
log.error("未知协议![{}]", testEntity.getTestClassName());
return null;
//TODO testcase_dos/testcase_rpc/ftp_vuln_reproduce
}
}
private String tcpCmd(testEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "tcp"))
public String parseParameters(TestEntity testEntity) throws FuzzException {
if (testEntity == null) {
throw new FuzzException("testEntity is null!");
}
try {
switch (testEntity.getTestClassName().toLowerCase()) {
case "arp":
return arpCmd(testEntity);
case "bgp":
return bgpCmd(testEntity);
case "dhcp":
return dhcpCmd(testEntity);
case "dns":
return dnsCmd(testEntity);
case "frp":
return frpCmd(testEntity);
case "ftp":
return ftpCmd(testEntity);
case "hdlc":
return hdlcCmd(testEntity);
case "http_dos_qemu":
return http_dos_qemuCmd(testEntity);
case "icmp"://need long time
return icmpCmd(testEntity);
case "igmpv1":
return igmpv1Cmd(testEntity);
case "igmpv2":
return igmpv2Cmd(testEntity);
case "imap"://cant run with error
return imapCmd(testEntity);
case "radius":
return radiusCmd(testEntity);
case "sip":
return sipCmd(testEntity);
case "rpc":
return rpcCmd(testEntity);
case "smb":
return smbCmd(testEntity);
case "ssl"://cant run with error
return sslCmd(testEntity);
case "ssh"://cant run with error
return sshCmd(testEntity);
case "nfs"://cant run with error
return nfsCmd(testEntity);
case "nntp"://cant run with error
return nntpCmd(testEntity);
case "ntp"://cant run with error
return ntpCmd(testEntity);
case "snmp"://cant run with error
return snmpCmd(testEntity);
case "upnp"://cant run with error
return upnpCmd(testEntity);
case "rarp":
return rarpCmd(testEntity);
case "lldp"://longtime
return lldpCmd(testEntity);
case "mstp"://longtime
return mstpCmd(testEntity);
case "ppp"://cant run with error
return pppCmd(testEntity);
case "pppoe"://longtime
return pppoeCmd(testEntity);
case "stp"://longtime
return stpCmd(testEntity);
case "vlan"://longtime cant get result
return vlanCmd(testEntity);
case "ospf"://longtime
return ospfCmd(testEntity);
case "isis"://have error
return isisCmd(testEntity);
case "ip"://have error
return ipCmd(testEntity);
case "telnet"://have error
return telnetCmd(testEntity);
case "pop3"://have error
return pop3Cmd(testEntity);
case "ipsec"://have error
return ipsecCmd(testEntity);
case "https"://have error
return httpsCmd(testEntity);
case "rip"://longtime
return ripCmd(testEntity);
case "netbios"://have error
return netbiosCmd(testEntity);
case "sharp":
return sharpCmd(testEntity);
case "tftp"://have error
return tftpCmd(testEntity);
case "udp":
return udpCmd(testEntity);
case "tcp"://have error
return tcpCmd(testEntity);
default:
log.error("未知协议![{}]", testEntity.getTestClassName());
return null;
//TODO testcase_dos/testcase_rpc/ftp_vuln_reproduce
}
} catch (Exception e) {
throw new FuzzException("Count of params is not match!");
}
}
private String tcpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "tcp")) {
return "";
}
String dst_ip = null;
String src_ip = null;
try {
......@@ -136,12 +146,13 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "udp"))
private String udpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "udp")) {
return "";
}
String dst_ip = null;
String src_ip = null;
try {
......@@ -150,11 +161,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "tftp"))
private String tftpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "tftp"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -164,11 +175,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "sharp"))
private String sharpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "sharp"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -178,11 +189,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "netbios"))
private String netbiosCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "netbios"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -192,11 +203,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rip"))
private String ripCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rip"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -206,11 +217,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "https"))
private String httpsCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "https"))
return "";
String src_ip = null;
String src_port = null;
......@@ -224,11 +235,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "ipsec"))
private String ipsecCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "ipsec"))
return "";
String src_ip = null;
String dst_ip = null;
......@@ -240,11 +251,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "pop3"))
private String pop3Cmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "pop3"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -254,11 +265,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "telnet"))
private String telnetCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "telnet"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -268,11 +279,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "ip"))
private String ipCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "ip"))
return "";
String dst_mac = null;
String src_mac = null;
......@@ -286,11 +297,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 1, "isis"))
private String isisCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 1, "isis"))
return "";
String dst_mac = null;
try {
......@@ -298,11 +309,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ospf"))
private String ospfCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ospf"))
return "";
String dst_mac = null;
String dst_ip = null;
......@@ -312,11 +323,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "vlan"))
private String vlanCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "vlan"))
return "";
String dts_mac = null;
String src_mac = null;
......@@ -326,11 +337,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "stp"))
private String stpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "stp"))
return "";
String src_mac = null;
String dts_mac = null;
......@@ -340,11 +351,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "pppoe"))
private String pppoeCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "pppoe"))
return "";
String dst_mac = null;
String src_mac = null;
......@@ -358,17 +369,17 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "ppp"))
private String pppCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "ppp"))
return "";
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.PPP;
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.PPP;
}
private String mstpCmd(testEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "mstp"))
private String mstpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "mstp"))
return "";
String src_mac = null;
String dst_mac = null;
......@@ -378,17 +389,17 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "lldp"))
private String lldpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "lldp"))
return "";
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.LLDP;
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.LLDP;
}
private String rarpCmd(testEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rarp"))
private String rarpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rarp"))
return "";
String dst_mac = null;
String src_mac = null;
......@@ -398,11 +409,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "upnp"))
private String upnpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "upnp"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -412,11 +423,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "snmp"))
private String snmpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "snmp"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -426,11 +437,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ntp"))
private String ntpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ntp"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -440,11 +451,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "nntp"))
private String nntpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "nntp"))
return "";
String src_ip = null;
String src_port = null;
......@@ -458,11 +469,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "nfs"))
private String nfsCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "nfs"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -472,11 +483,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ssh"))
private String sshCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ssh"))
return "";
String dst_ip = null;
try {
......@@ -484,11 +495,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ssl"))
private String sslCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ssl"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -498,11 +509,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "smb"))
private String smbCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "smb"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -512,11 +523,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rpc"))
private String rpcCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rpc"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -526,11 +537,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "sip"))
private String sipCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "sip"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -540,11 +551,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "radius"))
private String radiusCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "radius"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -556,11 +567,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "imap"))
private String imapCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "imap"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -570,11 +581,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "igmpv2"))
private String igmpv2Cmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "igmpv2"))
return "";
String src_ip = null;
String dst_ip = null;
......@@ -586,11 +597,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "igmpv1"))
private String igmpv1Cmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "igmpv1"))
return "";
String src_ip = null;
String dst_ip = null;
......@@ -602,11 +613,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "icmp"))
private String icmpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "icmp"))
return "";
String dst_mac = null;
String src_mac = null;
......@@ -620,11 +631,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "http"))
private String http_dos_qemuCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "http"))
return "";
String dst_ip = null;
String port = null;
......@@ -634,17 +645,18 @@ public class protocolTemplateImpl implements protocolTemplateService {
} catch (Exception e) {
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "hdlc"))
private String hdlcCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "hdlc"))
return "";
return kitty.getVenvPath() + " " + kitty.getPath() + protocolConstent.HDLC;
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.HDLC;
}
private String ftpCmd(testEntity testEntity) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ftp"))
//todo need change
private String ftpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ftp"))
return "";
String target_host = null;
String target_port = null;
......@@ -653,12 +665,13 @@ public class protocolTemplateImpl implements protocolTemplateService {
target_port = testEntity.getParamJson()[1];
} catch (Exception e) {
log.error("ftp参数解析失败!");
throw new FuzzException("count of params is not match!");
}
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "frp"))
private String frpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "frp"))
return "";
String target_host = null;
String target_port = null;
......@@ -667,12 +680,13 @@ public class protocolTemplateImpl implements protocolTemplateService {
target_port = testEntity.getParamJson()[1];
} catch (Exception e) {
log.error("frp参数解析失败!");
throw new FuzzException("count of params is not match!");
}
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "dns"))
private String dnsCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "dns"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -681,12 +695,13 @@ public class protocolTemplateImpl implements protocolTemplateService {
dst_port = testEntity.getParamJson()[1];
} catch (Exception e) {
log.error("dns参数解析失败!");
throw new FuzzException("count of params is not match!");
}
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "dhcp"))
private String dhcpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "dhcp"))
return "";
String dst_ip = null;
String dst_port = null;
......@@ -695,12 +710,13 @@ public class protocolTemplateImpl implements protocolTemplateService {
dst_port = testEntity.getParamJson()[1];
} catch (Exception e) {
log.error("dhcp参数解析失败!");
throw new FuzzException("count of params is not match!");
}
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "bgp"))
private String bgpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "bgp"))
return "";
String src_ip = null;
String src_port = null;
......@@ -713,12 +729,13 @@ public class protocolTemplateImpl implements protocolTemplateService {
dst_port = testEntity.getParamJson()[3];
} catch (Exception e) {
log.error("bgp参数解析失败!");
throw new FuzzException("count of params is not match!");
}
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) {
if (!testTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "arp"))
public String arpCmd(TestEntity testEntity) throws FuzzException {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "arp"))
return "";
String dst_mac = null;
String src_mac = null;
......@@ -727,7 +744,8 @@ public class protocolTemplateImpl implements protocolTemplateService {
src_mac = testEntity.getParamJson()[1];
} catch (Exception e) {
log.error("arp参数解析失败!");
throw new FuzzException("count of params is not match!");
}
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(),"getSeedFiles");
}
//todo 同步修改可能会出现问题
@Override
public void delFile(String fileName) throws CmdException {
int fileCountBefore = 0;
int fileCountAfter = 0;
try {
fileCountBefore = getSeedFileCount("delFile before.");
cmdTools.runCmd(CmdConstent.DELETE_FILE + properties.getSeedPath() + "/" + fileName,"delFile");
fileCountAfter = getSeedFileCount("delFile after.");
} catch (CmdException e) {
throw new CmdException(e.getMessage());
}
if(fileCountAfter==fileCountBefore){
throw new CmdException("Delete unsuccess ! The file has not changed .Attempt to change permissions.");
}
}
@Override
public void upload(MultipartFile file) throws FileException,CmdException {
int fileCountBefore = 0;
int fileCountAfter = 0;
try {
fileCountBefore = getSeedFileCount("upload before.");
fileTools.load(file);
fileCountAfter = getSeedFileCount("upload after.");
} catch (CmdException e) {
throw new CmdException(e.getMessage());
} catch (FileException e){
throw new FileException(e.getMessage());
}
if(fileCountAfter==fileCountBefore){
throw new FileException("upload file error !The file failed to be submitted.Attempt to change permissions.");
}
}
/**
*
* 获取种子文件目录下文件数量
*/
@Override
public int getSeedFileCount(String msg) throws CmdException {
int count = 0;
try {
List<String> files = cmdTools.runCmd(CmdConstent.GET_FILE_NAME+ properties.getSeedPath(),"getSeedFileCount");
count = files.size();
} catch (CmdException e) {
throw new CmdException(e.getMessage()+" when "+msg);
}
return count;
}
}
package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.SpringContextUtil;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.CmdConstent;
import com.example.fuzzControll.exception.AflnetException;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.pojo.vo.CmdStartParams;
import com.example.fuzzControll.service.TestService;
import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.TestControlTools;
import org.springframework.stereotype.Service;
@Service("testService")
public class TestServiceImpl implements TestService {
KittyProperties kittyProperties = (KittyProperties) SpringContextUtil.getBean("kittyProperties");
CmdTools cmdTools = new CmdTools();
//todo 不同服务不同端口
@Override
public void testStart(CmdStartParams cmdStartParams) throws AflnetException {
TestControlTools.setIsRunning(true);
String cmd = cmdTools.parse(cmdStartParams);
String finalCmd = CmdConstent.RUN_AFLNET + cmd + kittyProperties.getAflnetPath()+"live555/testProgs/testOnDemandRTSPServer 8554";
cmdTools.runProgramCmd(finalCmd);
}
@Override
public void testStop() {
TestControlTools.setIsRunning(false);
}
}
package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.kittyProperties;
import com.example.fuzzControll.pojo.vo.testEntity;
import com.example.fuzzControll.service.vulnerabilityTypeService;
import com.example.fuzzControll.tools.cmdTools;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.service.VulnerabilityTypeService;
import com.example.fuzzControll.tools.CmdTools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -13,18 +14,18 @@ import java.util.Map;
@Slf4j
@Service("vulnerabilityTypeService")
public class vulnerabilityTypeServiceImpl implements vulnerabilityTypeService {
cmdTools cmdTools = new cmdTools();
public class VulnerabilityTypeServiceImpl implements VulnerabilityTypeService {
CmdTools cmdTools = new CmdTools();
@Autowired
kittyProperties kitty;
KittyProperties kitty;
@Override
public Map<String, List<String>> generation(testEntity testEntity) {
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException {
String cmd = parseParameters(testEntity);
return cmdTools.runProgramCmdAndResult(cmd);
}
public String parseParameters(testEntity testEntity) {
public String parseParameters(TestEntity testEntity) {
switch (testEntity.getTestClassName().toLowerCase()) {
case "array_index_out_of_bounds_vulnerabilit"://have error
return cmd(testEntity, 0);
......@@ -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;
}
//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);
}
}
package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.constents.cmdConstent;
import com.example.fuzzControll.pojo.vo.cmdStartParams;
import com.example.fuzzControll.service.testService;
import com.example.fuzzControll.tools.cmdTools;
import com.example.fuzzControll.tools.testControlTools;
import org.springframework.stereotype.Service;
@Service("testService")
public class testServiceImpl implements testService {
cmdTools cmdTools = new cmdTools();
//todo 不同服务不同端口
@Override
public void testStart(cmdStartParams cmdStartParams) {
testControlTools.setIsRunning(true);
String cmd = cmdTools.parse(cmdStartParams);
String finalCmd = cmdConstent.RUN_AFLNET+cmd+"/home/qbq/live555/testProgs/testOnDemandRTSPServer 8554";
System.out.println(finalCmd);
cmdTools.runProgramCmd(finalCmd);
}
@Override
public void testStop() {
testControlTools.setIsRunning(false);
}
}
......@@ -3,8 +3,12 @@ package com.example.fuzzControll.tools;
import com.alibaba.fastjson.JSONObject;
import com.example.fuzzControll.conf.SpringContextUtil;
import com.example.fuzzControll.controller.WebSocket;
import com.example.fuzzControll.pojo.vo.cmdStartParams;
import com.example.fuzzControll.pojo.vo.testReturnEntity;
import com.example.fuzzControll.exception.AflnetException;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.CmdStartParams;
import com.example.fuzzControll.pojo.vo.TestReturnEntity;
import lombok.extern.slf4j.Slf4j;
import java.io.*;
......@@ -12,22 +16,23 @@ import java.util.*;
//todo need modify
public class cmdTools {
@Slf4j
public class CmdTools {
Boolean send = false;
WebSocket socket = (WebSocket) SpringContextUtil.getBean("WebSocket");
/**
* 运行不需要后台运行cmd
*/
public List<String> runCmd(String cmd) {
List<String> result = new ArrayList<>();
public List<String> runCmd(String cmd,String caller) throws CmdException {
List<String> result = new ArrayList<String>();
try {
Process process = Runtime.getRuntime().exec(cmd);
printMessage(process.getInputStream(), result);
printMessage(process.getErrorStream(), new ArrayList<>());
printMessage(process.getErrorStream(), new ArrayList<String>());
process.waitFor();
} catch (Exception e) {
e.printStackTrace();
throw new CmdException(caller+" run cmd failed!");
}
return result;
......@@ -43,7 +48,7 @@ public class cmdTools {
try {
Process process = Runtime.getRuntime().exec(cmd);
printMessageToWeb(process.getInputStream(), process);
printMessage(process.getErrorStream(), new ArrayList<>());
printMessage(process.getErrorStream(), new ArrayList<String>());
process.waitFor();
} catch (Exception e) {
e.printStackTrace();
......@@ -54,24 +59,25 @@ public class cmdTools {
* 运行需要后台运行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();
List<String> out = Collections.synchronizedList(new ArrayList<>());
List<String> error = Collections.synchronizedList(new ArrayList<>());
List<String> out = Collections.synchronizedList(new ArrayList<String>());
List<String> error = Collections.synchronizedList(new ArrayList<String>());
try {
Process process = Runtime.getRuntime().exec(cmd);
printMessageByProgramCmd(process.getInputStream(), out);
printMessageByProgramCmd(process.getErrorStream(), error);
process.waitFor();
} catch (Exception e) {
e.printStackTrace();
log.error("aflnet run error!");
throw new FuzzException("run fuzz error !");
}
result.put("out", out);
result.put("error", error);
return result;
}
private List<String> printMessageByProgramCmd(InputStream input, List<String> result) throws InterruptedException {
private List<String> printMessageByProgramCmd(final InputStream input, final List<String> result) throws InterruptedException {
new Thread(new Runnable() {
@Override
public void run() {
......@@ -91,7 +97,7 @@ public class cmdTools {
return result;
}
private List<String> printMessage(final InputStream input, List<String> result) {
private List<String> printMessage(final InputStream input, final List<String> result) {
new Thread(new Runnable() {
@Override
public void run() {
......@@ -115,19 +121,17 @@ public class cmdTools {
Reader reader = new InputStreamReader(input);
BufferedReader bf = new BufferedReader(reader);
String line = null;
testReturnEntity returnEntity = new testReturnEntity();
while ((line = bf.readLine()) != null && testControlTools.getIsRunning()) {
TestReturnEntity returnEntity = new TestReturnEntity();
while ((line = bf.readLine()) != null && TestControlTools.getIsRunning()) {
makeReturnEntity(line, returnEntity);
if (send) {
String data = JSONObject.toJSONString(returnEntity);
socket.appointSending("backend100", "web100", data);
System.out.println(returnEntity + "*");
socket.appointSending("backend", "web", data);
}
}
}
private testReturnEntity makeReturnEntity(String line, testReturnEntity returnEntity) {
System.out.println(line);
private TestReturnEntity makeReturnEntity(String line, TestReturnEntity returnEntity) {
if (line.contains("run time")) {
send = false;
int run_time = line.indexOf(":");
......@@ -217,7 +221,10 @@ public class cmdTools {
return returnEntity;
}
public String parse(cmdStartParams cmdStartParams) {
public String parse(CmdStartParams cmdStartParams) throws AflnetException{
if(cmdStartParams==null){
throw new AflnetException("CmdStartParams is null!");
}
StringBuilder cmd = new StringBuilder();
if (cmdStartParams.getNetinfo() != "") {
cmd.append(" -N " + cmdStartParams.getNetinfo());
......
package com.example.fuzzControll.tools;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;
import java.io.BufferedInputStream;
......@@ -9,15 +11,18 @@ import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
public class fileTools {
seedProperties properties = (seedProperties) SpringContextUtil.getBean("seedProperties");
@Slf4j
public class FileTools {
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();
FileOutputStream outputStream = new FileOutputStream(properties.getSeedPath() + "/" + file.getOriginalFilename());) {
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = bufferedInputStream.read(buffer)) != -1) {
......@@ -25,6 +30,7 @@ public class fileTools {
}
} catch (Exception e) {
e.printStackTrace();
throw new FileException("write file error !");
}
}
......
package com.example.fuzzControll.tools;
//todo 对ip等增加正则判断
public class regularTools {
public class RegularTools {
}
package com.example.fuzzControll.tools;
public class testControlTools {
public class TestControlTools {
private static Boolean isRunning;
public static Boolean getIsRunning() {
......@@ -8,6 +8,6 @@ public class testControlTools {
}
public static void setIsRunning(Boolean isRunning) {
testControlTools.isRunning = isRunning;
TestControlTools.isRunning = isRunning;
}
}
......@@ -3,7 +3,7 @@ package com.example.fuzzControll.tools;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class testTools {
public class TestTools {
public static boolean paramsLenghtTest(int paramsLen,int needParamsLen,String name){
Boolean isOk = paramsLen==needParamsLen;
if(!isOk){
......
......@@ -14,14 +14,15 @@ logging:
max-file-size: 10MB
filepath:
seedPath: "/home/qbq/aflnet/tutorials/live555/in-rtsp"
seedPath: "/home/aflnet/tutorials/live555/in-rtsp"
kitty:
path: "/home/qbq/fuzz50/kitty/renix/" #kitty项目下的各协议生成模板python文件路径
venvPath: "/home/qbq/fuzz50/kitty/venv/bin/python"
methodPath: "/home/qbq/fuzz50/kitty/2020test/"#kitty下变异方法路径
vulnerabilityTypePath: "/home/qbq/fuzz50/kitty/2020test/"#kitty下漏洞类型python路径
mutationPath: "/home/qbq/fuzz50/kitty/2020test/"
aflnetPath: "/home/"
path: "/home/fuzz50/kitty/renix/" #kitty项目下的各协议生成模板python文件路径
venvPath: "/home/fuzz50/kitty/venv/bin/python"
methodPath: "/home/fuzz50/kitty/2020test/"#kitty下变异方法路径
vulnerabilityTypePath: "/home/fuzz50/kitty/2020test/"#kitty下漏洞类型python路径
mutationPath: "/home/fuzz50/kitty/2020test/"
templateInfoHttp: "http://127.0.0.1:26001/api/template_info.json"#模板信息请求链接
statsHttp: "http://127.0.0.1:26001/api/stats.json"#运行时数据
stagesHttp: "http://127.0.0.1:26001/api/stages.json"#
......
,--, ___ ,-.
.--., ,--.'| ,--.'|_ ,---, ,--/ /| ,---,
,--.' \ | | : ,---, | | :,' ,---,.,---.'| ,--. :/ | ,---, ,---.'|
| | /\/ : : ' ,-+-. / | : : ' : ,' .' || | : : : ' / ,-+-. / | | | :
,--.--. : : : ,---. | ' | ,--.'|' | ,---. .;__,' / ,---.' ,: : : ,--.--. ,---. | ' / ,---. ,--.'|' | | | |
/ \ : | |-, / \ ' | | | | ,"' | / \ | | | | | |: |,-. / \ / \ ' | : / \| | ,"' | ,--.__| |
.--. .-. || : :/| / / || | : | | / | | / / |:__,'| : : : .' | : ' | .--. .-. | / / ' | | \ / / | | / | | / ,' |
\__\/: . .| | .'. ' / |' : |__ | | | | |. ' / | ' : |__ : |.' | | / : \__\/: . .. ' / ' : |. \ . ' / | | | | |. ' / |
," .--.; |' : ' ' ; /|| | '.'|| | | |/ ' ; /| | | '.'|`---' ' : |: | ," .--.; |' ; :__ | | ' \ \' ; /| | | |/ ' ; |: |
/ / ,. || | | ' | / |; : ;| | |--' ' | / | ; : ; | | '/ : / / ,. |' | '.'|' : |--' ' | / | | |--' | | '/ '
; : .' \ : \ | : || , / | |/ | : | | , / | : |; : .' \ : :; |,' | : | |/ | : :|
| , .-./ |,' \ \ / ---`-' '---' \ \ / ---`-' / \ / | , .-./\ \ / '--' \ \ /'---' \ \ /
`--`---' `--' `----' `----' `-'----' `--`---' `----' `----' `----'
__ ___ _ __ _
/ _|_ _ ________ / __\ __ _ ___| | __ /__\ __ __| |
| |_| | | |_ /_ //__\/// _` |/ __| |/ //_\| '_ \ / _` |
| _| |_| |/ / / // \/ \ (_| | (__| <//__| | | | (_| |
|_| \__,_/___/___\_____/\__,_|\___|_|\_\__/|_| |_|\__,_|
\ No newline at end of file
......@@ -8,7 +8,7 @@
var ws1 = null;
var ws2 = null;
function myFunction() {
ws1 = new WebSocket("ws://192.168.37.149:8100/websocket/testResult/" + "web");
ws1 = new WebSocket("ws://localhost:8100/websocket/testResult/" + "web");
ws1.onmessage = function (evt) {
console.log(evt);
var received_msg =JSON.parse(evt.data) ;
......
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