Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cwe_checker
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
fact-depend
cwe_checker
Commits
12bd9693
Unverified
Commit
12bd9693
authored
Feb 08, 2021
by
Enkelmann
Committed by
GitHub
Feb 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better error messages on failed Ghidra execution (#140)
parent
321a06c0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
main.rs
caller/src/main.rs
+16
-6
No files found.
caller/src/main.rs
View file @
12bd9693
...
...
@@ -245,7 +245,7 @@ fn get_project_from_ghidra(file_path: &Path, binary: &[u8], quiet_flag: bool) ->
let
output_path
=
tmp_folder
.join
(
output_filename
);
let
ghidra_plugin_path
=
get_ghidra_plugin_path
(
"p_code_extractor"
);
// Execute Ghidra
let
output
=
Command
::
new
(
&
headless_path
)
let
output
=
match
Command
::
new
(
&
headless_path
)
.arg
(
&
tmp_folder
)
// The folder where temporary files should be stored
.arg
(
format!
(
"PcodeExtractor_{}_{}"
,
filename
,
timestamp_suffix
))
// The name of the temporary Ghidra Project.
.arg
(
"-import"
)
// Import a file into the Ghidra project
...
...
@@ -259,15 +259,25 @@ fn get_project_from_ghidra(file_path: &Path, binary: &[u8], quiet_flag: bool) ->
.arg
(
"-analysisTimeoutPerFile"
)
// Set a timeout for how long the standard analysis can run before getting aborted
.arg
(
"3600"
)
// Timeout of one hour (=3600 seconds) // TODO: The post-script can detect that the timeout fired and react accordingly.
.output
()
// Execute the command and catch its output.
.unwrap
();
{
Ok
(
output
)
=>
output
,
Err
(
err
)
=>
{
eprintln!
(
"Error: Ghidra could not be executed:
\n
{}"
,
err
);
std
::
process
::
exit
(
101
);
}
};
if
!
output
.status
.success
()
{
match
output
.status
.code
()
{
Some
(
code
)
=>
{
println!
(
"{}"
,
String
::
from_utf8
(
output
.stdout
)
.unwrap
());
println!
(
"{}"
,
String
::
from_utf8
(
output
.stderr
)
.unwrap
());
panic!
(
"Execution of Ghidra plugin failed with exit code {}"
,
code
)
eprintln!
(
"{}"
,
String
::
from_utf8
(
output
.stdout
)
.unwrap
());
eprintln!
(
"{}"
,
String
::
from_utf8
(
output
.stderr
)
.unwrap
());
eprintln!
(
"Execution of Ghidra plugin failed with exit code {}"
,
code
);
std
::
process
::
exit
(
101
);
}
None
=>
{
eprintln!
(
"Execution of Ghidra plugin failed: Process was terminated."
);
std
::
process
::
exit
(
101
);
}
None
=>
panic!
(
"Execution of Ghidra plugin failed: Process was terminated."
),
}
}
// Read the results from the Ghidra script
...
...
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