Giter Club home page Giter Club logo

api-tool's Introduction

Raxis API Tool

The Raxis API tool is a simple Node.js class built for assessing API endpoints. The class is designed to be fully extensible and modifiable to support many different types of JSON-based REST APIs. It automatically handles token-based authentication, proxies requests, and exposes several functions designed to make it easier and faster to write a wrapper around an API and associated test code for the purposes of a penetration test.

This tool is not designed to work on its own, but to serve as a building block and quickstart for code-based API penetration testing.

Getting Started

These instructions will help you get set up to start building off the tool to assess an API.

Prerequisites

You'll need a few things in order to start building off of the Raxis API Tool:

  • A working knowledge of ES6 JavaScript.
  • A REST API and associated documentation.
  • Node.js 8.x.x installed on your machine (https://nodejs.org/en/).

Installing

For most use cases, you can simply download or clone this repository and enter into the /test directory, and create a new test file to start coding.

git clone https://github.com/RaxisInc/api-tool.git
cd api-tool/tests
touch my-api.js

Configuration Files

You can specify your API configuration in a .json file and require it in your test code, or you can use a JavaScript object. Configuration files can be stored in the api-tool/config directory for cleanliness. Here's an example configuration file:

{
  "host": "https://api.yourapp.com:3000",
  "username": "admin",
  "password": "password",

  "proxy": null,
  "endpoints": {
    "token": "/this/endpoint/is/required",
    "anotherEndpoint": "/specify/other/endpoints/here/",
    ...
  }
}

Configuration files can be included in your test JavaScript file like this:

const myApiConfig = require('../config/my-api.json');

To use a configuration file, simply pass it as the first parameter in the constructor of your extended APITool class:

const myAPI = new MyAPI(myApiConfig);

Writing Tests

To write tests, require and extend the base APITool class. Use ES6 syntax, supported by Node 8.x.x, to do this. Once the class is extended, add methods to correspond to each of the API methods you wish to test. You can access the endpoints defined in the configuration file as shown below, which is great in the event that they should change.

const APITool = require('../lib/api-tool');
const myAPIConfig = require('../config/my-api.json');

class MyAPI extends APITool {
    deleteUser(id) {
        // Note: this will return a promise. Use the async/await functions to have the easiest time with these.
        return this.doDelete(`${this.endpoints.user}/${id}`, APITool.Auth.Token);
    }
}

const api = new MyAPI(myAPIConfig);
api.deleteUser('10057286').then(console.log).catch(console.error);

Example Code

See test/example.js for an example of how to extend the APITool class and write tests.

Support

Raxis does not provide assistance with APITool. It's yours to use and do with as you please, but we can't help you if something goes wrong. Raxis does not condone unauthorized or illegal testing by releasing this code, and is not liable for any parties that chose to do so.

Author

This API tool was written by and is currently maintained by Adam Fernandez, Lead Application Developer and Senior Penetration Tester at raxis.com.

api-tool's People

Contributors

m3puckett avatar xarmin-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.