forked from jan/mem_edit
Compare commits
7 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 260d67bf81 | |||
| 4deaa41d7e | |||
| 8b5d5af95b | |||
| e8c6c4f74c | |||
| e842f81575 | |||
| 49a7c21ed2 | |||
| 6321d4221c |
7 changed files with 23 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,4 +4,5 @@ __pycache__
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
|
build/
|
||||||
dist/
|
dist/
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
include README.md
|
include README.md
|
||||||
include LICENSE.md
|
include LICENSE.md
|
||||||
|
include mem_edit/VERSION
|
||||||
|
|
|
||||||
12
README.md
12
README.md
|
|
@ -19,18 +19,18 @@
|
||||||
|
|
||||||
**Dependencies:**
|
**Dependencies:**
|
||||||
* python 3 (written and tested with 3.7)
|
* python 3 (written and tested with 3.7)
|
||||||
* ctypes
|
* ctypes
|
||||||
* typing (for type annotations)
|
* typing (for type annotations)
|
||||||
|
|
||||||
|
|
||||||
Install with pip, from PyPI (preferred):
|
Install with pip, from PyPI (preferred):
|
||||||
```bash
|
```bash
|
||||||
pip install mem_edit
|
pip3 install mem_edit
|
||||||
```
|
```
|
||||||
|
|
||||||
Install with pip from git repository
|
Install with pip from git repository
|
||||||
```bash
|
```bash
|
||||||
pip install git+https://mpxd.net/code/jan/mem_edit.git@release
|
pip3 install git+https://mpxd.net/code/jan/mem_edit.git@release
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ Increment a magic number (unsigned long 1234567890) found in 'magic.exe':
|
||||||
pid = Process.get_pid_by_name('magic.exe')
|
pid = Process.get_pid_by_name('magic.exe')
|
||||||
with Process.open_process(pid) as p:
|
with Process.open_process(pid) as p:
|
||||||
addrs = p.search_all_memory(magic_number)
|
addrs = p.search_all_memory(magic_number)
|
||||||
|
|
||||||
# We don't want to edit if there's more than one result...
|
# We don't want to edit if there's more than one result...
|
||||||
assert(len(addrs) == 1)
|
assert(len(addrs) == 1)
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ Read and alter a structure:
|
||||||
s = MyStruct()
|
s = MyStruct()
|
||||||
s.first_member = 1234567890
|
s.first_member = 1234567890
|
||||||
s.second_member = 0x1234
|
s.second_member = 0x1234
|
||||||
|
|
||||||
addrs = p.search_all_memory(s)
|
addrs = p.search_all_memory(s)
|
||||||
print(addrs)
|
print(addrs)
|
||||||
|
|
||||||
|
|
|
||||||
1
mem_edit/VERSION
Normal file
1
mem_edit/VERSION
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
0.3
|
||||||
|
|
@ -12,12 +12,16 @@ To get started, try:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import platform
|
import platform
|
||||||
|
import pathlib
|
||||||
|
|
||||||
from .utils import MemEditError
|
from .utils import MemEditError
|
||||||
|
|
||||||
|
|
||||||
__author__ = 'Jan Petykiewicz'
|
__author__ = 'Jan Petykiewicz'
|
||||||
version = '0.2'
|
|
||||||
|
with open(pathlib.Path(__file__).parent / 'VERSION', 'r') as f:
|
||||||
|
__version__ = f.read().strip()
|
||||||
|
version = __version__
|
||||||
|
|
||||||
|
|
||||||
system = platform.system()
|
system = platform.system()
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ def ptrace(command: int, pid: int = 0, arg1: int = 0, arg2: int = 0) -> int:
|
||||||
"""
|
"""
|
||||||
Call ptrace() with the provided pid and arguments. See the ```man ptrace```.
|
Call ptrace() with the provided pid and arguments. See the ```man ptrace```.
|
||||||
"""
|
"""
|
||||||
logger.debug('ptrace({}, {}, {}, {})'.format(command, pid, arg1, arg2))
|
logger.debug('ptrace({}, {}, {}, {})'.format(command, pid, arg1, arg2))
|
||||||
result = _ptrace(command, pid, arg1, arg2)
|
result = _ptrace(command, pid, arg1, arg2)
|
||||||
if result == -1:
|
if result == -1:
|
||||||
err_no = ctypes.get_errno()
|
err_no = ctypes.get_errno()
|
||||||
|
|
@ -58,7 +58,7 @@ class Process(AbstractProcess):
|
||||||
self.pid = process_id
|
self.pid = process_id
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
os.kill(self.pid, signal.SIGSTOP)
|
os.kill(self.pid, signal.SIGSTOP)
|
||||||
ptrace(ptrace_commands['PTRACE_DETACH'], self.pid, 0, 0)
|
ptrace(ptrace_commands['PTRACE_DETACH'], self.pid, 0, 0)
|
||||||
self.pid = None
|
self.pid = None
|
||||||
|
|
||||||
|
|
@ -78,7 +78,7 @@ class Process(AbstractProcess):
|
||||||
with open('/proc/{}/cmdline', 'rb') as f:
|
with open('/proc/{}/cmdline', 'rb') as f:
|
||||||
return f.read().decode().split('\x00')[0]
|
return f.read().decode().split('\x00')[0]
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def list_available_pids() -> List[int]:
|
def list_available_pids() -> List[int]:
|
||||||
|
|
|
||||||
10
setup.py
10
setup.py
|
|
@ -1,15 +1,15 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
import mem_edit
|
|
||||||
|
|
||||||
|
|
||||||
with open('README.md', 'r') as f:
|
with open('README.md', 'r') as f:
|
||||||
long_description = f.read()
|
long_description = f.read()
|
||||||
|
|
||||||
|
with open('mem_edit/VERSION', 'r') as f:
|
||||||
|
version = f.read().strip()
|
||||||
|
|
||||||
setup(name='mem_edit',
|
setup(name='mem_edit',
|
||||||
version=mem_edit.version,
|
version=version,
|
||||||
description='Multi-platform library for memory editing',
|
description='Multi-platform library for memory editing',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type='text/markdown',
|
long_description_content_type='text/markdown',
|
||||||
|
|
@ -34,7 +34,6 @@ setup(name='mem_edit',
|
||||||
'trainer',
|
'trainer',
|
||||||
],
|
],
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Programming Language :: Python',
|
|
||||||
'Programming Language :: Python :: 3',
|
'Programming Language :: Python :: 3',
|
||||||
'Development Status :: 4 - Beta',
|
'Development Status :: 4 - Beta',
|
||||||
'Environment :: Other Environment',
|
'Environment :: Other Environment',
|
||||||
|
|
@ -50,6 +49,9 @@ setup(name='mem_edit',
|
||||||
'Topic :: Utilities',
|
'Topic :: Utilities',
|
||||||
],
|
],
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
|
package_data={
|
||||||
|
'mem_edit': ['VERSION']
|
||||||
|
},
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'typing',
|
'typing',
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue