Commit aba81cda by 钱炳权

算法2能够测试

parent 762d93b3
package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.AlgorithmOneCmdParams;
import com.example.fuzzControll.pojo.vo.AlgorithmTwoCmdParams;
public interface TestService {
void algorithmOneStart(AlgorithmOneCmdParams algorithmOneCmdParams);
void algorithmOneStart(AlgorithmTwoCmdParams algorithmTwoCmdParams);
void algorithmTwoStart(AlgorithmOneCmdParams algorithmOneCmdParams);
void testStop();
......
......@@ -5,6 +5,7 @@ import com.example.fuzzControll.constents.AlgorithmOneCmd;
import com.example.fuzzControll.constents.CmdConstent;
import com.example.fuzzControll.exception.AflnetException;
import com.example.fuzzControll.pojo.vo.AlgorithmOneCmdParams;
import com.example.fuzzControll.pojo.vo.AlgorithmTwoCmdParams;
import com.example.fuzzControll.service.TestService;
import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.TestControlTools;
......@@ -191,24 +192,64 @@ public class TestServiceImpl implements TestService {
//todo 不同服务不同端口
@Override
public void algorithmOneStart(AlgorithmOneCmdParams algorithmOneCmdParams) {
public void algorithmOneStart(AlgorithmTwoCmdParams algorithmTwoCmdParams) {
TestControlTools.setIsRunning(true);
String cmd = cmdTools.parse(algorithmOneCmdParams);
Date date = new Date();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss-");
String outputFileName = df.format(date) + algorithmOneCmdParams.getProtopcol() + "-output";
String finalCmd = CmdConstent.RUN_AFLNET_BEFORE + outputFileName + CmdConstent.RUN_AFLNET_AFTER + cmd + aflnetProperties.getAflnetPath() + "live555/testProgs/testOnDemandRTSPServer 8554";
log.info("The cmd is [{}]", finalCmd);
String aflnetCmd = getAlgorithmOneFinalCmd(algorithmTwoCmdParams);
if (aflnetCmd == null) {
log.error("AlgorithmOne Cmd is null!");
throw new AflnetException("Cmd Generate error!");
}
log.info("The cmd is [{}]", aflnetCmd);
try {
cmdTools.runProgramCmd("/home/lddc/nemo/profuzzbench/SMGfuzz/afl-fuzz -d -i /home/lddc/nemo/profuzzbench/subjects/DNS/Dnsmasq/in-dns -o /home/lddc/SHENYANLONG/dnsmasq/src/output_dnsmasq_RLGfuzz -N udp://127.0.0.1/5353 -m none -P DNS -D 10000 -K -E -R -q 4 -s 4 -r '4' /home/lddc/SHENYANLONG/dnsmasq/src/dnsmasq\n", "");
cmdTools.runProgramCmd(aflnetCmd,"");
} catch (JSchException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
// TestControlTools.setIsRunning(true);
// String cmd = cmdTools.parse(algorithmOneCmdParams);
// Date date = new Date();
// DateFormat df = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss-");
// String outputFileName = df.format(date) + algorithmOneCmdParams.getProtopcol() + "-output";
// String finalCmd = "/home/lddc/nemo/profuzzbench/SMGfuzz/afl-fuzz -d -i /home/lddc/nemo/profuzzbench/subjects/DNS/Dnsmasq/in-dns -o /home/lddc/SHENYANLONG/dnsmasq/src"+ outputFileName +" -N udp://127.0.0.1/5353 -m none -P DNS -D 10000 -K -E -R -q 4 -s 4 -r '4' /home/lddc/SHENYANLONG/dnsmasq/src/dnsmasq";
// log.info("The cmd is [{}]", finalCmd);
// try {
// cmdTools.runProgramCmd("/home/lddc/nemo/profuzzbench/SMGfuzz/afl-fuzz -d -i /home/lddc/nemo/profuzzbench/subjects/DNS/Dnsmasq/in-dns -o /home/lddc/SHENYANLONG/dnsmasq/src/output_dnsmasq_RLGfuzz -N udp://127.0.0.1/5353 -m none -P DNS -D 10000 -K -E -R -q 4 -s 4 -r '4' /home/lddc/SHENYANLONG/dnsmasq/src/dnsmasq\n", "");
// } catch (JSchException e) {
// throw new RuntimeException(e);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
}
private String getAlgorithmOneFinalCmd(AlgorithmTwoCmdParams algorithmTwoCmdParams) {
switch (algorithmTwoCmdParams.getProtopcol().toLowerCase()) {
case "dns":
return dnsOne(algorithmTwoCmdParams);
case "sip":
return "";
case "ftp":
return "";
case "rtsp":
return "";
default:
return null;
//todo 增加其他协议 的格式
}
}
private String dnsOne(AlgorithmTwoCmdParams algorithmTwoCmdParams) {
TestControlTools.setIsRunning(true);
Date date = new Date();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss-");
String outputFileName = df.format(date) + algorithmTwoCmdParams.getProtopcol() + "-output";
String finalCmd = "/home/lddc/nemo/profuzzbench/SMGfuzz/afl-fuzz -d -i /home/lddc/nemo/profuzzbench/subjects/DNS/Dnsmasq/in-dns -o /home/lddc/SHENYANLONG/dnsmasq/src"+ outputFileName +" -N udp://127.0.0.1/5353 -m none -P DNS -D 10000 -K -E -R -q 4 -s 4 -r '4' /home/lddc/SHENYANLONG/dnsmasq/src/dnsmasq";
log.info("The cmd is [{}]", finalCmd);
return finalCmd;
}
@Override
public void testStop() {
TestControlTools.setIsRunning(false);
......
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