diff --git a/tools/bits-info.sh b/tools/bits-info.sh index 5cbf693b..feec0344 100755 --- a/tools/bits-info.sh +++ b/tools/bits-info.sh @@ -252,8 +252,8 @@ check_bitness_of_pe_file() { local _pe_header_pos _pe_header 2> /dev/null -echo 1>&2 '---' -echo 1>&2 '_"${1:?}"_' +echo '---' +echo ':_"${1:?}"_' if test ! -e "${1:?}" || ! command -v hexdump; then printf '%s\n' 'unknown' return 1 @@ -261,9 +261,11 @@ echo 1>&2 '_"${1:?}"_' # More info: https://learn.microsoft.com/en-us/windows/win32/debug/pe-format -hexdump 1>&2 -v -s 0x3C -n 4 -e '/1 "%02x\n"' -- "${1:?}" | tac | tr -d '\n' +echo '---' +hexdump -v -s 0x3C -n 4 -e '/1 "%02x\n"' -- "${1:?}" | tac | tr -d '\n' if _pe_header_pos="$(hexdump -v -s 0x3C -n 4 -e '/1 "%02x\n"' -- "${1:?}" | tac | tr -d '\n')" && test -n "${_pe_header_pos?}" && _pe_header_pos="0x${_pe_header_pos:?}"; then -hexdump 1>&2 -v -s "${_pe_header_pos:?}" -n 6 -e '/1 "%02x"' -- "${1:?}" +echo '---' +hexdump -v -s "${_pe_header_pos:?}" -n 6 -e '/1 "%02x"' -- "${1:?}" if _pe_header="$(hexdump 2> /dev/null -v -s "${_pe_header_pos:?}" -n 6 -e '/1 "%02x"' -- "${1:?}")" && printf '%s\n' "${_pe_header?}" | grep -m 1 -q -e '^50450000'; then # PE header => PE (0x50 0x45) + 0x00 0x00 + Machine field case "${_pe_header?}" in @@ -275,6 +277,7 @@ hexdump 1>&2 -v -s "${_pe_header_pos:?}" -n 6 -e '/1 "%02x"' -- "${1:?}" return 2 ;; esac +echo '---' return 0 fi fi @@ -312,6 +315,7 @@ main() shell_name="$(printf '%s\n' "${shell_info:?}" | cut -d ' ' -f '1' || true)" echo "_${shell_exe?}_" +check_bitness_of_pe_file "${shell_exe:?}" if test -n "${shell_exe?}" && tmp_var="$(hexdump 2> /dev/null -v -n 5 -e '/1 "%02x"' -- "${shell_exe:?}")" && test -n "${tmp_var?}" && printf '%s\n' "${tmp_var:?}" | grep -m 1 -q -e '^7f454c46'; then # On Linux / Android # ELF header => 0x7F + ELF (0x45 0x4C 0x46) + 0x01 for 32-bit or 0x02 for 64-bit @@ -320,8 +324,8 @@ echo "_${shell_exe?}_" *'01') shell_bit='32-bit ELF' ;; *) shell_bit='unknown' ;; esac - elif test -n "${shell_exe?}" && shell_bit="$(check_bitness_of_pe_file "${shell_exe:?}")"; then - : + #elif test -n "${shell_exe?}" && shell_bit="$(check_bitness_of_pe_file "${shell_exe:?}")"; then + #: elif tmp_var="$(uname 2> /dev/null -m)"; then case "${tmp_var?}" in x86_64 | ia64 | arm64 | aarch64 | mips64) shell_bit='64-bit' ;;