整合aflcrash(未测试)
This commit is contained in:
parent
4aec4dc99d
commit
c78ef4d33b
@ -85,13 +85,16 @@ public class AFLWorker extends DockerWorker {
|
||||
Object timeObj = taskProperties.get(RUNNING_TIME);
|
||||
Double timeHours = Double.valueOf(String.valueOf(timeObj));
|
||||
String outputPath = AFL_DOCKER_BASE_DIR + File.separator + output;
|
||||
String commandScript = "docker run -v "+volumeWorkDirPath+":"+AFL_DOCKER_BASE_DIR+" -it "+imageName+" bash\n" +
|
||||
"cd " + AFL_DOCKER_BASE_DIR+File.separator+workDir+ "\n"+
|
||||
String allDir = AFL_DOCKER_BASE_DIR + File.separator + workDir;
|
||||
String initScript = "docker run -v " + volumeWorkDirPath + ":" + AFL_DOCKER_BASE_DIR + " -it " + imageName + " bash\n" +
|
||||
"cd " + allDir + "\n";
|
||||
String commandScript = initScript +
|
||||
cdSourceName(fileName) +
|
||||
"rm -rf " + outputPath + "\n" +
|
||||
"mkdir -p "+ outputPath +"\n" +
|
||||
"chmod o+rwx -R "+outputPath+"\n"+
|
||||
"afl-fuzz -i "+ AFL_DOCKER_BASE_DIR+File.separator+seedPath+" -o "+ outputPath+" ./"+ executableName + " " +commandEnd;
|
||||
String aflCrashScript= initScript+" python "+allDir+"/afl-crash-analyzer-m/AflCrashAnalyzer.py -i "+outputPath+"/default/crashes/ -o "+allDir+"/aflCrash/ -b "+allDir+getSourcePath(fileName)+File.separator+executableName;
|
||||
try {
|
||||
//将节点的配置信息反编译成对象
|
||||
log.info("AFL模糊测试执行脚本:{}",commandScript);
|
||||
@ -100,6 +103,9 @@ public class AFLWorker extends DockerWorker {
|
||||
append(context,"运行时间"+runningTime);
|
||||
// 获取docker 暂时先写固定值
|
||||
dockerRun(commandScript,resourceById.getDockerInfo(),context, runningTime);
|
||||
log.info("AFLCrash文件分析命令:{}",commandScript);
|
||||
append(context,"AFLCrash文件分析脚本:"+commandScript);
|
||||
dockerRun(aflCrashScript,resourceById.getDockerInfo(),context);
|
||||
} catch (Exception e) {
|
||||
String errorMessage = "执行afl失败"+e.getMessage() + "\r\n";
|
||||
log.error("执行afl失败", e);
|
||||
@ -121,6 +127,15 @@ public class AFLWorker extends DockerWorker {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
private String getSourcePath(String fileName){
|
||||
if (fileName.contains(".zip")||fileName.contains(".tar")||fileName.contains(".tar.gz")) {
|
||||
return fileName
|
||||
.replace(".zip","")
|
||||
.replace(".tar.gz","")
|
||||
.replace(".tar","");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
private Long getRunningTime(Double runningTimeHours){
|
||||
if (runningTimeHours!=null && runningTimeHours >0) {
|
||||
return (long)(runningTimeHours*60*60*1000);
|
||||
|
Loading…
x
Reference in New Issue
Block a user