GithubHelp home page GithubHelp logo

Permission denied about flask-shell2http HOT 4 CLOSED

eshaan7 avatar eshaan7 commented on July 17, 2024
Permission denied

from flask-shell2http.

Comments (4)

devcoinfet avatar devcoinfet commented on July 17, 2024

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

from flask-shell2http.

devcoinfet avatar devcoinfet commented on July 17, 2024

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

from flask-shell2http.

eshaan7 avatar eshaan7 commented on July 17, 2024

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.

from flask-shell2http.

devcoinfet avatar devcoinfet commented on July 17, 2024

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

from flask-shell2http.

Related Issues (20)

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.