Name | stacksim JSON |
Version |
0.1.3
JSON |
| download |
home_page | None |
Summary | Stack Visualization Tool |
upload_time | 2024-07-27 02:26:31 |
maintainer | None |
docs_url | None |
author | None |
requires_python | None |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
Stacksim
========
Stacksim is a python package for simulating/visualizing stack operations. It also provides a sphinx extension for generating stack diagrams
Install
-------
.. code::
pip install stacksim
CLI
---
To run the cli,
.. code::
stacksim
This will start the cli interface. Here is a quick example of some commands:
.. code:: bash
(stacksim)>> push etc: ... --size 64
(stacksim)>> call main(2, "hello" "world")
(stacksim)>> char buffer[64]
(stacksim)>> push i: 0x89 --note Same as 'int i = 0x89'
(stacksim)>> call printf("vars %d %d", 17, 38)
(stacksim)>> function myFunction(int a, int b)
(stacksim)>> call myFunction(56,78)
.. image:: doc/assets/images/stack1.png
Because this is really just a tool for visualization, types are not strictly defined or used. For instance the following command is valid:
.. code:; c
int i = index of buffer
It will add a word to the stack with label `i` and value "index of buffer"
Local vars
~~~~~~~~~~
you can declare local variables using standard C syntax.
.. code::
char buffer[64]
int i = 0x89
Loading a C file
~~~~~~~~~~~~~~~~
You can load a file with C syntax to import functions. The functions will be loaded into the context including arguments, local variables, and calls to other functions.
.. code::
load test.c
Write
~~~~~
The `write` command lets you write data to the stack at a given address.
.. code::
write 0x56, 0x78, 0x90, 0x12 -a 0x1000
#you can also use references to variables with offsets
write 0x45 -a &buffer
write 0x45 -a &buffer+4
Push
~~~~
push will push a single `stack cell` onto the stack. A cell contains one or more words. Each cell can have a label, note, and words
.. code::
push arg1: 0x56 #Shortcut for 'push 0x56 --label arg1'
push --label buffer --size 64 #creates a 64 word cell with no specified data
push buf: 1,2,3,4,5 #creates a 5 word cell with the values filled in
push <main+0x54> --note return #creates a single word on the stack with no label, and a note
Pop
~~~
pop will remove words from the stack
.. code::
pop #remove a single word
pop 4 #remove 4 words
pop frame #remove current frame
ret
~~~
ret will pop one word and set the instruction pointer to the value popped.
.. note:: the `CallingConvention` has a concept of registers, but they are not utilized/shown yet
Functions
~~~~~~~~~
The ``call`` command gets run through a `CallingConvention` subclass (currently only cdecl is available) and performs operations according to the convention:
- push arguments to stack
- create a new stack frame
- pushes return address
You can declare functions to give the app context about argument type/size and labels, but you can also call arbitrary functions. It will just assume all arguments are a single row on the stack.
.. code::
function myFunction(int a, int b)
call myFunction(41,32)
call undeclareFunction(1,2,3,4) # Will assume all args are 32 bit values and label arg1, arg2, arg3, etc
.. note:: A lot of common functions from libc are already loaded in.
Sphinx
------
.. important:: not yet implemented
This package also contains an extension for sphinx. Add the extension in `conf.py` and then you can use the `stack` directive
.. code:: rst
.. stack::
:showAddresses:
push etc: ... --size 64
call main(2, "hello" "world")
char buffer[64]
call printf("vars %d %d", 17, 38)
function myFunction(int a, int b)
call myFunction(56,78)
Raw data
{
"_id": null,
"home_page": null,
"name": "stacksim",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/0b/95/825a13c72945e8d77b74f2324dd88eae772ca0454fbf51e99ea047db97ad/stacksim-0.1.3.tar.gz",
"platform": null,
"description": "Stacksim\n========\n\nStacksim is a python package for simulating/visualizing stack operations. It also provides a sphinx extension for generating stack diagrams\n\n\nInstall \n-------\n\n\n.. code:: \n\n pip install stacksim\n\n\n\nCLI \n---\n\n\nTo run the cli, \n\n.. code::\n\n stacksim \n\nThis will start the cli interface. Here is a quick example of some commands: \n\n.. code:: bash \n\n (stacksim)>> push etc: ... --size 64\n (stacksim)>> call main(2, \"hello\" \"world\")\n (stacksim)>> char buffer[64]\n (stacksim)>> push i: 0x89 --note Same as 'int i = 0x89'\n (stacksim)>> call printf(\"vars %d %d\", 17, 38)\n (stacksim)>> function myFunction(int a, int b)\n (stacksim)>> call myFunction(56,78)\n\n\n\n\n.. image:: doc/assets/images/stack1.png\n\n\nBecause this is really just a tool for visualization, types are not strictly defined or used. For instance the following command is valid: \n\n.. code:; c \n\n int i = index of buffer\n\nIt will add a word to the stack with label `i` and value \"index of buffer\"\n\nLocal vars\n~~~~~~~~~~\n\nyou can declare local variables using standard C syntax.\n\n.. code:: \n\n char buffer[64]\n int i = 0x89\n\nLoading a C file \n~~~~~~~~~~~~~~~~\n\nYou can load a file with C syntax to import functions. The functions will be loaded into the context including arguments, local variables, and calls to other functions.\n\n.. code:: \n\n load test.c\n\n\nWrite \n~~~~~\n\nThe `write` command lets you write data to the stack at a given address.\n\n.. code:: \n\n write 0x56, 0x78, 0x90, 0x12 -a 0x1000\n\n #you can also use references to variables with offsets \n write 0x45 -a &buffer\n write 0x45 -a &buffer+4\n\n\nPush \n~~~~\n\npush will push a single `stack cell` onto the stack. A cell contains one or more words. Each cell can have a label, note, and words\n\n.. code::\n\n push arg1: 0x56 #Shortcut for 'push 0x56 --label arg1'\n push --label buffer --size 64 #creates a 64 word cell with no specified data \n push buf: 1,2,3,4,5 #creates a 5 word cell with the values filled in \n push <main+0x54> --note return #creates a single word on the stack with no label, and a note\n\nPop\n~~~\n\npop will remove words from the stack \n\n.. code:: \n\n pop #remove a single word \n pop 4 #remove 4 words \n pop frame #remove current frame \n\n\nret \n~~~\n\nret will pop one word and set the instruction pointer to the value popped. \n\n.. note:: the `CallingConvention` has a concept of registers, but they are not utilized/shown yet\n\nFunctions \n~~~~~~~~~\n\nThe ``call`` command gets run through a `CallingConvention` subclass (currently only cdecl is available) and performs operations according to the convention: \n\n- push arguments to stack \n- create a new stack frame \n- pushes return address \n\n\nYou can declare functions to give the app context about argument type/size and labels, but you can also call arbitrary functions. It will just assume all arguments are a single row on the stack. \n\n.. code:: \n\n function myFunction(int a, int b)\n call myFunction(41,32)\n\n call undeclareFunction(1,2,3,4) # Will assume all args are 32 bit values and label arg1, arg2, arg3, etc\n\n.. note:: A lot of common functions from libc are already loaded in. \n\nSphinx\n------\n\n.. important:: not yet implemented \n\n\nThis package also contains an extension for sphinx. Add the extension in `conf.py` and then you can use the `stack` directive \n\n\n.. code:: rst \n\n .. stack:: \n :showAddresses: \n\n push etc: ... --size 64\n call main(2, \"hello\" \"world\")\n char buffer[64]\n call printf(\"vars %d %d\", 17, 38)\n function myFunction(int a, int b)\n call myFunction(56,78)\n",
"bugtrack_url": null,
"license": null,
"summary": "Stack Visualization Tool",
"version": "0.1.3",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0b95825a13c72945e8d77b74f2324dd88eae772ca0454fbf51e99ea047db97ad",
"md5": "441f2381042b1c530f08b0a92d89f196",
"sha256": "8d271deac88035b26ca115df51561c2b18f42689070c1e41b6ef6bb47d942a4c"
},
"downloads": -1,
"filename": "stacksim-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "441f2381042b1c530f08b0a92d89f196",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 19221,
"upload_time": "2024-07-27T02:26:31",
"upload_time_iso_8601": "2024-07-27T02:26:31.013206Z",
"url": "https://files.pythonhosted.org/packages/0b/95/825a13c72945e8d77b74f2324dd88eae772ca0454fbf51e99ea047db97ad/stacksim-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-27 02:26:31",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "stacksim"
}