0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

BurpでAxiosのHTTPS通信をのぞき見る

Posted at

Burpを使ってAxiosの通信内容を確認する方法です。

要点は、burp+ブラウザの場合とは異なりトンネルの確立を明示的にやらなければならない、ということです。

証明書の準備

derファイルを出力

BurpのProxyタブ→Optionタブから、Import / export CA certificateをクリックし、ウィザードでCertificate in DER formatを選択してder形式で(以下ではout.der)出力します。

derをpemに変換

以下のコマンドを実行して、derファイルをpem形式(以下ではcert.pem)に変換します。

openssl x509 -inform der -in out.der -out cert.pem

以下では生成したpemをスクリプトと同一のディレクトリに置くものとします。

スクリプト

ライブラリの準備

axios,fsの他にtunnelを使います。

コード

axios-burp.ts

import axios from "axios";
import * as fs from "fs";
import * as tunnel from "tunnel";

async function main() {
    try {
        const agent = tunnel.httpsOverHttp({
            // Burp
            proxy: {
                host: "127.0.0.1",
                port: 8080
            },
            ca: [fs.readFileSync("./cert.pem")]
        });

        await axios.get("https://postman-echo.com/get?foo1=bar1&foo2=bar2", {
            httpsAgent: agent
        });
    } catch (e) {
    }
}

main();

実行結果

% ts-node axios-burp.ts
{
  args: { foo1: 'bar1', foo2: 'bar2' },
  headers: {
    'x-forwarded-proto': 'https',
    'x-forwarded-port': '443',
    host: 'postman-echo.com',
    'x-amzn-trace-id': 'Root=1-5fc6e5e4-36f4714f2d2c8a9a5d91149d',
    accept: 'application/json, text/plain, */*',
    'user-agent': 'axios/0.21.0'
  },
  url: 'https://postman-echo.com/get?foo1=bar1&foo2=bar2'
}

axios-burp.png

この他にもaxios.getのオプションでproxyを指定して(このときscheme"https"を指定しないとエラー)、burpのinvisible proxyを有効にすることで、tunnelを使わずに通信内容をのぞき見ることが可能です。ただし、この方法だとクライアントとburpの間の通信(CONNECTリクエストなど)を観察できないので1、上の方法がおすすめです。

参考リンク

プロキシを介したHTTPS通信のしくみについては以下の記事が参考になりました。
[HTTPSとCONNECTメソッド - ITの窓辺から]
(http://realizeznsg.hatenablog.com/entry/2018/08/07/070000)

  1. burpから見る方法はないのだろうか?

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?