Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
gaasedelen committed Nov 24, 2024
2 parents 5a8c621 + 6ee5917 commit f790203
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 77 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/package-plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ jobs:
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.16.0
uses: dawidd6/action-download-artifact@v6
with:

# the target repo for external artifacts (built libs)
Expand All @@ -27,10 +27,10 @@ jobs:
shell: bash
run: |
mkdir dist && cd dist
mkdir win32 && cp -r ../plugins/* ./win32/ && cp -r ../artifact/keystone_win32/* ./win32/patching/keystone && cd ./win32 && zip -r ../patching_win32.zip ./* && cd ..
mkdir linux && cp -r ../plugins/* ./linux/ && cp -r ../artifact/keystone_linux/* ./linux/patching/keystone && cd ./linux && zip -r ../patching_linux.zip ./* && cd ..
mkdir darwin && cp -r ../plugins/* ./darwin/ && cp -r ../artifact/keystone_darwin/* ./darwin/patching/keystone && cd ./darwin && zip -r ../patching_macos.zip ./* && cd ..
mkdir win32 && cp -r ../plugins/* ./win32/ && cp -r ../artifact_windows-latest/* ./win32/patching/keystone && cd ./win32 && zip -r ../patching_win32.zip ./* && cd ..
mkdir linux && cp -r ../plugins/* ./linux/ && cp -r ../artifact_ubuntu-latest/* ./linux/patching/keystone && cd ./linux && zip -r ../patching_linux.zip ./* && cd ..
mkdir darwin && cp -r ../plugins/* ./darwin/ && cp -r ../artifact_macos-latest/* ./darwin/patching/keystone && cd ./darwin && zip -r ../patching_macos.zip ./* && cd ..
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
path: ${{ github.workspace }}/dist/*.zip
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ Special thanks to [Hex-Rays](https://hex-rays.com/) for supporting the developme

## Releases

* v0.2 -- Important bugfixes, IDA 9 compatibility
* v0.1 -- Initial release

# Installation

This plugin requires IDA 7.6 and Python 3. It supports Windows, Linux, and macOS.

*Please note, older versions of IDA (8.2 and below) are [not compatible](https://hex-rays.com/products/ida/news/8_2sp1/) with Python 3.11 and above.*

## Easy Install

Run the following line in the IDA console to automatically install the plugin:
Expand Down
16 changes: 16 additions & 0 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@
except:
SUPPORTED_IDA = False

#
# XXX/NOTE: older versions of IDA have compatability issues with newer
# versions of Python. if the user is running IDA 8.2 or below and Python 3.11
# or above, we will not proceed with installation.
#
# https://hex-rays.com/products/ida/news/8_2sp1/
# https://github.com/gaasedelen/patching/issues/10
# https://github.com/gaasedelen/patching/issues/16
# ...
#

if SUPPORTED_IDA and ida_pro.IDA_SDK_VERSION < 830:
SUPPORTED_PYTHON = sys.version_info[0] == 3 and sys.version_info[1] < 11
if not SUPPORTED_PYTHON:
print("[i] IDA 8.2 and below do not support Python 3.11 and above")

# is this deemed to be a compatible environment for the plugin to load?
SUPPORTED_ENVIRONMENT = bool(SUPPORTED_IDA and SUPPORTED_PYTHON)

Expand Down
4 changes: 2 additions & 2 deletions plugins/patching/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def update(self, ctx):
class AssembleAction(ida_kernwin.action_handler_t):
NAME = 'patching:assemble'
ICON = 'assemble.png'
TEXT = "Assemble..."
TEXT = "~A~ssemble..."
TOOLTIP = "Assemble new instructions at the selected address"
HOTKEY = None

Expand All @@ -135,7 +135,7 @@ def update(self, ctx):
class ApplyAction(ida_kernwin.action_handler_t):
NAME = 'patching:apply'
ICON = 'save.png'
TEXT = "Apply patches to..."
TEXT = "A~p~ply patches to..."
TOOLTIP = "Select where to save the patched binary"
HOTKEY = None

Expand Down
32 changes: 16 additions & 16 deletions plugins/patching/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,13 @@ class AsmX86(KeystoneAssembler):
'REPE CMPSW',
]

def __init__(self, inf):
def __init__(self):
arch = keystone.KS_ARCH_X86

if inf.is_64bit():
if ida_ida.inf_is_64bit():
mode = keystone.KS_MODE_64
self.MAX_PREVIEW_BYTES = 7
elif inf.is_32bit():
elif ida_ida.inf_is_32bit_exactly():
mode = keystone.KS_MODE_32
self.MAX_PREVIEW_BYTES = 6
else:
Expand Down Expand Up @@ -644,13 +644,13 @@ class AsmARM(KeystoneAssembler):
# TODO: MRS and MOV (32/64 bit) are semi-supported too
]

def __init__(self, inf):
def __init__(self):

# ARM64
if inf.is_64bit():
if ida_ida.inf_is_64bit():
arch = keystone.KS_ARCH_ARM64

if inf.is_be():
if ida_ida.inf_is_be():
mode = keystone.KS_MODE_BIG_ENDIAN
else:
mode = keystone.KS_MODE_LITTLE_ENDIAN
Expand All @@ -662,7 +662,7 @@ def __init__(self, inf):
else:
arch = keystone.KS_ARCH_ARM

if inf.is_be():
if ida_ida.inf_is_be():
mode = keystone.KS_MODE_ARM | keystone.KS_MODE_BIG_ENDIAN
self._ks_thumb = keystone.Ks(arch, keystone.KS_MODE_THUMB | keystone.KS_MODE_BIG_ENDIAN)
else:
Expand Down Expand Up @@ -810,10 +810,10 @@ def unalias(self, assembly):

class AsmPPC(KeystoneAssembler):

def __init__(self, inf):
def __init__(self):
arch = keystone.KS_ARCH_PPC

if inf.is_64bit():
if ida_ida.inf_is_64bit():
mode = keystone.KS_MODE_PPC64
else:
mode = keystone.KS_MODE_PPC32
Expand All @@ -831,15 +831,15 @@ def __init__(self, inf):

class AsmMIPS(KeystoneAssembler):

def __init__(self, inf):
def __init__(self):
arch = keystone.KS_ARCH_MIPS

if inf.is_64bit():
if ida_ida.inf_is_64bit():
mode = keystone.KS_MODE_MIPS64
else:
mode = keystone.KS_MODE_MIPS32

if inf.is_be():
if ida_ida.inf_is_be():
mode |= keystone.KS_MODE_BIG_ENDIAN
else:
mode |= keystone.KS_MODE_LITTLE_ENDIAN
Expand All @@ -853,15 +853,15 @@ def __init__(self, inf):

class AsmSPARC(KeystoneAssembler):

def __init__(self, inf):
def __init__(self):
arch = keystone.KS_ARCH_SPARC

if inf.is_64bit():
if ida_ida.inf_is_64bit():
mode = keystone.KS_MODE_SPARC64
else:
mode = keystone.KS_MODE_SPARC32

if inf.is_be():
if ida_ida.inf_is_be():
mode |= keystone.KS_MODE_BIG_ENDIAN
else:
mode |= keystone.KS_MODE_LITTLE_ENDIAN
Expand All @@ -875,5 +875,5 @@ def __init__(self, inf):

class AsmSystemZ(KeystoneAssembler):

def __init__(self, inf):
def __init__(self):
super(AsmSystemZ, self).__init__(keystone.KS_ARCH_SYSTEMZ, keystone.KS_MODE_BIG_ENDIAN)
Loading

0 comments on commit f790203

Please sign in to comment.