Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fuzzBackEnd
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钱炳权
fuzzBackEnd
Commits
51383361
Commit
51383361
authored
Jun 14, 2024
by
钱炳权
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实验室环境成功返回websocket数据
parent
2b6461e2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
181 additions
and
102 deletions
+181
-102
TestServiceImpl.java
...om/example/fuzzControll/service/impl/TestServiceImpl.java
+123
-82
CmdTools.java
...rc/main/java/com/example/fuzzControll/tools/CmdTools.java
+4
-2
LinuxCommandUtil.java
...java/com/example/fuzzControll/tools/LinuxCommandUtil.java
+51
-13
result.html
fuzzIntegration/src/main/resources/result.html
+3
-5
No files found.
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/TestServiceImpl.java
View file @
51383361
...
...
@@ -31,14 +31,24 @@ public class TestServiceImpl implements TestService {
@Override
public
void
algorithmOneStart
(
AlgorithmOneCmdParams
algorithmOneCmdParams
)
{
TestControlTools
.
setIsRunning
(
true
);
String
finalCmd
=
getAlgorithmOneFinalCmd
(
algorithmOneCmdParams
);
if
(
finalCmd
==
null
)
{
String
aflnetCmd
=
getAlgorithmOneFinalCmd
(
algorithmOneCmdParams
);
String
pythonCmd
=
getAlgorithmOnePythonCmd
(
algorithmOneCmdParams
);
String
recodeCmd
=
getAlgorithmOneResultCmd
(
algorithmOneCmdParams
);
if
(
aflnetCmd
==
null
)
{
log
.
error
(
"AlgorithmOne Cmd is null!"
);
throw
new
AflnetException
(
"Cmd Generate error!"
);
}
log
.
info
(
"The cmd is [{}]"
,
finalCmd
);
if
(
pythonCmd
==
null
)
{
log
.
error
(
"pythonCmd Cmd is null!"
);
throw
new
AflnetException
(
"Cmd Generate error!"
);
}
if
(
recodeCmd
==
null
)
{
log
.
error
(
"recodeCmd Cmd is null!"
);
throw
new
AflnetException
(
"Cmd Generate error!"
);
}
log
.
info
(
"The cmd is [{}]"
,
aflnetCmd
);
try
{
cmdTools
.
runProgramCmd
(
final
Cmd
);
cmdTools
.
runProgramCmd
(
aflnetCmd
,
pythonCmd
,
recode
Cmd
);
}
catch
(
JSchException
e
)
{
throw
new
RuntimeException
(
e
);
}
catch
(
IOException
e
)
{
...
...
@@ -47,6 +57,39 @@ public class TestServiceImpl implements TestService {
}
private
String
getAlgorithmOneResultCmd
(
AlgorithmOneCmdParams
algorithmOneCmdParams
)
{
switch
(
algorithmOneCmdParams
.
getProtopcol
().
toLowerCase
())
{
case
"dns"
:
return
"cd /home/lddc/SHENYANLONG/SMGfuzz && python Copy_fuzz_stats.py --SUT dnsmasq --ALG RLGfuzz"
;
case
"sip"
:
return
"cd /home/lddc/SHENYANLONG/SMGfuzz/RL_Pytorch && python Copy_fuzz_stats.py --SUT kamailio --ALG RLGfuzz"
;
case
"ftp"
:
return
"cd /home/lddc/SHENYANLONG/SMGfuzz && python Copy_fuzz_stats.py --SUT kamailio --ALG RLGfuzz"
;
case
"rtsp"
:
return
"cd /home/lddc/SHENYANLONG/SMGfuzz && python Copy_fuzz_stats.py --SUT live555 --ALG RLGfuzz"
;
default
:
return
null
;
//todo 增加其他协议 的格式
}
}
private
String
getAlgorithmOnePythonCmd
(
AlgorithmOneCmdParams
algorithmOneCmdParams
)
{
switch
(
algorithmOneCmdParams
.
getProtopcol
().
toLowerCase
())
{
case
"dns"
:
return
"dnsResultCmd(algorithmOneCmdParams)"
;
case
"sip"
:
return
"sipResultCmd(algorithmOneCmdParams)"
;
case
"ftp"
:
return
"ftpResultCmd(algorithmOneCmdParams)"
;
case
"rtsp"
:
return
"rtspResultCmd(algorithmOneCmdParams)"
;
default
:
return
null
;
//todo 增加其他协议 的格式
}
}
private
String
getAlgorithmOneFinalCmd
(
AlgorithmOneCmdParams
algorithmOneCmdParams
)
{
switch
(
algorithmOneCmdParams
.
getProtopcol
().
toLowerCase
())
{
case
"dns"
:
...
...
@@ -64,92 +107,90 @@ public class TestServiceImpl implements TestService {
}
private
String
dnsCmd
(
AlgorithmOneCmdParams
algorithmOneCmdParams
)
{
// String before = AlgorithmOneCmd.ALFNET_PATH + " -d " + AlgorithmOneCmd.ALFNET_INPUT_PATH + "/dnsmasq/in-dns "
// +AlgorithmOneCmd.ALFNET_OUTPUT_PATH+"/dnsmasq/src/output_dnsmasq_RLGfuzz"+" -z "+algorithmOneCmdParams.getTrainedModelInputPath()
// +" -N "+algorithmOneCmdParams.getNetinfo()+" -m none "+" -P "+algorithmOneCmdParams.getProtopcol()+" -D "
// +algorithmOneCmdParams.getWaiting();
// String after = " -q "+algorithmOneCmdParams.getStateSelectionAlgo()+" -s "+algorithmOneCmdParams.getSeedSelectionAlgo()+" -r '4' /home/lddc/SHENYANLONG/dnsmasq/src/dnsmasq";
// String finalCmd = before;
// if(algorithmOneCmdParams.getKill()){
// finalCmd = finalCmd+" -K ";
// }
// if(algorithmOneCmdParams.getAwareMode())
// finalCmd = finalCmd+" -E ";
// if(algorithmOneCmdParams.getRegionMutationOperators())
// finalCmd = finalCmd+" -R ";
// if(!"".equals(algorithmOneCmdParams.getScript()))
// finalCmd = finalCmd+" -c "+algorithmOneCmdParams.getScript();
// if(!"".equals(algorithmOneCmdParams.getTrainedModelInputPath()))
// finalCmd = finalCmd+" -c "+algorithmOneCmdParams.getScript();
// finalCmd = finalCmd+after;
// return finalCmd;
return
"/home/lddc/SHENYANLONG/SMGfuzz/afl-fuzz -d -i /home/lddc/SHENYANLONG/dnsmasq/in-dns -o /home/lddc/SHENYANLONG/dnsmasq/src/output_dnsmasq_RLGfuzz -z /home/lddc/SHENYANLONG/SMGfuzz/RL_Pytorch/Train_Result/dnsmasq/RL_Result -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"
;
String
before
=
AlgorithmOneCmd
.
ALFNET_PATH
+
" -d "
+
AlgorithmOneCmd
.
ALFNET_INPUT_PATH
+
"/dnsmasq/in-dns "
+
AlgorithmOneCmd
.
ALFNET_OUTPUT_PATH
+
"/dnsmasq/src/output_dnsmasq_RLGfuzz"
;
if
(!
""
.
equals
(
algorithmOneCmdParams
.
getTrainedModelInputPath
()))
{
before
=
before
+
" -z "
+
algorithmOneCmdParams
.
getTrainedModelInputPath
();
}
before
=
before
+
" -N "
+
algorithmOneCmdParams
.
getNetinfo
()
+
" -m none "
+
" -P "
+
algorithmOneCmdParams
.
getProtopcol
()
+
" -D "
+
algorithmOneCmdParams
.
getWaiting
();
String
after
=
" -q "
+
algorithmOneCmdParams
.
getStateSelectionAlgo
()
+
" -s "
+
algorithmOneCmdParams
.
getSeedSelectionAlgo
()
+
" -r '4' /home/lddc/SHENYANLONG/dnsmasq/src/dnsmasq"
;
String
finalCmd
=
before
;
if
(
algorithmOneCmdParams
.
getKill
())
{
finalCmd
=
finalCmd
+
" -K "
;
}
if
(
algorithmOneCmdParams
.
getAwareMode
())
finalCmd
=
finalCmd
+
" -E "
;
if
(
algorithmOneCmdParams
.
getRegionMutationOperators
())
finalCmd
=
finalCmd
+
" -R "
;
if
(!
""
.
equals
(
algorithmOneCmdParams
.
getScript
()))
finalCmd
=
finalCmd
+
" -c "
+
algorithmOneCmdParams
.
getScript
();
finalCmd
=
finalCmd
+
after
;
return
finalCmd
;
// return "/home/lddc/SHENYANLONG/SMGfuzz/afl-fuzz -d -i /home/lddc/SHENYANLONG/dnsmasq/in-dns -o /home/lddc/SHENYANLONG/dnsmasq/src/output_dnsmasq_RLGfuzz -z /home/lddc/SHENYANLONG/SMGfuzz/RL_Pytorch/Train_Result/dnsmasq/RL_Result -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";
}
private
String
sipCmd
(
AlgorithmOneCmdParams
algorithmOneCmdParams
)
{
// String before = AlgorithmOneCmd.ALFNET_PATH
+ AlgorithmOneCmd.ALFNET_INPUT_PATH + "/kamailio/in-sip "
// +AlgorithmOneCmd.ALFNET_OUTPUT_PATH+"/kamailio/output_kamailio_RLGfuzz"+" -z "+algorithmOneCmdParams.getTrainedModelInputPath()
// +" -N "+algorithmOneCmdParams.getNetinfo()+" -m none -t 3000+ "+" -P "+algorithmOneCmdParams.getProtopcol()+" -l 5061 "+" -D "
// +algorithmOneCmdParams.getWaiting()+" -d "
;
// String after = " -q "+algorithmOneCmdParams.getStateSelectionAlgo()+" -s "+algorithmOneCmdParams.getSeedSelectionAlgo()
// +" /home/lddc/SHENYANLONG/kamailio/src/kamailio -f /home/lddc/SHENYANLONG/kamailio/kamailio-basic.cfg -L /home/lddc/SHENYANLONG/kamailio/src/modules -n 1 -Y /home/lddc/SHENYANLONG/kamailio/runtime_dir"
;
// String finalCmd = before;
// if(algorithmOneCmdParams.getKill()){
// finalCmd = finalCmd+" -K ";
// }
// if(algorithmOneCmdParams.getAwareMode())
// finalCmd = finalCmd+" -E ";
// if(algorithmOneCmdParams.getRegionMutationOperators())
// finalCmd = finalCmd+" -R ";
// if(!"".equals(algorithmOneCmdParams.getScript()))
// finalCmd = finalCmd+" -c "+algorithmOneCmdParams.getScript()
;
// finalCmd = finalCmd+
after;
// return finalCmd
;
return
"/home/lddc/SHENYANLONG/SMGfuzz/afl-fuzz -i /home/lddc/SHENYANLONG/kamailio/in-sip -o /home/lddc/SHENYANLONG/kamailio/output_kamailio_RLGfuzz -z /home/lddc/SHENYANLONG/SMGfuzz/RL_Pytorch/Train_Result/kamailio/RL_Result -N udp://127.0.0.1/5060 -m none -t 3000+ -P SIP -l 5061 -D 50000 -q 4 -s 4 -E -K -R -d -c /home/lddc/SHENYANLONG/kamailio/run_pjsip.sh /home/lddc/SHENYANLONG/kamailio/src/kamailio -f /home/lddc/SHENYANLONG/kamailio/kamailio-basic.cfg -L /home/lddc/SHENYANLONG/kamailio/src/modules -n 1 -Y /home/lddc/SHENYANLONG/kamailio/runtime_dir"
;
String
before
=
AlgorithmOneCmd
.
ALFNET_PATH
+
AlgorithmOneCmd
.
ALFNET_INPUT_PATH
+
"/kamailio/in-sip "
+
AlgorithmOneCmd
.
ALFNET_OUTPUT_PATH
+
"/kamailio/output_kamailio_RLGfuzz"
;
if
(!
""
.
equals
(
algorithmOneCmdParams
.
getTrainedModelInputPath
()))
before
=
before
+
" -z "
+
algorithmOneCmdParams
.
getTrainedModelInputPath
()
;
before
=
before
+
" -N "
+
algorithmOneCmdParams
.
getNetinfo
()
+
" -m none -t 3000+ "
+
" -P "
+
algorithmOneCmdParams
.
getProtopcol
()
+
" -l 5061 "
+
" -D "
+
algorithmOneCmdParams
.
getWaiting
()+
" -q "
+
algorithmOneCmdParams
.
getStateSelectionAlgo
()
+
" -s "
+
algorithmOneCmdParams
.
getSeedSelectionAlgo
()
;
if
(
algorithmOneCmdParams
.
getKill
())
{
before
=
before
+
" -K "
;
}
if
(
algorithmOneCmdParams
.
getAwareMode
())
before
=
before
+
" -E "
;
if
(
algorithmOneCmdParams
.
getRegionMutationOperators
())
before
=
before
+
" -R "
;
if
(!
""
.
equals
(
algorithmOneCmdParams
.
getScript
()))
before
=
before
+
" -c "
+
algorithmOneCmdParams
.
getScript
();
String
after
=
" -d /home/lddc/SHENYANLONG/kamailio/src/kamailio -f /home/lddc/SHENYANLONG/kamailio/kamailio-basic.cfg -L /home/lddc/SHENYANLONG/kamailio/src/modules -n 1 -Y /home/lddc/SHENYANLONG/kamailio/runtime_dir"
;
before
=
before
+
after
;
return
before
;
//
return "/home/lddc/SHENYANLONG/SMGfuzz/afl-fuzz -i /home/lddc/SHENYANLONG/kamailio/in-sip -o /home/lddc/SHENYANLONG/kamailio/output_kamailio_RLGfuzz -z /home/lddc/SHENYANLONG/SMGfuzz/RL_Pytorch/Train_Result/kamailio/RL_Result -N udp://127.0.0.1/5060 -m none -t 3000+ -P SIP -l 5061 -D 50000 -q 4 -s 4 -E -K -R -d -c /home/lddc/SHENYANLONG/kamailio/run_pjsip.sh /home/lddc/SHENYANLONG/kamailio/src/kamailio -f /home/lddc/SHENYANLONG/kamailio/kamailio-basic.cfg -L /home/lddc/SHENYANLONG/kamailio/src/modules -n 1 -Y /home/lddc/SHENYANLONG/kamailio/runtime_dir";
}
private
String
ftpCmd
(
AlgorithmOneCmdParams
algorithmOneCmdParams
)
{
// String before = AlgorithmOneCmd.ALFNET_PATH + AlgorithmOneCmd.ALFNET_INPUT_PATH + "/SMGfuzz/tutorials/lightftp/in-ftp "
// +AlgorithmOneCmd.ALFNET_OUTPUT_PATH+"/LightFTP/Source/Release/output_lightftp_RLGfuzz"+" -z "+algorithmOneCmdParams.getTrainedModelInputPath()
// +" -N "+algorithmOneCmdParams.getNetinfo()+" -m none "+" -P "+algorithmOneCmdParams.getProtopcol()+" -l 5061 "+" -D "
// +algorithmOneCmdParams.getWaiting()+" -d ";
// String after = " -q "+algorithmOneCmdParams.getStateSelectionAlgo()+" -s "+algorithmOneCmdParams.getSeedSelectionAlgo()
// +" /home/lddc/SHENYANLONG/kamailio/src/kamailio -f /home/lddc/SHENYANLONG/kamailio/kamailio-basic.cfg -L /home/lddc/SHENYANLONG/kamailio/src/modules -n 1 -Y /home/lddc/SHENYANLONG/kamailio/runtime_dir";
// String finalCmd = before;
// if(algorithmOneCmdParams.getKill()){
// finalCmd = finalCmd+" -K ";
// }
// if(algorithmOneCmdParams.getAwareMode())
// finalCmd = finalCmd+" -E ";
// if(algorithmOneCmdParams.getRegionMutationOperators())
// finalCmd = finalCmd+" -R ";
// if(!"".equals(algorithmOneCmdParams.getScript()))
// finalCmd = finalCmd+" -c "+algorithmOneCmdParams.getScript();
// finalCmd = finalCmd+after;
// return finalCmd;
return
"/home/lddc/SHENYANLONG/SMGfuzz/afl-fuzz -m none -i /home/lddc/SHENYANLONG/SMGfuzz/tutorials/lightftp/in-ftp -o /home/lddc/SHENYANLONG/LightFTP/Source/Release/output_lightftp_RLGfuzz -N tcp://127.0.0.1/2200 -z /home/lddc/SHENYANLONG/SMGfuzz/RL_Pytorch/Train_Result/lightftp/RL_Result -x /home/lddc/SHENYANLONG/SMGfuzz/tutorials/lightftp/ftp.dict -P FTP -D 10000 -q 4 -s 4 -E -K -R -d -c /home/lddc/SHENYANLONG/LightFTP/Source/Release/ftpclean.sh /home/lddc/SHENYANLONG/LightFTP/Source/Release/fftp /home/lddc/SHENYANLONG/LightFTP/Source/Release/fftp.conf 2200"
;
String
before
=
AlgorithmOneCmd
.
ALFNET_PATH
+
" -m none "
+
AlgorithmOneCmd
.
ALFNET_INPUT_PATH
+
"/SMGfuzz/tutorials/lightftp/in-ftp "
+
AlgorithmOneCmd
.
ALFNET_OUTPUT_PATH
+
"/LightFTP/Source/Release/output_lightftp_RLGfuzz"
+
" -z "
+
algorithmOneCmdParams
.
getTrainedModelInputPath
()
+
" -x /home/lddc/SHENYANLONG/SMGfuzz/tutorials/lightftp/ftp.dict"
+
" -N "
+
algorithmOneCmdParams
.
getNetinfo
()+
" -P "
+
algorithmOneCmdParams
.
getProtopcol
()+
" -D "
+
algorithmOneCmdParams
.
getWaiting
()+
" -d "
+
" -q "
+
algorithmOneCmdParams
.
getStateSelectionAlgo
()+
" -s "
+
algorithmOneCmdParams
.
getSeedSelectionAlgo
();
if
(
algorithmOneCmdParams
.
getKill
()){
before
=
before
+
" -K "
;
}
if
(
algorithmOneCmdParams
.
getAwareMode
())
before
=
before
+
" -E "
;
if
(
algorithmOneCmdParams
.
getRegionMutationOperators
())
before
=
before
+
" -R "
;
if
(!
""
.
equals
(
algorithmOneCmdParams
.
getScript
()))
before
=
before
+
" -c "
+
algorithmOneCmdParams
.
getScript
();
before
=
before
+
" /home/lddc/SHENYANLONG/LightFTP/Source/Release/fftp /home/lddc/SHENYANLONG/LightFTP/Source/Release/fftp.conf 2200"
;;
return
before
;
// return "/home/lddc/SHENYANLONG/SMGfuzz/afl-fuzz -m none -i /home/lddc/SHENYANLONG/SMGfuzz/tutorials/lightftp/in-ftp -o /home/lddc/SHENYANLONG/LightFTP/Source/Release/output_lightftp_RLGfuzz -N tcp://127.0.0.1/2200 -z /home/lddc/SHENYANLONG/SMGfuzz/RL_Pytorch/Train_Result/lightftp/RL_Result -x /home/lddc/SHENYANLONG/SMGfuzz/tutorials/lightftp/ftp.dict -P FTP -D 10000 -q 4 -s 4 -E -K -R -d -c /home/lddc/SHENYANLONG/LightFTP/Source/Release/ftpclean.sh /home/lddc/SHENYANLONG/LightFTP/Source/Release/fftp /home/lddc/SHENYANLONG/LightFTP/Source/Release/fftp.conf 2200";
}
private
String
rtspCmd
(
AlgorithmOneCmdParams
algorithmOneCmdParams
)
{
// String before = AlgorithmOneCmd.ALFNET_PATH + AlgorithmOneCmd.ALFNET_INPUT_PATH + "/kamailio/in-sip "
// +AlgorithmOneCmd.ALFNET_OUTPUT_PATH+"/kamailio/output_kamailio_RLGfuzz"+" -z "+algorithmOneCmdParams.getTrainedModelInputPath()
// +" -N "+algorithmOneCmdParams.getNetinfo()+" -m none -t 3000+ "+" -P "+algorithmOneCmdParams.getProtopcol()+" -l 5061 "+" -D "
// +algorithmOneCmdParams.getWaiting()+" -d ";
// String after = " -q "+algorithmOneCmdParams.getStateSelectionAlgo()+" -s "+algorithmOneCmdParams.getSeedSelectionAlgo()
// +" /home/lddc/SHENYANLONG/kamailio/src/kamailio -f /home/lddc/SHENYANLONG/kamailio/kamailio-basic.cfg -L /home/lddc/SHENYANLONG/kamailio/src/modules -n 1 -Y /home/lddc/SHENYANLONG/kamailio/runtime_dir";
// String finalCmd = before;
// if(algorithmOneCmdParams.getKill()){
// finalCmd = finalCmd+" -K ";
// }
// if(algorithmOneCmdParams.getAwareMode())
// finalCmd = finalCmd+" -E ";
// if(algorithmOneCmdParams.getRegionMutationOperators())
// finalCmd = finalCmd+" -R ";
// if(!"".equals(algorithmOneCmdParams.getScript()))
// finalCmd = finalCmd+" -c "+algorithmOneCmdParams.getScript();
// finalCmd = finalCmd+after;
// return finalCmd;
return
"/home/lddc/SHENYANLONG/SMGfuzz/afl-fuzz -i /home/lddc/SHENYANLONG/SMGfuzz/tutorials/live555/in-rtsp -o /home/lddc/SHENYANLONG/live555/testProgs/output_live555_RLGfuzz -z /home/lddc/SHENYANLONG/SMGfuzz/RL_Pytorch/Train_Result/live555/RL_Result -N tcp://127.0.0.1/8554 -x /home/lddc/SHENYANLONG/SMGfuzz/tutorials/live555/rtsp.dict -m none -D 10000 -K -E -R -q 4 -s 4 -d /home/lddc/SHENYANLONG/live555/testProgs/testOnDemandRTSPServer 85540"
;
String
before
=
AlgorithmOneCmd
.
ALFNET_PATH
+
AlgorithmOneCmd
.
ALFNET_INPUT_PATH
+
"/SMGfuzz/tutorials/live555/in-rtsp "
+
AlgorithmOneCmd
.
ALFNET_OUTPUT_PATH
+
"/live555/testProgs/output_live555_RLGfuzz"
+
" -z "
+
algorithmOneCmdParams
.
getTrainedModelInputPath
()
+
" -N "
+
algorithmOneCmdParams
.
getNetinfo
()+
" -x /home/lddc/SHENYANLONG/SMGfuzz/tutorials/live555/rtsp.dict "
+
" -P "
+
algorithmOneCmdParams
.
getProtopcol
()+
" -m none "
+
" -D "
+
algorithmOneCmdParams
.
getWaiting
()+
" -d -r 400"
;
String
after
=
" -q "
+
algorithmOneCmdParams
.
getStateSelectionAlgo
()+
" -s "
+
algorithmOneCmdParams
.
getSeedSelectionAlgo
()
+
" /home/lddc/SHENYANLONG/live555/testProgs/testOnDemandRTSPServer 8554"
;
if
(
algorithmOneCmdParams
.
getKill
()){
before
=
before
+
" -K "
;
}
if
(
algorithmOneCmdParams
.
getAwareMode
())
before
=
before
+
" -E "
;
if
(
algorithmOneCmdParams
.
getRegionMutationOperators
())
before
=
before
+
" -R "
;
if
(!
""
.
equals
(
algorithmOneCmdParams
.
getScript
()))
before
=
before
+
" -c "
+
algorithmOneCmdParams
.
getScript
();
before
=
before
+
after
;
return
before
;
// return "/home/lddc/SHENYANLONG/SMGfuzz/afl-fuzz -i /home/lddc/SHENYANLONG/SMGfuzz/tutorials/live555/in-rtsp -o /home/lddc/SHENYANLONG/live555/testProgs/output_live555_RLGfuzz -z /home/lddc/SHENYANLONG/SMGfuzz/RL_Pytorch/Train_Result/live555/RL_Result -N tcp://127.0.0.1/8554 -x /home/lddc/SHENYANLONG/SMGfuzz/tutorials/live555/rtsp.dict -m none -D 10000 -K -E -R -q 4 -s 4 -d /home/lddc/SHENYANLONG/live555/testProgs/testOnDemandRTSPServer 85540";
}
//todo 不同服务不同端口
...
...
@@ -163,7 +204,7 @@ public class TestServiceImpl implements TestService {
String
finalCmd
=
CmdConstent
.
RUN_AFLNET_BEFORE
+
outputFileName
+
CmdConstent
.
RUN_AFLNET_AFTER
+
cmd
+
aflnetProperties
.
getAflnetPath
()
+
"live555/testProgs/testOnDemandRTSPServer 8554"
;
log
.
info
(
"The cmd is [{}]"
,
finalCmd
);
try
{
cmdTools
.
runProgramCmd
(
"source /etc/profile && "
+
finalCmd
);
cmdTools
.
runProgramCmd
(
"source /etc/profile && "
+
finalCmd
,
""
,
""
);
}
catch
(
JSchException
e
)
{
throw
new
RuntimeException
(
e
);
}
catch
(
IOException
e
)
{
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/CmdTools.java
View file @
51383361
...
...
@@ -41,7 +41,7 @@ public class CmdTools {
* 运行需要后台运行cmd
* 通过websocket返回数据
*/
public
void
runProgramCmd
(
String
c
md
)
throws
AflnetException
,
JSchException
,
IOException
{
public
void
runProgramCmd
(
String
aflnetCmd
,
String
pythonCmd
,
String
recodeC
md
)
throws
AflnetException
,
JSchException
,
IOException
{
AflnetSshProperties
aflnetSshProperties
=
GlobalParameters
.
aflnetSshProperties
;
String
host
=
aflnetSshProperties
.
getHost
();
int
port
=
aflnetSshProperties
.
getPort
();
...
...
@@ -50,7 +50,9 @@ public class CmdTools {
// 手动创建对象实现连接
LinuxCommandUtil
linuxCommandUtil
=
new
LinuxCommandUtil
();
linuxCommandUtil
.
connect
(
host
,
port
,
user
,
password
);
linuxCommandUtil
.
execCmd
(
cmd
);
linuxCommandUtil
.
execCmd
(
aflnetCmd
);
// linuxCommandUtil.execCmdWithoutResults(pythonCmd);
// linuxCommandUtil.execCmdWithoutResults(recodeCmd);
}
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/LinuxCommandUtil.java
View file @
51383361
...
...
@@ -3,6 +3,7 @@ package com.example.fuzzControll.tools;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Scanner
;
import
com.alibaba.fastjson.JSONObject
;
import
com.example.fuzzControll.pojo.vo.TestReturnEntity
;
...
...
@@ -11,6 +12,7 @@ import com.jcraft.jsch.ChannelExec;
import
com.jcraft.jsch.JSch
;
import
com.jcraft.jsch.JSchException
;
import
com.jcraft.jsch.Session
;
import
org.apache.tomcat.util.buf.Utf8Decoder
;
public
class
LinuxCommandUtil
{
...
...
@@ -82,30 +84,66 @@ public class LinuxCommandUtil {
public
void
execCmd
(
String
command
)
throws
JSchException
,
IOException
{
List
<
String
>
result
=
new
ArrayList
<>();
InputStream
in
=
channelExec
.
getInputStream
();
InputStream
error
=
channelExec
.
getErrStream
();
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
outPutStream
(
in
);
}
}).
start
();
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
errorStream
(
error
);
}
}).
start
();
channelExec
.
setCommand
(
command
);
channelExec
.
setErrStream
(
System
.
err
);
channelExec
.
connect
();
}
/**
* 不需要结果执行指令
*/
public
void
execCmdWithoutResults
(
String
command
)
throws
JSchException
,
IOException
{
channelExec
.
setCommand
(
command
);
channelExec
.
connect
();
}
public
void
outPutStream
(
InputStream
in
)
{
Reader
reader
=
new
InputStreamReader
(
in
);
BufferedReader
bf
=
new
BufferedReader
(
reader
);
CmdTools
cmdTools
=
new
CmdTools
();
String
line
=
null
;
TestReturnEntity
returnEntity
=
new
TestReturnEntity
();
List
<
String
>
list
=
null
;
try
{
while
((
line
=
bf
.
readLine
())
!=
null
&&
TestControlTools
.
getIsRunning
())
{
System
.
out
.
println
(
line
);
if
(
line
.
contains
(
"american fuzzy"
))
{
list
=
new
ArrayList
<>();
}
if
(
list
!=
null
)
list
.
add
(
line
+
"\n"
);
if
(
line
.
contains
(
"cpu"
))
GlobalParameters
.
webSocket
.
appointSending
(
"fuzzMaster"
,
"web"
,
list
.
toString
());
}
//结束就关闭
if
(!
TestControlTools
.
getIsRunning
())
{
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
public
void
errorStream
(
InputStream
error
)
{
Reader
reader
=
new
InputStreamReader
(
error
);
BufferedReader
bf
=
new
BufferedReader
(
reader
);
String
line
=
null
;
List
<
String
>
list
=
null
;
try
{
while
((
line
=
bf
.
readLine
())
!=
null
&&
TestControlTools
.
getIsRunning
())
{
System
.
out
.
println
(
line
);
// cmdTools.makeReturnEntity(line, returnEntity);
// if (cmdTools.send) {
// String data = JSONObject.toJSONString(returnEntity);
// try {
// GlobalParameters.webSocket.appointSending("fuzzMaster", "web", data);
// } catch (Exception ignored) {
// }
// }
}
//结束就关闭
if
(!
TestControlTools
.
getIsRunning
())
{
if
(!
TestControlTools
.
getIsRunning
())
{
close
();
}
}
catch
(
IOException
e
)
{
...
...
fuzzIntegration/src/main/resources/result.html
View file @
51383361
...
...
@@ -8,19 +8,17 @@
var
ws1
=
null
;
var
ws2
=
null
;
function
myFunction
()
{
ws1
=
new
WebSocket
(
"ws://192.168.
9.177
:8100/websocket/testResult/web"
);
ws1
=
new
WebSocket
(
"ws://192.168.
31.133
:8100/websocket/testResult/web"
);
ws1
.
onmessage
=
function
(
evt
)
{
console
.
log
(
evt
);
var
received_msg
=
JSON
.
parse
(
evt
.
data
)
;
const
nameValue
=
Object
.
values
(
received_msg
)
console
.
log
(
evt
.
data
)
var
context
=
'<div class="sendMsg">'
+
'aflnet:<br/>'
+
'aflnet<h3>'
+
nameValue
+
'</h3><br/>'
+
'aflnet<h3>'
+
evt
.
data
+
'</h3><br/>'
+
' </div>'
;
document
.
getElementById
(
"sendDiv"
).
innerHTML
=
context
;
};
ws1
.
onclose
=
function
()
{
// 关闭 websocket
alert
(
"连接已关闭..."
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment