Skip to content

Commit

Permalink
Merge branch 'dev' into windbg
Browse files Browse the repository at this point in the history
  • Loading branch information
peace-maker committed Jan 17, 2024
2 parents a3f8bb4 + 7b78334 commit d147f3b
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 20 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/ci.yml
Expand Up @@ -178,18 +178,19 @@ jobs:
pwn libcdb hash b229d1da1e161f95e839cf90cded5f719e5de308
- name: Build source and wheel distributions
if: matrix.python_version > '2.7'
if: matrix.python_version != '2.7'
run: |
python -m build
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: matrix.python_version != '2.7'
with:
name: packages
path: dist/

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: coverage
name: coverage-${{ matrix.python_version }}
path: .coverage*


Expand All @@ -201,10 +202,10 @@ jobs:
with:
fetch-depth: 20

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: coverage
path: .
pattern: coverage-*
merge-multiple: true

- name: Install coveralls
run: |
Expand Down Expand Up @@ -243,7 +244,7 @@ jobs:
needs: test
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: packages
path: dist
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -80,6 +80,7 @@ The table below shows which release corresponds to each branch, and what date th
- [#2308][2308] Fix WinExec shellcraft to make sure it's 16 byte aligned
- [#2279][2279] Make `pwn template` always set context.binary
- [#2310][2310] Add support to start a process on Windows
- [#2334][2334] Speed up disasm commandline tool with colored output
- [#2327][2327] Add basic support to debug processes on Windows

[2242]: https://github.com/Gallopsled/pwntools/pull/2242
Expand All @@ -92,6 +93,7 @@ The table below shows which release corresponds to each branch, and what date th
[2308]: https://github.com/Gallopsled/pwntools/pull/2308
[2279]: https://github.com/Gallopsled/pwntools/pull/2279
[2310]: https://github.com/Gallopsled/pwntools/pull/2310
[2334]: https://github.com/Gallopsled/pwntools/pull/2334
[2327]: https://github.com/Gallopsled/pwntools/pull/2327

## 4.12.0 (`beta`)
Expand Down
2 changes: 2 additions & 0 deletions pwnlib/asm.py
Expand Up @@ -860,6 +860,8 @@ def disasm(data, vma = 0, byte = True, offset = True, instructions = True):


lines = []

# Note: those patterns are also used in pwnlib/commandline/disasm.py
pattern = '^( *[0-9a-f]+: *)', '((?:[0-9a-f]+ )+ *)', '(.*)'
if not byte:
pattern = pattern[::2]
Expand Down
37 changes: 27 additions & 10 deletions pwnlib/commandline/disasm.py
Expand Up @@ -3,6 +3,7 @@
from __future__ import print_function

import argparse
import re
import string
import sys

Expand Down Expand Up @@ -76,18 +77,34 @@ def main(args):
from pygments.formatters import TerminalFormatter
from pwnlib.lexer import PwntoolsLexer

offsets = disasm(dat, vma=safeeval.const(args.address), instructions=False, byte=False)
bytes = disasm(dat, vma=safeeval.const(args.address), instructions=False, offset=False)
instrs = disasm(dat, vma=safeeval.const(args.address), byte=False, offset=False)
# instrs = highlight(instrs, PwntoolsLexer(), TerminalFormatter())
dis = disasm(dat, vma=safeeval.const(args.address))

highlight_bytes = lambda t: ''.join(map(lambda x: x.replace('00', text.red('00')).replace('0a', text.red('0a')), group(2, t)))
for o,b,i in zip(*map(str.splitlines, (offsets, bytes, instrs))):
b = ' '.join(highlight_bytes(bb) for bb in b.split(' '))
i = highlight(i.strip(), PwntoolsLexer(), TerminalFormatter()).strip()
i = i.replace(',',', ')
# Note: those patterns are copied from disasm function
pattern = '^( *[0-9a-f]+: *)((?:[0-9a-f]+ )+ *)(.*)'
lines = []
for line in dis.splitlines():
match = re.search(pattern, line)
if not match:
# Append as one element tuple
lines.append((line,))
continue

groups = match.groups()
o, b, i = groups

lines.append((o, b, i))

print(o,b,i)

highlight_bytes = lambda t: ''.join(map(lambda x: x.replace('00', text.red('00')).replace('0a', text.red('0a')), group(2, t)))
for line in lines:
if len(line) == 3:
o, b, i = line
b = ' '.join(highlight_bytes(bb) for bb in b.split(' '))
i = highlight(i.strip(), PwntoolsLexer(), TerminalFormatter()).strip()
i = i.replace(',',', ')
print(o,b,i)
else:
print(line[0])
return

print(disasm(dat, vma=safeeval.const(args.address)))
Expand Down
7 changes: 6 additions & 1 deletion pwnlib/util/fiddling.py
Expand Up @@ -37,10 +37,15 @@ def unhex(s):
b'test'
>>> unhex("F\n")
b'\x0f'
>>> unhex(bytearray(b" F "))
b'\x0f'
"""
s = s.strip()
if len(s) % 2 != 0:
s = '0' + s
if isinstance(s, (bytes, bytearray)):
s = b'0' + s
else:
s = '0' + s
return binascii.unhexlify(s)

def enhex(x):
Expand Down
2 changes: 1 addition & 1 deletion travis/setup_avd_fast.sh
Expand Up @@ -14,7 +14,7 @@ ANDROIDV=android-24
# Create our emulator Android Virtual Device (AVD)
# --snapshot flag is deprecated, see bitrise-steplib/steps-create-android-emulator#18
export PATH=$PATH:"$ANDROID_HOME"/cmdline-tools/latest/bin:"$ANDROID_HOME"/platform-tools
yes | sdkmanager --sdk_root="$ANDROID_HOME" --install "system-images;$ANDROIDV;default;$ANDROID_ABI"
yes | sdkmanager --sdk_root="$ANDROID_HOME" --install "system-images;$ANDROIDV;default;$ANDROID_ABI" "emulator" "platform-tools" "platforms;$ANDROIDV"
yes | sdkmanager --sdk_root="$ANDROID_HOME" --licenses
echo no | avdmanager --silent create avd --name android-$ANDROID_ABI --force --package "system-images;$ANDROIDV;default;$ANDROID_ABI"

Expand Down

0 comments on commit d147f3b

Please sign in to comment.