Created
May 23, 2021 19:45
-
-
Save speters/c32edd290415d28335b73cb282a43b3e to your computer and use it in GitHub Desktop.
git repo search for non-stripped files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # git-search-exe.sh | |
| # 20210523 by Soenke J. Peters @ opcenter.de | |
| # | |
| # search for files with symbols (not stripped) or containing debug_info in a git repository | |
| # as there are sometimes interesting leftovers which are a good start for RE | |
| DIR=$1 | |
| CWD=$(pwd) | |
| if [ ! -d "$DIR" ] ; then | |
| echo "need DIR with git repo as argument" | |
| exit 1 | |
| fi | |
| cd "$DIR" | |
| $(git status >/dev/null 2>&1) | |
| if [ $? -ne 0 ] ; then | |
| echo "$DIR does not contain a git repo" | |
| cd "$CWD" | |
| exit 1 | |
| fi | |
| IFS=$'\n' | |
| for OBJ_INFO in $(git rev-list --all --objects ) ; do | |
| OBJ_O=$(echo $OBJ_INFO | sed -e 's/ .*//g') | |
| OBJ_PATH=$(echo "${OBJ_INFO}" | sed -e 's/.* //g') | |
| if [ -n "$OBJ_PATH" ] ; then | |
| git cat-file blob $OBJ_O 2>/dev/null | file -E - | sed -e 's#/dev/stdin#'$OBJ_O' '"${OBJ_PATH}"'#g' | |
| fi | |
| done | egrep "not stripped|debug_info" | |
| unset IFS | |
| cd "$CWD" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment