Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hardening-check: obey READELF, LDD & OBJDUMP env vars for tool names #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions scripts/hardening-check.pl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
pod2usage(1) if $help;
pod2usage(-exitstatus => 0, -verbose => 2, -noperldoc => 1) if $man;

my $ldd = $ENV{'LDD'} || "ldd";
my $objdump = $ENV{'OBJDUMP'} || "objdump";
my $readelf = $ENV{'READELF'} || "readelf";
my $overall = 0;
my $rc = 0;
my $report = "";
Expand Down Expand Up @@ -220,8 +223,8 @@ (@)
# Find the libc used in this executable, if any.
sub find_libc($) {
my ($file) = @_;
my $ldd = output("ldd", $file);
$ldd =~ /^\s*libc\.so\.\S+\s+\S+\s+(\S+)/m;
my $ldd_out = output($ldd, $file);
$ldd_out =~ /^\s*libc\.so\.\S+\s+\S+\s+(\S+)/m;
return $1 || "";
}

Expand All @@ -232,7 +235,7 @@ ($$)
# Catch "NOTYPE" for object archives.
my $func_regex = " (I?FUNC|NOTYPE) ";

my $relocs = output("readelf", "-sW", $file);
my $relocs = output($readelf, "-sW", $file);
for my $line (split("\n", $relocs)) {
next if ($line !~ /$func_regex/);
next if ($undefined && $line !~ /$func_regex.* UND /);
Expand Down Expand Up @@ -271,21 +274,21 @@ ($$)
@tags = ();

# Get program headers.
my $PROG_REPORT = output("readelf", "-lW", $file);
my $PROG_REPORT = output($readelf, "-lW", $file);
if (length($PROG_REPORT) == 0) {
$overall = 1;
next;
}

# Get ELF headers.
my $DYN_REPORT = output("readelf", "-dW", $file);
my $DYN_REPORT = output($readelf, "-dW", $file);

# Get disassembly
my $DISASM
= output("objdump", "-d", "--no-show-raw-insn", "-M", "intel", $file);
= output($objdump, "-d", "--no-show-raw-insn", "-M", "intel", $file);

# Get notes
my $NOTES = output("readelf", "-n", $file);
my $NOTES = output($readelf, "-n", $file);

# Get list of all symbols needing external resolution.
my $functions = find_functions($file, 1);
Expand Down