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
51383361
Commit
51383361
authored
Jun 14, 2024
by
钱炳权
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实验室环境成功返回websocket数据
parent
2b6461e2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
20 deletions
+58
-20
TestServiceImpl.java
...om/example/fuzzControll/service/impl/TestServiceImpl.java
+0
-0
CmdTools.java
...rc/main/java/com/example/fuzzControll/tools/CmdTools.java
+4
-2
LinuxCommandUtil.java
...java/com/example/fuzzControll/tools/LinuxCommandUtil.java
+51
-13
result.html
fuzzIntegration/src/main/resources/result.html
+3
-5
No files found.
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/TestServiceImpl.java
View file @
51383361
This diff is collapsed.
Click to expand it.
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/CmdTools.java
View file @
51383361
...
@@ -41,7 +41,7 @@ public class CmdTools {
...
@@ -41,7 +41,7 @@ public class CmdTools {
* 运行需要后台运行cmd
* 运行需要后台运行cmd
* 通过websocket返回数据
* 通过websocket返回数据
*/
*/
public
void
runProgramCmd
(
String
c
md
)
throws
AflnetException
,
JSchException
,
IOException
{
public
void
runProgramCmd
(
String
aflnetCmd
,
String
pythonCmd
,
String
recodeC
md
)
throws
AflnetException
,
JSchException
,
IOException
{
AflnetSshProperties
aflnetSshProperties
=
GlobalParameters
.
aflnetSshProperties
;
AflnetSshProperties
aflnetSshProperties
=
GlobalParameters
.
aflnetSshProperties
;
String
host
=
aflnetSshProperties
.
getHost
();
String
host
=
aflnetSshProperties
.
getHost
();
int
port
=
aflnetSshProperties
.
getPort
();
int
port
=
aflnetSshProperties
.
getPort
();
...
@@ -50,7 +50,9 @@ public class CmdTools {
...
@@ -50,7 +50,9 @@ public class CmdTools {
// 手动创建对象实现连接
// 手动创建对象实现连接
LinuxCommandUtil
linuxCommandUtil
=
new
LinuxCommandUtil
();
LinuxCommandUtil
linuxCommandUtil
=
new
LinuxCommandUtil
();
linuxCommandUtil
.
connect
(
host
,
port
,
user
,
password
);
linuxCommandUtil
.
connect
(
host
,
port
,
user
,
password
);
linuxCommandUtil
.
execCmd
(
cmd
);
linuxCommandUtil
.
execCmd
(
aflnetCmd
);
// linuxCommandUtil.execCmdWithoutResults(pythonCmd);
// linuxCommandUtil.execCmdWithoutResults(recodeCmd);
}
}
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/LinuxCommandUtil.java
View file @
51383361
...
@@ -3,6 +3,7 @@ package com.example.fuzzControll.tools;
...
@@ -3,6 +3,7 @@ package com.example.fuzzControll.tools;
import
java.io.*
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Scanner
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.example.fuzzControll.pojo.vo.TestReturnEntity
;
import
com.example.fuzzControll.pojo.vo.TestReturnEntity
;
...
@@ -11,6 +12,7 @@ import com.jcraft.jsch.ChannelExec;
...
@@ -11,6 +12,7 @@ import com.jcraft.jsch.ChannelExec;
import
com.jcraft.jsch.JSch
;
import
com.jcraft.jsch.JSch
;
import
com.jcraft.jsch.JSchException
;
import
com.jcraft.jsch.JSchException
;
import
com.jcraft.jsch.Session
;
import
com.jcraft.jsch.Session
;
import
org.apache.tomcat.util.buf.Utf8Decoder
;
public
class
LinuxCommandUtil
{
public
class
LinuxCommandUtil
{
...
@@ -82,30 +84,66 @@ public class LinuxCommandUtil {
...
@@ -82,30 +84,66 @@ public class LinuxCommandUtil {
public
void
execCmd
(
String
command
)
throws
JSchException
,
IOException
{
public
void
execCmd
(
String
command
)
throws
JSchException
,
IOException
{
List
<
String
>
result
=
new
ArrayList
<>();
List
<
String
>
result
=
new
ArrayList
<>();
InputStream
in
=
channelExec
.
getInputStream
();
InputStream
in
=
channelExec
.
getInputStream
();
InputStream
error
=
channelExec
.
getErrStream
();
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
outPutStream
(
in
);
}
}).
start
();
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
errorStream
(
error
);
}
}).
start
();
channelExec
.
setCommand
(
command
);
channelExec
.
setCommand
(
command
);
channelExec
.
setErrStream
(
System
.
err
);
channelExec
.
connect
();
channelExec
.
connect
();
}
/**
* 不需要结果执行指令
*/
public
void
execCmdWithoutResults
(
String
command
)
throws
JSchException
,
IOException
{
channelExec
.
setCommand
(
command
);
channelExec
.
connect
();
}
public
void
outPutStream
(
InputStream
in
)
{
Reader
reader
=
new
InputStreamReader
(
in
);
Reader
reader
=
new
InputStreamReader
(
in
);
BufferedReader
bf
=
new
BufferedReader
(
reader
);
BufferedReader
bf
=
new
BufferedReader
(
reader
);
CmdTools
cmdTools
=
new
CmdTools
();
String
line
=
null
;
String
line
=
null
;
TestReturnEntity
returnEntity
=
new
TestReturnEntity
();
List
<
String
>
list
=
null
;
try
{
while
((
line
=
bf
.
readLine
())
!=
null
&&
TestControlTools
.
getIsRunning
())
{
System
.
out
.
println
(
line
);
if
(
line
.
contains
(
"american fuzzy"
))
{
list
=
new
ArrayList
<>();
}
if
(
list
!=
null
)
list
.
add
(
line
+
"\n"
);
if
(
line
.
contains
(
"cpu"
))
GlobalParameters
.
webSocket
.
appointSending
(
"fuzzMaster"
,
"web"
,
list
.
toString
());
}
//结束就关闭
if
(!
TestControlTools
.
getIsRunning
())
{
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
public
void
errorStream
(
InputStream
error
)
{
Reader
reader
=
new
InputStreamReader
(
error
);
BufferedReader
bf
=
new
BufferedReader
(
reader
);
String
line
=
null
;
List
<
String
>
list
=
null
;
try
{
try
{
while
((
line
=
bf
.
readLine
())
!=
null
&&
TestControlTools
.
getIsRunning
())
{
while
((
line
=
bf
.
readLine
())
!=
null
&&
TestControlTools
.
getIsRunning
())
{
System
.
out
.
println
(
line
);
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
())
{
if
(!
TestControlTools
.
getIsRunning
())
{
close
();
close
();
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
...
fuzzIntegration/src/main/resources/result.html
View file @
51383361
...
@@ -8,19 +8,17 @@
...
@@ -8,19 +8,17 @@
var
ws1
=
null
;
var
ws1
=
null
;
var
ws2
=
null
;
var
ws2
=
null
;
function
myFunction
()
{
function
myFunction
()
{
ws1
=
new
WebSocket
(
"ws://192.168.
9.177
:8100/websocket/testResult/web"
);
ws1
=
new
WebSocket
(
"ws://192.168.
31.133
:8100/websocket/testResult/web"
);
ws1
.
onmessage
=
function
(
evt
)
{
ws1
.
onmessage
=
function
(
evt
)
{
console
.
log
(
evt
);
console
.
log
(
evt
);
var
received_msg
=
JSON
.
parse
(
evt
.
data
)
;
console
.
log
(
evt
.
data
)
const
nameValue
=
Object
.
values
(
received_msg
)
var
context
=
'<div class="sendMsg">'
+
var
context
=
'<div class="sendMsg">'
+
'aflnet:<br/>'
+
'aflnet:<br/>'
+
'aflnet<h3>'
+
nameValue
+
'</h3><br/>'
+
'aflnet<h3>'
+
evt
.
data
+
'</h3><br/>'
+
' </div>'
;
' </div>'
;
document
.
getElementById
(
"sendDiv"
).
innerHTML
=
context
;
document
.
getElementById
(
"sendDiv"
).
innerHTML
=
context
;
};
};
ws1
.
onclose
=
function
()
{
ws1
.
onclose
=
function
()
{
// 关闭 websocket
// 关闭 websocket
alert
(
"连接已关闭..."
);
alert
(
"连接已关闭..."
);
};
};
...
...
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