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?

Fiddler でローカルホストのパケットをキャプチャする

Posted at

ローカルホストで動かしているアプリケーション(PowerShellのInvoke-WebRequest)のCookieをヘッダに設定した場合の挙動が納得いかなかったため、Fiddlerを、使ったのだが、ちょっと設定に苦労したので、メモをしておく。

ローカルホストのキャプチャを有効化する

昔は8888だった気がするが、今は違う様子。

image.png

ローカルで動くアプリのIPAddress/PortをProxyとして設定しておく。ちなみに、このポートは、私のアプリの場合、毎回変わる

image.png

ポイントは、リクエストはその端末のIPAddressで実行するのと、プロキシをFiddlerのポートに指定すること。

$result = curl -v http://192.168.xxx.xxx:54269/api/Conversation -WebSession $session -Proxy 'http://127.0.0.1:8866'

Works

image.png

ちなみに、私が調べたかったことは、上記の -WebSession を使う場合は、うまくいくのですが、自分で Cookie を指定すると無視されます。Set-Cookie から値を取得して、セットします。

$headers = @{
  Cookie = $cookie
}
$responseWithCookie = Invoke-WebRequest -Uri "http://192.168.xxx.xxx:54269/api/Conversation" -Headers $headers -Proxy 'http://127.0.0.1:8866'

image.png

ううむ。自分でセットした場合、何故か Cookie ヘッダが無視されるようです。これがクライアントレベルで起こっているので、おそらくInvoke-WebRequest 側できっとなにかやってるのだと思いますが、めんどくさいのでここまでわかればまずは良いか。

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?