|
Packit |
8ea169 |
#!/bin/sh
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
# Do we have the tools we need?
|
|
Packit |
8ea169 |
# If no, exit silently.
|
|
Packit |
8ea169 |
command -v @GDB@ >/dev/null 2>&1 || exit 0
|
|
Packit |
8ea169 |
command -v eu-readelf >/dev/null 2>&1 || exit 0
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
# Do we have coredump?
|
|
Packit |
8ea169 |
test -r coredump || {
|
|
Packit |
8ea169 |
echo 'No file "coredump" in current directory' >&2
|
|
Packit |
8ea169 |
exit 1
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
# Find "cursig: N" and extract N.
|
|
Packit |
8ea169 |
# This gets used by abrt-exploitable as a fallback
|
|
Packit |
8ea169 |
# if gdb and/or kernel is uncooperative.
|
|
Packit |
8ea169 |
# "grep -m1": take the first match (on Linux, every thread has its own
|
|
Packit |
8ea169 |
# prstatus struct in the coredump, but the signal number which killed us
|
|
Packit |
8ea169 |
# must be the same in all these structs).
|
|
Packit |
8ea169 |
SIGNO_OF_THE_COREDUMP=$(eu-readelf -n coredump | grep -m1 -o 'cursig: *[0-9]*' | sed 's/[^0-9]//g')
|
|
Packit |
8ea169 |
export SIGNO_OF_THE_COREDUMP
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
# Run gdb, hiding its messages. Example:
|
|
Packit |
8ea169 |
# Missing separate debuginfo for the main executable file
|
|
Packit |
8ea169 |
# Core was generated by...
|
|
Packit |
8ea169 |
# Program terminated with signal 11, Segmentation fault.
|
|
Packit |
8ea169 |
# #0 0x09fa5348 in ?? ()
|
|
Packit |
8ea169 |
# We don't want to see all this.
|
|
Packit |
8ea169 |
# abrt-exploitable plugin is instructed to create ./exploitable file
|
|
Packit |
8ea169 |
# with explanation if severity is >= 4
|
|
Packit |
8ea169 |
GDBOUT=$(
|
|
Packit |
8ea169 |
@GDB@ --batch \
|
|
Packit |
8ea169 |
-ex 'python exec(open("/usr/libexec/abrt-gdb-exploitable").read())' \
|
|
Packit |
8ea169 |
-ex 'core-file ./coredump' \
|
|
Packit |
8ea169 |
-ex 'abrt-exploitable 4 ./exploitable' \
|
|
Packit |
8ea169 |
2>&1 \
|
|
Packit |
8ea169 |
) && exit 0
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
# There was an error. Show the messages.
|
|
Packit |
8ea169 |
printf "Error while running gdb:\n%s\n" "$GDBOUT"
|
|
Packit |
8ea169 |
exit 1
|