Making a fiddler script to replace a number with a random number

717 views
Skip to first unread message

maca G

unread,
Aug 17, 2016, 9:46:49 PM8/17/16
to Fiddler
Hi everyone.
I need to make a script to replace a number present on a request with a random number.
Im new to fiddler and i dont really know where should i start, I already installed fiddlescript editor but i cant find a sample script so im kinda lost :/.
All i could find about this was this post https://groups.google.com/forum/#!topic/httpfiddler/zmbdm40483s
So i added import Microsoft.JScript at the top of the script but i dont know what should i do next.
Any help will be appreciated.
Thanks in advance.
Message has been deleted
Message has been deleted
Message has been deleted

maca G

unread,
Aug 17, 2016, 10:28:15 PM8/17/16
to Fiddler
I cant edit the original post but heres an update:
I didnt know i could just edit the original customrules.js
Now that i know that i just need to know how to replace a number on a request with a random generated one  using MathObject.random()}
The request looks like this:
00000100000010000:1234567890:1:3:WindowsNoEditor:1:7:0:0
I just need to replace the numbers that are in between ":" (in this case, 1234567890).

Btw do i need to download anything else to achieve this?

EricLaw

unread,
Aug 17, 2016, 10:35:11 PM8/17/16
to Fiddler
You don't need to download anything else.

What does the full request look like? Is the target text in the body? Is the request always to the same server or url?
Message has been deleted
Message has been deleted

maca G

unread,
Aug 17, 2016, 11:25:53 PM8/17/16
to Fiddler
Thanks for the reply.
The entire request would be: http://pastebin.com/ACC4ZgL3
The target text is in the body, and yes it is the same server, however the url changes a bit everytime i login for example: www.example.com/myuseridnumberhere/requestIwantToEditHere
My user id number changes everytime i login.

EricLaw

unread,
Aug 18, 2016, 8:21:15 AM8/18/16
to Fiddler
So you'd do something like this inside OnBeforeRequest:

  if (oSession.HostnameIs("api.prod.capcomfighters.net") && 
     oSession.HTTPMethodIs("POST"))
  {
       oSession.utilReplaceInRequest("form-data; name=\"game_rpt\"\n\n",
                                                          "form-data; name=\"game_rpt\"\n\n"+oSession.id);
       oSession["ui-backcolor"] = "red";
  }

You should try that first and see whether it's modifying the request in the right place. If the server is picky about the length of the number our script can get more complex...

maca G

unread,
Aug 18, 2016, 1:21:39 PM8/18/16
to Fiddler
Thanks Eric, I got it working with this one

        if (oSession.uriContains("match")){
            oSession.utilReplaceInRequest("1234567890", MathObject.random());

One more question, if I want to replace just two numbers (the server is picky about the amount of numbers in another part of the request) what should i do?

Thanks.
Message has been deleted

maca G

unread,
Aug 18, 2016, 2:59:36 PM8/18/16
to Fiddler
I will explain a little bit more. For example, i want to do this:
  1. ----PostData
  2. Content-Disposition: form-data; name="player_rpt"
  3.  
  4. 4090921472:21:3126787584:XX::::::::::::
I want to replace XX with two random numbers.

maca G

unread,
Aug 18, 2016, 10:24:17 PM8/18/16
to Fiddler
Ok, im using Math.floor(Math.random() * 98); and it works fine! It generates a random number between 0 and 97
Last question: is there any way to make it pick a number between 30 and 97 instead?
Thanks!

EricLaw

unread,
Aug 18, 2016, 11:23:45 PM8/18/16
to Fiddler
30 + Math.floor(Math.random() 68);
Reply all
Reply to author
Forward
0 new messages