WSL2のcurlをburpに経由させる
- ip制限の都合でburpのupstream proxy serversでproxyの設定をしている
- curlをしたいが、proxyに通せないのでipが変わってしまう
ということに困ったので、書く。
summary
以下で自分のグローバルipが見れる。
$ curl http://httpbin.org/ip { "origin": "xx.xx.xx.xx" }
-x
でプロキシを指定できるという記事を見つけたため、試してみる。
$ curl http://httpbin.org/ip -x http://localhost:8080 curl: (7) Failed to connect to localhost port 8080: Connection refused
localhost:8080
にburp proxyがあるはずなのに、うまくいかない
WSLあるある(?)のlocalhost問題だ。
solve
proxyのoptionsタブからipを指定する。
ipはたぶん127.0.0.1
以外だったらどれでもよさそう。ここでは192.168.33.1
を選択した。
このプロキシのipを指定して、再度curlしてみる。
$ curl http://httpbin.org/ip -x http://192.168.33.1:8080
burpに経由され、burpで編集できる状態になる。
結果、proxyのipになっているのが確認できる。
$ curl http://httpbin.org/ip -x http://192.168.33.1:8080 { "origin": "yy.yy.y.yy" }
HTTPSに対応したい
この状況だと、証明書関連の影響でHTTPSはcurlできない。
(-k
でできるようになるけど)
$ curl https://httpbin.org/ip -x http://192.168.33.1:8080 curl: (60) SSL certificate problem: self signed certificate in certificate chain More details here: https://curl.haxx.se/docs/sslcerts.html curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the web page mentioned above.
burpの証明書をcurlによしなにしてあげる必要がある。
cacert.derをダウンロードし、pemに変換。
$ openssl x509 -inform der -in cacert.der -out burp.pem
ls
とかすると、burp.pemが作成されてるはず。
それを指定してcurlしてみる。
$ curl https://httpbin.org/ip -x http://192.168.33.1:8080 --cacert burp.pem { "origin": "yy.yy.yy.yy" }
オプションの省略
何回もcurlする場合、いちいち-x
とかついてるのは不格好なので、設定ファイルに書き込んじゃう。
$ cat .curlrc proxy = "http://192.168.33.1:8080" cacert = "/home/y0d3n/burp.pem"
.culcrc
に2行書けばただcurlをするだけでburpを通して通信できる。
$ curl https://httpbin.org/ip { "origin": "yy.yy.yy.yy" }