Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seeing Indy Traffic in Fiddler

Tags:

delphi

indy

I think this is an easy question for someone familiar with Indy. I'm using Delphi 2010 and Indy 10. I am trying to get off the ground accessing an SSL web service. I think it will be a lot easier if I can get Fiddler to see my HTTP traffic. I have seen posts on StackOverflow that indicate it's no big thing to get Fiddler to see your Indy traffic, that you just have to configure the port to make it work. My question is how do you do that?

Here is my code so far:

procedure TForm1.Button1Click(Sender: TObject);
var slRequest: TStringList;
    sResponse,
    sFileName: String;
    lHTTP: TIdHTTP;
    lIOHandler: TIdSSLIOHandlerSocketOpenSSL;
begin
  sFileName := 'Ping.xml';
  slRequest := TStringList.Create;
  try
    slRequest.LoadFromFile(sFileName);
    lHTTP := TIdHTTP.Create(nil);
    lHTTP.Intercept := IdLogDebug1;
    lIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
    try
      lHTTP.IOHandler := lIOHandler;
      sResponse := lHTTP.Post('https://FSETTESTPROD.EDD.CA.GOV/fsetservice', slRequest);
      Memo1.Lines.Text := sResponse;
    finally
      lIOHandler.Free;
    end;
  finally
    slRequest.Free;
  end;
end;

Edit: If I don't use the proxy for Fiddler and click the button while Wireshark is running, I get this traffic in Wireshark. enter image description here

like image 313
jrodenhi Avatar asked Dec 17 '22 04:12

jrodenhi


1 Answers

You can set Indy to use the proxy fiddler provides easily by setting the ProxyParams:

try
  lHTTP.IOHandler := lIOHandler;
  lHTTP.ProxyParams.ProxyServer := '127.0.0.1';
  lHTTP.ProxyParams.ProxyPort := 8888;
  sResponse := lHTTP.Post('<URL>', slRequest);
  Memo1.Lines.Text := sResponse;
finally
  lIOHandler.Free;
end;

You should be able to see all traffic in Fiddler then.

Edit: If that does not work you can add a TIdLogDebug component and add it as interceptor (like you did in your question). The OnReceive and OnSend events contain the complete headers sent and received aswell as the reply data:

procedure TForm10.captureTraffic(ASender: TIdConnectionIntercept; 
  var ABuffer: TArray<Byte>);
var
  i: Integer;
  s: String;
begin
  s := '';

  for i := Low(ABuffer) to High(ABuffer) do
    s := s + chr(ABuffer[i]);

  Memo1.Lines.Add(s);
end;
like image 169
Chris Avatar answered Dec 30 '22 05:12

Chris