Skip to content

Commit 7e5e79d

Browse files
authored
Allow running with Unicorn 2.1.[34] but throw when emulating MIPS (#2721)
* Allow running with Unicorn 2.1.[34] but throw when emulating MIPS Unicorn 2.1.5 wasn't released for a while and 2.1.2 doesn't have binary wheels for Python 3.14. This made installing pwntools on newer Python versions more annoying since you had to build Unicorn yourself. The only problem with the blocked versions is MIPS emulation, so only avoid that while allowing to use Unicorn 2.1.3 or 2.1.4 for other architectures. Refs #2621 * Update CHANGELOG
1 parent e551b4a commit 7e5e79d

4 files changed

Lines changed: 13 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ jobs:
150150
pip install --upgrade wheel build
151151
pip install --upgrade flake8 appdirs
152152
pip install --upgrade --editable .
153+
# Pin to known working version until 2.1.5 is out. https://github.com/unicorn-engine/unicorn/issues/2134
154+
pip install 'unicorn==2.1.2'
153155
154156
- name: Sanity checks
155157
run: PWNLIB_NOTERM=1 python -bb -c 'from pwn import *; print(pwnlib.term.term_mode)'
@@ -285,7 +287,7 @@ jobs:
285287
run: |
286288
pip install --upgrade pip
287289
pip install --upgrade --editable .
288-
290+
289291
- name: Sanity checks
290292
run: |
291293
python -bb -c 'from pwn import *'

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,11 @@ The table below shows which release corresponds to each branch, and what date th
133133

134134
- [#2694][2694] fix: pad bytes fields to correct field size in FileStructure
135135
- [#2701][2701] Fix `adb._build_date()` crash on devices with non-standard locale date strings
136+
- [#2721][2721] Allow running with Unicorn 2.1.[34] but throw when emulating MIPS
136137

137138
[2694]: https://github.com/Gallopsled/pwntools/pull/2694
138139
[2701]: https://github.com/Gallopsled/pwntools/pull/2701
140+
[2721]: https://github.com/Gallopsled/pwntools/pull/2721
139141

140142
## 4.15.0 (`stable`)
141143

pwnlib/elf/plt.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ def __ensure_memory_to_run_unicorn():
7878
def prepare_unicorn_and_context(elf, got, address, data):
7979
import unicorn as U
8080

81+
if elf.arch in ('mips', 'mips64'):
82+
# Unicorn 2.1.3 and 2.1.4 have a crashing bug when trying to emulate MIPS.
83+
# https://github.com/unicorn-engine/unicorn/issues/2134
84+
if U.UC_VERSION_MAJOR == 2 and U.UC_VERSION_MINOR == 1 and U.UC_VERSION_PATCH in (3, 4):
85+
raise OSError("Unicorn Engine 2.1.3 and 2.1.4 have a crashing bug when emulating MIPS, please install an earlier or later version: https://github.com/unicorn-engine/unicorn/issues/2134")
86+
87+
8188
__ensure_memory_to_run_unicorn()
8289

8390
# Instantiate the emulator with the correct arguments for the current

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ dependencies = [
5050
"psutil>=3.3.0",
5151
"intervaltree>=3.0",
5252
"sortedcontainers",
53-
"unicorn>=2.0.1, !=2.1.3, !=2.1.4", # see https://github.com/unicorn-engine/unicorn/issues/2134
53+
"unicorn>=2.0.1",
5454
"six>=1.12.0",
5555
"rpyc",
5656
"colored_traceback<0.4; python_version < '3'",

0 commit comments

Comments
 (0)