Skip to content

Commit

Permalink
Fix asm() instruction consistency (#2144)
Browse files Browse the repository at this point in the history
* sets p2align header to 0 for x86-32 x86-64 and thumb

* updates changelog

* adds PR link to changelog

* Update pwnlib/asm.py

Co-authored-by: Arusekk <[email protected]>

Co-authored-by: Arusekk <[email protected]>
  • Loading branch information
rtlcopymemory and Arusekk authored Dec 28, 2022
1 parent 21131bd commit b771fc5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ The table below shows which release corresponds to each branch, and what date th
- [#2092][2092] shellcraft: dup() is now called dupio() consistently across all supported arches
- [#2093][2093] setresuid() in shellcraft uses current euid by default
- [#2125][2125] Allow tube.recvregex to return capture groups
- [#2144][2144] Removes `p2align 2` `asm()` headers from `x86-32`, `x86-64` and `mips` architectures to avoid inconsistent instruction length when patching binaries

[2062]: https://github.com/Gallopsled/pwntools/pull/2062
[2092]: https://github.com/Gallopsled/pwntools/pull/2092
[2093]: https://github.com/Gallopsled/pwntools/pull/2093
[2125]: https://github.com/Gallopsled/pwntools/pull/2125
[2144]: https://github.com/Gallopsled/pwntools/pull/2144

## 4.9.0 (`beta`)

Expand Down
13 changes: 8 additions & 5 deletions pwnlib/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,20 +320,23 @@ def _arch_header():
prefix = ['.section .shellcode,"awx"',
'.global _start',
'.global __start',
'.p2align 2',
'_start:',
'__start:']
headers = {
'i386' : ['.intel_syntax noprefix'],
'amd64' : ['.intel_syntax noprefix'],
'i386' : ['.intel_syntax noprefix', '.p2align 0'],
'amd64' : ['.intel_syntax noprefix', '.p2align 0'],
'arm' : ['.syntax unified',
'.arch armv7-a',
'.arm'],
'.arm',
'.p2align 2'],
'thumb' : ['.syntax unified',
'.arch armv7-a',
'.thumb'],
'.thumb',
'.p2align 1'
],
'mips' : ['.set mips2',
'.set noreorder',
'.p2align 2'
],
}

Expand Down

0 comments on commit b771fc5

Please sign in to comment.