-
Notifications
You must be signed in to change notification settings - Fork 855
/
__init__.py
64 lines (45 loc) · 1.66 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from flask import Blueprint
from objection.utils.plugin import Plugin
class ApiLoader(Plugin):
"""
ApiLoader is a plugin that includes an API.
This is just an example plugin to demonstrate how you
could extend the objection API add your own endpoints.
Since this plugins namespace is called api, the urls in
our http_api method will therefore be:
http://localhost/api/ping
http://localhost/api/pong
For more information on Flask blueprints, check out the
documentation here:
https://flask.palletsprojects.com/en/1.1.x/blueprints/
"""
def __init__(self, ns):
"""
Creates a new instance of the plugin
:param ns:
"""
implementation = {}
super().__init__(__file__, ns, implementation)
self.inject()
def http_api(self) -> Blueprint:
"""
The API endpoints for this plugin.
:return:
"""
# sets the uri path to /api in this case
bp = Blueprint(self.namespace, __name__, url_prefix='/' + self.namespace)
# the endpoint with this function as the logic will be
# /api/ping.
# that's because the url_prefix is the namespace name,
# and the endpoint is /ping
@bp.route('/ping', methods=('GET', 'POST'))
def ping():
return 'pong'
@bp.route('/version', methods=('GET', 'POST'))
def version():
# call getVersion via the Frida RPC for this plugins
# agent, defined in index.js
return self.api.get_version()
return bp
namespace = 'api'
plugin = ApiLoader