Skip to content

Commit

Permalink
Add PyPI package (#4)
Browse files Browse the repository at this point in the history
* Update README, setup.py

* Set long_description_content_type

* Update version

* Update README

* Add badges
  • Loading branch information
bonprosoft authored Jan 2, 2020
1 parent 686a6db commit 1d7188d
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ __pycache__
*.pyc
.mypy_cache
*.egg-info
build/
dist/
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include README.md
include LICENSE

recursive-include shamiko *.py py.typed *.template
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# shamiko
[![PyPI](https://img.shields.io/pypi/v/shamiko.svg)](https://pypi.org/project/shamiko/)
[![PyPI Supported Python Versions](https://img.shields.io/pypi/pyversions/shamiko.svg)](https://pypi.org/project/shamiko/)
[![GitHub license](https://img.shields.io/github/license/bonprosoft/shamiko.svg)](https://github.com/bonprosoft/shamiko)

shamiko is a library for inspecting running Python processes.

It can
- inspect Python processes
- obtain information about current frames and threads of the running process
- inject arbitrary code into specified frame and thread
- attach pdb
- inject arbitrary code into specified frame and thread of the process
- attach the running process with pdb

## Install

Expand All @@ -17,7 +19,7 @@ pip install shamiko

## CLI

shamiko provides the command line interface.
shamiko provides the command-line interface.

```sh
shamiko --help
Expand Down Expand Up @@ -50,7 +52,7 @@ inspect the running process
Usage: shamiko PID inspect
```

![](./imgs/inspect.gif)
![](https://raw.githubusercontent.com/bonprosoft/shamiko/master/imgs/inspect.gif)

### attach

Expand All @@ -60,12 +62,12 @@ attach a debugger to the running process
Usage: shamiko PID attach [OPTIONS]
Options:
--thread (int): thread id where you can obtain by inspect command
--frame (int): frame id where you can obtain by inspect command
--thread (int): thread id where you can obtain by `inspect` command
--frame (int): frame id where you can obtain by `inspect` command
--debugger (str): debugger type. available debuggers: [pdb]
```

![](./imgs/attach.gif)
![](https://raw.githubusercontent.com/bonprosoft/shamiko/master/imgs/attach.gif)

### run-file

Expand All @@ -75,14 +77,14 @@ inject a python script file into the running process
Usage: shamiko PID run-file [OPTIONS] FILE_PATH
Arguments:
FILE_PATH (str): a path of python script that you want to inject into given PID
FILE_PATH (str): a path of the python script that you want to inject into given PID
Options:
--thread (int): thread id where you can obtain by inspect command
--frame (int): frame id where you can obtain by inspect command
--thread (int): thread id where you can obtain by `inspect` command
--frame (int): frame id where you can obtain by `inspect` command
```

![](./imgs/runfile.gif)
![](https://raw.githubusercontent.com/bonprosoft/shamiko/master/imgs/runfile.gif)

### run-script

Expand All @@ -95,11 +97,11 @@ Arguments:
SCRIPT (str): a python code that you want to inject into given PID
Options:
--thread (int): thread id where you can obtain by inspect command
--frame (int): frame id where you can obtain by inspect command
--thread (int): thread id where you can obtain by `inspect` command
--frame (int): frame id where you can obtain by `inspect` command
```

![](./imgs/runscript.gif)
![](https://raw.githubusercontent.com/bonprosoft/shamiko/master/imgs/runscript.gif)

### shell

Expand All @@ -109,7 +111,7 @@ launch an interactive shell
Usage: shamiko PID shell
```

![](./imgs/shell.gif)
![](https://raw.githubusercontent.com/bonprosoft/shamiko/master/imgs/shell.gif)

## FAQ

Expand All @@ -122,7 +124,7 @@ again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
```

In most distributions, executing ptrace of non-child process by non-super user is disallowed.
In most distributions, executing ptrace of non-child processes by a non-super user is disallowed.
You can disable this temporarily by
```sh
echo 0 > /proc/sys/kernel/yama/ptrace_scope
Expand Down
37 changes: 21 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
from setuptools import setup
from setuptools import find_packages, setup

__version__ = "0.1.0"

setup(
name="shamiko",
version="0.0.1",
version=__version__,
description="Shamiko ga waruindayo",
long_description="",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
author="Yuki Igarashi",
author_email="[email protected]",
url="https://github.com/bonprosoft/shamiko",
license="MIT License",
packages=["shamiko", "shamiko.gdb", "shamiko.simple_rpc"],
package_data={
"shamiko": [
"templates/*.template",
],
},
install_requires=[
"psutil>=5.6.7,<6",
packages=find_packages(),
classifiers=[
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python",
"License :: OSI Approved :: MIT License",
],
entry_points={
"console_scripts": [
"shamiko = shamiko.cli:cli",
],
},
package_data={"shamiko": ["py.typed", "templates/*.template"]},
install_requires=["psutil>=5.6.7,<6", "Jinja2>=2.10.3,<3"],
entry_points={"console_scripts": ["shamiko = shamiko.cli:cli"]},
zip_safe=False,
)
4 changes: 4 additions & 0 deletions shamiko/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
try:
import gdb # NOQA
except ImportError:
import shutil
if shutil.which("gdb") is None:
raise RuntimeError("gdb command is required") from None

from shamiko.app import Shamiko # NOQA
from shamiko.session import Session # NOQA

Expand Down

0 comments on commit 1d7188d

Please sign in to comment.