mirror of
https://github.com/hackerschoice/thc-tips-tricks-hacks-cheat-sheet.git
synced 2026-01-09 15:58:02 -05:00
Merge pull request #32 from laplante-sean/master
UPX: Handle 32-bit binaries that don't have PROT_EXEC|PROT_WRITE
This commit is contained in:
@@ -2132,10 +2132,11 @@ Optionally cleanse signatures and traces of UPX:
|
||||
```shell
|
||||
cat "${BIN}" \
|
||||
| perl -e 'local($/);$_=<>;s/(.*)(\$Info:[^\0]*)(.*)/print "$1";print "\0"x length($2); print "$3"/es;' \
|
||||
| perl -e 'local($/);$_=<>;s/(.*)(\$Id:[^\0]*)(.*)/print "$1";print "\0"x length($2); print "$3"/es;' \
|
||||
| perl -e 'local($/);$_=<>;s/(.*)(PROT_EXEC\|PROT_WRI[^\0]*)(.*)/print "$1";print "\0"x length($2); print "$3"/es;' >"${BIN}.tmpupx"
|
||||
cat "${BIN}.tmpupx" >"${BIN}"
|
||||
rm -f "${BIN}.tmpupx"
|
||||
| perl -e 'local($/);$_=<>;s/(.*)(\$Id:[^\0]*)(.*)/print "$1";print "\0"x length($2); print "$3"/es;' >"${BIN}.tmpupx"
|
||||
mv "${BIN}.tmpupx" "${BIN}"
|
||||
grep -Eq "PROT_EXEC\|PROT_WRITE" "${BIN}" \
|
||||
&& cat "${BIN}" | perl -e 'local($/);$_=<>;s/(.*)(PROT_EXEC\|PROT_WRI[^\0]*)(.*)/print "$1";print "\0"x length($2); print "$3"/es;' >"${BIN}.tmpupx" \
|
||||
&& mv "${BIN}.tmpupx" "${BIN}"
|
||||
perl -i -0777 -pe 's/UPX!/\0\0\0\0/sg' "${BIN}"
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user