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
4f11b8a8
Commit
4f11b8a8
authored
Apr 02, 2024
by
钱炳权
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
24/4/2 class of testOutput is ok
parent
91c7e11d
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
328 additions
and
124 deletions
+328
-124
pom.xml
fuzzbackend/pom.xml
+5
-0
kittyProperties.java
...n/java/com/example/fuzzControll/conf/kittyProperties.java
+37
-0
kittyServerMessageController.java
...fuzzControll/controller/kittyServerMessageController.java
+59
-0
mutationController.java
...m/example/fuzzControll/controller/mutationController.java
+24
-0
protocolTemplatController.java
...le/fuzzControll/controller/protocolTemplatController.java
+3
-5
testClassController.java
.../example/fuzzControll/controller/testClassController.java
+17
-7
vulnerabilityTypeController.java
.../fuzzControll/controller/vulnerabilityTypeController.java
+3
-6
protocolGenerationEntity.java
...xample/fuzzControll/pojo/vo/protocolGenerationEntity.java
+0
-15
testEntity.java
...ain/java/com/example/fuzzControll/pojo/vo/testEntity.java
+3
-3
vulnerabilityTypeEntity.java
...example/fuzzControll/pojo/vo/vulnerabilityTypeEntity.java
+0
-9
generateMethodService.java
...m/example/fuzzControll/service/generateMethodService.java
+3
-3
getServerMessageService.java
...example/fuzzControll/service/getServerMessageService.java
+14
-0
generateMethodServiceImpl.java
.../fuzzControll/service/impl/generateMethodServiceImpl.java
+15
-15
getServerMessageImpl.java
...ample/fuzzControll/service/impl/getServerMessageImpl.java
+88
-0
protocolTemplateImpl.java
...ample/fuzzControll/service/impl/protocolTemplateImpl.java
+16
-19
vulnerabilityTypeServiceImpl.java
...zzControll/service/impl/vulnerabilityTypeServiceImpl.java
+12
-11
protocolTemplateService.java
...example/fuzzControll/service/protocolTemplateService.java
+5
-4
vulnerabilityTypeService.java
...xample/fuzzControll/service/vulnerabilityTypeService.java
+5
-3
cmdTools.java
...rc/main/java/com/example/fuzzControll/tools/cmdTools.java
+13
-22
application-dev.yml
fuzzbackend/src/main/resources/application-dev.yml
+6
-2
No files found.
fuzzbackend/pom.xml
View file @
4f11b8a8
...
...
@@ -15,6 +15,11 @@
</properties>
<dependencies>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.5.13
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
...
...
fuzzbackend/src/main/java/com/example/fuzzControll/conf/kittyProperties.java
View file @
4f11b8a8
...
...
@@ -10,6 +10,43 @@ public class kittyProperties {
String
venvPath
;
String
methodPath
;
String
vulnerabilityTypePath
;
String
templateInfoHttp
;
String
statsHttp
;
String
stagesHttp
;
String
reportHttp
;
public
String
getTemplateInfoHttp
()
{
return
templateInfoHttp
;
}
public
void
setTemplateInfoHttp
(
String
templateInfoHttp
)
{
this
.
templateInfoHttp
=
templateInfoHttp
;
}
public
String
getStatsHttp
()
{
return
statsHttp
;
}
public
void
setStatsHttp
(
String
statsHttp
)
{
this
.
statsHttp
=
statsHttp
;
}
public
String
getStagesHttp
()
{
return
stagesHttp
;
}
public
void
setStagesHttp
(
String
stagesHttp
)
{
this
.
stagesHttp
=
stagesHttp
;
}
public
String
getReportHttp
()
{
return
reportHttp
;
}
public
void
setReportHttp
(
String
reportHttp
)
{
this
.
reportHttp
=
reportHttp
;
}
public
String
getPath
()
{
return
path
;
}
...
...
fuzzbackend/src/main/java/com/example/fuzzControll/controller/kittyServerMessageController.java
0 → 100644
View file @
4f11b8a8
package
com
.
example
.
fuzzControll
.
controller
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.service.getServerMessageService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/kittyServer"
)
public
class
kittyServerMessageController
{
@Autowired
getServerMessageService
getServerMessageService
;
/**
* 获取服务器stats信息
*/
@RequestMapping
(
value
=
"/stats"
,
method
=
RequestMethod
.
GET
)
public
AjaxResult
getStats
(
)
{
try
{
return
AjaxResult
.
success
(
getServerMessageService
.
getStats
());
}
catch
(
Exception
e
)
{
return
AjaxResult
.
error
(
"stats信息获取失败!"
);
}
}
/**
* 获取服务器templateInfo信息
*/
@RequestMapping
(
value
=
"/templateInfo"
,
method
=
RequestMethod
.
GET
)
public
AjaxResult
getTemplateInfo
(
)
{
try
{
return
AjaxResult
.
success
(
getServerMessageService
.
getTemplateInfo
());
}
catch
(
Exception
e
)
{
return
AjaxResult
.
error
(
"templateInfo信息获取失败!"
);
}
}
/**
* 获取服务器stages信息
*/
@RequestMapping
(
value
=
"/stages"
,
method
=
RequestMethod
.
GET
)
public
AjaxResult
getStages
(
)
{
try
{
return
AjaxResult
.
success
(
getServerMessageService
.
getStages
());
}
catch
(
Exception
e
)
{
return
AjaxResult
.
error
(
"stats信息获取失败!"
);
}
}
/**
* 获取服务器report信息
*/
@RequestMapping
(
value
=
"/report"
,
method
=
RequestMethod
.
GET
)
public
AjaxResult
getReport
(
)
{
try
{
return
AjaxResult
.
success
(
getServerMessageService
.
getReport
());
}
catch
(
Exception
e
)
{
return
AjaxResult
.
error
(
"stats信息获取失败!"
);
}
}
}
fuzzbackend/src/main/java/com/example/fuzzControll/controller/mutationController.java
0 → 100644
View file @
4f11b8a8
package
com
.
example
.
fuzzControll
.
controller
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.service.getServerMessageService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/mutation"
)
public
class
mutationController
{
@Autowired
getServerMessageService
getServerMessageService
;
@RequestMapping
(
value
=
"/mutation"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
getStats
()
{
try
{
return
AjaxResult
.
success
(
getServerMessageService
.
getStats
());
}
catch
(
Exception
e
)
{
return
AjaxResult
.
error
(
"mutationTest失败!"
);
}
}
}
fuzzbackend/src/main/java/com/example/fuzzControll/controller/protocolTemplatController.java
View file @
4f11b8a8
package
com
.
example
.
fuzzControll
.
controller
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.pojo.vo.
protocolGeneration
Entity
;
import
com.example.fuzzControll.pojo.vo.
test
Entity
;
import
com.example.fuzzControll.service.protocolTemplateService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
@RestController
@RequestMapping
(
"/protocolTemplate"
)
...
...
@@ -20,12 +19,11 @@ public class protocolTemplatController {
* seeFileUpload
*/
@RequestMapping
(
value
=
"/generation"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
upload
(
@RequestBody
protocolGenerationEntity
protocolGeneration
)
{
public
AjaxResult
upload
(
@RequestBody
testEntity
testEntity
)
{
try
{
protocolTemplateService
.
generation
(
protocolGeneration
);
return
AjaxResult
.
success
(
protocolTemplateService
.
generation
(
testEntity
)
);
}
catch
(
Exception
e
)
{
return
AjaxResult
.
error
(
"模板文件生成失败!"
);
}
return
AjaxResult
.
success
(
"模板文件生成成功!"
);
}
}
fuzzbackend/src/main/java/com/example/fuzzControll/controller/
generateMethod
Controller.java
→
fuzzbackend/src/main/java/com/example/fuzzControll/controller/
testClass
Controller.java
View file @
4f11b8a8
package
com
.
example
.
fuzzControll
.
controller
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.pojo.vo.generateMethodEntity
;
import
com.example.fuzzControll.pojo.vo.protocolGenerationEntity
;
import
com.example.fuzzControll.pojo.vo.testEntity
;
import
com.example.fuzzControll.service.generateMethodService
;
import
com.example.fuzzControll.service.getServerMessageService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -11,18 +11,28 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/generateMethod"
)
public
class
generateMethodController
{
@RequestMapping
(
"/testClass"
)
public
class
testClassController
{
@Autowired
generateMethodService
service
;
@Autowired
getServerMessageService
getServerMessageService
;
@RequestMapping
(
value
=
"/generate"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
upload
(
@RequestBody
generateMethodEntity
generateMethod
Entity
)
{
public
AjaxResult
upload
(
@RequestBody
testEntity
test
Entity
)
{
try
{
return
AjaxResult
.
success
(
service
.
generation
(
generateMethod
Entity
));
return
AjaxResult
.
success
(
service
.
generation
(
test
Entity
));
}
catch
(
Exception
e
)
{
return
AjaxResult
.
error
(
"变异方法使用失败!"
);
}
}
@RequestMapping
(
value
=
"/mutation"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
getStats
()
{
try
{
return
AjaxResult
.
success
(
getServerMessageService
.
getStats
());
}
catch
(
Exception
e
)
{
return
AjaxResult
.
error
(
"mutationTest失败!"
);
}
}
}
fuzzbackend/src/main/java/com/example/fuzzControll/controller/vulnerabilityTypeController.java
View file @
4f11b8a8
package
com
.
example
.
fuzzControll
.
controller
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.pojo.vo.generateMethodEntity
;
import
com.example.fuzzControll.pojo.vo.vulnerabilityTypeEntity
;
import
com.example.fuzzControll.service.testService
;
import
com.example.fuzzControll.pojo.vo.testEntity
;
import
com.example.fuzzControll.service.vulnerabilityTypeService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -18,12 +16,11 @@ public class vulnerabilityTypeController {
vulnerabilityTypeService
service
;
@RequestMapping
(
value
=
"/generate"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
upload
(
@RequestBody
vulnerabilityTypeEntity
vulnerabilityType
Entity
)
{
public
AjaxResult
upload
(
@RequestBody
testEntity
test
Entity
)
{
try
{
service
.
generation
(
vulnerabilityTypeEntity
);
return
AjaxResult
.
success
(
service
.
generation
(
testEntity
)
);
}
catch
(
Exception
e
)
{
return
AjaxResult
.
error
(
"漏洞类型测试失败!"
);
}
return
AjaxResult
.
success
(
"漏洞类型测试成功!"
);
}
}
fuzzbackend/src/main/java/com/example/fuzzControll/pojo/vo/protocolGenerationEntity.java
deleted
100644 → 0
View file @
91c7e11d
package
com
.
example
.
fuzzControll
.
pojo
.
vo
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Setter
;
@Data
@Getter
@Setter
public
class
protocolGenerationEntity
{
String
protocolName
;
String
[]
paramJson
;
}
fuzzbackend/src/main/java/com/example/fuzzControll/pojo/vo/
generateMethod
Entity.java
→
fuzzbackend/src/main/java/com/example/fuzzControll/pojo/vo/
test
Entity.java
View file @
4f11b8a8
...
...
@@ -5,9 +5,9 @@ import lombok.Getter;
import
lombok.Setter
;
@Data
@Setter
@Getter
public
class
generateMethodEntity
{
String
methodName
;
@Setter
public
class
testEntity
{
String
testClassName
;
String
[]
paramJson
;
}
fuzzbackend/src/main/java/com/example/fuzzControll/pojo/vo/vulnerabilityTypeEntity.java
deleted
100644 → 0
View file @
91c7e11d
package
com
.
example
.
fuzzControll
.
pojo
.
vo
;
import
lombok.Data
;
@Data
public
class
vulnerabilityTypeEntity
{
String
vulnerabilityTypeName
;
String
[]
paramJson
;
}
fuzzbackend/src/main/java/com/example/fuzzControll/service/generateMethodService.java
View file @
4f11b8a8
package
com
.
example
.
fuzzControll
.
service
;
import
com.example.fuzzControll.pojo.vo.generateMethodEntity
;
import
com.example.fuzzControll.pojo.vo.protocolGenerationEntity
;
import
com.example.fuzzControll.pojo.vo.testEntity
;
import
java.util.List
;
import
java.util.Map
;
public
interface
generateMethodService
{
List
<
String
>
generation
(
generateMethodEntity
generateMethod
Entity
);
Map
<
String
,
List
<
String
>>
generation
(
testEntity
test
Entity
);
}
fuzzbackend/src/main/java/com/example/fuzzControll/service/getServerMessageService.java
0 → 100644
View file @
4f11b8a8
package
com
.
example
.
fuzzControll
.
service
;
import
java.util.List
;
import
java.util.Map
;
public
interface
getServerMessageService
{
String
getStats
();
String
getTemplateInfo
();
String
getStages
();
String
getReport
();
}
fuzzbackend/src/main/java/com/example/fuzzControll/service/impl/generateMethodServiceImpl.java
View file @
4f11b8a8
package
com
.
example
.
fuzzControll
.
service
.
impl
;
import
com.example.fuzzControll.conf.kittyProperties
;
import
com.example.fuzzControll.pojo.vo.generateMethodEntity
;
import
com.example.fuzzControll.pojo.vo.protocolGenerationEntity
;
import
com.example.fuzzControll.pojo.vo.testEntity
;
import
com.example.fuzzControll.service.generateMethodService
;
import
com.example.fuzzControll.tools.cmdTools
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -10,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Map
;
@Service
@Slf4j
...
...
@@ -19,33 +19,33 @@ public class generateMethodServiceImpl implements generateMethodService {
kittyProperties
kitty
;
@Override
public
List
<
String
>
generation
(
generateMethodEntity
generateMethod
Entity
)
{
String
cmd
=
parseParameters
(
generateMethod
Entity
);
return
cmdTools
.
runProgramCmdAndResult
Tofile
(
cmd
);
public
Map
<
String
,
List
<
String
>>
generation
(
testEntity
test
Entity
)
{
String
cmd
=
parseParameters
(
test
Entity
);
return
cmdTools
.
runProgramCmdAndResult
(
cmd
);
}
public
String
parseParameters
(
generateMethodEntity
generateMethod
Entity
)
{
switch
(
generateMethodEntity
.
getMethod
Name
().
toLowerCase
())
{
public
String
parseParameters
(
testEntity
test
Entity
)
{
switch
(
testEntity
.
getTestClass
Name
().
toLowerCase
())
{
case
"foreach"
:
return
foreachCmd
(
generateMethod
Entity
);
return
foreachCmd
(
test
Entity
);
default
:
log
.
error
(
"未知变异方法![{}]"
,
generateMethodEntity
.
getMethod
Name
());
log
.
error
(
"未知变异方法![{}]"
,
testEntity
.
getTestClass
Name
());
return
null
;
}
}
private
String
foreachCmd
(
generateMethodEntity
generateMethod
Entity
)
{
private
String
foreachCmd
(
testEntity
test
Entity
)
{
String
target_host
=
null
;
String
target_port
=
null
;
String
s1
=
null
;
String
s2
=
null
;
String
s3
=
null
;
try
{
target_host
=
generateMethod
Entity
.
getParamJson
()[
0
];
target_port
=
generateMethod
Entity
.
getParamJson
()[
1
];
s1
=
generateMethod
Entity
.
getParamJson
()[
2
];
s2
=
generateMethod
Entity
.
getParamJson
()[
3
];
s3
=
generateMethod
Entity
.
getParamJson
()[
4
];
target_host
=
test
Entity
.
getParamJson
()[
0
];
target_port
=
test
Entity
.
getParamJson
()[
1
];
s1
=
test
Entity
.
getParamJson
()[
2
];
s2
=
test
Entity
.
getParamJson
()[
3
];
s3
=
test
Entity
.
getParamJson
()[
4
];
}
catch
(
Exception
e
)
{
log
.
error
(
"http_dos_qemu参数解析失败!"
);
}
...
...
fuzzbackend/src/main/java/com/example/fuzzControll/service/impl/getServerMessageImpl.java
0 → 100644
View file @
4f11b8a8
package
com
.
example
.
fuzzControll
.
service
.
impl
;
import
com.example.fuzzControll.conf.kittyProperties
;
import
com.example.fuzzControll.service.getServerMessageService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.HttpStatus
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
@Service
(
"getServerMessageService"
)
public
class
getServerMessageImpl
implements
getServerMessageService
{
@Autowired
kittyProperties
kitty
;
public
String
getServerMsg
(
String
messageName
)
{
switch
(
messageName
)
{
case
"templateInfo"
:
{
HttpGet
httpGetTemplateInfo
=
new
HttpGet
(
kitty
.
getTemplateInfoHttp
());
try
(
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpResponse
templateInfoResponse
=
httpClient
.
execute
(
httpGetTemplateInfo
);)
{
return
EntityUtils
.
toString
(
templateInfoResponse
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"templateInfo http error!"
);
}
}
case
"stats"
:
{
HttpGet
httpGetStats
=
new
HttpGet
(
kitty
.
getStatsHttp
());
try
(
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpResponse
statsResponse
=
httpClient
.
execute
(
httpGetStats
);)
{
return
EntityUtils
.
toString
(
statsResponse
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"stats http error!"
);
}
}
case
"report"
:
{
HttpGet
httpGetStats
=
new
HttpGet
(
kitty
.
getReportHttp
());
try
(
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpResponse
reportResponse
=
httpClient
.
execute
(
httpGetStats
);)
{
return
EntityUtils
.
toString
(
reportResponse
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"report http error!"
);
}
}
case
"stages"
:
{
HttpGet
httpGetStats
=
new
HttpGet
(
kitty
.
getStagesHttp
());
try
(
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpResponse
stagesResponse
=
httpClient
.
execute
(
httpGetStats
);)
{
return
EntityUtils
.
toString
(
stagesResponse
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"stages http error!"
);
}
}
default
:
return
""
;
}
}
@Override
public
String
getStats
()
{
return
getServerMsg
(
"stats"
);
}
@Override
public
String
getTemplateInfo
()
{
return
getServerMsg
(
"templateInfo"
);
}
@Override
public
String
getStages
()
{
return
getServerMsg
(
"report"
);
}
@Override
public
String
getReport
()
{
return
getServerMsg
(
"stages"
);
}
}
fuzzbackend/src/main/java/com/example/fuzzControll/service/impl/protocolTemplateImpl.java
View file @
4f11b8a8
package
com
.
example
.
fuzzControll
.
service
.
impl
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.example.fuzzControll.conf.kittyProperties
;
import
com.example.fuzzControll.conf.seedProperties
;
import
com.example.fuzzControll.constents.protocolConstent
;
import
com.example.fuzzControll.pojo.vo.
protocolGeneration
Entity
;
import
com.example.fuzzControll.pojo.vo.
test
Entity
;
import
com.example.fuzzControll.service.protocolTemplateService
;
import
com.example.fuzzControll.tools.cmdTools
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
@Service
...
...
@@ -24,13 +21,13 @@ public class protocolTemplateImpl implements protocolTemplateService {
kittyProperties
kitty
;
@Override
public
void
generation
(
protocolGenerationEntity
protocolGeneration
)
{
String
cmd
=
parseParameters
(
protocolGeneration
);
cmdTools
.
runProgramCmdAndResultTofile
(
cmd
);
public
Map
<
String
,
List
<
String
>>
generation
(
testEntity
testEntity
)
{
String
cmd
=
parseParameters
(
testEntity
);
return
cmdTools
.
runProgramCmdAndResult
(
cmd
);
}
public
String
parseParameters
(
protocolGeneration
Entity
protocolGeneration
)
{
switch
(
protocolGeneration
.
get
Protocol
Name
().
toLowerCase
())
{
public
String
parseParameters
(
test
Entity
protocolGeneration
)
{
switch
(
protocolGeneration
.
get
TestClass
Name
().
toLowerCase
())
{
case
"arp"
:
return
arpCmd
(
protocolGeneration
);
case
"bgp"
:
...
...
@@ -48,12 +45,12 @@ public class protocolTemplateImpl implements protocolTemplateService {
case
"http_dos_qemu"
:
return
http_dos_qemuCmd
(
protocolGeneration
);
default
:
log
.
error
(
"未知协议![{}]"
,
protocolGeneration
.
get
Protocol
Name
());
log
.
error
(
"未知协议![{}]"
,
protocolGeneration
.
get
TestClass
Name
());
return
null
;
}
}
private
String
http_dos_qemuCmd
(
protocolGeneration
Entity
protocolGeneration
)
{
private
String
http_dos_qemuCmd
(
test
Entity
protocolGeneration
)
{
String
dst_ip
=
null
;
String
port
=
null
;
try
{
...
...
@@ -65,11 +62,11 @@ public class protocolTemplateImpl implements protocolTemplateService {
return
kitty
.
getVenvPath
()
+
" "
+
kitty
.
getPath
()
+
protocolConstent
.
HTTP_DOS_QUMU
+
" -d "
+
dst_ip
+
" -p "
+
port
;
}
private
String
hdlcCmd
(
protocolGeneration
Entity
protocolGeneration
)
{
private
String
hdlcCmd
(
test
Entity
protocolGeneration
)
{
return
kitty
.
getVenvPath
()
+
" "
+
kitty
.
getPath
()
+
protocolConstent
.
HDLC
;
}
private
String
ftpCmd
(
protocolGeneration
Entity
protocolGeneration
)
{
private
String
ftpCmd
(
test
Entity
protocolGeneration
)
{
String
target_host
=
null
;
String
target_port
=
null
;
try
{
...
...
@@ -81,7 +78,7 @@ public class protocolTemplateImpl implements protocolTemplateService {
return
kitty
.
getVenvPath
()
+
" "
+
kitty
.
getPath
()
+
protocolConstent
.
FTP
+
target_host
+
" "
+
target_port
;
}
private
String
frpCmd
(
protocolGeneration
Entity
protocolGeneration
)
{
private
String
frpCmd
(
test
Entity
protocolGeneration
)
{
String
target_host
=
null
;
String
target_port
=
null
;
try
{
...
...
@@ -93,7 +90,7 @@ public class protocolTemplateImpl implements protocolTemplateService {
return
kitty
.
getVenvPath
()
+
" "
+
kitty
.
getPath
()
+
protocolConstent
.
FRP
+
target_host
+
" "
+
target_port
;
}
private
String
dnsCmd
(
protocolGeneration
Entity
protocolGeneration
)
{
private
String
dnsCmd
(
test
Entity
protocolGeneration
)
{
String
dst_ip
=
null
;
String
dst_port
=
null
;
try
{
...
...
@@ -105,7 +102,7 @@ public class protocolTemplateImpl implements protocolTemplateService {
return
kitty
.
getVenvPath
()
+
" "
+
kitty
.
getPath
()
+
protocolConstent
.
DNS
+
dst_ip
+
" "
+
dst_port
;
}
private
String
dhcpCmd
(
protocolGeneration
Entity
protocolGeneration
)
{
private
String
dhcpCmd
(
test
Entity
protocolGeneration
)
{
String
dst_ip
=
null
;
String
dst_port
=
null
;
try
{
...
...
@@ -117,7 +114,7 @@ public class protocolTemplateImpl implements protocolTemplateService {
return
kitty
.
getVenvPath
()
+
" "
+
kitty
.
getPath
()
+
protocolConstent
.
DHCP
+
dst_ip
+
" "
+
dst_port
;
}
private
String
bgpCmd
(
protocolGeneration
Entity
protocolGeneration
)
{
private
String
bgpCmd
(
test
Entity
protocolGeneration
)
{
String
src_ip
=
null
;
String
src_port
=
null
;
String
dst_ip
=
null
;
...
...
@@ -133,7 +130,7 @@ public class protocolTemplateImpl implements protocolTemplateService {
return
kitty
.
getVenvPath
()
+
" "
+
kitty
.
getPath
()
+
protocolConstent
.
BGP
+
src_ip
+
" "
+
src_port
+
" "
+
dst_ip
+
" "
+
dst_port
;
}
public
String
arpCmd
(
protocolGeneration
Entity
protocolGeneration
)
{
public
String
arpCmd
(
test
Entity
protocolGeneration
)
{
String
dst_mac
=
null
;
String
src_mac
=
null
;
try
{
...
...
fuzzbackend/src/main/java/com/example/fuzzControll/service/impl/vulnerabilityTypeServiceImpl.java
View file @
4f11b8a8
package
com
.
example
.
fuzzControll
.
service
.
impl
;
import
com.example.fuzzControll.conf.kittyProperties
;
import
com.example.fuzzControll.constents.protocolConstent
;
import
com.example.fuzzControll.constents.vulnerabilityTypeConstent
;
import
com.example.fuzzControll.pojo.vo.protocolGenerationEntity
;
import
com.example.fuzzControll.pojo.vo.vulnerabilityTypeEntity
;
import
com.example.fuzzControll.pojo.vo.testEntity
;
import
com.example.fuzzControll.service.vulnerabilityTypeService
;
import
com.example.fuzzControll.tools.cmdTools
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
@Service
(
"vulnerabilityTypeService"
)
public
class
vulnerabilityTypeServiceImpl
implements
vulnerabilityTypeService
{
...
...
@@ -19,22 +20,22 @@ public class vulnerabilityTypeServiceImpl implements vulnerabilityTypeService {
kittyProperties
kitty
;
@Override
public
void
generation
(
vulnerabilityTypeEntity
vulnerabilityType
Entity
)
{
String
cmd
=
parseParameters
(
vulnerabilityType
Entity
);
cmdTools
.
runProgramCmdAndResultTofile
(
cmd
);
public
Map
<
String
,
List
<
String
>>
generation
(
testEntity
test
Entity
)
{
String
cmd
=
parseParameters
(
test
Entity
);
return
cmdTools
.
runProgramCmdAndResult
(
cmd
);
}
public
String
parseParameters
(
vulnerabilityTypeEntity
vulnerabilityType
Entity
)
{
switch
(
vulnerabilityTypeEntity
.
getVulnerabilityType
Name
().
toLowerCase
())
{
public
String
parseParameters
(
testEntity
test
Entity
)
{
switch
(
testEntity
.
getTestClass
Name
().
toLowerCase
())
{
case
"array_index_out_of_bounds_vulnerabilit"
:
return
arrayIndexOutOfBoundsVulnerabilitCmd
(
vulnerabilityType
Entity
);
return
arrayIndexOutOfBoundsVulnerabilitCmd
(
test
Entity
);
default
:
log
.
error
(
"未知漏洞![{}]"
,
vulnerabilityTypeEntity
.
getVulnerabilityType
Name
());
log
.
error
(
"未知漏洞![{}]"
,
testEntity
.
getTestClass
Name
());
return
null
;
}
}
private
String
arrayIndexOutOfBoundsVulnerabilitCmd
(
vulnerabilityTypeEntity
vulnerabilityType
Entity
)
{
private
String
arrayIndexOutOfBoundsVulnerabilitCmd
(
testEntity
test
Entity
)
{
return
kitty
.
getVenvPath
()
+
" "
+
kitty
.
getVulnerabilityTypePath
()
+
"vul_types_test.py "
+
vulnerabilityTypeConstent
.
ARRAY_INDEX_OUT_OF_BOUNDS_VULNERABILIT
;
}
//todo 还有很多类型要写
...
...
fuzzbackend/src/main/java/com/example/fuzzControll/service/protocolTemplateService.java
View file @
4f11b8a8
package
com
.
example
.
fuzzControll
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
com.example.fuzzControll.pojo.vo.protocolGenerationEntity
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.example.fuzzControll.pojo.vo.testEntity
;
import
java.util.List
;
import
java.util.Map
;
public
interface
protocolTemplateService
{
void
generation
(
protocolGenerationEntity
protocolGeneration
);
Map
<
String
,
List
<
String
>>
generation
(
testEntity
testEntity
);
}
fuzzbackend/src/main/java/com/example/fuzzControll/service/vulnerabilityTypeService.java
View file @
4f11b8a8
package
com
.
example
.
fuzzControll
.
service
;
import
com.example.fuzzControll.pojo.vo.protocolGenerationEntity
;
import
com.example.fuzzControll.pojo.vo.vulnerabilityTypeEntity
;
import
com.example.fuzzControll.pojo.vo.testEntity
;
import
java.util.List
;
import
java.util.Map
;
public
interface
vulnerabilityTypeService
{
void
generation
(
vulnerabilityTypeEntity
vulnerabilityType
Entity
);
Map
<
String
,
List
<
String
>>
generation
(
testEntity
test
Entity
);
}
fuzzbackend/src/main/java/com/example/fuzzControll/tools/cmdTools.java
View file @
4f11b8a8
...
...
@@ -8,8 +8,8 @@ import com.example.fuzzControll.pojo.vo.testReturnEntity;
import
java.io.*
;
import
java.util.
ArrayList
;
import
java.util.List
;
import
java.util.
*
;
//todo need modify
public
class
cmdTools
{
...
...
@@ -54,20 +54,24 @@ public class cmdTools {
* 运行需要后台运行cmd
* 将数据存入文件中
*/
public
List
<
String
>
runProgramCmdAndResultTofile
(
String
cmd
)
{
List
<
String
>
result
=
new
ArrayList
<>();
public
Map
<
String
,
List
<
String
>>
runProgramCmdAndResult
(
String
cmd
)
{
Map
<
String
,
List
<
String
>>
result
=
new
HashMap
();
List
<
String
>
out
=
Collections
.
synchronizedList
(
new
ArrayList
<>());
List
<
String
>
error
=
Collections
.
synchronizedList
(
new
ArrayList
<>());
try
{
Process
process
=
Runtime
.
getRuntime
().
exec
(
cmd
);
printMessage
ToFile
(
process
.
getInputStream
(),
resul
t
);
printMessage
ToFile
(
process
.
getErrorStream
(),
new
ArrayList
<
String
>()
);
printMessage
ByProgramCmd
(
process
.
getInputStream
(),
ou
t
);
printMessage
ByProgramCmd
(
process
.
getErrorStream
(),
error
);
process
.
waitFor
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
result
.
put
(
"out"
,
out
);
result
.
put
(
"error"
,
error
);
return
result
;
}
private
List
<
String
>
printMessage
ToFile
(
InputStream
input
,
List
<
String
>
result
)
{
private
List
<
String
>
printMessage
ByProgramCmd
(
InputStream
input
,
List
<
String
>
result
)
throws
InterruptedException
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -108,21 +112,6 @@ public class cmdTools {
}
private
void
printMessageToWeb
(
final
InputStream
input
,
Process
process
)
throws
IOException
{
// try (FileOutputStream outputStream = new FileOutputStream("/home/qbq/1.text");
// BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);) {
//
// byte[] buffer = new byte[1024];
// int bytesRead;
// while ((bytesRead = input.read(buffer)) != -1) {
// bufferedOutputStream.write(buffer, 0, bytesRead);
// }
// if (testControlTools.getIsRunning()) {
// process.destroy();
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
Reader
reader
=
new
InputStreamReader
(
input
);
BufferedReader
bf
=
new
BufferedReader
(
reader
);
String
line
=
null
;
...
...
@@ -265,4 +254,5 @@ public class cmdTools {
}
return
cmd
.
toString
();
}
}
\ No newline at end of file
fuzzbackend/src/main/resources/application-dev.yml
View file @
4f11b8a8
...
...
@@ -20,4 +20,8 @@ kitty:
path
:
"
/home/qbq/fuzz50/kitty/renix/"
#kitty项目下的各协议生成模板python文件路径
venvPath
:
"
/home/qbq/fuzz50/kitty/venv/bin/python"
methodPath
:
"
/home/qbq/fuzz50/kitty/2020test/"
#kitty下变异方法路径
vulnerabilityTypePath
:
"
/home/qbq/fuzz50/kitty/2020test/"
#kitty下漏洞类型python路径
\ No newline at end of file
vulnerabilityTypePath
:
"
/home/qbq/fuzz50/kitty/2020test/"
#kitty下漏洞类型python路径
templateInfoHttp
:
"
http://127.0.0.1:26001/api/template_info.json"
#模板信息请求链接
statsHttp
:
"
http://127.0.0.1:26001/api/stats.json"
#运行时数据
stagesHttp
:
"
http://127.0.0.1:26001/api/stages.json"
#
reportHttp
:
"
http://127.0.0.1:26001/api/report"
#
\ 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