Exemplo n.º 1
0
# system imports
import requests

# 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="/cmd/")

ENDPOINT = "echo"

shell2http.register_command(endpoint=ENDPOINT, command_name="echo")


@app.route("/")
def test():
    """
    The final executed command becomes:
    ```bash
    $ echo hello world
    ```
    """
    url = f"http://localhost:4000/cmd/{ENDPOINT}"
    data = {"args": ["hello", "world"]}
    resp = requests.post(url, json=data)
Exemplo n.º 2
0
# system imports
import os
import logging

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

# Globals
app = Flask(__name__)
executor = Executor(app)
shell2http = Shell2HTTP(app, executor)

# with this, we can make http calls to the endpoint: /peframe
shell2http.register_command(endpoint="peframe", command_name="peframe")

# Config
CONFIG = {
    "SECRET_KEY": __import__("secrets").token_hex(16),
}
app.config.update(CONFIG)

# Application Runner
if __name__ == "__main__":
    app.run(port=4000)
else:
    # get flask-shell2http logger instance
    logger = logging.getLogger("flask_shell2http")
    # logger config
    formatter = logging.Formatter(
Exemplo n.º 3
0
from flask import Flask
from flask_executor import Executor
from flask_shell2http import Shell2HTTP

# Flask application instance
app = Flask(__name__)

executor = Executor(app)
shell2http = Shell2HTTP(app=app, executor=executor, base_url_prefix="/api/")

def my_callback_fn(context, future):
  # optional user-defined callback function
  print(context, future.result())

shell2http.register_command(endpoint="execute", command_name="behave", callback_fn=my_callback_fn, decorators=[])
Exemplo n.º 4
0
# 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="./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()
Exemplo n.º 5
0
import time
import subprocess
import re
import select
import html


class vars:
    cache_dict = {}
    last_time = int(time.time())


app = Flask(__name__)
executor = Executor(app)
shell2http = Shell2HTTP(app=app,
                        executor=executor,
                        base_url_prefix="/rainbow/cmd/")
shell2http.register_command(endpoint="rcrack",
                            command_name="./lookup.sh",
                            decorators=[])
SECRET_KEY = "CSRF"
app.config['SECRET_KEY'] = SECRET_KEY


class HashForm(FlaskForm):
    hash = StringField('Hash', validators=[DataRequired()])
    submit = SubmitField('Lookup')


@app.route('/rainbow', methods=['GET', 'POST'])
def lookup():
Exemplo n.º 6
0
# system imports
import requests
import tempfile

# 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()
executor.init_app(app)
shell2http = Shell2HTTP(base_url_prefix="/cmd/")
shell2http.init_app(app, executor)

ENDPOINT = "catthisformeplease"

shell2http.register_command(endpoint=ENDPOINT, command_name="strings")


@app.route("/")
def test():
    """
    Prefix each filename with @ in arguments.\n
    Files are stored in temporary directories which are flushed on command completion.\n
    The final executed command becomes:
    ```bash
    $ strings /tmp/inputfile /tmp/someotherfile
Exemplo n.º 7
0
from flask import Flask
from flask_executor import Executor
from flask_shell2http import Shell2HTTP

app = Flask(__name__)
executor = Executor(app)
shell2http = Shell2HTTP(app=app, executor=executor, base_url_prefix="/commands/")

shell2http.register_command(endpoint="saythis", command_name="echo")
shell2http.register_command(endpoint="rasa", command_name="rasa")
# shell2http.register_command(endpoint="bash", command_name="bash")

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=4000)