notes

fiddler url repeater

2020-09-14

fiddlerscript

/*\nhttps://example.com/?id={@start_decimal@,@limit_decimal@}\nhttps://example.com/?id={@0@,@999@}\n*/\nstatic function OnBeforeRequest(oSession: Session) {\n\tvar regex = /{@([0-9]+)@,@([0-9]+)@}/i;\n\tvar repeater = oSession.PathAndQuery.match(regex);\n\n\tif (repeater) {\n\n\t\tvar path = oSession.PathAndQuery;\n\n\t\tvar headers = oSession.oRequest.headers;\n\t\theaders = headers.ToString();\n\t\theaders = headers.Substring(headers.IndexOf(Environment.NewLine) + 1);\n\n\t\tvar body = oSession.GetRequestBodyAsString();\n\n\t\tvar start = Int32.Parse(repeater[1]);\n\t\tvar limit = Int32.Parse(repeater[2]);\n\n\t\tfor (var x = start; x < start+limit; x++){\n\t\t\toSession.PathAndQuery = path.replace(regex, x);\n\t\t\tif (x < start+limit-1) {\n\t\t\t\tFiddlerObject.utilIssueRequest("GET " + oSession.fullUrl + " HTTP/1.1" +\n\t\t\t\t\tEnvironment.NewLine + headers.ToString().Trim() +\n\t\t\t\t\tEnvironment.NewLine + Environment.NewLine + body.Trim());\n\t\t\t}\n\t\t\tSystem.Threading.Thread.Sleep(2000);\n\t\t}\n\t}\n}\n