capture traffic with cmd?

11 posts, 1 answers
  1. Zsolt
    Zsolt avatar
    7 posts
    Member since:
    Nov 2015

    Posted 17 Nov 2015 Link to this post

    I'm wondering if it's possible with command line to start to recording specific hosts headers, save to file and stop it? How?
  2. Zsolt
    Zsolt avatar
    7 posts
    Member since:
    Nov 2015

    Posted 17 Nov 2015 Link to this post

    I managed to do a workaround with the quickexec cls,start,stop,dump functions. there is any quickexec function where can dump/save to .txt file the selected (@host) sessions to any location? thanks
  3. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 17 Nov 2015 Link to this post

    Hello, Zsolt--

    I assume you've figured out that a command runner can use the ExecAction.exe program to invoke QuickExec commands inside Fiddler?

    Those QuickExec commands simply invoke the OnExecAction handler inside your Fiddler Rules Script (Rules > Customize Rules...). If you examine the source of that function, you can see how you can add new commands that do anything you like, implemented in JScript.NET.

    I'm not entirely clear on what you want your function to do, but you'll probably use the File.WriteAllText method (after adding import System.IO and System.Text to the list atop your script) to write a text file. You would get the list of Sessions in the Session list using FiddlerApplication.UI.GetAllSessions();

    So, maybe something like:

       case "dumphosts":
           var arrSess: Fiddler.Session[] = FiddlerApplication.UI.GetAllSessions();
           var sbAllHosts: StringBuilder = new StringBuilder();
           for (var i = 0; i < arrSess.Length; i++)
           {
               sbAllHosts.AppendLine(arrSess[i].host);
           }
          File.WriteAllText("C:\\temp\\allHosts.txt", sbAllHosts.ToString());

        return true;


    Regards,
    Eric Lawrence
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  4. Zsolt
    Zsolt avatar
    7 posts
    Member since:
    Nov 2015

    Posted 18 Nov 2015 in reply to Eric Lawrence Link to this post

    Hi, Eric

    Thanks for your reply it helps a lot! I'm trying to create my function however I'm struggling with it. What I'm trying to achieve is:
    select the specified host's (param[1]) header and save it to a file(param[2]) and/or the command line would return it. Specifically I want to get the Cookies from it at the same format how it's showing at the Raw View. 

  5. Zsolt
    Zsolt avatar
    7 posts
    Member since:
    Nov 2015

    Posted 18 Nov 2015 Link to this post

    also I read the scripteditor have intellisense feature however doesn't work for me.How can I switch that on? Can't find it
  6. Zsolt
    Zsolt avatar
    7 posts
    Member since:
    Nov 2015

    Posted 18 Nov 2015 Link to this post

    This forum really needs an edit button :D so actually intelliSense works but only if I specify the full length as FiddlerApplication.UI.andthefunctions come up here. I did import FiddlerApplication.UI; what am I missing? 
  7. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 18 Nov 2015 Link to this post

    Hello, Zsolt--

    It's hard to keep track of what your questions are. 

    Intellisense in the FiddlerScript Editor is based on the capabilities of the underlying component; various "shorthand" objects (e.g. "UI") don't have Intellisense behaviors.

    select the specified host's (param[1]) header and save it to a file(param[2]) and/or the command line would return it. Specifically I want to get the Cookies from it at the same format how it's showing at the Raw View.

    I think you're saying you want to be able to do

        ExecAction.exe "dumpcookies example.com C:\temp\CookiesFromExample.txt"

    ...is that right?

    You haven't mentioned whether you're looking for the REQUEST Cookie header or the RESPONSE Set-Cookie header?


      case "dumpcookies":
           var arrSess: Fiddler.Session[] = FiddlerApplication.UI.GetAllSessions();
           var sbAllCookies: StringBuilder = new StringBuilder();
           for (var i = 0; i < arrSess.Length; i++)
           { 
               if (arrSess[i].HostnameIs(sParams[0]))
               {
                  // Get Cookie
                  var sCookie = arrSess[i].RequestHeaders["Cookie"];
                  if (!String.IsNullOrEmpty(sCookie)){
                     sbAllCookies.AppendLine(sCookie);
                  }
           }
          File.WriteAllText(sParams[1], sbAllCookies.ToString());

        return true;





    Regards,
    Eric Lawrence
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. Zsolt
    Zsolt avatar
    7 posts
    Member since:
    Nov 2015

    Posted 18 Nov 2015 in reply to Eric Lawrence Link to this post

    Nice examples Eric! However, I realized I asked the question wrongly. I want to get the cookies of a specific URL not host. Sorry for it but your examples gave me enough knowledge to craft this:

    for selecting I wanted to use the ?sometext command which works if I do it in the gui but it isn't If I do through cmd?! How can I select the URL so after I can proceed with the savecookie script?

    case "savecookie":
            var Session = FiddlerApplication.UI.GetFirstSelectedSession();
            File.WriteAllText(sParams[1], Session.RequestHeaders["Cookie"].ToString());
            return true;
  9. Answer
    Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 18 Nov 2015 Link to this post

    You can just do this (remove the break if you want to allow multiple instances of the target URL):

      case "dumpcookies":
           var arrSess: Fiddler.Session[] = FiddlerApplication.UI.GetAllSessions();
           var sbAllCookies: StringBuilder = new StringBuilder();
           for (var i = 0; i < arrSess.Length; i++)
           { 
               if (arrSess[i].fullUrl == sParams[0])
               {
                  // Get Cookie
                  var sCookie = arrSess[i].RequestHeaders["Cookie"];
                  if (!String.IsNullOrEmpty(sCookie)){
                     sbAllCookies.AppendLine(sCookie);
    break;
                  }
           }
          File.WriteAllText(sParams[1], sbAllCookies.ToString());

        return true;


    Regards,
    Eric Lawrence
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  10. Zsolt
    Zsolt avatar
    7 posts
    Member since:
    Nov 2015

    Posted 18 Nov 2015 in reply to Eric Lawrence Link to this post

    Thanks Eric you saved my day! I appreciate it! It works like charm!

    Just add an extra closing curly bracket after the break; and change sParams[0] to sParams[1] and sParams[1] to sParams[2] if somebody else wants to use it. 

    I wasn't beware of the fullURL property
  11. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 18 Nov 2015 Link to this post

    Sorry about the typos, glad you got it working.

    In the Fiddler Script Editor, the View > Class Explorer command is a great way to learn about the object model available to you. The Fiddler Book is another good reference.

    Regards,
    Eric Lawrence
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top