npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

axios-burp

v1.0.16

Published

A library that convert axios object to burp-like repeater

Downloads

25

Readme

Axios-Burp convertor

If you have ever using Burp, you must have encountered HTTP requests logs (in repeater, intruder, http log, etc), for example:

POST /admin HTTP/1.1
Host: test.test.com
Connection: close
Content-Length: 21
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: https://test.test.com
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,vi;q=0.8

user=admin&pass=admin

And if you have ever using Axios, the following code snippet might look familiar to you:

async function example() {
  const opt: AxiosRequestConfig = {
    method: 'GET' as Method,
    url: `${packet.origin}${packet.path}`,
    data: body,
  }
  const resp = await axios.request(opt);
  // ...
}

axios-burp is a simple library to convert burp HTTP message to axios request option and vice-versa.

However, to keep the logic simple, axios-burp re-define AxiosRequest type, please see Usage below.

Installation

Install with npm:

npm i axios-burp --save

Install with yarn:

yarn add axios-burp

Usage

First, let's define type of AxiosRequest.

interface AxiosRequest {
  url: string;
  httpVersion?: string;
  method?: HttpMethod;
  headers?: string[];
  body?: string;
}

| Property | Description | Type | Required | :------------- |:-------------: | :-----:| :-----:| | url | The full url or only path | string | ✔️ | | httpVersion | The http version (Default "HTTP/1.1") | string | | | method | The http method (Default "GET") | string | | | headers | The http headers (Default []) | string[] | | | body | The http body (Default "") | string | |

requestToBurp(req: AxiosRequest [, autoAddHeader: boolean])

This function parses AxiosRequest to Burp-like HTTP msg string. Passing autoAddHeader=true results in adding Origin header and Host header. However, if AxiosRequest already contains Origin or Host headers, the result will priority AxiosRequest more.

const { requestToBurp } = require('axios-burp');
const msg = requestToBurp({
  url: 'https://google.com:3434/ayyo/../dcm',
  body: 'yooo',
}, true);
console.log(msg);

Returns:

GET /ayyo/../dcm HTTP/1.1
Host: google.com:3434
Origin: https://google.com:3434
Content-Length: 4
Connection: close

yooo

burpToRequest(burp: string)

This function parses HTTP msg string to AxiosRequest. If there is Origin header presented, the result url will be the full url; or else the result url only contains the path.

This function tries to parse using \r\n first, if failed it will parse using \n .

const { burpToRequest } = require('axios-burp');
const burp =
`OPTIONS /ayyoHTTP/1.1yo?a=1 HTTP/1.1
Test: close
WTF: Test

this is my body`

const obj = burpToRequest(burp);
console.log(obj)

returns

{
  method: 'OPTIONS',
  url: '/ayyoHTTP/1.1yo?a=1',
  body: 'this is my body',
  headers: [ 'Test: close', 'WTF: Test' ],
  httpVersion: 'HTTP/1.1'
}

License

The project is released under the MIT license.

Credits

phvietan