Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission denied #36

Closed
devcoinfet opened this issue Nov 1, 2021 · 4 comments
Closed

Permission denied #36

devcoinfet opened this issue Nov 1, 2021 · 4 comments

Comments

@devcoinfet
Copy link

Question why am i getting a permission denied error on one of your example scripts for running a post to a python file
no need to give any example other than it dont work lol

@devcoinfet
Copy link
Author

devcoinfet commented Nov 1, 2021

PermissionError: [Errno 13] Permission denied: './private.py'
that's as far as i'm gonna go error wise as there is no context other than tht
does not work with your example on kali or ubuntu

@devcoinfet
Copy link
Author

devcoinfet commented Nov 1, 2021

ok so a self solve

# web imports
from flask import Flask
from flask_executor import Executor
from flask_shell2http import Shell2HTTP

# Flask application instance
app = Flask(__name__)

# application factory
executor = Executor(app)
shell2http = Shell2HTTP(app, executor, base_url_prefix="/scripts/")

shell2http.register_command(endpoint="hacktheplanet", command_name="python3 ./fuxsocy.py")


# Application Runner
if __name__ == "__main__":
    app.testing = True
    c = app.test_client()
    """
    The final executed command becomes:
    ```bash
    $ ./fuxsocy.py
    ```
    """
    uri = "/scripts/hacktheplanet"
    resp1 = c.post(uri, json={"args": []}).get_json()
    print(resp1)
    # fetch result
    result_url = resp1["result_url"]
    resp2 = c.get(result_url).get_json()
    print(resp2)

this is how your script should be

than the contents of the py like so

import os
import sys

print(2*2)

and return code proving the example is flat out not working

{"end_time":1635766722.6711774,"error":"","key":"5bb35ab3","process_time":0.012186288833618164,"report":"4\n","returncode":0,"start_time":1635766722.658991}

so the problem is you were passing a python script to bash with no Interpreter

@eshaan7
Copy link
Owner

eshaan7 commented Nov 1, 2021

Hey!

PermissionError: [Errno 13] Permission denied: './private.py'

The reason you are getting PermissionError is because your user does not have the executable permission on the private.py file. Assuming you are on a unix based system, you can simply run the command chmod u+x private.py to solve this.

so the problem is you were passing a python script to bash with no Interpreter

If a python file includes the shebang statement (#!/usr/bin/env python3) on the first line and has the executable flag (x) set, then it's possible to run it by just invoking it with ./ instead of python3.

Of course your solution is fine too and maybe even better for the sake of simplicity.

@devcoinfet
Copy link
Author

devcoinfet commented Nov 2, 2021

nope tht was not it i have no permission errors simply like i showed you above when calling python via bash it needs to be prefixed with python3 the permission error was due to not using python3 before the fuxsocy.py file go figure it works though

but u make a good point shhh dont tell anyone i forgot my shebangs plz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants