Commit 91c7e11d by 钱炳权

24/4/1 漏洞类型、模板生成、变异方法 控制输出转为字符串输出

parent 3e45851d
......@@ -13,16 +13,16 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/generateMethod")
public class generateMethodController {
@Autowired
generateMethodService service;
@RequestMapping(value = "/generate", method = RequestMethod.POST)
public AjaxResult upload(@RequestBody generateMethodEntity generateMethodEntity) {
try {
service.generation(generateMethodEntity);
return AjaxResult.success(service.generation(generateMethodEntity));
} catch (Exception e) {
return AjaxResult.error("变异方法使用失败!");
}
return AjaxResult.success("变异方法生成成功!");
}
}
......@@ -3,6 +3,8 @@ package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.generateMethodEntity;
import com.example.fuzzControll.pojo.vo.protocolGenerationEntity;
import java.util.List;
public interface generateMethodService {
void generation(generateMethodEntity generateMethodEntity);
List<String> generation(generateMethodEntity generateMethodEntity);
}
......@@ -9,6 +9,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class generateMethodServiceImpl implements generateMethodService {
......@@ -17,9 +19,9 @@ public class generateMethodServiceImpl implements generateMethodService {
kittyProperties kitty;
@Override
public void generation(generateMethodEntity generateMethodEntity) {
public List<String> generation(generateMethodEntity generateMethodEntity) {
String cmd = parseParameters(generateMethodEntity);
cmdTools.runProgramCmdAndResultTofile(cmd);
return cmdTools.runProgramCmdAndResultTofile(cmd);
}
public String parseParameters(generateMethodEntity generateMethodEntity) {
......
......@@ -54,18 +54,20 @@ public class cmdTools {
* 运行需要后台运行cmd
* 将数据存入文件中
*/
public void runProgramCmdAndResultTofile(String cmd) {
public List<String> runProgramCmdAndResultTofile(String cmd) {
List<String> result = new ArrayList<>();
try {
Process process = Runtime.getRuntime().exec(cmd);
printMessageToFile(process.getInputStream());
printMessageToFile(process.getErrorStream());
printMessageToFile(process.getInputStream(), result);
printMessageToFile(process.getErrorStream(), new ArrayList<String>());
process.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
private void printMessageToFile(InputStream input) {
private List<String> printMessageToFile(InputStream input, List<String> result) {
new Thread(new Runnable() {
@Override
public void run() {
......@@ -74,7 +76,7 @@ public class cmdTools {
String line = null;
try {
while ((line = bf.readLine()) != null) {
System.out.println(line);
result.add(line);
}
} catch (IOException e) {
e.printStackTrace();
......@@ -82,6 +84,7 @@ public class cmdTools {
}
}).start();
return result;
}
private List<String> printMessage(final InputStream input, List<String> result) {
......
......@@ -8,7 +8,7 @@
var ws1 = null;
var ws2 = null;
function myFunction() {
ws1 = new WebSocket("ws://127.0.0.1:8080/websocket/testResult/" + "web"+100);
ws1 = new WebSocket("ws://192.168.37.149: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