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
3786ab39
Commit
3786ab39
authored
Aug 21, 2024
by
钱炳权
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kitty全流程贯通
parent
6c96d5bf
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
96 additions
and
92 deletions
+96
-92
aroundAop.java
...src/main/java/com/example/fuzzControll/aop/aroundAop.java
+0
-13
TestMissionController.java
...roll/controller/dataController/TestMissionController.java
+2
-2
KittyController.java
...zzControll/controller/testController/KittyController.java
+0
-15
ProtocolTemplateService.java
...example/fuzzControll/service/ProtocolTemplateService.java
+2
-1
TestMissionService.java
.../com/example/fuzzControll/service/TestMissionService.java
+2
-1
FuzzLogServiceImpl.java
...example/fuzzControll/service/impl/FuzzLogServiceImpl.java
+16
-15
GenerateMethodServiceImpl.java
.../fuzzControll/service/impl/GenerateMethodServiceImpl.java
+1
-1
MutationServiceImpl.java
...xample/fuzzControll/service/impl/MutationServiceImpl.java
+2
-1
ProtocolTemplateImpl.java
...ample/fuzzControll/service/impl/ProtocolTemplateImpl.java
+17
-12
TestMissionServiceImpl.java
...ple/fuzzControll/service/impl/TestMissionServiceImpl.java
+43
-11
VulnerabilityTypeServiceImpl.java
...zzControll/service/impl/VulnerabilityTypeServiceImpl.java
+7
-6
TestCmdTools.java
...ava/com/example/fuzzControll/tools/test/TestCmdTools.java
+4
-14
No files found.
fuzzIntegration/src/main/java/com/example/fuzzControll/aop/aroundAop.java
View file @
3786ab39
...
...
@@ -71,20 +71,7 @@ public class aroundAop implements Ordered {
}
if
(
"generation"
.
equals
(
function
))
{
/*运行前处理*/
/*存入kitty启动时的任务信息*/
try
{
// int missionId = GlobalClass.missionInfoMapper.selectTopMissionId() + 1;
// SystemRunningParams.kittyMissionId = missionId;
// MissionInfo missionInfo = new MissionInfo(missionId, TableClassEnum.KITTY_RESULT.getTableId(), new Date(), SystemRunningParams.kittyData.get("missionName"),
// MissionStateEnum.RUNNING.getStateCode(), 0L);
// GlobalClass.missionInfoMapper.insertMission(missionInfo);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
MysqlException
(
"Kitty start backup failed!"
);
}
SystemRunningParams
.
testTimeMessage
.
get
(
"kitty"
).
put
(
"start"
,
System
.
currentTimeMillis
());
System
.
out
.
println
(
"**************1**********"
);
System
.
out
.
println
(
SystemRunningParams
.
testTimeMessage
.
get
(
"kitty"
).
put
(
"start"
,
System
.
currentTimeMillis
()));
/*放行方法*/
try
{
result
=
point
.
proceed
();
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/controller/dataController/TestMissionController.java
View file @
3786ab39
...
...
@@ -31,11 +31,11 @@ public class TestMissionController {
@RequestMapping
(
value
=
"/startmission"
,
method
=
RequestMethod
.
GET
)
public
AjaxResult
startmission
(
@RequestParam
int
id
)
{
try
{
testMissionService
.
startMission
(
id
);
return
testMissionService
.
startMission
(
id
);
}
catch
(
Exception
e
)
{
return
AjaxResult
.
error
(
"测试启动失败!"
);
}
return
AjaxResult
.
success
(
"测试启动成功!"
);
}
/**
* 测试信息获取
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/controller/testController/KittyController.java
View file @
3786ab39
...
...
@@ -37,21 +37,6 @@ public class KittyController {
VulnerabilityTypeService
vulnerabilityTypeService
;
/**
* 模板
*/
@RequestMapping
(
value
=
"/protocolTemplate"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
protocolTemplate
(
@RequestBody
TestEntity
testEntity
)
{
try
{
SystemRunningParams
.
kittyData
.
put
(
"missionName"
,
testEntity
.
getTestClassName
());
Map
<
String
,
List
<
String
>>
result
=
protocolTemplateService
.
generation
(
testEntity
);
return
AjaxResult
.
success
(
result
==
null
?
"模板文件生成未成功运行!第三方接口可能存在问题。"
:
result
);
}
catch
(
CmdException
|
FuzzException
e
)
{
log
.
error
(
e
.
getDefaultMessage
());
return
AjaxResult
.
error
(
"模板生成失败!系统存在问题。"
);
}
}
/**
* 生成方法
*/
@RequestMapping
(
value
=
"/generate"
,
method
=
RequestMethod
.
POST
)
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/ProtocolTemplateService.java
View file @
3786ab39
package
com
.
example
.
fuzzControll
.
service
;
import
com.example.fuzzControll.domain.bo.TestEntity
;
import
com.example.fuzzControll.domain.po.MissionInfo
;
import
java.util.List
;
import
java.util.Map
;
public
interface
ProtocolTemplateService
{
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
);
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
,
MissionInfo
missionInfo
);
}
fuzzIntegration/src/main/java/com/example/fuzzControll/service/TestMissionService.java
View file @
3786ab39
...
...
@@ -6,6 +6,7 @@ import com.example.fuzzControll.domain.bo.FuzzParams;
import
com.example.fuzzControll.domain.bo.TestEntity
;
import
com.example.fuzzControll.domain.po.Test
;
import
com.example.fuzzControll.domain.po.TestAndParams
;
import
com.example.fuzzControll.domain.vo.AjaxResult
;
import
java.util.List
;
...
...
@@ -22,5 +23,5 @@ public interface TestMissionService {
boolean
editTestName
(
String
testName
,
int
id
);
void
startMission
(
int
id
)
;
AjaxResult
startMission
(
int
id
)
;
}
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/FuzzLogServiceImpl.java
View file @
3786ab39
...
...
@@ -2,6 +2,7 @@ package com.example.fuzzControll.service.impl;
import
com.example.fuzzControll.domain.vo.AflnetResult
;
import
com.example.fuzzControll.domain.bo.FuzzLogTransEntity
;
import
com.example.fuzzControll.domain.vo.KittyPackageFile
;
import
com.example.fuzzControll.domain.vo.KittyResult
;
import
com.example.fuzzControll.domain.po.MissionInfo
;
import
com.example.fuzzControll.exception.mysqlException.MysqlException
;
...
...
@@ -51,28 +52,28 @@ public class FuzzLogServiceImpl implements FuzzLogService {
public
List
<
FuzzLogTransEntity
>
downloadKittyProtocalFile
(
MissionInfo
missionInfo
)
{
/*获取结果日志*/
List
<
FuzzLogTransEntity
>
fuzzLogList
=
new
ArrayList
<
FuzzLogTransEntity
>();
// KittyResult kittyResult = kittyMapper.getKittyResultByMissionId(missionInfo.getMission
Id());
//
StringBuffer buffer = new StringBuffer();
//
buffer.append(kittyResult.getResultError()).append(System.lineSeparator()).append(kittyResult.getResultOut());
//
FuzzLogTransEntity fuzzLogTransEntity = new FuzzLogTransEntity(buffer.toString().getBytes(), missionInfo.getMissionName() + ".txt");
//
fuzzLogList.add(fuzzLogTransEntity);
KittyResult
kittyResult
=
kittyMapper
.
getKittyResultByMissionId
(
missionInfo
.
get
Id
());
StringBuffer
buffer
=
new
StringBuffer
();
buffer
.
append
(
kittyResult
.
getResultError
()).
append
(
System
.
lineSeparator
()).
append
(
kittyResult
.
getResultOut
());
FuzzLogTransEntity
fuzzLogTransEntity
=
new
FuzzLogTransEntity
(
buffer
.
toString
().
getBytes
(),
missionInfo
.
getMissionName
()
+
".txt"
);
fuzzLogList
.
add
(
fuzzLogTransEntity
);
/*获取数据包文件*/
// KittyPackageFile kittyPackageFile = kittyMapper.getKittyPackageFileById(missionInfo.getMission
Id());
//
FuzzLogTransEntity fuzzLogTransEntitySend = new FuzzLogTransEntity(kittyPackageFile.getKittySendFile(), kittyPackageFile.getKittyRecvFileName());
//
FuzzLogTransEntity fuzzLogTransEntityRecv = new FuzzLogTransEntity(kittyPackageFile.getKittyRecvFile(), kittyPackageFile.getKittyRecvFileName());
//
fuzzLogList.add(fuzzLogTransEntitySend);
//
fuzzLogList.add(fuzzLogTransEntityRecv);
KittyPackageFile
kittyPackageFile
=
kittyMapper
.
getKittyPackageFileById
(
missionInfo
.
get
Id
());
FuzzLogTransEntity
fuzzLogTransEntitySend
=
new
FuzzLogTransEntity
(
kittyPackageFile
.
getKittySendFile
(),
kittyPackageFile
.
getKittyRecvFileName
());
FuzzLogTransEntity
fuzzLogTransEntityRecv
=
new
FuzzLogTransEntity
(
kittyPackageFile
.
getKittyRecvFile
(),
kittyPackageFile
.
getKittyRecvFileName
());
fuzzLogList
.
add
(
fuzzLogTransEntitySend
);
fuzzLogList
.
add
(
fuzzLogTransEntityRecv
);
return
fuzzLogList
;
}
@Transactional
(
rollbackFor
=
MysqlException
.
class
)
public
List
<
FuzzLogTransEntity
>
downloadKittyOtherMethodFile
(
MissionInfo
missionInfo
)
{
List
<
FuzzLogTransEntity
>
fuzzLogList
=
new
ArrayList
<
FuzzLogTransEntity
>();
// KittyResult kittyResult = kittyMapper.getKittyResultByMissionId(missionInfo.getMission
Id());
//
StringBuffer buffer = new StringBuffer();
//
buffer.append(kittyResult.getResultError()).append(System.lineSeparator()).append(kittyResult.getResultOut());
//
FuzzLogTransEntity fuzzLogTransEntity = new FuzzLogTransEntity(buffer.toString().getBytes(), missionInfo.getMissionName() + ".txt");
//
fuzzLogList.add(fuzzLogTransEntity);
KittyResult
kittyResult
=
kittyMapper
.
getKittyResultByMissionId
(
missionInfo
.
get
Id
());
StringBuffer
buffer
=
new
StringBuffer
();
buffer
.
append
(
kittyResult
.
getResultError
()).
append
(
System
.
lineSeparator
()).
append
(
kittyResult
.
getResultOut
());
FuzzLogTransEntity
fuzzLogTransEntity
=
new
FuzzLogTransEntity
(
buffer
.
toString
().
getBytes
(),
missionInfo
.
getMissionName
()
+
".txt"
);
fuzzLogList
.
add
(
fuzzLogTransEntity
);
return
fuzzLogList
;
}
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/GenerateMethodServiceImpl.java
View file @
3786ab39
...
...
@@ -44,7 +44,7 @@ public class GenerateMethodServiceImpl implements GenerateMethodService {
if
(
cmd
.
isEmpty
())
{
throw
new
FuzzException
(
"cmd is null ! The number of parameters does not match!"
);
}
return
cmdTools
.
runProgramCmdAndResult
(
cmd
,
"generate"
,
"Generate-"
+
testEntity
.
getTestClassName
())
;
return
null
;
}
public
String
parseParameters
(
TestEntity
testEntity
)
{
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/MutationServiceImpl.java
View file @
3786ab39
...
...
@@ -46,7 +46,8 @@ class MutationServiceImpl implements MutationService {
if
(
cmd
.
isEmpty
())
{
throw
new
FuzzException
(
"cmd is null ! The number of parameters does not match!"
);
}
return
cmdTools
.
runProgramCmdAndResult
(
cmd
,
"mutation"
,
"Mutation-"
+
testEntity
.
getTestClassName
());
// cmdTools.runProgramCmdAndResult(cmd, "mutation", "Mutation-" + testEntity.getTestClassName());
return
null
;
}
public
String
parseParameters
(
TestEntity
testEntity
)
{
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/ProtocolTemplateImpl.java
View file @
3786ab39
...
...
@@ -6,8 +6,10 @@ import com.example.fuzzControll.annotion.NeedCutAround;
import
com.example.fuzzControll.annotion.NeedCutBefore
;
import
com.example.fuzzControll.conf.KittyProperties
;
import
com.example.fuzzControll.constents.CmdConstent
;
import
com.example.fuzzControll.constents.MissionStateEnum
;
import
com.example.fuzzControll.constents.ProtocolConstent
;
import
com.example.fuzzControll.domain.bo.FuzzParams
;
import
com.example.fuzzControll.domain.po.MissionInfo
;
import
com.example.fuzzControll.domain.po.TestAndParams
;
import
com.example.fuzzControll.exception.testException.AflnetException
;
import
com.example.fuzzControll.exception.testException.CmdException
;
...
...
@@ -15,8 +17,8 @@ import com.example.fuzzControll.exception.testException.FuzzException;
import
com.example.fuzzControll.domain.bo.TestEntity
;
import
com.example.fuzzControll.service.FuzzParamsService
;
import
com.example.fuzzControll.service.ProtocolTemplateService
;
import
com.example.fuzzControll.service.TestMissionService
;
import
com.example.fuzzControll.tools.system.GlobalClass
;
import
com.example.fuzzControll.tools.system.SystemRunningParams
;
import
com.example.fuzzControll.tools.test.SingleCmdTools
;
import
com.example.fuzzControll.tools.test.TestCmdTools
;
import
com.example.fuzzControll.tools.test.TestTools
;
...
...
@@ -37,25 +39,28 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
KittyProperties
kitty
;
@Autowired
FuzzParamsService
fuzzParamsService
;
@Autowired
TestMissionService
testMissionService
;
@Override
@NeedCutAround
(
name
=
"kitty"
,
function
=
"generation"
)
public
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
)
throws
FuzzException
,
CmdException
{
/*存入参数*/
// int missionId = GlobalClass.missionInfoMapper.selectTopMissionId();
// boolean flag = fuzzParamsService.saveFuzzParams(new FuzzParams(JSON.toJSONString(testEntity.getParamJson()), new Date(), missionId));
// if (!flag) {
// throw new AflnetException("Save params error!");
// }
public
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
,
MissionInfo
missionInfo
)
throws
FuzzException
,
CmdException
{
Long
startTime
=
System
.
currentTimeMillis
();
/*生成日志前先清除日志*/
singleCmdTools
.
runCmd
(
CmdConstent
.
DELETE_FILE
+
GlobalClass
.
kittyProperties
.
getLogOutPath
(),
"delete kittyLogs"
);
String
cmd
=
parseParameters
(
testEntity
);
if
(
cmd
==
null
||
""
.
equals
(
cmd
))
{
throw
new
FuzzException
(
"cmd is null ! The number of parameters does not match!"
);
}
return
testCmdTools
.
runProgramCmdAndResult
(
cmd
,
"protocolTemplate"
,
"ProtocolTemplate-"
+
testEntity
.
getTestClassName
());
/*运行测试*/
Map
<
String
,
List
<
String
>>
result
=
testCmdTools
.
runProgramCmdAndResult
(
cmd
,
"protocolTemplate"
,
"ProtocolTemplate-"
+
testEntity
.
getTestClassName
(),
missionInfo
);
/*运行完成后存入运行时间等信息*/
Long
total
=
System
.
currentTimeMillis
()
-
startTime
;
missionInfo
.
setState
(
MissionStateEnum
.
DONE
.
getStateCode
());
missionInfo
.
setRunTime
(
total
);
try
{
GlobalClass
.
missionInfoMapper
.
updateMission
(
missionInfo
);
//更新该次任务的执行时间;
}
catch
(
Exception
e
)
{
log
.
error
(
"Update mission failed:[{}]"
,
e
.
getMessage
());
}
return
result
;
}
public
String
parseParameters
(
TestEntity
testEntity
)
throws
FuzzException
{
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/TestMissionServiceImpl.java
View file @
3786ab39
...
...
@@ -12,10 +12,13 @@ import com.example.fuzzControll.domain.po.Test;
import
com.example.fuzzControll.domain.po.TestAndParams
;
import
com.example.fuzzControll.domain.vo.AjaxResult
;
import
com.example.fuzzControll.exception.mysqlException.MysqlException
;
import
com.example.fuzzControll.exception.testException.CmdException
;
import
com.example.fuzzControll.exception.testException.FuzzException
;
import
com.example.fuzzControll.exception.threadException.MyExceptionHandler
;
import
com.example.fuzzControll.mapper.FuzzParamsMapper
;
import
com.example.fuzzControll.mapper.MissionInfoMapper
;
import
com.example.fuzzControll.mapper.TestMapper
;
import
com.example.fuzzControll.service.ProtocolTemplateService
;
import
com.example.fuzzControll.service.TestMissionService
;
import
com.example.fuzzControll.service.TestService
;
import
com.example.fuzzControll.tools.component.StringUtils
;
...
...
@@ -42,7 +45,8 @@ public class TestMissionServiceImpl implements TestMissionService {
MissionInfoMapper
missionInfoMapper
;
@Autowired
TestService
service
;
@Autowired
ProtocolTemplateService
protocolTemplateService
;
@Override
public
List
<
TestAndParams
>
getTestAndParamsList
()
{
List
<
TestAndParams
>
testParamsRelevantList
=
new
ArrayList
();
...
...
@@ -125,13 +129,13 @@ public class TestMissionServiceImpl implements TestMissionService {
Test
test
=
testMapper
.
getTestById
(
id
);
int
fuzzParamsId
;
if
(
test
.
getFuzzParamsId
()
==
0
)
{
//为0则插入id
FuzzParams
fuzzParams
=
new
FuzzParams
(
JSON
.
toJSONString
(
testEntity
.
getParamJson
()
),
testEntity
.
getTestClassName
());
FuzzParams
fuzzParams
=
new
FuzzParams
(
JSON
.
toJSONString
(
testEntity
),
testEntity
.
getTestClassName
());
fuzzParamsMapper
.
insertFuzzParamsReturnId
(
fuzzParams
);
fuzzParamsId
=
fuzzParams
.
getId
();
test
.
setFuzzParamsId
(
fuzzParamsId
);
}
else
{
//有则更新数据
FuzzParams
fuzzParams
=
new
FuzzParams
(
JSON
.
toJSONString
(
testEntity
.
getParamJson
()
),
testEntity
.
getTestClassName
());
if
(!
fuzzParamsMapper
.
editFuzzParams
(
fuzzParams
.
get
Id
(),
fuzzParams
.
getParams
(),
fuzzParams
.
getProtocol
()))
{
FuzzParams
fuzzParams
=
new
FuzzParams
(
JSON
.
toJSONString
(
testEntity
),
testEntity
.
getTestClassName
());
if
(!
fuzzParamsMapper
.
editFuzzParams
(
test
.
getFuzzParams
Id
(),
fuzzParams
.
getParams
(),
fuzzParams
.
getProtocol
()))
{
throw
new
RuntimeException
(
"EditFuzzParams failed!"
);
}
}
...
...
@@ -158,7 +162,7 @@ public class TestMissionServiceImpl implements TestMissionService {
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
@Override
public
void
startMission
(
int
id
)
{
public
AjaxResult
startMission
(
int
id
)
{
Boolean
isAflnet
=
false
;
Test
test
=
testMapper
.
getTestById
(
id
);
if
(
test
.
getFuzzParamsId
()
==
0
)
{
...
...
@@ -207,9 +211,11 @@ public class TestMissionServiceImpl implements TestMissionService {
/*运行程序*/
try
{
if
(
isAflnet
)
{
// 启动alfnet
aflnetMissionStart
(
fuzzParams
,
missionInfo
);
aflnetMissionStart
(
fuzzParams
,
missionInfo
);
return
AjaxResult
.
success
(
"启动成功!"
);
}
else
{
Map
<
String
,
List
<
String
>>
result
=
kittyMissionStart
(
fuzzParams
,
missionInfo
);
return
AjaxResult
.
success
(
result
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"Mission start error:[{}]"
,
e
.
getMessage
());
...
...
@@ -218,10 +224,36 @@ public class TestMissionServiceImpl implements TestMissionService {
}
/**
* 启动kitty任务
*/
private
Map
<
String
,
List
<
String
>>
kittyMissionStart
(
FuzzParams
fuzzParams
,
MissionInfo
missionInfo
)
{
TestEntity
testEntity
=
(
TestEntity
)
JSONObject
.
parseObject
(
fuzzParams
.
getParams
(),
TestEntity
.
class
);
try
{
try
{
missionInfo
.
setState
(
MissionStateEnum
.
RUNNING
.
getStateCode
());
missionInfoMapper
.
updateMission
(
missionInfo
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Error updating mission:[{}]"
,
e
.
getMessage
());
throw
new
RuntimeException
(
e
);
}
SystemRunningParams
.
kittyData
.
put
(
"missionName"
,
testEntity
.
getTestClassName
());
Map
<
String
,
List
<
String
>>
result
=
protocolTemplateService
.
generation
(
testEntity
,
missionInfo
);
if
(
result
==
null
)
{
log
.
error
(
"模板文件生成未成功运行!第三方接口可能存在问题。"
);
throw
new
RuntimeException
();
}
return
result
;
}
catch
(
CmdException
|
FuzzException
e
)
{
log
.
error
(
"Run error:[{}]"
,
e
.
getMessage
());
throw
new
RuntimeException
();
}
}
/**
* 启动aflnet任务
*/
private
void
aflnetMissionStart
(
FuzzParams
fuzzParams
,
MissionInfo
missionInfo
)
{
CmdStartParams
cmdStartParams
=
(
CmdStartParams
)
JSONObject
.
parseObject
(
fuzzParams
.
getParams
(),
CmdStartParams
.
class
);
private
void
aflnetMissionStart
(
FuzzParams
fuzzParams
,
MissionInfo
missionInfo
)
{
CmdStartParams
cmdStartParams
=
(
CmdStartParams
)
JSONObject
.
parseObject
(
fuzzParams
.
getParams
(),
CmdStartParams
.
class
);
try
{
SystemRunningParams
.
aflnetData
.
put
(
"missionName"
,
cmdStartParams
.
getProtopcol
());
Thread
subThread
=
new
Thread
(
new
Runnable
()
{
...
...
@@ -231,10 +263,10 @@ public class TestMissionServiceImpl implements TestMissionService {
missionInfo
.
setState
(
MissionStateEnum
.
RUNNING
.
getStateCode
());
missionInfoMapper
.
updateMission
(
missionInfo
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Error updating mission:[{}]"
,
e
.
getMessage
());
log
.
error
(
"Error updating mission:[{}]"
,
e
.
getMessage
());
throw
new
RuntimeException
(
e
);
}
service
.
testStart
(
cmdStartParams
,
missionInfo
);
service
.
testStart
(
cmdStartParams
,
missionInfo
);
}
});
SystemRunningParams
.
ThreadState
.
put
(
subThread
,
"start"
);
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/VulnerabilityTypeServiceImpl.java
View file @
3786ab39
...
...
@@ -29,8 +29,9 @@ public class VulnerabilityTypeServiceImpl implements VulnerabilityTypeService {
KittyProperties
kitty
;
@Autowired
FuzzParamsService
fuzzParamsService
;
@Override
@NeedCutAround
(
name
=
"kitty"
,
function
=
"generation"
)
@NeedCutAround
(
name
=
"kitty"
,
function
=
"generation"
)
public
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
)
throws
FuzzException
,
CmdException
{
/*存入参数*/
// int missionId = GlobalClass.missionInfoMapper.selectTopMissionId();
...
...
@@ -38,11 +39,11 @@ public class VulnerabilityTypeServiceImpl implements VulnerabilityTypeService {
// if (!flag) {
// throw new AflnetException("Save params error!");
// }
String
cmd
=
parseParameters
(
testEntity
);
if
(
cmd
.
isEmpty
())
{
throw
new
FuzzException
(
"cmd is null ! The number of parameters does not match!"
);
}
return
cmdTools
.
runProgramCmdAndResult
(
cmd
,
"vulnerability"
,
"Vulnerability-"
+
testEntity
.
getTestClassName
())
;
//
String cmd = parseParameters(testEntity);
//
if (cmd.isEmpty()) {
//
throw new FuzzException("cmd is null ! The number of parameters does not match!");
//
}
return
null
;
}
public
String
parseParameters
(
TestEntity
testEntity
)
{
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/test/TestCmdTools.java
View file @
3786ab39
...
...
@@ -136,7 +136,7 @@ public class TestCmdTools {
* 运行需要后台运行cmd
* 将数据存入文件中
*/
public
Map
<
String
,
List
<
String
>>
runProgramCmdAndResult
(
String
cmd
,
String
caller
,
String
missionName
)
throws
public
Map
<
String
,
List
<
String
>>
runProgramCmdAndResult
(
String
cmd
,
String
caller
,
String
missionName
,
MissionInfo
missionInfo
)
throws
CmdException
{
Map
<
String
,
List
<
String
>>
result
=
new
HashMap
();
List
<
String
>
out
=
Collections
.
synchronizedList
(
new
ArrayList
<
String
>());
...
...
@@ -161,7 +161,7 @@ public class TestCmdTools {
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
dataBackUpTransaction
(
caller
,
finalOut
,
finalError
,
missionName
);
dataBackUpTransaction
(
caller
,
finalOut
,
finalError
,
missionName
,
missionInfo
);
}
}).
start
();
//todo 需要传入任务参数,后期再开发
...
...
@@ -426,23 +426,14 @@ public class TestCmdTools {
}
@Transactional
(
rollbackFor
=
MysqlException
.
class
)
public
void
dataBackUpTransaction
(
String
caller
,
List
<
String
>
out
,
List
<
String
>
error
,
String
missionName
)
{
int
missionId
=
SystemRunningParams
.
kittyMissionId
;
public
void
dataBackUpTransaction
(
String
caller
,
List
<
String
>
out
,
List
<
String
>
error
,
String
missionName
,
MissionInfo
missionInfo
)
{
try
{
/*kitty结果存入数据库*/
KittyResult
kittyResult
=
new
KittyResult
(
missionI
d
,
out
.
toString
(),
error
.
toString
());
KittyResult
kittyResult
=
new
KittyResult
(
missionI
nfo
.
getId
()
,
out
.
toString
(),
error
.
toString
());
GlobalClass
.
kittyMapper
.
kittyResultsBackup
(
kittyResult
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"kitty backup error!"
);
}
// /*kitty的协议模板方法的日志和数据包文件存入数据库*/
// if (caller.equals("protocolTemplate")) {
//// GlobalClass.kittyFuzzPersistenceService.KittyPackagesBackup(missionId);
// GlobalClass.missionInfoMapper.insertMission(new MissionInfo(missionId, 2, new Date(), missionName,));
// } else {
// /*存入missionInfo信息*/
// GlobalClass.missionInfoMapper.insertMission(new MissionInfo(missionId, 3, new Date(), missionName));
// }
}
}
\ No newline at end of file
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