• Stars
    star
    151
  • Rank 237,786 (Top 5 %)
  • Language
    C++
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Command line utility for modifying Mach-O binaries in various ways.

macho_edit

Command line utility for modifying Mach-O binaries in various ways.

Supported functionality

  • Extracting and removing archs from a fat binary.
  • Inserting an arch from another binary into a fat binary.
  • Making a fat binary thin or a thin binary fat.
  • Moving around and removing load commands.
  • Inserting new load commands. Currently only LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB and LC_RPATH is supported.
  • Removing code signature (LC_CODE_SIGNATURE).

Removing code signature

To remove the code signature it is enough to delete the LC_CODE_SIGNATURE load command and fixup the mach header's ncmds and sizeofcmds, assuming it is the last load command.

However if you just do this codesign_allocate (used by codesign and ldid) will fail with the error:

.../codesign_allocate: file not in an order that can be processed (link edit information does not fill the __LINKEDIT segment):

To fix this macho_edit assumes that the code signature that LC_CODE_SIGNATURE is in the end of the __LINKEDIT segment and the that the segment is in the end of the architectures slice.

It then truncate that slice to remove the code signature part of the __LINKEDIT segment. It also updates the LC_SEGMENT (or LC_SEGMENT64) load command for the __LINKEDIT segment from the new file size. If the binary is fat we also update the size and we might also move the slice and so the offset should also be updated.

After removing the code signature from the __LINKEDIT segment, the last thing in that segment is typically the string table. As the code signature seems to be aligned by 0x10, and so after removing the code signature, nothing points to the padding at the end of the segment, which codesign_allocate doesn't like either. To fix this we just trim the file so the string table in the LC_SYMTAB command is at the end of the slice.

Todo

  • Option to modify mach header flags

More Repositories

1

insert_dylib

Command line utility for inserting a dylib load command into a Mach-O binary
C
1,527
star
2

NetworkAutoLogin

Automagically logs into to Captive Portal Networks
Objective-C
131
star
3

cycript-utils

Various cycript functions
Cycript
127
star
4

asm_repl

A REPL for assembly
C
95
star
5

z4

z3++
Python
24
star
6

get_aslr

C
22
star
7

objc_instance_finder

Find instances of objc classes at runtime
Objective-C
22
star
8

kextd_patcher

Patch kextd using radare2
Python
16
star
9

yt_dlp_firefox

Svelte
10
star
10

ineffective_hooker

Lets you replace a functions implementation with another function which can call the original function normally
C
9
star
11

link_cut_tree

A link/cut tree implemented in python
Python
9
star
12

auprint

Allows you to setup Aarhus University's printers on their prt11.uni.au.dk server
Python
8
star
13

class-dump-a

Combines class-dump and class-dump-z
8
star
14

inject_dylib

Command-line utility to inject a dylib into a running process
C
8
star
15

Lid-sleep

Automatically sleep a MacBook when closing the lid with an external screen attached.
Objective-C
5
star
16

lldb-utils

Various utilities to use with lldb
Python
5
star
17

apkmagician

Python
4
star
18

albert-extensions

Python
4
star
19

us_da-layout

US keyboard layout with level 3-4 รฆรธรฅ
Shell
3
star
20

fork-futures

Provides an alternative to concurrent.futures.ProcessPoolExecutor implemented using fork.
Python
3
star
21

theos-templates

2
star
22

fbtk

TK-navne pรฅ Facebook
JavaScript
2
star
23

Mathematica-init.m

Mathematica init.m
Mathematica
2
star
24

runtime_class-dump

Objective-C
2
star
25

SimpleInjector

Objective-C
2
star
26

JSON_with_NaN

JSON with NaN (and Infinity/-Infinity)
JavaScript
1
star
27

DisablePowerButton

Disables the power button on OS X
Objective-C
1
star
28

no-html-download

JavaScript
1
star
29

kattis-test

Tool for running problem submissions against samples.
Python
1
star
30

alfred_workflows

Various Alfred workflows
Objective-C
1
star
31

dk_mac_fixed-layout

Shell
1
star
32

kattis-improvements

JavaScript
1
star
33

ijvm-disasm

Tool for disassembling IJVM bytecode files
Python
1
star
34

neutrino

C++
1
star
35

patricia_tree_rust

Rust
1
star
36

pacclean

A better `pacman -R $(pacman -Qdtq)`
C++
1
star
37

vtable

Rust
1
star