diff options
| author | WorksButNotTested <62701594+WorksButNotTested@users.noreply.github.com> | 2021-07-06 08:09:43 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-06 09:09:43 +0200 |
| commit | 2a433f90c456b19cf9aa39384540f618c6eeb1a8 (patch) | |
| tree | d5c44a780cd74a7b1931a7bd17ac8ad4bc0d65e4 /frida_mode/util | |
| parent | bf9a15541888ac8836a70b4d01c2c9e7bd940051 (diff) | |
| download | afl++-2a433f90c456b19cf9aa39384540f618c6eeb1a8.tar.gz | |
Improved OSX support (#1005)
Co-authored-by: Your Name <you@example.com>
Diffstat (limited to 'frida_mode/util')
| -rwxr-xr-x | frida_mode/util/get_symbol_addr.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/frida_mode/util/get_symbol_addr.sh b/frida_mode/util/get_symbol_addr.sh new file mode 100755 index 00000000..7f9b7d22 --- /dev/null +++ b/frida_mode/util/get_symbol_addr.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# set -x +target="$1" +symbol="$2" +base="$3" + +test -z "$target" -o -z "$symbol" -o '!' -e "$target" && exit 0 + +test $(uname -s) = "Darwin" && symbol=_"$symbol" + +file "$target" | grep -q executable && { + nm "$target" | grep -i "T $symbol" | awk '{print"0x"$1}' + exit 0 +} + +hex_base=$(echo "$3" | awk '{sub("^0x","");print $0}') +nm "$target" | grep -i "T $symbol" | awk '{print$1}' | tr a-f A-F | \ + xargs echo "ibase=16;obase=10;$hex_base + " | bc | tr A-F a-f | awk '{print "0x"$0}' +exit 0 |
