owtf.api.handlers package¶
Submodules¶
owtf.api.handlers.auth module¶
owtf.api.handlers.auth¶
- class owtf.api.handlers.auth.AccountActivationGenerateHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
APIRequestHandlerCreates an email confirmation mail and sends it to the user for account confirmation.
- SUPPORTED_METHODS = ['POST']¶
- post()[source]¶
Post an email verification link to the specified email.
Example request:
POST /api/v1/generate/confirm_email/ HTTP/1.1 { "email": "test@test.com", }
Example response:
HTTP/1.1 200 OK Content-Encoding: gzip Vary: Accept-Encoding Content-Type: application/json; charset=UTF-8 { "status": "success", "message": "Email send successful" }
- class owtf.api.handlers.auth.AccountActivationValidateHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
APIRequestHandlerValidates an email confirmation mail which was sent to the user.
- SUPPORTED_METHODS = ['GET']¶
- get(key_value)[source]¶
Get the email link to verify and activate user account.
Example request:
GET /api/v1/verify/confirm_email/<link> HTTP/1.1
Example response:
HTTP/1.1 200 OK Content-Encoding: gzip Vary: Accept-Encoding Content-Type: application/json; charset=UTF-8 { "status": "success", "message": "Email Verified" }
- class owtf.api.handlers.auth.LogInHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
APIRequestHandlerLogIn using the correct credentials (email, password). After successfull login a JWT Token is generated.
- SUPPORTED_METHODS = ['POST']¶
- post()[source]¶
Post login data and return jwt token based on user credentials.
Example request:
POST /api/v1/login/ HTTP/1.1 Content-Type: application/json; charset=UTF-8 { "emailOrUsername": "test@test.com", "password": "Test@34335", }
Example successful login response:
HTTP/1.1 200 OK Content-Encoding: gzip Vary: Accept-Encoding Content-Type: application/json; charset=UTF-8 { "status": "success", "message": { "jwt-token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjozNSwiZXhwIjoxNjIzMjUyMjQwfQ.FjTpJySn3wprlaS26dC9LGBOMrtHJeJsTDJnyCKNmBk" } }
Example failed login response;
HTTP/1.1 200 OK Content-Encoding: gzip Vary: Accept-Encoding Content-Type: application/json; charset=UTF-8 { "status": "fail", "message": "Invalid login credentials" }
- class owtf.api.handlers.auth.LogOutHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
APIRequestHandlerLogs out the current user and clears the cookie.
- class owtf.api.handlers.auth.OtpGenerateHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
APIRequestHandlerCreates an otp and sends it to the user for password change
- SUPPORTED_METHODS = ['POST']¶
- class owtf.api.handlers.auth.OtpVerifyHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
APIRequestHandlerValidates an otp which was sent to the user
- SUPPORTED_METHODS = ['POST']¶
- class owtf.api.handlers.auth.PasswordChangeHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
APIRequestHandlerHandles setting a new password for the verified user
- SUPPORTED_METHODS = ['POST']¶
- class owtf.api.handlers.auth.RegisterHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
APIRequestHandlerRegisters a new user when he provides email, name, password and confirm password.
- SUPPORTED_METHODS = ['POST']¶
- post()[source]¶
Post data for creating a new user as per the data given by user.
Example request:
POST /api/v1/register/ HTTP/1.1 Content-Type: application/json; charset=UTF-8 { "email": "test@test.com", "password": "Test@34335", "confirm_password": "Test@34335", "name": "test" }
Example Successful registration response:
HTTP/1.1 200 OK Content-Encoding: gzip Vary: Accept-Encoding Content-Type: application/json; charset=UTF-8 { "status": "success", "message": "User created successfully" }
Example Failed registration response:
HTTP/1.1 200 OK Content-Encoding: gzip Vary: Accept-Encoding Content-Type: application/json; charset=UTF-8 { "status": "fail", "message": "Email already exists" }
owtf.api.handlers.base module¶
owtf.api.handlers.base¶
- class owtf.api.handlers.base.APIRequestHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
BaseRequestHandler- error(message, data=None, code=None)[source]¶
An error occurred in processing the request, i.e. an exception was thrown.
- Parameters:
data (A JSON-serializable object) – A generic container for any other information about the error, i.e. the conditions that caused the error, stack traces, etc.
message (A JSON-serializable object) – A meaningful, end-user-readable (or at the least log-worthy) message, explaining what went wrong
code (int) – A numeric code corresponding to the error, if applicable
- fail(data)[source]¶
There was a problem with the data submitted, or some pre-condition of the API call wasn’t satisfied.
- Parameters:
data (A JSON-serializable object) – Provides the wrapper for the details of why the request failed. If the reasons for failure correspond to POST values, the response object’s keys SHOULD correspond to those POST values.
- on_finish()[source]¶
Called after the end of a request.
Override this method to perform cleanup, logging, etc. This method is a counterpart to prepare.
on_finishmay not produce any output, as it is called after the response has been sent to the client.
- success(data)[source]¶
When an API call is successful, the JSend object is used as a simple envelope for the results, using the data key.
- Parameters:
data (A JSON-serializable object) – Acts as the wrapper for any data returned by the API call. If the call returns no data, data should be set to null.
- write(chunk)[source]¶
Writes the given chunk to the output buffer.
To write the output to the network, use the flush() method below.
If the given chunk is a dictionary, we write it as JSON and set the Content-Type of the response to be
application/json. (if you want to send JSON as a differentContent-Type, callset_headerafter callingwrite()).Note that lists are not converted to JSON because of a potential cross-site security vulnerability. All JSON output should be wrapped in a dictionary. More details at http://haacked.com/archive/2009/06/25/json-hijacking.aspx/ and https://github.com/facebook/tornado/issues/1009
- class owtf.api.handlers.base.FileRedirectHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
BaseRequestHandler- SUPPORTED_METHODS = ['GET']¶
- class owtf.api.handlers.base.UIRequestHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
BaseRequestHandler- get_session_cookie()[source]¶
Get the session id from a cookie Returns None if no session id is stored
- set_session_cookie()[source]¶
Set a new session id cookie new session id is returned Session id cookie is not encrypted, so other services on this domain can read it.
- property template_context¶
owtf.api.handlers.config module¶
owtf.api.handlers.config¶
- class owtf.api.handlers.config.ConfigurationHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
APIRequestHandlerUpdate framework settings and tool paths.
- SUPPORTED_METHODS = ['GET', 'PATCH', 'OPTIONS']¶
- get()[source]¶
Return all configuration items.
Example request:
GET /api/v1/configuration HTTP/1.1 Accept: application/json
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "status": "success", "data": [ { "dirty": false, "key": "ATTACHMENT_NAME", "descrip": "Filename for the attachment to be sent", "section": "AUX_PLUGIN_DATA", "value": "report" }, { "dirty": false, "key": "BRUTEFORCER", "descrip": "", "section": "DICTIONARIES", "value": "hydra" }, ] }
- patch()[source]¶
Update configuration item
Example request:
PATCH /api/v1/configuration/ HTTP/1.1 Accept: */* Content-Type: application/x-www-form-urlencoded; charset=UTF-8 X-Requested-With: XMLHttpRequest
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "status": "success", "data": null }
owtf.api.handlers.health module¶
owtf.api.handlers.health¶
- class owtf.api.handlers.health.HealthCheckHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
APIRequestHandlerAPI server health check
- SUPPORTED_METHODS = ['GET']¶
owtf.api.handlers.index module¶
owtf.api.handlers.index¶
- class owtf.api.handlers.index.IndexHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
UIRequestHandlerServes the main webapp
- SUPPORTED_METHODS = ['GET']¶
- get(path)[source]¶
Render the homepage with all JavaScript and context.
Example request:
GET / HTTP/1.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Example response:
HTTP/1.1 200 OK Content-Encoding: gzip Vary: Accept-Encoding Server: TornadoServer/5.0.1 Content-Type: text/html; charset=UTF-8
owtf.api.handlers.jwtauth module¶
JSON Web Token auth for Tornado
owtf.api.handlers.misc module¶
owtf.api.handlers.plugin module¶
owtf.api.handlers.report module¶
owtf.api.handlers.session module¶
owtf.api.handlers.session¶
- class owtf.api.handlers.session.OWTFSessionHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
APIRequestHandlerHandles OWTF sessions.
- SUPPORTED_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']¶
- delete(session_id=None, action=None)[source]¶
Delete a session.
Example request:
DELETE /api/v1/sessions/2 HTTP/1.1 X-Requested-With: XMLHttpRequest
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "status": "success", "data": null }
- get(session_id=None, action=None)[source]¶
Get all registered sessions.
Example request:
GET /api/v1/sessions/ HTTP/1.1 Accept: application/json, text/javascript, */*; q=0.01 X-Requested-With: XMLHttpRequest
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "status": "success", "data": [ { "active": true, "name": "default session", "id": 1 } ] }
- patch(session_id=None, action=None)[source]¶
Change session.
Example request:
PATCH /api/v1/sessions/1/activate HTTP/1.1 X-Requested-With: XMLHttpRequest
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "status": "success", "data": null }
- post(session_id=None, action=None)[source]¶
Create a new session.
Example request:
POST /api/v1/sessions/ HTTP/1.1 Content-Type: application/x-www-form-urlencoded; charset=UTF-8 X-Requested-With: XMLHttpRequest name=google-vrp
Example response:
HTTP/1.1 201 Created Content-Type: application/json { "status": "success", "data": null }