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 {
...
@@ -71,20 +71,7 @@ public class aroundAop implements Ordered {
}
}
if
(
"generation"
.
equals
(
function
))
{
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
());
SystemRunningParams
.
testTimeMessage
.
get
(
"kitty"
).
put
(
"start"
,
System
.
currentTimeMillis
());
System
.
out
.
println
(
"**************1**********"
);
System
.
out
.
println
(
SystemRunningParams
.
testTimeMessage
.
get
(
"kitty"
).
put
(
"start"
,
System
.
currentTimeMillis
()));
/*放行方法*/
/*放行方法*/
try
{
try
{
result
=
point
.
proceed
();
result
=
point
.
proceed
();
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/controller/dataController/TestMissionController.java
View file @
3786ab39
...
@@ -31,11 +31,11 @@ public class TestMissionController {
...
@@ -31,11 +31,11 @@ public class TestMissionController {
@RequestMapping
(
value
=
"/startmission"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/startmission"
,
method
=
RequestMethod
.
GET
)
public
AjaxResult
startmission
(
@RequestParam
int
id
)
{
public
AjaxResult
startmission
(
@RequestParam
int
id
)
{
try
{
try
{
testMissionService
.
startMission
(
id
);
return
testMissionService
.
startMission
(
id
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
AjaxResult
.
error
(
"测试启动失败!"
);
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 {
...
@@ -37,21 +37,6 @@ public class KittyController {
VulnerabilityTypeService
vulnerabilityTypeService
;
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
)
@RequestMapping
(
value
=
"/generate"
,
method
=
RequestMethod
.
POST
)
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/ProtocolTemplateService.java
View file @
3786ab39
package
com
.
example
.
fuzzControll
.
service
;
package
com
.
example
.
fuzzControll
.
service
;
import
com.example.fuzzControll.domain.bo.TestEntity
;
import
com.example.fuzzControll.domain.bo.TestEntity
;
import
com.example.fuzzControll.domain.po.MissionInfo
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
public
interface
ProtocolTemplateService
{
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;
...
@@ -6,6 +6,7 @@ import com.example.fuzzControll.domain.bo.FuzzParams;
import
com.example.fuzzControll.domain.bo.TestEntity
;
import
com.example.fuzzControll.domain.bo.TestEntity
;
import
com.example.fuzzControll.domain.po.Test
;
import
com.example.fuzzControll.domain.po.Test
;
import
com.example.fuzzControll.domain.po.TestAndParams
;
import
com.example.fuzzControll.domain.po.TestAndParams
;
import
com.example.fuzzControll.domain.vo.AjaxResult
;
import
java.util.List
;
import
java.util.List
;
...
@@ -22,5 +23,5 @@ public interface TestMissionService {
...
@@ -22,5 +23,5 @@ public interface TestMissionService {
boolean
editTestName
(
String
testName
,
int
id
);
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;
...
@@ -2,6 +2,7 @@ package com.example.fuzzControll.service.impl;
import
com.example.fuzzControll.domain.vo.AflnetResult
;
import
com.example.fuzzControll.domain.vo.AflnetResult
;
import
com.example.fuzzControll.domain.bo.FuzzLogTransEntity
;
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.vo.KittyResult
;
import
com.example.fuzzControll.domain.po.MissionInfo
;
import
com.example.fuzzControll.domain.po.MissionInfo
;
import
com.example.fuzzControll.exception.mysqlException.MysqlException
;
import
com.example.fuzzControll.exception.mysqlException.MysqlException
;
...
@@ -51,28 +52,28 @@ public class FuzzLogServiceImpl implements FuzzLogService {
...
@@ -51,28 +52,28 @@ public class FuzzLogServiceImpl implements FuzzLogService {
public
List
<
FuzzLogTransEntity
>
downloadKittyProtocalFile
(
MissionInfo
missionInfo
)
{
public
List
<
FuzzLogTransEntity
>
downloadKittyProtocalFile
(
MissionInfo
missionInfo
)
{
/*获取结果日志*/
/*获取结果日志*/
List
<
FuzzLogTransEntity
>
fuzzLogList
=
new
ArrayList
<
FuzzLogTransEntity
>();
List
<
FuzzLogTransEntity
>
fuzzLogList
=
new
ArrayList
<
FuzzLogTransEntity
>();
// KittyResult kittyResult = kittyMapper.getKittyResultByMissionId(missionInfo.getMission
Id());
KittyResult
kittyResult
=
kittyMapper
.
getKittyResultByMissionId
(
missionInfo
.
get
Id
());
//
StringBuffer buffer = new StringBuffer();
StringBuffer
buffer
=
new
StringBuffer
();
//
buffer.append(kittyResult.getResultError()).append(System.lineSeparator()).append(kittyResult.getResultOut());
buffer
.
append
(
kittyResult
.
getResultError
()).
append
(
System
.
lineSeparator
()).
append
(
kittyResult
.
getResultOut
());
//
FuzzLogTransEntity fuzzLogTransEntity = new FuzzLogTransEntity(buffer.toString().getBytes(), missionInfo.getMissionName() + ".txt");
FuzzLogTransEntity
fuzzLogTransEntity
=
new
FuzzLogTransEntity
(
buffer
.
toString
().
getBytes
(),
missionInfo
.
getMissionName
()
+
".txt"
);
//
fuzzLogList.add(fuzzLogTransEntity);
fuzzLogList
.
add
(
fuzzLogTransEntity
);
/*获取数据包文件*/
/*获取数据包文件*/
// KittyPackageFile kittyPackageFile = kittyMapper.getKittyPackageFileById(missionInfo.getMission
Id());
KittyPackageFile
kittyPackageFile
=
kittyMapper
.
getKittyPackageFileById
(
missionInfo
.
get
Id
());
//
FuzzLogTransEntity fuzzLogTransEntitySend = new FuzzLogTransEntity(kittyPackageFile.getKittySendFile(), kittyPackageFile.getKittyRecvFileName());
FuzzLogTransEntity
fuzzLogTransEntitySend
=
new
FuzzLogTransEntity
(
kittyPackageFile
.
getKittySendFile
(),
kittyPackageFile
.
getKittyRecvFileName
());
//
FuzzLogTransEntity fuzzLogTransEntityRecv = new FuzzLogTransEntity(kittyPackageFile.getKittyRecvFile(), kittyPackageFile.getKittyRecvFileName());
FuzzLogTransEntity
fuzzLogTransEntityRecv
=
new
FuzzLogTransEntity
(
kittyPackageFile
.
getKittyRecvFile
(),
kittyPackageFile
.
getKittyRecvFileName
());
//
fuzzLogList.add(fuzzLogTransEntitySend);
fuzzLogList
.
add
(
fuzzLogTransEntitySend
);
//
fuzzLogList.add(fuzzLogTransEntityRecv);
fuzzLogList
.
add
(
fuzzLogTransEntityRecv
);
return
fuzzLogList
;
return
fuzzLogList
;
}
}
@Transactional
(
rollbackFor
=
MysqlException
.
class
)
@Transactional
(
rollbackFor
=
MysqlException
.
class
)
public
List
<
FuzzLogTransEntity
>
downloadKittyOtherMethodFile
(
MissionInfo
missionInfo
)
{
public
List
<
FuzzLogTransEntity
>
downloadKittyOtherMethodFile
(
MissionInfo
missionInfo
)
{
List
<
FuzzLogTransEntity
>
fuzzLogList
=
new
ArrayList
<
FuzzLogTransEntity
>();
List
<
FuzzLogTransEntity
>
fuzzLogList
=
new
ArrayList
<
FuzzLogTransEntity
>();
// KittyResult kittyResult = kittyMapper.getKittyResultByMissionId(missionInfo.getMission
Id());
KittyResult
kittyResult
=
kittyMapper
.
getKittyResultByMissionId
(
missionInfo
.
get
Id
());
//
StringBuffer buffer = new StringBuffer();
StringBuffer
buffer
=
new
StringBuffer
();
//
buffer.append(kittyResult.getResultError()).append(System.lineSeparator()).append(kittyResult.getResultOut());
buffer
.
append
(
kittyResult
.
getResultError
()).
append
(
System
.
lineSeparator
()).
append
(
kittyResult
.
getResultOut
());
//
FuzzLogTransEntity fuzzLogTransEntity = new FuzzLogTransEntity(buffer.toString().getBytes(), missionInfo.getMissionName() + ".txt");
FuzzLogTransEntity
fuzzLogTransEntity
=
new
FuzzLogTransEntity
(
buffer
.
toString
().
getBytes
(),
missionInfo
.
getMissionName
()
+
".txt"
);
//
fuzzLogList.add(fuzzLogTransEntity);
fuzzLogList
.
add
(
fuzzLogTransEntity
);
return
fuzzLogList
;
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 {
...
@@ -44,7 +44,7 @@ public class GenerateMethodServiceImpl implements GenerateMethodService {
if
(
cmd
.
isEmpty
())
{
if
(
cmd
.
isEmpty
())
{
throw
new
FuzzException
(
"cmd is null ! The number of parameters does not match!"
);
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
)
{
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 {
...
@@ -46,7 +46,8 @@ class MutationServiceImpl implements MutationService {
if
(
cmd
.
isEmpty
())
{
if
(
cmd
.
isEmpty
())
{
throw
new
FuzzException
(
"cmd is null ! The number of parameters does not match!"
);
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
)
{
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;
...
@@ -6,8 +6,10 @@ import com.example.fuzzControll.annotion.NeedCutAround;
import
com.example.fuzzControll.annotion.NeedCutBefore
;
import
com.example.fuzzControll.annotion.NeedCutBefore
;
import
com.example.fuzzControll.conf.KittyProperties
;
import
com.example.fuzzControll.conf.KittyProperties
;
import
com.example.fuzzControll.constents.CmdConstent
;
import
com.example.fuzzControll.constents.CmdConstent
;
import
com.example.fuzzControll.constents.MissionStateEnum
;
import
com.example.fuzzControll.constents.ProtocolConstent
;
import
com.example.fuzzControll.constents.ProtocolConstent
;
import
com.example.fuzzControll.domain.bo.FuzzParams
;
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.domain.po.TestAndParams
;
import
com.example.fuzzControll.exception.testException.AflnetException
;
import
com.example.fuzzControll.exception.testException.AflnetException
;
import
com.example.fuzzControll.exception.testException.CmdException
;
import
com.example.fuzzControll.exception.testException.CmdException
;
...
@@ -15,8 +17,8 @@ import com.example.fuzzControll.exception.testException.FuzzException;
...
@@ -15,8 +17,8 @@ import com.example.fuzzControll.exception.testException.FuzzException;
import
com.example.fuzzControll.domain.bo.TestEntity
;
import
com.example.fuzzControll.domain.bo.TestEntity
;
import
com.example.fuzzControll.service.FuzzParamsService
;
import
com.example.fuzzControll.service.FuzzParamsService
;
import
com.example.fuzzControll.service.ProtocolTemplateService
;
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.GlobalClass
;
import
com.example.fuzzControll.tools.system.SystemRunningParams
;
import
com.example.fuzzControll.tools.test.SingleCmdTools
;
import
com.example.fuzzControll.tools.test.SingleCmdTools
;
import
com.example.fuzzControll.tools.test.TestCmdTools
;
import
com.example.fuzzControll.tools.test.TestCmdTools
;
import
com.example.fuzzControll.tools.test.TestTools
;
import
com.example.fuzzControll.tools.test.TestTools
;
...
@@ -37,25 +39,28 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
...
@@ -37,25 +39,28 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
KittyProperties
kitty
;
KittyProperties
kitty
;
@Autowired
@Autowired
FuzzParamsService
fuzzParamsService
;
FuzzParamsService
fuzzParamsService
;
@Autowired
TestMissionService
testMissionService
;
@Override
@Override
@NeedCutAround
(
name
=
"kitty"
,
function
=
"generation"
)
public
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
,
MissionInfo
missionInfo
)
throws
FuzzException
,
CmdException
{
public
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
)
throws
FuzzException
,
CmdException
{
Long
startTime
=
System
.
currentTimeMillis
();
/*存入参数*/
// 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!");
// }
/*生成日志前先清除日志*/
/*生成日志前先清除日志*/
singleCmdTools
.
runCmd
(
CmdConstent
.
DELETE_FILE
+
GlobalClass
.
kittyProperties
.
getLogOutPath
(),
"delete kittyLogs"
);
singleCmdTools
.
runCmd
(
CmdConstent
.
DELETE_FILE
+
GlobalClass
.
kittyProperties
.
getLogOutPath
(),
"delete kittyLogs"
);
String
cmd
=
parseParameters
(
testEntity
);
String
cmd
=
parseParameters
(
testEntity
);
if
(
cmd
==
null
||
""
.
equals
(
cmd
))
{
if
(
cmd
==
null
||
""
.
equals
(
cmd
))
{
throw
new
FuzzException
(
"cmd is null ! The number of parameters does not match!"
);
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
{
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;
...
@@ -12,10 +12,13 @@ import com.example.fuzzControll.domain.po.Test;
import
com.example.fuzzControll.domain.po.TestAndParams
;
import
com.example.fuzzControll.domain.po.TestAndParams
;
import
com.example.fuzzControll.domain.vo.AjaxResult
;
import
com.example.fuzzControll.domain.vo.AjaxResult
;
import
com.example.fuzzControll.exception.mysqlException.MysqlException
;
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.exception.threadException.MyExceptionHandler
;
import
com.example.fuzzControll.mapper.FuzzParamsMapper
;
import
com.example.fuzzControll.mapper.FuzzParamsMapper
;
import
com.example.fuzzControll.mapper.MissionInfoMapper
;
import
com.example.fuzzControll.mapper.MissionInfoMapper
;
import
com.example.fuzzControll.mapper.TestMapper
;
import
com.example.fuzzControll.mapper.TestMapper
;
import
com.example.fuzzControll.service.ProtocolTemplateService
;
import
com.example.fuzzControll.service.TestMissionService
;
import
com.example.fuzzControll.service.TestMissionService
;
import
com.example.fuzzControll.service.TestService
;
import
com.example.fuzzControll.service.TestService
;
import
com.example.fuzzControll.tools.component.StringUtils
;
import
com.example.fuzzControll.tools.component.StringUtils
;
...
@@ -42,7 +45,8 @@ public class TestMissionServiceImpl implements TestMissionService {
...
@@ -42,7 +45,8 @@ public class TestMissionServiceImpl implements TestMissionService {
MissionInfoMapper
missionInfoMapper
;
MissionInfoMapper
missionInfoMapper
;
@Autowired
@Autowired
TestService
service
;
TestService
service
;
@Autowired
ProtocolTemplateService
protocolTemplateService
;
@Override
@Override
public
List
<
TestAndParams
>
getTestAndParamsList
()
{
public
List
<
TestAndParams
>
getTestAndParamsList
()
{
List
<
TestAndParams
>
testParamsRelevantList
=
new
ArrayList
();
List
<
TestAndParams
>
testParamsRelevantList
=
new
ArrayList
();
...
@@ -125,13 +129,13 @@ public class TestMissionServiceImpl implements TestMissionService {
...
@@ -125,13 +129,13 @@ public class TestMissionServiceImpl implements TestMissionService {
Test
test
=
testMapper
.
getTestById
(
id
);
Test
test
=
testMapper
.
getTestById
(
id
);
int
fuzzParamsId
;
int
fuzzParamsId
;
if
(
test
.
getFuzzParamsId
()
==
0
)
{
//为0则插入id
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
);
fuzzParamsMapper
.
insertFuzzParamsReturnId
(
fuzzParams
);
fuzzParamsId
=
fuzzParams
.
getId
();
fuzzParamsId
=
fuzzParams
.
getId
();
test
.
setFuzzParamsId
(
fuzzParamsId
);
test
.
setFuzzParamsId
(
fuzzParamsId
);
}
else
{
//有则更新数据
}
else
{
//有则更新数据
FuzzParams
fuzzParams
=
new
FuzzParams
(
JSON
.
toJSONString
(
testEntity
.
getParamJson
()
),
testEntity
.
getTestClassName
());
FuzzParams
fuzzParams
=
new
FuzzParams
(
JSON
.
toJSONString
(
testEntity
),
testEntity
.
getTestClassName
());
if
(!
fuzzParamsMapper
.
editFuzzParams
(
fuzzParams
.
get
Id
(),
fuzzParams
.
getParams
(),
fuzzParams
.
getProtocol
()))
{
if
(!
fuzzParamsMapper
.
editFuzzParams
(
test
.
getFuzzParams
Id
(),
fuzzParams
.
getParams
(),
fuzzParams
.
getProtocol
()))
{
throw
new
RuntimeException
(
"EditFuzzParams failed!"
);
throw
new
RuntimeException
(
"EditFuzzParams failed!"
);
}
}
}
}
...
@@ -158,7 +162,7 @@ public class TestMissionServiceImpl implements TestMissionService {
...
@@ -158,7 +162,7 @@ public class TestMissionServiceImpl implements TestMissionService {
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
@Override
@Override
public
void
startMission
(
int
id
)
{
public
AjaxResult
startMission
(
int
id
)
{
Boolean
isAflnet
=
false
;
Boolean
isAflnet
=
false
;
Test
test
=
testMapper
.
getTestById
(
id
);
Test
test
=
testMapper
.
getTestById
(
id
);
if
(
test
.
getFuzzParamsId
()
==
0
)
{
if
(
test
.
getFuzzParamsId
()
==
0
)
{
...
@@ -207,9 +211,11 @@ public class TestMissionServiceImpl implements TestMissionService {
...
@@ -207,9 +211,11 @@ public class TestMissionServiceImpl implements TestMissionService {
/*运行程序*/
/*运行程序*/
try
{
try
{
if
(
isAflnet
)
{
// 启动alfnet
if
(
isAflnet
)
{
// 启动alfnet
aflnetMissionStart
(
fuzzParams
,
missionInfo
);
aflnetMissionStart
(
fuzzParams
,
missionInfo
);
return
AjaxResult
.
success
(
"启动成功!"
);
}
else
{
}
else
{
Map
<
String
,
List
<
String
>>
result
=
kittyMissionStart
(
fuzzParams
,
missionInfo
);
return
AjaxResult
.
success
(
result
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"Mission start error:[{}]"
,
e
.
getMessage
());
log
.
error
(
"Mission start error:[{}]"
,
e
.
getMessage
());
...
@@ -218,10 +224,36 @@ public class TestMissionServiceImpl implements TestMissionService {
...
@@ -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任务
* 启动aflnet任务
*/
*/
private
void
aflnetMissionStart
(
FuzzParams
fuzzParams
,
MissionInfo
missionInfo
)
{
private
void
aflnetMissionStart
(
FuzzParams
fuzzParams
,
MissionInfo
missionInfo
)
{
CmdStartParams
cmdStartParams
=
(
CmdStartParams
)
JSONObject
.
parseObject
(
fuzzParams
.
getParams
(),
CmdStartParams
.
class
);
CmdStartParams
cmdStartParams
=
(
CmdStartParams
)
JSONObject
.
parseObject
(
fuzzParams
.
getParams
(),
CmdStartParams
.
class
);
try
{
try
{
SystemRunningParams
.
aflnetData
.
put
(
"missionName"
,
cmdStartParams
.
getProtopcol
());
SystemRunningParams
.
aflnetData
.
put
(
"missionName"
,
cmdStartParams
.
getProtopcol
());
Thread
subThread
=
new
Thread
(
new
Runnable
()
{
Thread
subThread
=
new
Thread
(
new
Runnable
()
{
...
@@ -231,10 +263,10 @@ public class TestMissionServiceImpl implements TestMissionService {
...
@@ -231,10 +263,10 @@ public class TestMissionServiceImpl implements TestMissionService {
missionInfo
.
setState
(
MissionStateEnum
.
RUNNING
.
getStateCode
());
missionInfo
.
setState
(
MissionStateEnum
.
RUNNING
.
getStateCode
());
missionInfoMapper
.
updateMission
(
missionInfo
);
missionInfoMapper
.
updateMission
(
missionInfo
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"Error updating mission:[{}]"
,
e
.
getMessage
());
log
.
error
(
"Error updating mission:[{}]"
,
e
.
getMessage
());
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
service
.
testStart
(
cmdStartParams
,
missionInfo
);
service
.
testStart
(
cmdStartParams
,
missionInfo
);
}
}
});
});
SystemRunningParams
.
ThreadState
.
put
(
subThread
,
"start"
);
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 {
...
@@ -29,8 +29,9 @@ public class VulnerabilityTypeServiceImpl implements VulnerabilityTypeService {
KittyProperties
kitty
;
KittyProperties
kitty
;
@Autowired
@Autowired
FuzzParamsService
fuzzParamsService
;
FuzzParamsService
fuzzParamsService
;
@Override
@Override
@NeedCutAround
(
name
=
"kitty"
,
function
=
"generation"
)
@NeedCutAround
(
name
=
"kitty"
,
function
=
"generation"
)
public
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
)
throws
FuzzException
,
CmdException
{
public
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
)
throws
FuzzException
,
CmdException
{
/*存入参数*/
/*存入参数*/
// int missionId = GlobalClass.missionInfoMapper.selectTopMissionId();
// int missionId = GlobalClass.missionInfoMapper.selectTopMissionId();
...
@@ -38,11 +39,11 @@ public class VulnerabilityTypeServiceImpl implements VulnerabilityTypeService {
...
@@ -38,11 +39,11 @@ public class VulnerabilityTypeServiceImpl implements VulnerabilityTypeService {
// if (!flag) {
// if (!flag) {
// throw new AflnetException("Save params error!");
// throw new AflnetException("Save params error!");
// }
// }
String
cmd
=
parseParameters
(
testEntity
);
//
String cmd = parseParameters(testEntity);
if
(
cmd
.
isEmpty
())
{
//
if (cmd.isEmpty()) {
throw
new
FuzzException
(
"cmd is null ! The number of parameters does not match!"
);
//
throw new FuzzException("cmd is null ! The number of parameters does not match!");
}
//
}
return
cmdTools
.
runProgramCmdAndResult
(
cmd
,
"vulnerability"
,
"Vulnerability-"
+
testEntity
.
getTestClassName
())
;
return
null
;
}
}
public
String
parseParameters
(
TestEntity
testEntity
)
{
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 {
...
@@ -136,7 +136,7 @@ public class TestCmdTools {
* 运行需要后台运行cmd
* 运行需要后台运行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
{
CmdException
{
Map
<
String
,
List
<
String
>>
result
=
new
HashMap
();
Map
<
String
,
List
<
String
>>
result
=
new
HashMap
();
List
<
String
>
out
=
Collections
.
synchronizedList
(
new
ArrayList
<
String
>());
List
<
String
>
out
=
Collections
.
synchronizedList
(
new
ArrayList
<
String
>());
...
@@ -161,7 +161,7 @@ public class TestCmdTools {
...
@@ -161,7 +161,7 @@ public class TestCmdTools {
new
Thread
(
new
Runnable
()
{
new
Thread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
dataBackUpTransaction
(
caller
,
finalOut
,
finalError
,
missionName
);
dataBackUpTransaction
(
caller
,
finalOut
,
finalError
,
missionName
,
missionInfo
);
}
}
}).
start
();
}).
start
();
//todo 需要传入任务参数,后期再开发
//todo 需要传入任务参数,后期再开发
...
@@ -426,23 +426,14 @@ public class TestCmdTools {
...
@@ -426,23 +426,14 @@ public class TestCmdTools {
}
}
@Transactional
(
rollbackFor
=
MysqlException
.
class
)
@Transactional
(
rollbackFor
=
MysqlException
.
class
)
public
void
dataBackUpTransaction
(
String
caller
,
List
<
String
>
out
,
List
<
String
>
error
,
String
missionName
)
{
public
void
dataBackUpTransaction
(
String
caller
,
List
<
String
>
out
,
List
<
String
>
error
,
String
missionName
,
MissionInfo
missionInfo
)
{
int
missionId
=
SystemRunningParams
.
kittyMissionId
;
try
{
try
{
/*kitty结果存入数据库*/
/*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
);
GlobalClass
.
kittyMapper
.
kittyResultsBackup
(
kittyResult
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
log
.
error
(
"kitty backup error!"
);
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