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
918202f5
Commit
918202f5
authored
May 15, 2024
by
钱炳权
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aflnet结果读出成功
parent
b66e695c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
122 additions
and
20 deletions
+122
-20
AflnetDataController.java
...troll/controller/dataController/AflnetDataController.java
+23
-4
KittyDataController.java
...ntroll/controller/dataController/KittyDataController.java
+2
-6
MysqlException.java
...va/com/example/fuzzControll/exception/MysqlException.java
+9
-0
AflnetMapper.java
...in/java/com/example/fuzzControll/mapper/AflnetMapper.java
+4
-1
KittyMapper.java
...ain/java/com/example/fuzzControll/mapper/KittyMapper.java
+1
-0
AflnetDataParams.java
...va/com/example/fuzzControll/pojo/vo/AflnetDataParams.java
+17
-0
AflnetPersistenceService.java
...xample/fuzzControll/service/AflnetPersistenceService.java
+1
-0
KittyFuzzPersistenceService.java
...ple/fuzzControll/service/KittyFuzzPersistenceService.java
+2
-1
AflnetPersistenceServiceImpl.java
...zzControll/service/impl/AflnetPersistenceServiceImpl.java
+19
-2
KittyFuzzPersistenceServiceImpl.java
...ontroll/service/impl/KittyFuzzPersistenceServiceImpl.java
+7
-2
FileTools.java
...c/main/java/com/example/fuzzControll/tools/FileTools.java
+29
-0
application-dev.yml
fuzzIntegration/src/main/resources/application-dev.yml
+1
-1
AflnetMapper.xml
fuzzIntegration/src/main/resources/mapper/AflnetMapper.xml
+7
-3
result.html
fuzzIntegration/src/main/resources/result.html
+0
-0
No files found.
fuzzIntegration/src/main/java/com/example/fuzzControll/controller/dataController/AflnetDataController.java
View file @
918202f5
package
com
.
example
.
fuzzControll
.
controller
.
dataController
;
package
com
.
example
.
fuzzControll
.
controller
.
dataController
;
import
com.example.fuzzControll.pojo.vo.AflnetDataParams
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.pojo.vo.KittyResult
;
import
com.example.fuzzControll.service.AflnetPersistenceService
;
import
com.example.fuzzControll.service.AflnetPersistenceService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
@RestController
@RestController
@RequestMapping
(
"/aflnet"
)
@RequestMapping
(
"/aflnet"
)
@Slf4j
@Slf4j
public
class
AflnetDataController
{
public
class
AflnetDataController
{
// @Autowired
@Autowired
// AflnetPersistenceService aflnetPersistenceService;
AflnetPersistenceService
aflnetPersistenceService
;
/**
* 读取数据库文件至指定目录
*/
@RequestMapping
(
value
=
"/loadFile"
,
method
=
RequestMethod
.
GET
)
public
AjaxResult
AflnetResultSelect
(
@RequestBody
AflnetDataParams
aflnetDataParams
)
{
try
{
aflnetPersistenceService
.
loadInFile
(
aflnetDataParams
.
getMissionId
(),
aflnetDataParams
.
getFilPath
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
AjaxResult
.
error
(
"File load failed!"
);
}
return
AjaxResult
.
success
(
"File loaded successfully!"
);
}
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/controller/dataController/KittyDataController.java
View file @
918202f5
package
com
.
example
.
fuzzControll
.
controller
.
dataController
;
package
com
.
example
.
fuzzControll
.
controller
.
dataController
;
import
com.example.fuzzControll.exception.CmdException
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.pojo.vo.KittyResult
;
import
com.example.fuzzControll.pojo.vo.KittyResult
;
import
com.example.fuzzControll.service.FuzzPersistenceService
;
import
com.example.fuzzControll.service.KittyFuzzPersistenceService
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -20,7 +16,7 @@ import java.util.List;
...
@@ -20,7 +16,7 @@ import java.util.List;
@Slf4j
@Slf4j
public
class
KittyDataController
{
public
class
KittyDataController
{
@Autowired
@Autowired
FuzzPersistenceService
fuzzPersistenceService
;
Kitty
FuzzPersistenceService
fuzzPersistenceService
;
/**
/**
* 查询kitty结果
* 查询kitty结果
*/
*/
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/exception/MysqlException.java
0 → 100644
View file @
918202f5
package
com
.
example
.
fuzzControll
.
exception
;
public
class
MysqlException
extends
BaseException
{
private
static
final
long
serialVersionUID
=
1L
;
public
MysqlException
(
String
defaultMessage
)
{
super
(
defaultMessage
,
"mysql"
);
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/mapper/AflnetMapper.java
View file @
918202f5
...
@@ -14,8 +14,11 @@ public interface AflnetMapper {
...
@@ -14,8 +14,11 @@ public interface AflnetMapper {
* 查询kitty模糊测试结果
* 查询kitty模糊测试结果
*/
*/
// List<KittyResult> getKittyResults();
// List<KittyResult> getKittyResults();
/**
/**
* 存储alfnet测试结果
* 存储alfnet测试结果
*/
*/
int
aflnetOutputBackup
(
AflnetResult
aflnetResult
);
int
aflnetOutputBackup
(
AflnetResult
aflnetResult
);
AflnetResult
selectResultById
(
int
missionId
);
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/mapper/KittyMapper.java
View file @
918202f5
...
@@ -18,6 +18,7 @@ public interface KittyMapper {
...
@@ -18,6 +18,7 @@ public interface KittyMapper {
void
kittyResultsBackup
(
KittyResult
kittyResult
);
void
kittyResultsBackup
(
KittyResult
kittyResult
);
/**
/**
* 查询kitty日志
* 查询kitty日志
*/
*/
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/pojo/vo/AflnetDataParams.java
0 → 100644
View file @
918202f5
package
com
.
example
.
fuzzControll
.
pojo
.
vo
;
import
lombok.Data
;
@Data
public
class
AflnetDataParams
{
private
String
filPath
;
private
int
missionId
;
public
AflnetDataParams
()
{
}
public
AflnetDataParams
(
String
filPath
,
int
missionId
)
{
this
.
filPath
=
filPath
;
this
.
missionId
=
missionId
;
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/service/AflnetPersistenceService.java
View file @
918202f5
...
@@ -2,4 +2,5 @@ package com.example.fuzzControll.service;
...
@@ -2,4 +2,5 @@ package com.example.fuzzControll.service;
public
interface
AflnetPersistenceService
{
public
interface
AflnetPersistenceService
{
public
int
aflnetResultBackup
(
String
filename
);
public
int
aflnetResultBackup
(
String
filename
);
public
void
loadInFile
(
int
missionId
,
String
filePath
);
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/service/FuzzPersistenceService.java
→
fuzzIntegration/src/main/java/com/example/fuzzControll/service/
Kitty
FuzzPersistenceService.java
View file @
918202f5
...
@@ -4,7 +4,8 @@ import com.example.fuzzControll.pojo.vo.KittyResult;
...
@@ -4,7 +4,8 @@ import com.example.fuzzControll.pojo.vo.KittyResult;
import
java.util.List
;
import
java.util.List
;
public
interface
FuzzPersistenceService
{
public
interface
Kitty
FuzzPersistenceService
{
List
<
KittyResult
>
getKittyResults
();
List
<
KittyResult
>
getKittyResults
();
// void loadInFile(int missionId);
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/AflnetPersistenceServiceImpl.java
View file @
918202f5
package
com
.
example
.
fuzzControll
.
service
.
impl
;
package
com
.
example
.
fuzzControll
.
service
.
impl
;
import
com.example.fuzzControll.exception.MysqlException
;
import
com.example.fuzzControll.mapper.AflnetMapper
;
import
com.example.fuzzControll.mapper.AflnetMapper
;
import
com.example.fuzzControll.pojo.vo.AflnetResult
;
import
com.example.fuzzControll.pojo.vo.AflnetResult
;
import
com.example.fuzzControll.pojo.vo.KittyResult
;
import
com.example.fuzzControll.service.AflnetPersistenceService
;
import
com.example.fuzzControll.service.AflnetPersistenceService
;
import
com.example.fuzzControll.tools.FileTools
;
import
com.example.fuzzControll.tools.FileTools
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
@Slf4j
@Slf4j
@Service
(
"AflnetPersistenceService"
)
@Service
(
"AflnetPersistenceService"
)
public
class
AflnetPersistenceServiceImpl
implements
AflnetPersistenceService
{
public
class
AflnetPersistenceServiceImpl
implements
AflnetPersistenceService
{
@Autowired
@Autowired
AflnetMapper
AflnetMapper
;
AflnetMapper
AflnetMapper
;
FileTools
fileTools
=
new
FileTools
();
FileTools
fileTools
=
new
FileTools
();
@Override
@Override
public
int
aflnetResultBackup
(
String
filename
)
{
public
int
aflnetResultBackup
(
String
filename
)
{
//todo 需要传入任务id
//todo 需要传入任务id
AflnetResult
result
=
new
AflnetResult
(
1
,
fileTools
.
fileReadAndBackup
(
filename
),
filename
);
AflnetResult
result
=
new
AflnetResult
(
1
,
fileTools
.
fileReadAndBackup
(
filename
),
filename
);
return
AflnetMapper
.
aflnetOutputBackup
(
result
);
return
AflnetMapper
.
aflnetOutputBackup
(
result
);
}
@Override
public
void
loadInFile
(
int
missionId
,
String
filePath
)
{
AflnetResult
aflnetResult
=
null
;
try
{
aflnetResult
=
AflnetMapper
.
selectResultById
(
missionId
);
}
catch
(
MysqlException
e
)
{
e
.
printStackTrace
();
throw
new
MysqlException
(
"AflnetMapper.selectResultById() Error!"
);
}
fileTools
.
loadFileInLocal
(
aflnetResult
,
filePath
);
}
}
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/FuzzPersistenceServiceImpl.java
→
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/
Kitty
FuzzPersistenceServiceImpl.java
View file @
918202f5
...
@@ -2,7 +2,8 @@ package com.example.fuzzControll.service.impl;
...
@@ -2,7 +2,8 @@ package com.example.fuzzControll.service.impl;
import
com.example.fuzzControll.mapper.KittyMapper
;
import
com.example.fuzzControll.mapper.KittyMapper
;
import
com.example.fuzzControll.pojo.vo.KittyResult
;
import
com.example.fuzzControll.pojo.vo.KittyResult
;
import
com.example.fuzzControll.service.FuzzPersistenceService
;
import
com.example.fuzzControll.service.AflnetPersistenceService
;
import
com.example.fuzzControll.service.KittyFuzzPersistenceService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -11,11 +12,15 @@ import java.util.List;
...
@@ -11,11 +12,15 @@ import java.util.List;
@Service
@Service
@Slf4j
@Slf4j
public
class
FuzzPersistenceServiceImpl
implements
FuzzPersistenceService
{
public
class
KittyFuzzPersistenceServiceImpl
implements
Kitty
FuzzPersistenceService
{
@Autowired
@Autowired
KittyMapper
kittyMapper
;
KittyMapper
kittyMapper
;
@Autowired
AflnetPersistenceService
aflnetPersistenceService
;
@Override
@Override
public
List
<
KittyResult
>
getKittyResults
()
{
public
List
<
KittyResult
>
getKittyResults
()
{
return
kittyMapper
.
getKittyResults
();
return
kittyMapper
.
getKittyResults
();
}
}
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/FileTools.java
View file @
918202f5
...
@@ -3,6 +3,7 @@ package com.example.fuzzControll.tools;
...
@@ -3,6 +3,7 @@ package com.example.fuzzControll.tools;
import
com.example.fuzzControll.conf.AflnetProperties
;
import
com.example.fuzzControll.conf.AflnetProperties
;
import
com.example.fuzzControll.conf.SpringContextUtil
;
import
com.example.fuzzControll.conf.SpringContextUtil
;
import
com.example.fuzzControll.exception.FileException
;
import
com.example.fuzzControll.exception.FileException
;
import
com.example.fuzzControll.pojo.vo.AflnetResult
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -32,6 +33,12 @@ public class FileTools {
...
@@ -32,6 +33,12 @@ public class FileTools {
}
}
/**
* 文件备份至数据库
*
* @param filename
* @return
*/
public
byte
[]
fileReadAndBackup
(
String
filename
)
{
public
byte
[]
fileReadAndBackup
(
String
filename
)
{
File
file
=
new
File
(
properties
.
getOutputPath
()
+
"/"
+
filename
);
File
file
=
new
File
(
properties
.
getOutputPath
()
+
"/"
+
filename
);
try
(
try
(
...
@@ -52,4 +59,25 @@ public class FileTools {
...
@@ -52,4 +59,25 @@ public class FileTools {
throw
new
RuntimeException
(
"File is to large "
+
file
.
getName
());
throw
new
RuntimeException
(
"File is to large "
+
file
.
getName
());
}
}
}
}
/**
* 读取数据库文件至本地
*/
public
void
loadFileInLocal
(
AflnetResult
aflnetResult
,
String
fileLoadPath
)
{
File
file
=
new
File
(
fileLoadPath
+
"/"
+
aflnetResult
.
getFileName
());
try
(
FileOutputStream
fileOutputStream
=
new
FileOutputStream
(
file
);
BufferedOutputStream
bufferedOutputStream
=
new
BufferedOutputStream
(
fileOutputStream
);
ByteArrayInputStream
byteArrayInputStream
=
new
ByteArrayInputStream
(
aflnetResult
.
getFile
());
BufferedInputStream
bufferedInputStream
=
new
BufferedInputStream
(
byteArrayInputStream
);)
{
byte
[]
buffer
=
new
byte
[
1024
];
int
bytesRead
;
while
((
bytesRead
=
bufferedInputStream
.
read
(
buffer
))
!=
-
1
)
{
bufferedOutputStream
.
write
(
buffer
,
0
,
bytesRead
);
}
}
catch
(
FileNotFoundException
e
)
{
throw
new
FileException
(
"Cannot find path:"
+
fileLoadPath
+
"! Maybe there is no permission for this file!"
);
}
catch
(
IOException
e
)
{
throw
new
FileException
(
"Load file failed!"
);
}
}
}
}
\ No newline at end of file
fuzzIntegration/src/main/resources/application-dev.yml
View file @
918202f5
...
@@ -31,7 +31,7 @@ kitty:
...
@@ -31,7 +31,7 @@ kitty:
vulnerabilityTypePath
:
"
/usr/fuzzenv/fuzzenv/fuzz50/kitty/2020test/"
#kitty下漏洞类型python路径
vulnerabilityTypePath
:
"
/usr/fuzzenv/fuzzenv/fuzz50/kitty/2020test/"
#kitty下漏洞类型python路径
mutationPath
:
"
/usr/fuzzenv/fuzzenv/fuzz50/kitty/2020test/"
mutationPath
:
"
/usr/fuzzenv/fuzzenv/fuzz50/kitty/2020test/"
templateInfoHttp
:
"
http://127.0.0.1:26001/api/template_info.json"
#模板信息请求链接
templateInfoHttp
:
"
http://127.0.0.1:26001/api/template_info.json"
#模板信息请求链接
statsHttp
:
"
http://127.0.0.1:26001
/api/stats.json
"
#运行时数据
statsHttp
:
"
http://127.0.0.1:26001"
#运行时数据
stagesHttp
:
"
http://127.0.0.1:26001/api/stages.json"
#
stagesHttp
:
"
http://127.0.0.1:26001/api/stages.json"
#
reportHttp
:
"
http://127.0.0.1:26001/api/report"
#
reportHttp
:
"
http://127.0.0.1:26001/api/report"
#
spring
:
spring
:
...
...
fuzzIntegration/src/main/resources/mapper/AflnetMapper.xml
View file @
918202f5
...
@@ -11,12 +11,15 @@
...
@@ -11,12 +11,15 @@
<result
property=
"fileName"
column=
"fileName"
/>
<result
property=
"fileName"
column=
"fileName"
/>
</resultMap>
</resultMap>
<sql
id=
"select
Kitty
Result"
>
<sql
id=
"select
Alfnet
Result"
>
select id, missionId,file, fileName from
kittyResult;
select id, missionId,file, fileName from
alfnetResult
</sql>
</sql>
<insert
id=
"aflnetOutputBackup"
>
<insert
id=
"aflnetOutputBackup"
>
insert into alfnetResult(id,missionId, file, fileName) values(#{id}, #{missionId},#{file}, #{fileName})
insert into alfnetResult(id,missionId, file, fileName) values(#{id}, #{missionId},#{file}, #{fileName})
</insert>
</insert>
<select
id=
"selectResultById"
resultMap=
"AflnetResult"
>
<include
refid=
"selectAlfnetResult"
/>
where missionId = #{missionId};
</select>
</mapper>
</mapper>
\ No newline at end of file
fuzzIntegration/src/main/resources/result.html
View file @
918202f5
This diff is collapsed.
Click to expand it.
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