Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
unifuzz-validate
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
文周繁
unifuzz-validate
Commits
81f13b8f
Commit
81f13b8f
authored
5 months ago
by
文周繁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
master
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
311 additions
and
0 deletions
+311
-0
asan.py
asan.py
+60
-0
protocol_asan.py
protocol_asan.py
+85
-0
protocol_valgrind.py
protocol_valgrind.py
+80
-0
valgrind.py
valgrind.py
+86
-0
No files found.
asan.py
0 → 100644
View file @
81f13b8f
import
os
import
sys
import
logging
import
subprocess
import
datetime
import
os
import
time
import
signal
import
re
pattern_asan_head
=
re
.
compile
(
r'==\d+==ERROR: AddressSanitizer:'
)
# pattern_asan_shadow = re.compile(r'Shadow bytes around the buggy address:')
def
search_file
(
dirname
):
paths
=
[]
for
root
,
dirs
,
files
in
os
.
walk
(
dirname
):
for
file
in
files
:
print
(
file
)
if
file
.
startswith
(
"README"
):
continue
else
:
path
=
os
.
path
.
join
(
root
,
file
)
paths
.
append
(
path
)
print
(
len
(
paths
))
return
paths
def
TIMEOUT_COMMAND
(
command
,
stdout
,
stderr
):
"""call shell-command and either return its output or kill it
if it doesn't normally exit within timeout seconds and return None"""
process
=
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
outs
,
errs
=
process
.
communicate
()
stdout
.
write
(
outs
)
if
pattern_asan_head
.
search
(
errs
)
is
not
None
:
stderr
.
write
(
errs
)
def
generation_command
(
target
,
parameter
,
paths
,
stdout_outputfile
,
stderr_outputfile
):
stdout_output
=
open
(
stdout_outputfile
,
"w+"
)
stderr_output
=
open
(
stderr_outputfile
,
"w+"
)
for
path
in
paths
:
command
=
target
+
" "
+
parameter
.
replace
(
"@@"
,
path
,
1
)
+
" "
print
(
command
)
TIMEOUT_COMMAND
(
command
,
stdout_output
,
stderr_output
)
def
main
(
argv
):
target
=
argv
[
0
]
cmd
=
"@@"
dirname
=
argv
[
1
]
stdout_outputfile
=
argv
[
2
]
stderr_outputfile
=
argv
[
3
]
print
(
"Searching files
\n
"
)
paths
=
search_file
(
dirname
)
generation_command
(
target
,
cmd
,
paths
,
stdout_outputfile
,
stderr_outputfile
)
if
__name__
==
"__main__"
:
main
(
sys
.
argv
[
1
:])
This diff is collapsed.
Click to expand it.
protocol_asan.py
0 → 100644
View file @
81f13b8f
import
os
import
sys
import
logging
import
subprocess
import
datetime
import
time
import
signal
def
search_file
(
dirname
):
paths
=
[]
for
root
,
dirs
,
files
in
os
.
walk
(
dirname
):
for
file
in
files
:
print
(
file
)
if
file
.
startswith
(
"README"
):
continue
else
:
path
=
os
.
path
.
join
(
root
,
file
)
paths
.
append
(
path
)
print
(
len
(
paths
))
return
paths
def
TIMEOUT_COMMAND
(
command
,
fl
):
"""call shell-command and either return its output or kill it
if it doesn't normally exit within timeout seconds and return None"""
process
=
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
for
info
in
process
.
communicate
():
fl
.
write
(
info
)
def
generation_command
(
target
,
parameter
,
paths
,
outputfile
):
fl
=
open
(
outputfile
,
"w+"
)
for
path
in
paths
:
# print(path)
command
=
target
+
" "
+
parameter
.
replace
(
"@@"
,
path
,
1
)
+
" "
print
(
command
)
ret
=
TIMEOUT_COMMAND
(
command
,
fl
)
# 启动服务
def
service_on
(
service
,
port
,
conf_file
,
outputfile
):
command
=
service
+
" "
+
conf_file
+
" "
+
port
print
(
command
)
process
=
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
print
(
"service on"
)
return
process
# 关闭服务
def
service_off
(
process
:
subprocess
.
Popen
):
process
.
kill
()
def
afl_replay
(
target
,
afl_replay_path
,
paths
,
protocol
,
port
,
conf_file
,
outputfile
):
fl
=
open
(
outputfile
,
"w+"
)
for
path
in
paths
:
process
=
service_on
(
target
,
port
,
conf_file
,
outputfile
)
command
=
afl_replay_path
+
" "
+
path
+
" "
+
protocol
+
" "
+
port
print
(
command
)
# 使用afl-replay
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
for
info
in
process
.
communicate
():
try
:
fl
.
write
(
info
.
decode
(
"utf-8"
))
except
UnicodeDecodeError
:
fl
.
write
(
str
(
info
))
service_off
(
process
)
def
main
(
argv
):
target
=
argv
[
0
]
# 被测程序
conf_file
=
argv
[
1
]
# 被测程序配置文件
port
=
argv
[
2
]
# 被测程序开放端口
afl_replay_path
=
argv
[
3
]
# afl_replay_path
dirname
=
argv
[
4
]
# seeds目录
protocol
=
argv
[
5
]
# 协议
outputfile
=
argv
[
6
]
# 输出文件
print
(
"Searching files
\n
"
)
paths
=
search_file
(
dirname
)
afl_replay
(
target
,
afl_replay_path
,
paths
,
protocol
,
port
,
conf_file
,
outputfile
)
# afl-replay
if
__name__
==
"__main__"
:
main
(
sys
.
argv
[
1
:])
This diff is collapsed.
Click to expand it.
protocol_valgrind.py
0 → 100644
View file @
81f13b8f
import
sys
import
subprocess
import
os
def
search_file
(
dirname
):
paths
=
[]
for
root
,
dirs
,
files
in
os
.
walk
(
dirname
):
for
file
in
files
:
print
(
file
)
if
file
.
startswith
(
"README"
):
continue
else
:
path
=
os
.
path
.
join
(
root
,
file
)
paths
.
append
(
path
)
print
(
len
(
paths
))
return
paths
def
TIMEOUT_COMMAND
(
command
,
fl
):
"""call shell-command and either return its output or kill it
if it doesn't normally exit within timeout seconds and return None"""
process
=
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
for
info
in
process
.
communicate
():
fl
.
write
(
info
)
def
generation_command
(
target
,
parameter
,
paths
,
outputfile
):
fl
=
open
(
outputfile
,
"w+"
)
for
path
in
paths
:
command
=
"valgrind "
+
target
+
" "
+
parameter
.
replace
(
"@@"
,
path
,
1
)
+
" "
print
(
command
)
ret
=
TIMEOUT_COMMAND
(
command
,
fl
)
# 启动服务
def
service_on
(
service
,
port
,
conf_file
,
outputfile
):
command
=
"valgrind"
+
" "
+
service
+
" "
+
conf_file
+
" "
+
port
print
(
command
)
process
=
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
print
(
"service on"
)
return
process
# 关闭服务
def
service_off
(
process
:
subprocess
.
Popen
):
process
.
kill
()
def
afl_replay
(
target
,
afl_replay_path
,
paths
,
protocol
,
port
,
conf_file
,
outputfile
):
fl
=
open
(
outputfile
,
"w+"
)
for
path
in
paths
:
process
=
service_on
(
target
,
port
,
conf_file
,
outputfile
)
command
=
afl_replay_path
+
" "
+
path
+
" "
+
protocol
+
" "
+
port
print
(
command
)
# 使用afl-replay
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
for
info
in
process
.
communicate
():
try
:
fl
.
write
(
info
.
decode
(
"utf-8"
))
except
UnicodeDecodeError
:
fl
.
write
(
str
(
info
))
service_off
(
process
)
def
main
(
argv
):
target
=
argv
[
0
]
# 被测程序
conf_file
=
argv
[
1
]
# 被测程序配置文件
port
=
argv
[
2
]
# 被测程序开放端口
afl_replay_path
=
argv
[
3
]
# afl_replay_path
dirname
=
argv
[
4
]
# seeds目录
protocol
=
argv
[
5
]
# 协议
outputfile
=
argv
[
6
]
# 输出文件
print
(
"Searching files
\n
"
)
paths
=
search_file
(
dirname
)
afl_replay
(
target
,
afl_replay_path
,
paths
,
protocol
,
port
,
conf_file
,
outputfile
)
# afl-replay
if
__name__
==
"__main__"
:
main
(
sys
.
argv
[
1
:])
This diff is collapsed.
Click to expand it.
valgrind.py
0 → 100644
View file @
81f13b8f
import
sys
import
logging
import
subprocess
import
datetime
import
os
import
time
import
signal
import
re
import
string
pattern_valgrind_head
=
re
.
compile
(
r'==\d+=='
)
pattern_valgrind_tail
=
re
.
compile
(
r'==\d+== ERROR SUMMARY: [1-9]+'
)
pattern_valgrind_at
=
re
.
compile
(
r'==\d+== {4}at 0x\w+: '
)
pattern_valgrind_by
=
re
.
compile
(
r'==\d+== {4}by 0x\w+: '
)
invalid_cause_dict
=
dict
()
def
search_file
(
dirname
):
paths
=
[]
for
root
,
dirs
,
files
in
os
.
walk
(
dirname
):
for
file
in
files
:
print
(
file
)
if
file
.
startswith
(
"README"
):
continue
else
:
path
=
os
.
path
.
join
(
root
,
file
)
paths
.
append
(
path
)
print
(
len
(
paths
))
return
paths
def
TIMEOUT_COMMAND
(
command
,
stdout
,
stderr
):
"""call shell-command and either return its output or kill it
if it doesn't normally exit within timeout seconds and return None"""
process
=
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
outs
,
errs
=
process
.
communicate
()
stdout
.
write
(
outs
)
err_data
=
''
is_search_at
=
False
search_by_count
=
0
error_cause
=
''
for
i
in
errs
.
splitlines
():
if
pattern_valgrind_at
.
match
(
i
)
is
not
None
and
not
is_search_at
:
is_search_at
=
True
err_data
=
err_data
+
i
+
"
\n
"
_
,
end
=
pattern_valgrind_at
.
search
(
i
)
.
span
()
error_cause
+=
i
[
end
:]
elif
pattern_valgrind_by
.
match
(
i
)
is
not
None
and
search_by_count
<=
10
:
search_by_count
+=
1
err_data
=
err_data
+
i
+
"
\n
"
_
,
end
=
pattern_valgrind_by
.
search
(
i
)
.
span
()
error_cause
+=
i
[
end
:]
elif
pattern_valgrind_tail
.
match
(
i
)
is
not
None
:
err_data
=
err_data
+
i
+
"
\n
"
if
not
invalid_cause_dict
.
has_key
(
error_cause
):
stderr
.
write
(
err_data
)
# TODO write to mangodb
invalid_cause_dict
[
error_cause
]
=
1
elif
pattern_valgrind_head
.
match
(
i
)
is
not
None
:
err_data
=
err_data
+
i
+
"
\n
"
else
:
pass
def
generation_command
(
target
,
parameter
,
paths
,
stdout_outputfile
,
stderr_outputfile
):
stdout_output
=
open
(
stdout_outputfile
,
"w+"
)
stderr_output
=
open
(
stderr_outputfile
,
"w+"
)
for
path
in
paths
:
command
=
"valgrind "
+
target
+
" "
+
parameter
.
replace
(
"@@"
,
path
,
1
)
+
" "
print
(
command
)
TIMEOUT_COMMAND
(
command
,
stdout_output
,
stderr_output
)
def
main
(
argv
):
target
=
argv
[
0
]
# target program
cmd
=
"@@"
dirname
=
argv
[
1
]
# seeds dir
stdout_outputfile
=
argv
[
2
]
stderr_outputfile
=
argv
[
3
]
print
(
"Searching files
\n
"
)
paths
=
search_file
(
dirname
)
generation_command
(
target
,
cmd
,
paths
,
stdout_outputfile
,
stderr_outputfile
)
if
__name__
==
"__main__"
:
main
(
sys
.
argv
[
1
:])
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