Coder Social home page Coder Social logo

bytejection's People

Contributors

naleraphael avatar

Stargazers

 avatar

Watchers

 avatar

bytejection's Issues

Error of `Segmentation fault` is raised when a patched function is called where there is no `print` function inside the payload

Steps to reproduce this issue:

  1. comment out the print function in demo/run_patched_module.py at line 61.
    # Payload to be injected
    def new_verification():
    print('... Content has been modified ...')
  2. add arbitrary code to make that function work normally. (just make sure there is no print function in it)
  3. repeat the function call modified.foo() as line 73 more than 3 times.
    # Check the output of modified function
    print('--- modified version ---')
    modified_mod = load_module_from_path('modified', osp.join(THIS_DIR, 'modified.pyc'))
    modified_mod.foo()
  4. execute demo/run_patched_module.py.

Result of execution:

  • Ubuntu 18.04, Python 3.6.9 (with gdb):
--- modified version ---
foo
foo
foo
Fatal Python error: deletion of interned string failed
KeyError: ''eyError'

Current thread 0x00007ffff7fd7740 (most recent call first):
  File "/media/nale/Data/Users/nale/project/bytejection/demo/pkg/foobarbuzz/core.py", line 8 in foo
  File "run_patch_module.py", line 78 in main
  File "run_patch_module.py", line 90 in <module>

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
  • Ubuntu 18.04, Python 3.7.4 (with gdb):
--- modified version ---
foo

Program received signal SIGSEGV, Segmentation fault.
PyFunction_NewWithQualName ()
    at /tmp/build/80754af9/python_1565725737370/work/Objects/funcobject.c:33
33	/tmp/build/80754af9/python_1565725737370/work/Objects/funcobject.c: No such file or directory.

Generated .pyc file is failed to be imported in Python 3.7

Something related to importlib.util.MAGIC_NUMBER makes it failed to import generated .pyc file.

  • Error message:
  File "demo/run_patch_module.py", line 77, in <module>
    main()
  File "demo/run_patch_module.py", line 72, in main
    modified_mod = load_module_from_path('modified', osp.join(THIS_DIR, 'modified.pyc'))
  File "demo/run_patch_module.py", line 42, in load_module_from_path
    mod = _load_module(name, path)
  File "demo/run_patch_module.py", line 31, in _load_module
    spec.loader.exec_module(mod)
  File "<frozen importlib._bootstrap_external>", line 724, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1005, in get_code
  File "<frozen importlib._bootstrap_external>", line 467, in _classify_pyc
ImportError: invalid flags 1571323424 in 'modified'
  • Value of flags is also different on Windows 7 (local environment) and repl.it:
    • Windows 7: Python 3.7.4 [MSC v.1915 64 bit (AMD64)]
      ImportError: invalid flags 1571323537 in 'modified'
      
    • repl.it: Python 3.7.4 [GCC 6.3.0 20170516]
      ImportError: invalid flags 1571323424 in 'modified'
      

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.