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
2b6461e2
Commit
2b6461e2
authored
Jun 13, 2024
by
钱炳权
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ssh至服务器并成功调用服务
parent
336793c0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
119 additions
and
49 deletions
+119
-49
AlgorithmOneCmd.java
...a/com/example/fuzzControll/constents/AlgorithmOneCmd.java
+7
-0
AlfnetController.java
...com/example/fuzzControll/controller/AlfnetController.java
+28
-8
AlgorithmOneCmdParams.java
...m/example/fuzzControll/pojo/vo/AlgorithmOneCmdParams.java
+41
-0
AlgorithmTwoCmdParams.java
...m/example/fuzzControll/pojo/vo/AlgorithmTwoCmdParams.java
+1
-1
TestService.java
...in/java/com/example/fuzzControll/service/TestService.java
+3
-5
TestServiceImpl.java
...om/example/fuzzControll/service/impl/TestServiceImpl.java
+0
-0
CmdTools.java
...rc/main/java/com/example/fuzzControll/tools/CmdTools.java
+20
-23
LinuxCommandUtil.java
...java/com/example/fuzzControll/tools/LinuxCommandUtil.java
+9
-8
application-dev.yml
fuzzIntegration/src/main/resources/application-dev.yml
+10
-4
No files found.
fuzzIntegration/src/main/java/com/example/fuzzControll/constents/AlgorithmOneCmd.java
0 → 100644
View file @
2b6461e2
package
com
.
example
.
fuzzControll
.
constents
;
public
class
AlgorithmOneCmd
{
public
static
final
String
ALFNET_PATH
=
"/home/lddc/SHENYANLONG/SMGfuzz/afl-fuzz "
;
//aflnet服务启动路径
public
static
final
String
ALFNET_INPUT_PATH
=
" -i /home/lddc/SHENYANLONG"
;
//aflnet种子根路径
public
static
final
String
ALFNET_OUTPUT_PATH
=
" -o /home/lddc/SHENYANLONG"
;
//aflnet种子根路径
}
fuzzIntegration/src/main/java/com/example/fuzzControll/controller/AlfnetController.java
View file @
2b6461e2
...
...
@@ -4,9 +4,8 @@ import com.example.fuzzControll.exception.AflnetException;
import
com.example.fuzzControll.exception.BaseException
;
import
com.example.fuzzControll.exception.CmdException
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.pojo.vo.
CmdStart
Params
;
import
com.example.fuzzControll.pojo.vo.
AlgorithmOneCmd
Params
;
import
com.example.fuzzControll.service.TestService
;
import
com.example.fuzzControll.tools.GlobalParameters
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -25,17 +24,16 @@ public class AlfnetController {
TestService
service
;
/**
*
测试启动
*
算法1 有参数型
*/
@RequestMapping
(
value
=
"/testStart"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
start
(
@RequestBody
final
CmdStartParams
cmdStartParams
)
{
System
.
out
.
println
(
cmdStartParams
);
//todo 捕获子线程错误
@RequestMapping
(
value
=
"/algorithmOneStart"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
algorithmOneStart
(
@RequestBody
final
AlgorithmOneCmdParams
algorithmOneCmdParams
)
{
System
.
out
.
println
(
algorithmOneCmdParams
);
try
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
service
.
testStart
(
cmdStart
Params
);
service
.
algorithmOneStart
(
algorithmOneCmd
Params
);
}
}).
start
();
}
catch
(
Exception
e
)
{
...
...
@@ -48,6 +46,28 @@ public class AlfnetController {
}
/**
* 算法2 无参数型
*/
@RequestMapping
(
value
=
"/algorithmTwoStart"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
algorithmTwoStart
(
@RequestBody
final
AlgorithmOneCmdParams
algorithmOneCmdParams
)
{
System
.
out
.
println
(
algorithmOneCmdParams
);
//todo 捕获子线程错误
try
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
service
.
algorithmTwoStart
(
algorithmOneCmdParams
);
}
}).
start
();
}
catch
(
Exception
e
)
{
if
(
e
instanceof
AflnetException
||
e
instanceof
CmdException
)
{
log
.
error
(((
BaseException
)
e
).
getDefaultMessage
());
}
return
AjaxResult
.
error
(
"测试启动失败!"
);
}
return
AjaxResult
.
success
(
"测试已启动!"
);
}
/**
* 测试停止
*/
@RequestMapping
(
value
=
"/testStop"
,
method
=
RequestMethod
.
GET
)
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/pojo/vo/AlgorithmOneCmdParams.java
0 → 100644
View file @
2b6461e2
package
com
.
example
.
fuzzControll
.
pojo
.
vo
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Setter
;
@Data
@Getter
@Setter
public
class
AlgorithmOneCmdParams
{
String
netinfo
;
//netInfo
String
protopcol
;
//protocol
int
waiting
;
//usec
String
nsname
;
//netnsname
Boolean
kill
;
Boolean
awareMode
;
Boolean
regionMutationOperators
;
Boolean
falseNegativeMode
;
String
script
;
//script
int
stateSelectionAlgo
;
int
seedSelectionAlgo
;
String
trainedModelInputPath
;
@Override
public
String
toString
()
{
return
"AlgorithmTwoCmdParams{"
+
"netinfo='"
+
netinfo
+
'\''
+
", protopcol='"
+
protopcol
+
'\''
+
", waiting="
+
waiting
+
", nsname='"
+
nsname
+
'\''
+
", kill="
+
kill
+
", awareMode="
+
awareMode
+
", regionMutationOperators="
+
regionMutationOperators
+
", falseNegativeMode="
+
falseNegativeMode
+
", script='"
+
script
+
'\''
+
", stateSelectionAlgo="
+
stateSelectionAlgo
+
", seedSelectionAlgo="
+
seedSelectionAlgo
+
", trainedModelInputPath='"
+
trainedModelInputPath
+
'\''
+
'}'
;
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/pojo/vo/
CmdStart
Params.java
→
fuzzIntegration/src/main/java/com/example/fuzzControll/pojo/vo/
AlgorithmTwoCmd
Params.java
View file @
2b6461e2
...
...
@@ -7,7 +7,7 @@ import lombok.Setter;
@Data
@Getter
@Setter
public
class
CmdStart
Params
{
public
class
AlgorithmTwoCmd
Params
{
String
netinfo
;
//netInfo
String
protopcol
;
//protocol
int
waiting
;
//usec
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/service/TestService.java
View file @
2b6461e2
package
com
.
example
.
fuzzControll
.
service
;
import
com.example.fuzzControll.pojo.vo.CmdStartParams
;
import
java.util.concurrent.CountDownLatch
;
import
com.example.fuzzControll.pojo.vo.AlgorithmOneCmdParams
;
public
interface
TestService
{
void
testStart
(
CmdStartParams
cmdStart
Params
);
void
algorithmOneStart
(
AlgorithmOneCmdParams
algorithmOneCmd
Params
);
void
algorithmTwoStart
(
AlgorithmOneCmdParams
algorithmOneCmdParams
);
void
testStop
();
}
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/TestServiceImpl.java
View file @
2b6461e2
This diff is collapsed.
Click to expand it.
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/CmdTools.java
View file @
2b6461e2
package
com
.
example
.
fuzzControll
.
tools
;
import
com.alibaba.fastjson.JSONObject
;
import
com.example.fuzzControll.conf.AflnetSshProperties
;
import
com.example.fuzzControll.exception.AflnetException
;
import
com.example.fuzzControll.exception.CmdException
;
import
com.example.fuzzControll.pojo.vo.*
;
import
com.jcraft.jsch.JSchException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
//todo need modify
...
...
@@ -88,46 +85,46 @@ public class CmdTools {
}
public
String
parse
(
CmdStartParams
cmdStart
Params
)
throws
AflnetException
{
if
(
cmdStart
Params
==
null
)
{
public
String
parse
(
AlgorithmOneCmdParams
algorithmOneCmd
Params
)
throws
AflnetException
{
if
(
algorithmOneCmd
Params
==
null
)
{
throw
new
AflnetException
(
"CmdStartParams is null !"
);
}
StringBuilder
cmd
=
new
StringBuilder
();
if
(
cmdStartParams
.
getNetinfo
()
!=
""
&&
cmdStart
Params
.
getNetinfo
()
!=
null
)
{
cmd
.
append
(
" -N "
+
cmdStart
Params
.
getNetinfo
());
if
(
algorithmOneCmdParams
.
getNetinfo
()
!=
""
&&
algorithmOneCmd
Params
.
getNetinfo
()
!=
null
)
{
cmd
.
append
(
" -N "
+
algorithmOneCmd
Params
.
getNetinfo
());
}
else
{
log
.
error
(
"There is no netinfo !"
);
throw
new
AflnetException
(
"There is no netinfo !"
);
}
if
(
cmdStart
Params
.
getProtopcol
()
!=
""
)
{
cmd
.
append
(
" -P "
+
cmdStart
Params
.
getProtopcol
());
if
(
algorithmOneCmd
Params
.
getProtopcol
()
!=
""
)
{
cmd
.
append
(
" -P "
+
algorithmOneCmd
Params
.
getProtopcol
());
}
if
(
cmdStart
Params
.
getWaiting
()
!=
0
)
{
cmd
.
append
(
" -D "
+
cmdStart
Params
.
getWaiting
());
if
(
algorithmOneCmd
Params
.
getWaiting
()
!=
0
)
{
cmd
.
append
(
" -D "
+
algorithmOneCmd
Params
.
getWaiting
());
}
if
(
cmdStart
Params
.
getNsname
()
!=
""
)
{
cmd
.
append
(
" -e "
+
cmdStart
Params
.
getNsname
());
if
(
algorithmOneCmd
Params
.
getNsname
()
!=
""
)
{
cmd
.
append
(
" -e "
+
algorithmOneCmd
Params
.
getNsname
());
}
if
(
cmdStart
Params
.
getKill
())
{
if
(
algorithmOneCmd
Params
.
getKill
())
{
cmd
.
append
(
" -K "
);
}
if
(
cmdStart
Params
.
getAwareMode
())
{
if
(
algorithmOneCmd
Params
.
getAwareMode
())
{
cmd
.
append
(
" -E "
);
}
if
(
cmdStart
Params
.
getRegionMutationOperators
())
{
if
(
algorithmOneCmd
Params
.
getRegionMutationOperators
())
{
cmd
.
append
(
" -R "
);
}
if
(
cmdStart
Params
.
getFalseNegativeMode
())
{
if
(
algorithmOneCmd
Params
.
getFalseNegativeMode
())
{
cmd
.
append
(
" -F "
);
}
if
(
cmdStart
Params
.
getScript
()
!=
""
)
{
cmd
.
append
(
" -c "
+
cmdStart
Params
.
getScript
());
if
(
algorithmOneCmd
Params
.
getScript
()
!=
""
)
{
cmd
.
append
(
" -c "
+
algorithmOneCmd
Params
.
getScript
());
}
if
(
cmdStart
Params
.
getStateSelectionAlgo
()
!=
0
)
{
cmd
.
append
(
" -q "
+
cmdStart
Params
.
getStateSelectionAlgo
());
if
(
algorithmOneCmd
Params
.
getStateSelectionAlgo
()
!=
0
)
{
cmd
.
append
(
" -q "
+
algorithmOneCmd
Params
.
getStateSelectionAlgo
());
}
if
(
cmdStart
Params
.
getSeedSelectionAlgo
()
!=
0
)
{
cmd
.
append
(
" -s "
+
cmdStart
Params
.
getSeedSelectionAlgo
()
+
" "
);
if
(
algorithmOneCmd
Params
.
getSeedSelectionAlgo
()
!=
0
)
{
cmd
.
append
(
" -s "
+
algorithmOneCmd
Params
.
getSeedSelectionAlgo
()
+
" "
);
}
return
cmd
.
toString
();
}
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/LinuxCommandUtil.java
View file @
2b6461e2
...
...
@@ -94,14 +94,15 @@ public class LinuxCommandUtil {
TestReturnEntity
returnEntity
=
new
TestReturnEntity
();
try
{
while
((
line
=
bf
.
readLine
())
!=
null
&&
TestControlTools
.
getIsRunning
())
{
cmdTools
.
makeReturnEntity
(
line
,
returnEntity
);
if
(
cmdTools
.
send
)
{
String
data
=
JSONObject
.
toJSONString
(
returnEntity
);
try
{
GlobalParameters
.
webSocket
.
appointSending
(
"fuzzMaster"
,
"web"
,
data
);
}
catch
(
Exception
ignored
)
{
}
}
System
.
out
.
println
(
line
);
// cmdTools.makeReturnEntity(line, returnEntity);
// if (cmdTools.send) {
// String data = JSONObject.toJSONString(returnEntity);
// try {
// GlobalParameters.webSocket.appointSending("fuzzMaster", "web", data);
// } catch (Exception ignored) {
// }
// }
}
//结束就关闭
if
(!
TestControlTools
.
getIsRunning
()){
...
...
fuzzIntegration/src/main/resources/application-dev.yml
View file @
2b6461e2
...
...
@@ -22,7 +22,13 @@ web:
ip
:
192.168.9.177
aflnetssh
:
host
:
192.168.
9.177
host
:
192.168.
31.53
port
:
22
user
:
root
password
:
123456
\ No newline at end of file
user
:
lddc
password
:
sysulddc
#aflnetssh:
# host: 192.168.31.133
# port: 22
# user: root
# password: 123456
\ 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