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
10fb02a4
Commit
10fb02a4
authored
Jun 18, 2024
by
钱炳权
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kitty信息能够存储
parent
267c45e2
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
294 additions
and
88 deletions
+294
-88
afterAop.java
.../src/main/java/com/example/fuzzControll/aop/afterAop.java
+63
-0
aroundAop.java
...src/main/java/com/example/fuzzControll/aop/aroundAop.java
+117
-0
beforeAop.java
...src/main/java/com/example/fuzzControll/aop/beforeAop.java
+27
-42
SystemConfig.java
...main/java/com/example/fuzzControll/conf/SystemConfig.java
+2
-0
TableClassEnum.java
...va/com/example/fuzzControll/constents/TableClassEnum.java
+3
-2
KittyController.java
...zzControll/controller/testController/KittyController.java
+7
-2
KittyException.java
.../fuzzControll/exception/testException/KittyException.java
+11
-0
FuzzLogServiceImpl.java
...example/fuzzControll/service/impl/FuzzLogServiceImpl.java
+2
-2
GenerateMethodServiceImpl.java
.../fuzzControll/service/impl/GenerateMethodServiceImpl.java
+5
-2
KittyFuzzPersistenceServiceImpl.java
...ontroll/service/impl/KittyFuzzPersistenceServiceImpl.java
+2
-2
MutationServiceImpl.java
...xample/fuzzControll/service/impl/MutationServiceImpl.java
+8
-4
ProtocolTemplateImpl.java
...ample/fuzzControll/service/impl/ProtocolTemplateImpl.java
+15
-10
SeedFileServiceImpl.java
...xample/fuzzControll/service/impl/SeedFileServiceImpl.java
+2
-2
TestServiceImpl.java
...om/example/fuzzControll/service/impl/TestServiceImpl.java
+2
-4
VulnerabilityTypeServiceImpl.java
...zzControll/service/impl/VulnerabilityTypeServiceImpl.java
+5
-2
GlobalClass.java
...va/com/example/fuzzControll/tools/system/GlobalClass.java
+2
-0
SystemRunningParams.java
...xample/fuzzControll/tools/system/SystemRunningParams.java
+8
-0
TestCmdTools.java
...ava/com/example/fuzzControll/tools/test/TestCmdTools.java
+7
-11
MissionInfoMapper.xml
...tegration/src/main/resources/mapper/MissionInfoMapper.xml
+6
-3
No files found.
fuzzIntegration/src/main/java/com/example/fuzzControll/aop/afterAop.java
0 → 100644
View file @
10fb02a4
package
com
.
example
.
fuzzControll
.
aop
;
import
com.example.fuzzControll.annotion.NeedCutBefore
;
import
com.example.fuzzControll.exception.mysqlException.MysqlException
;
import
com.example.fuzzControll.exception.testException.AflnetException
;
import
com.example.fuzzControll.tools.system.GlobalClass
;
import
com.example.fuzzControll.tools.system.SystemRunningParams
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.Signature
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.core.Ordered
;
import
org.springframework.stereotype.Component
;
import
java.lang.reflect.Method
;
@Aspect
@Component
@Slf4j
public
class
afterAop
implements
Ordered
{
@Pointcut
(
value
=
"@annotation(com.example.fuzzControll.annotion.NeedCutAfter)"
)
private
void
afterCut
()
{
}
@Around
(
"afterCut()"
)
public
void
after
(
JoinPoint
point
)
throws
Throwable
{
Signature
signature
=
point
.
getSignature
();
MethodSignature
methodSignature
=
null
;
if
(!(
signature
instanceof
MethodSignature
))
{
throw
new
IllegalArgumentException
(
"该注解只能用于方法"
);
}
methodSignature
=
(
MethodSignature
)
signature
;
Object
target
=
point
.
getTarget
();
Method
currentMethod
=
null
;
try
{
currentMethod
=
target
.
getClass
().
getMethod
(
methodSignature
.
getName
(),
methodSignature
.
getParameterTypes
());
}
catch
(
NoSuchMethodException
e
)
{
log
.
error
(
"NoSuchMethod!"
);
e
.
printStackTrace
();
throw
new
RuntimeException
(
e
);
}
NeedCutBefore
logotype
=
currentMethod
.
getAnnotation
(
NeedCutBefore
.
class
);
/*相关处理逻辑,负责数据存入*/
switch
(
logotype
.
name
())
{
case
"aflnet"
:
// aflnet(logotype.function());
break
;
case
"kitty"
:
// kittyAfter(logotype.function());
break
;
default
:
throw
new
AflnetException
(
"Cut error: There is no name of anotation!"
);
}
}
@Override
public
int
getOrder
()
{
return
3
;
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/aop/aroundAop.java
0 → 100644
View file @
10fb02a4
package
com
.
example
.
fuzzControll
.
aop
;
import
com.example.fuzzControll.annotion.NeedCutAround
;
import
com.example.fuzzControll.annotion.NeedCutBefore
;
import
com.example.fuzzControll.constents.MissionStateEnum
;
import
com.example.fuzzControll.constents.TableClassEnum
;
import
com.example.fuzzControll.domain.po.MissionInfo
;
import
com.example.fuzzControll.exception.mysqlException.MysqlException
;
import
com.example.fuzzControll.exception.testException.AflnetException
;
import
com.example.fuzzControll.exception.testException.KittyException
;
import
com.example.fuzzControll.tools.system.GlobalClass
;
import
com.example.fuzzControll.tools.system.SystemRunningParams
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.Signature
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.core.Ordered
;
import
org.springframework.stereotype.Component
;
import
java.lang.reflect.Method
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
@Aspect
@Component
@Slf4j
public
class
aroundAop
implements
Ordered
{
@Pointcut
(
value
=
"@annotation(com.example.fuzzControll.annotion.NeedCutAround)"
)
private
void
aroundCut
()
{
}
@Around
(
"aroundCut()"
)
public
Map
<
String
,
List
<
String
>>
around
(
ProceedingJoinPoint
point
)
throws
Throwable
{
Signature
signature
=
point
.
getSignature
();
MethodSignature
methodSignature
=
null
;
if
(!(
signature
instanceof
MethodSignature
))
{
throw
new
IllegalArgumentException
(
"该注解只能用于方法"
);
}
methodSignature
=
(
MethodSignature
)
signature
;
Object
target
=
point
.
getTarget
();
Method
currentMethod
=
target
.
getClass
().
getMethod
(
methodSignature
.
getName
(),
methodSignature
.
getParameterTypes
());
NeedCutAround
logotype
=
currentMethod
.
getAnnotation
(
NeedCutAround
.
class
);
/*aflnet相关处理逻辑,负责数据存入*/
switch
(
logotype
.
name
())
{
case
"aflnet"
:
return
null
;
// aflnetAround(logotype.function());
case
"kitty"
:
return
kittyAround
(
logotype
.
function
(),
point
);
default
:
return
null
;
}
}
private
Map
<
String
,
List
<
String
>>
kittyAround
(
String
function
,
ProceedingJoinPoint
point
)
{
Object
result
=
null
;
if
(
function
==
null
||
""
.
equals
(
function
))
{
throw
new
AflnetException
(
"There is no value in 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
());
/*放行方法*/
try
{
result
=
point
.
proceed
();
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
throw
new
KittyException
(
"Kitty run error!"
);
}
/*运行后方法*/
if
(
function
==
null
||
""
.
equals
(
function
))
{
throw
new
AflnetException
(
"There is no value in function!"
);
}
if
(
"startBackup"
.
equals
(
function
))
{
/*存入kitty结束时的任务信息*/
try
{
SystemRunningParams
.
testTimeMessage
.
get
(
"kitty"
).
put
(
"end"
,
System
.
currentTimeMillis
());
int
missionId
=
SystemRunningParams
.
kittyMissionId
;
Long
runTime
=
SystemRunningParams
.
testTimeMessage
.
get
(
"kitty"
).
get
(
"end"
)
-
SystemRunningParams
.
testTimeMessage
.
get
(
"kitty"
).
get
(
"start"
);
GlobalClass
.
missionInfoMapper
.
updateMission
(
MissionStateEnum
.
DONE
.
getStateCode
(),
runTime
,
missionId
);
//更新该次任务的执行时间;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
MysqlException
(
"Kitty start backup failed!"
);
}
}
}
if
(
result
==
null
)
{
throw
new
KittyException
(
"Result is null!"
);
}
System
.
out
.
println
(
result
);
return
(
Map
<
String
,
List
<
String
>>)
result
;
}
@Override
public
int
getOrder
()
{
return
2
;
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/aop/
Integration
Aop.java
→
fuzzIntegration/src/main/java/com/example/fuzzControll/aop/
before
Aop.java
View file @
10fb02a4
...
...
@@ -23,6 +23,7 @@ import org.aspectj.lang.reflect.MethodSignature;
import
org.springframework.core.Ordered
;
import
org.springframework.stereotype.Component
;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Method
;
import
java.util.Arrays
;
import
java.util.Date
;
...
...
@@ -34,25 +35,18 @@ import static com.example.fuzzControll.tools.system.GlobalClass.aflnetPersistenc
@Aspect
@Component
@Slf4j
public
class
IntegrationAop
implements
Ordered
{
public
class
beforeAop
implements
Ordered
{
SingleCmdTools
singleCmdTools
=
new
SingleCmdTools
();
@Pointcut
(
value
=
"@annotation(com.example.fuzzControll.annotion.NeedCutBefore)"
)
private
void
beforCut
()
{
@Pointcut
(
value
=
"@annotation(com.example.fuzzControll.annotion.NeedCutBefore)
||@within(com.example.fuzzControll.annotion.NeedCutBefore)
"
)
private
void
befor
e
Cut
()
{
}
@Pointcut
(
value
=
"@annotation(com.example.fuzzControll.annotion.NeedCutBefore)"
)
private
void
afterCut
()
{
}
@Pointcut
(
value
=
"@annotation(com.example.fuzzControll.annotion.NeedCutBefore)"
)
private
void
aroundCut
()
{
}
/**
* 用于aflnet测试相关的数据库操作
*/
@Before
(
"beforCut()"
)
@Before
(
"befor
e
Cut()"
)
private
void
before
(
JoinPoint
point
)
{
/*负责获取反射对象*/
Signature
signature
=
point
.
getSignature
();
...
...
@@ -77,41 +71,13 @@ public class IntegrationAop implements Ordered {
aflnet
(
logotype
.
function
());
break
;
case
"kitty"
:
kitty
(
logotype
.
function
());
//
kitty(logotype.function());
break
;
default
:
throw
new
AflnetException
(
"Cut error: There is no name of anotation!"
);
}
}
@Around
(
"aroundCut()"
)
public
Object
around
(
ProceedingJoinPoint
point
)
throws
Throwable
{
Signature
signature
=
point
.
getSignature
();
MethodSignature
methodSignature
=
null
;
if
(!(
signature
instanceof
MethodSignature
))
{
throw
new
IllegalArgumentException
(
"该注解只能用于方法"
);
}
methodSignature
=
(
MethodSignature
)
signature
;
Object
target
=
point
.
getTarget
();
Method
currentMethod
=
target
.
getClass
().
getMethod
(
methodSignature
.
getName
(),
methodSignature
.
getParameterTypes
());
NeedCutBefore
logotype
=
currentMethod
.
getAnnotation
(
NeedCutBefore
.
class
);
// if (datasource != null) {
// DataSourceContextHolder.setDataSourceType(logotype.name());
// log.debug("设置数据源为:" + datasource.name());
// } else {
// DataSourceContextHolder.setDataSourceType(DSEnum.DATA_SOURCE_CORE);
// log.debug("设置数据源为:dataSourceCore");
// }
// try {
return
point
.
proceed
();
// } finally {
// log.debug("清空数据源信息!");
// DataSourceContextHolder.clearDataSourceType();
// }
}
private
void
aflnet
(
String
function
)
{
if
(
function
==
null
||
""
.
equals
(
function
))
{
...
...
@@ -145,7 +111,7 @@ public class IntegrationAop implements Ordered {
}
/*存入压缩包*/
while
(
files
.
contains
(
fileZipName
)
&&
flag
==
0
)
{
//当前存在压缩包,且没有存过才存入,循环是等待压缩完成 todo 感觉这里后期会出现问题
flag
=
aflnetPersistenceService
.
aflnetResultBackup
(
fileZipName
,
1
,
flag
=
aflnetPersistenceService
.
aflnetResultBackup
(
fileZipName
,
0
,
SystemRunningParams
.
testTimeMessage
.
get
(
"aflnet"
).
get
(
"end"
)
-
SystemRunningParams
.
testTimeMessage
.
get
(
"aflnet"
).
get
(
"start"
));
}
/*清除生成的文件*/
...
...
@@ -168,11 +134,30 @@ public class IntegrationAop implements Ordered {
}
private
void
kitty
(
String
function
)
{
//todo 四种测试无法同时运行,因为只存了一个missionName
if
(
function
==
null
||
""
.
equals
(
function
))
{
throw
new
AflnetException
(
"There is no value in function!"
);
}
if
(
"startBackup"
.
equals
(
function
))
{
/*存入kitty启动时的任务信息*/
try
{
int
missionId
=
GlobalClass
.
missionInfoMapper
.
selectTopMissionId
()
+
1
;
SystemRunningParams
.
kittyMissionId
=
missionId
;
GlobalClass
.
missionInfoMapper
.
insertMission
(
new
MissionInfo
(
missionId
,
TableClassEnum
.
KITTY_RESULT
.
getTableId
(),
new
Date
(),
SystemRunningParams
.
kittyData
.
get
(
"missionName"
),
MissionStateEnum
.
RUNNING
.
getStateCode
(),
0L
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
MysqlException
(
"Kitty start backup failed!"
);
}
}
// }else if("afterBackup".equals(function)){
//
// }
}
@Override
public
int
getOrder
()
{
return
1
;
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/conf/SystemConfig.java
View file @
10fb02a4
...
...
@@ -2,8 +2,10 @@ package com.example.fuzzControll.conf;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.EnableAspectJAutoProxy
;
@Configuration
@EnableFeignClients
@EnableAspectJAutoProxy
(
proxyTargetClass
=
true
,
exposeProxy
=
true
)
public
class
SystemConfig
{
}
fuzzIntegration/src/main/java/com/example/fuzzControll/constents/TableClassEnum.java
View file @
10fb02a4
...
...
@@ -5,8 +5,9 @@ package com.example.fuzzControll.constents;
*/
public
enum
TableClassEnum
{
AFLNET
(
"alfnetResult"
,
1
),
KITTY_PACKAGE
(
"kittyPackageFile"
,
2
),
KITTY_RESULT
(
"kittyResult"
,
3
);
KITTY_RESULT
(
"kittyResult"
,
2
),
KITTY_PACKAGE
(
"kittyPackageFile"
,
3
);
private
String
tableName
;
private
int
tableId
;
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/controller/testController/KittyController.java
View file @
10fb02a4
package
com
.
example
.
fuzzControll
.
controller
.
testController
;
import
com.example.fuzzControll.annotion.NeedCutBefore
;
import
com.example.fuzzControll.exception.testException.CmdException
;
import
com.example.fuzzControll.exception.testException.FuzzException
;
import
com.example.fuzzControll.domain.vo.AjaxResult
;
...
...
@@ -8,6 +9,7 @@ import com.example.fuzzControll.service.GenerateMethodService;
import
com.example.fuzzControll.service.MutationService
;
import
com.example.fuzzControll.service.ProtocolTemplateService
;
import
com.example.fuzzControll.service.VulnerabilityTypeService
;
import
com.example.fuzzControll.tools.system.SystemRunningParams
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -39,7 +41,8 @@ public class KittyController {
*/
@RequestMapping
(
value
=
"/protocolTemplate"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
protocolTemplate
(
@RequestBody
TestEntity
testEntity
)
{
try
{
//todo missionId
try
{
SystemRunningParams
.
kittyData
.
put
(
"missionName"
,
testEntity
.
getTestClassName
());
Map
<
String
,
List
<
String
>>
result
=
protocolTemplateService
.
generation
(
testEntity
,
1
);
return
AjaxResult
.
success
(
result
==
null
?
"模板文件生成未成功运行!第三方接口可能存在问题。"
:
result
);
}
catch
(
CmdException
|
FuzzException
e
)
{
...
...
@@ -54,7 +57,7 @@ public class KittyController {
@RequestMapping
(
value
=
"/generate"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
generate
(
@RequestBody
TestEntity
testEntity
)
{
try
{
//todo 需要传入missionId
SystemRunningParams
.
kittyData
.
put
(
"missionName"
,
testEntity
.
getTestClassName
());
Map
<
String
,
List
<
String
>>
result
=
generateMethodService
.
generation
(
testEntity
,
1
);
return
AjaxResult
.
success
(
result
==
null
?
"生成方法未成功运行!第三方接口可能存在问题。"
:
result
);
}
catch
(
CmdException
|
FuzzException
e
)
{
...
...
@@ -69,6 +72,7 @@ public class KittyController {
@RequestMapping
(
value
=
"/mutation"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
mutation
(
@RequestBody
TestEntity
testEntity
)
{
try
{
SystemRunningParams
.
kittyData
.
put
(
"missionName"
,
testEntity
.
getTestClassName
());
Map
<
String
,
List
<
String
>>
result
=
mutationService
.
generation
(
testEntity
,
1
);
return
AjaxResult
.
success
(
result
==
null
?
"mutationTest未成功运行!第三方接口可能存在问题。"
:
result
);
}
catch
(
CmdException
|
FuzzException
e
)
{
...
...
@@ -83,6 +87,7 @@ public class KittyController {
@RequestMapping
(
value
=
"/vulnerabilityType"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
vulnerability
(
@RequestBody
TestEntity
testEntity
)
{
try
{
SystemRunningParams
.
kittyData
.
put
(
"missionName"
,
testEntity
.
getTestClassName
());
Map
<
String
,
List
<
String
>>
result
=
vulnerabilityTypeService
.
generation
(
testEntity
,
1
);
return
AjaxResult
.
success
(
result
==
null
?
"漏洞类型未成功运行!第三方接口可能存在问题。"
:
result
);
}
catch
(
CmdException
|
FuzzException
e
)
{
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/exception/testException/KittyException.java
0 → 100644
View file @
10fb02a4
package
com
.
example
.
fuzzControll
.
exception
.
testException
;
import
com.example.fuzzControll.exception.BaseException
;
public
class
KittyException
extends
BaseException
{
private
static
final
long
serialVersionUID
=
1L
;
public
KittyException
(
String
defaultMessage
)
{
super
(
defaultMessage
,
"kitty"
);
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/FuzzLogServiceImpl.java
View file @
10fb02a4
...
...
@@ -38,9 +38,9 @@ public class FuzzLogServiceImpl implements FuzzLogService {
switch
(
missionInfo
.
getTableId
())
{
case
1
:
return
downloadAflnetFile
(
missionInfo
);
case
2
:
return
downloadKittyProtocalFile
(
missionInfo
);
case
3
:
return
downloadKittyProtocalFile
(
missionInfo
);
case
2
:
return
downloadKittyOtherMethodFile
(
missionInfo
);
default
:
throw
new
IllegalAccessException
(
"Invalid mission!"
);
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/GenerateMethodServiceImpl.java
View file @
10fb02a4
package
com
.
example
.
fuzzControll
.
service
.
impl
;
import
com.example.fuzzControll.annotion.NeedCutAround
;
import
com.example.fuzzControll.annotion.NeedCutBefore
;
import
com.example.fuzzControll.conf.KittyProperties
;
import
com.example.fuzzControll.exception.testException.CmdException
;
import
com.example.fuzzControll.exception.testException.FuzzException
;
import
com.example.fuzzControll.domain.bo.TestEntity
;
import
com.example.fuzzControll.service.GenerateMethodService
;
import
com.example.fuzzControll.tools.test.CmdTools
;
import
com.example.fuzzControll.tools.test.
Test
CmdTools
;
import
com.example.fuzzControll.tools.test.TestTools
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -17,11 +19,12 @@ import java.util.Map;
@Service
@Slf4j
public
class
GenerateMethodServiceImpl
implements
GenerateMethodService
{
CmdTools
cmdTools
=
new
CmdTools
();
TestCmdTools
cmdTools
=
new
Test
CmdTools
();
@Autowired
KittyProperties
kitty
;
@Override
@NeedCutAround
(
name
=
"kitty"
,
function
=
"generation"
)
public
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
,
int
missionId
)
throws
FuzzException
,
CmdException
{
String
cmd
=
parseParameters
(
testEntity
);
if
(
cmd
.
isEmpty
())
{
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/KittyFuzzPersistenceServiceImpl.java
View file @
10fb02a4
...
...
@@ -8,7 +8,7 @@ import com.example.fuzzControll.domain.bo.KittyDataParams;
import
com.example.fuzzControll.domain.vo.KittyResult
;
import
com.example.fuzzControll.domain.vo.KittyPackageFile
;
import
com.example.fuzzControll.service.KittyFuzzPersistenceService
;
import
com.example.fuzzControll.tools.test.CmdTools
;
import
com.example.fuzzControll.tools.test.
Test
CmdTools
;
import
com.example.fuzzControll.tools.file.FileTools
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -23,7 +23,7 @@ public class KittyFuzzPersistenceServiceImpl implements KittyFuzzPersistenceServ
@Autowired
KittyMapper
kittyMapper
;
FileTools
fileTools
=
new
FileTools
();
CmdTools
cmdTools
=
new
CmdTools
();
TestCmdTools
cmdTools
=
new
Test
CmdTools
();
@Autowired
KittyProperties
kittyProperties
;
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/MutationServiceImpl.java
View file @
10fb02a4
package
com
.
example
.
fuzzControll
.
service
.
impl
;
import
com.example.fuzzControll.annotion.NeedCutAfter
;
import
com.example.fuzzControll.annotion.NeedCutAround
;
import
com.example.fuzzControll.annotion.NeedCutBefore
;
import
com.example.fuzzControll.conf.KittyProperties
;
import
com.example.fuzzControll.constents.MutationConstent
;
import
com.example.fuzzControll.exception.testException.CmdException
;
import
com.example.fuzzControll.exception.testException.FuzzException
;
import
com.example.fuzzControll.domain.bo.TestEntity
;
import
com.example.fuzzControll.service.MutationService
;
import
com.example.fuzzControll.tools.test.CmdTools
;
import
com.example.fuzzControll.tools.test.
Test
CmdTools
;
import
com.example.fuzzControll.tools.test.TestTools
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -18,18 +21,19 @@ import java.util.Map;
@Service
(
"mutationService"
)
@Slf4j
class
MutationServiceImpl
implements
MutationService
{
CmdTools
cmdTools
=
new
CmdTools
();
TestCmdTools
cmdTools
=
new
Test
CmdTools
();
@Autowired
KittyProperties
kitty
;
@Override
public
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
,
int
missionId
)
throws
FuzzException
,
CmdException
{
@NeedCutAround
(
name
=
"kitty"
,
function
=
"generation"
)
public
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
,
int
missionId
)
throws
FuzzException
,
CmdException
{
String
cmd
=
parseParameters
(
testEntity
);
if
(
cmd
.
isEmpty
())
{
throw
new
FuzzException
(
"cmd is null ! The number of parameters does not match!"
);
}
return
cmdTools
.
runProgramCmdAndResult
(
cmd
,
"mutation"
,
"Mutation-"
+
testEntity
.
getTestClassName
());
return
cmdTools
.
runProgramCmdAndResult
(
cmd
,
"mutation"
,
"Mutation-"
+
testEntity
.
getTestClassName
());
}
public
String
parseParameters
(
TestEntity
testEntity
)
{
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/ProtocolTemplateImpl.java
View file @
10fb02a4
package
com
.
example
.
fuzzControll
.
service
.
impl
;
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.ProtocolConstent
;
...
...
@@ -8,8 +10,9 @@ import com.example.fuzzControll.exception.testException.CmdException;
import
com.example.fuzzControll.exception.testException.FuzzException
;
import
com.example.fuzzControll.domain.bo.TestEntity
;
import
com.example.fuzzControll.service.ProtocolTemplateService
;
import
com.example.fuzzControll.tools.test.CmdTools
;
import
com.example.fuzzControll.tools.system.GlobalClass
;
import
com.example.fuzzControll.tools.test.SingleCmdTools
;
import
com.example.fuzzControll.tools.test.TestCmdTools
;
import
com.example.fuzzControll.tools.test.TestTools
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -21,19 +24,21 @@ import java.util.Map;
@Slf4j
@Service
public
class
ProtocolTemplateImpl
implements
ProtocolTemplateService
{
CmdTools
cmdTools
=
new
CmdTools
();
SingleCmdTools
singleCmdTools
=
new
SingleCmdTools
();
TestCmdTools
testCmdTools
=
new
TestCmdTools
();
@Autowired
KittyProperties
kitty
;
@Override
public
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
,
int
missionId
)
throws
FuzzException
,
CmdException
{
@NeedCutAround
(
name
=
"kitty"
,
function
=
"generation"
)
public
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
,
int
missionId
)
throws
FuzzException
,
CmdException
{
/*生成日志前先清除日志*/
cmdTools
.
runCmd
(
CmdConstent
.
DELETE_FILE
+
GlobalClass
.
kittyProperties
.
getLogOutPath
(),
"delete kittyLogs"
);
singleCmdTools
.
runCmd
(
CmdConstent
.
DELETE_FILE
+
GlobalClass
.
kittyProperties
.
getLogOutPath
(),
"delete kittyLogs"
);
String
cmd
=
parseParameters
(
testEntity
);
if
(
cmd
==
null
||
cmd
.
equals
(
""
))
{
if
(
cmd
==
null
||
""
.
equals
(
cmd
))
{
throw
new
FuzzException
(
"cmd is null ! The number of parameters does not match!"
);
}
return
cmdTools
.
runProgramCmdAndResult
(
cmd
,
"protocolTemplate"
,
"ProtocolTemplate-"
+
testEntity
.
getTestClassName
());
return
testCmdTools
.
runProgramCmdAndResult
(
cmd
,
"protocolTemplate"
,
"ProtocolTemplate-"
+
testEntity
.
getTestClassName
());
}
public
String
parseParameters
(
TestEntity
testEntity
)
throws
FuzzException
{
...
...
@@ -163,7 +168,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
private
String
sendPcapCmd
(
TestEntity
testEntity
)
{
//todo 还不清楚怎么做
return
null
;
return
null
;
}
private
String
mqttCmd
(
TestEntity
testEntity
)
{
...
...
@@ -184,7 +189,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
}
catch
(
Exception
e
)
{
log
.
error
(
"mqtt参数解析失败!"
);
}
return
kitty
.
getVenvPath
()
+
" "
+
kitty
.
getPath
()
+
ProtocolConstent
.
MQTT
+
" "
+
ip
+
" "
+
port
+
" "
+
topic
+
" "
+
username
+
" "
+
password
;
return
kitty
.
getVenvPath
()
+
" "
+
kitty
.
getPath
()
+
ProtocolConstent
.
MQTT
+
" "
+
ip
+
" "
+
port
+
" "
+
topic
+
" "
+
username
+
" "
+
password
;
}
private
String
coapCmd
(
TestEntity
testEntity
)
{
...
...
@@ -201,7 +206,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
}
catch
(
Exception
e
)
{
log
.
error
(
"coap参数解析失败!"
);
}
return
kitty
.
getVenvPath
()
+
" "
+
kitty
.
getPath
()
+
ProtocolConstent
.
COAP
+
" "
+
ip
+
" "
+
port
+
" "
+
path
;
return
kitty
.
getVenvPath
()
+
" "
+
kitty
.
getPath
()
+
ProtocolConstent
.
COAP
+
" "
+
ip
+
" "
+
port
+
" "
+
path
;
}
private
String
doipCmd
(
TestEntity
testEntity
)
{
...
...
@@ -269,7 +274,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
}
catch
(
Exception
e
)
{
log
.
error
(
"amqp参数解析失败!"
);
}
return
kitty
.
getVenvPath
()
+
" "
+
kitty
.
getPath
()
+
ProtocolConstent
.
AMQP
+
" "
+
ip
+
" "
+
port
+
" "
+
queue
+
" "
+
exchange
+
" "
+
routing_key
;
return
kitty
.
getVenvPath
()
+
" "
+
kitty
.
getPath
()
+
ProtocolConstent
.
AMQP
+
" "
+
ip
+
" "
+
port
+
" "
+
queue
+
" "
+
exchange
+
" "
+
routing_key
;
}
private
String
tirpCmd
(
TestEntity
testEntity
)
{
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/SeedFileServiceImpl.java
View file @
10fb02a4
...
...
@@ -5,7 +5,7 @@ import com.example.fuzzControll.constents.CmdConstent;
import
com.example.fuzzControll.exception.testException.CmdException
;
import
com.example.fuzzControll.exception.fileExcption.FileException
;
import
com.example.fuzzControll.service.SeedFileService
;
import
com.example.fuzzControll.tools.test.CmdTools
;
import
com.example.fuzzControll.tools.test.
Test
CmdTools
;
import
com.example.fuzzControll.tools.file.FileTools
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -17,7 +17,7 @@ import java.util.List;
@Slf4j
@Service
public
class
SeedFileServiceImpl
implements
SeedFileService
{
CmdTools
cmdTools
=
new
CmdTools
();
TestCmdTools
cmdTools
=
new
Test
CmdTools
();
FileTools
fileTools
=
new
FileTools
();
@Autowired
AflnetProperties
properties
;
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/TestServiceImpl.java
View file @
10fb02a4
...
...
@@ -8,8 +8,7 @@ import com.example.fuzzControll.exception.testException.CmdException;
import
com.example.fuzzControll.domain.bo.CmdStartParams
;
import
com.example.fuzzControll.service.AflnetPersistenceService
;
import
com.example.fuzzControll.service.TestService
;
import
com.example.fuzzControll.tools.test.CmdTools
;
import
com.example.fuzzControll.tools.system.GlobalClass
;
import
com.example.fuzzControll.tools.test.TestCmdTools
;
import
com.example.fuzzControll.tools.test.TestControlTools
;
import
com.example.fuzzControll.tools.system.SystemRunningParams
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -19,14 +18,13 @@ import org.springframework.stereotype.Service;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
@Service
(
"testService"
)
@Slf4j
public
class
TestServiceImpl
implements
TestService
{
@Autowired
CmdTools
cmdTools
;
Test
CmdTools
cmdTools
;
@Autowired
AflnetPersistenceService
aflnetPersistenceService
;
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/VulnerabilityTypeServiceImpl.java
View file @
10fb02a4
package
com
.
example
.
fuzzControll
.
service
.
impl
;
import
com.example.fuzzControll.annotion.NeedCutAround
;
import
com.example.fuzzControll.annotion.NeedCutBefore
;
import
com.example.fuzzControll.conf.KittyProperties
;
import
com.example.fuzzControll.exception.testException.CmdException
;
import
com.example.fuzzControll.exception.testException.FuzzException
;
import
com.example.fuzzControll.domain.bo.TestEntity
;
import
com.example.fuzzControll.service.VulnerabilityTypeService
;
import
com.example.fuzzControll.tools.test.CmdTools
;
import
com.example.fuzzControll.tools.test.
Test
CmdTools
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -16,11 +18,12 @@ import java.util.Map;
@Slf4j
@Service
(
"vulnerabilityTypeService"
)
public
class
VulnerabilityTypeServiceImpl
implements
VulnerabilityTypeService
{
CmdTools
cmdTools
=
new
CmdTools
();
TestCmdTools
cmdTools
=
new
Test
CmdTools
();
@Autowired
KittyProperties
kitty
;
@Override
@NeedCutAround
(
name
=
"kitty"
,
function
=
"generation"
)
public
Map
<
String
,
List
<
String
>>
generation
(
TestEntity
testEntity
,
int
missionId
)
throws
FuzzException
,
CmdException
{
String
cmd
=
parseParameters
(
testEntity
);
if
(
cmd
.
isEmpty
())
{
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/system/GlobalClass.java
View file @
10fb02a4
...
...
@@ -7,6 +7,7 @@ import com.example.fuzzControll.mapper.KittyMapper;
import
com.example.fuzzControll.mapper.MissionInfoMapper
;
import
com.example.fuzzControll.service.AflnetPersistenceService
;
import
com.example.fuzzControll.service.KittyFuzzPersistenceService
;
import
com.example.fuzzControll.tools.test.TestCmdTools
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -20,4 +21,5 @@ public class GlobalClass {
public
static
AflnetProperties
aflnetProperties
=
(
AflnetProperties
)
SpringContextUtil
.
getBean
(
"AflnetProperties"
);
public
static
AflnetPersistenceService
aflnetPersistenceService
=
(
AflnetPersistenceService
)
SpringContextUtil
.
getBean
(
"AflnetPersistenceService"
);
public
static
MissionInfoMapper
missionInfoMapper
=
(
MissionInfoMapper
)
SpringContextUtil
.
getBean
(
"MissionInfoMapper"
);
public
static
TestCmdTools
testCmdTools
=
(
TestCmdTools
)
SpringContextUtil
.
getBean
(
"TestCmdTools"
);
}
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/system/SystemRunningParams.java
View file @
10fb02a4
...
...
@@ -19,9 +19,17 @@ public class SystemRunningParams {
*/
public
static
int
aflnetMissionId
=
0
;
/**
* 系统中运行的kitty当前missionId
*/
public
static
int
kittyMissionId
=
0
;
/**
* aflnet运行时数据
*/
public
static
ConcurrentHashMap
<
String
,
String
>
aflnetData
=
new
ConcurrentHashMap
<>();
//当前aflnet任务的数据
/**
* kitty运行时数据
*/
public
static
ConcurrentHashMap
<
String
,
String
>
kittyData
=
new
ConcurrentHashMap
<>();
//当前kitty任务的数据
public
static
void
init
(){
/*初始化aflnet和kitty时间参数*/
testTimeMessage
.
put
(
"aflnet"
,
new
ConcurrentHashMap
<>());
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/test/CmdTools.java
→
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/test/
Test
CmdTools.java
View file @
10fb02a4
...
...
@@ -11,7 +11,6 @@ import com.example.fuzzControll.exception.mysqlException.MysqlException;
import
com.example.fuzzControll.service.impl.websocketClientServiceImpl
;
import
com.example.fuzzControll.tools.system.GlobalClass
;
import
com.example.fuzzControll.tools.system.SystemRunningParams
;
import
com.example.fuzzControll.tools.test.TestControlTools
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -19,16 +18,13 @@ import org.springframework.transaction.annotation.Transactional;
import
java.io.*
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.stream.Collectors
;
import
static
org
.
bouncycastle
.
asn1
.
x500
.
style
.
RFC4519Style
.
l
;
//todo need modify
@Slf4j
@Component
public
class
CmdTools
{
@Component
(
"TestCmdTools"
)
public
class
Test
CmdTools
{
Boolean
send
=
false
;
Boolean
show
=
true
;
...
...
@@ -58,7 +54,7 @@ public class CmdTools {
* 运行需要后台运行cmd
* 通过websocket返回数据
*/
@NeedCutBefore
(
name
=
"aflnet"
,
function
=
"startBackup"
)
@NeedCutBefore
(
name
=
"aflnet"
,
function
=
"startBackup"
)
public
void
runProgramCmd
(
String
cmd
,
String
outputFileName
)
throws
AflnetException
{
try
{
Process
process
=
Runtime
.
getRuntime
().
exec
(
cmd
);
//执行模糊测试指令
...
...
@@ -68,7 +64,7 @@ public class CmdTools {
process
.
waitFor
();
log
.
info
(
"Aflnet cmd have been run."
);
}
catch
(
Exception
e
)
{
log
.
error
(
"alfnet run error!:"
+
e
.
getMessage
());
log
.
error
(
"alfnet run error!:"
+
e
.
getMessage
());
throw
new
AflnetException
(
"Aflnet run error"
);
}
}
...
...
@@ -82,7 +78,6 @@ public class CmdTools {
List
<
String
>
out
=
Collections
.
synchronizedList
(
new
ArrayList
<
String
>());
List
<
String
>
error
=
Collections
.
synchronizedList
(
new
ArrayList
<
String
>());
try
{
SystemRunningParams
.
testTimeMessage
.
get
(
"kitty"
).
put
(
"start"
,
System
.
currentTimeMillis
());
Process
process
=
Runtime
.
getRuntime
().
exec
(
cmd
);
printMessageByProgramCmd
(
process
.
getInputStream
(),
out
);
printMessageByProgramCmd
(
process
.
getErrorStream
(),
error
);
...
...
@@ -99,7 +94,6 @@ public class CmdTools {
/*新开一个线程存入数据*/
List
<
String
>
finalOut
=
out
;
List
<
String
>
finalError
=
error
;
SystemRunningParams
.
testTimeMessage
.
get
(
"kitty"
).
put
(
"end"
,
System
.
currentTimeMillis
());
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -132,6 +126,7 @@ public class CmdTools {
/**
* 错误输出
*
* @param input
* @param result
* @return
...
...
@@ -176,6 +171,7 @@ public class CmdTools {
/**
* aflnet模糊测试数据键值对返回
*
* @param line
* @param returnEntity
* @return
...
...
@@ -331,7 +327,7 @@ public class CmdTools {
@Transactional
(
rollbackFor
=
MysqlException
.
class
)
public
void
dataBackUpTransaction
(
String
caller
,
List
<
String
>
out
,
List
<
String
>
error
,
String
missionName
)
{
int
missionId
=
GlobalClass
.
missionInfoMapper
.
selectTopMissionId
()
+
1
;
int
missionId
=
SystemRunningParams
.
kittyMissionId
;
try
{
/*kitty结果存入数据库*/
KittyResult
kittyResult
=
new
KittyResult
(
missionId
,
out
.
toString
(),
error
.
toString
());
...
...
fuzzIntegration/src/main/resources/mapper/MissionInfoMapper.xml
View file @
10fb02a4
...
...
@@ -22,7 +22,10 @@
<result
property=
"runTime"
column=
"runTime"
/>
</resultMap>
<sql
id=
"selectMissionInfo"
>
select id, missionId, createTime,missionName ,state,runTime from missionIdInfo
select id, missionId ,createTime,missionName ,state,runTime from missionIdInfo
</sql>
<sql
id=
"selectMissionInfoInDataBase"
>
select id, missionId,tableId, createTime,missionName ,state,runTime from missionIdInfo
</sql>
<insert
id=
"insertMission"
>
insert into missionIdInfo(missionId, tableId, createTime, missionName, state, runTime)
...
...
@@ -34,8 +37,8 @@
where missionId = #{missionId}
</update>
<select
id=
"selectByMissionId"
resultMap=
"MissionInfoInVo"
>
<include
refid=
"selectMissionInfo"
/>
and
missionId = #{missionId}
<include
refid=
"selectMissionInfo
InDataBase
"
/>
where
missionId = #{missionId}
</select>
<select
id=
"selectMissionInfoList"
resultMap=
"MissionInfoInVo"
>
<include
refid=
"selectMissionInfo"
/>
...
...
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