(lower v2.02) Details of global objects - ngduyquockhanh/JScriptor GitHub Wiki

jsrequest

jsrequest object have many method for user to hook to request before it will be send.

With request, return of method will be shown below

POST /?b=1&c=2 HTTP/1.1
Host: localhost:3000
User-Agent: test
Accept: */*
Accept-Language: vi-VN,vi;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Content-Type: application/json
Content-Length: 7

{"a":1}

bodyToString()

  • return a string of request's body
{"a":1}

contenType()

  • return a string of content type
JSON

headers()

  • return a list of request's header
[Host: localhost:3000, User-Agent: test, Accept: */*, Accept-Language: vi-VN,vi;q=0.8,en-US;q=0.5,en;q=0.3, Accept-Encoding: gzip, deflate, br, Content-Type: application/json, Content-Length: 7]

httpService()

  • return a string of http service
http://localhost:3000

httpVersion()

  • return a string of http service
HTTP/1.1

method()

  • return a string of http method
POST

path()

  • return a string of http path
/?b=1&c=2

url()

  • return a string of request url
http://localhost:3000/?b=1&c=2

withAddedHeader(String name, String value)

  • return a HttpRequest object with the added header Script below will add Header Hash:123 to http request
jsrequest.withAddedHeader("Hash", "123")

Modified request:

POST /?b=1&c=2 HTTP/1.1
Host: localhost:3000
User-Agent: test
Accept: */*
Accept-Language: vi-VN,vi;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Content-Type: application/json
Content-Length: 7
Hash: 123

{"a":1}

witHeader(String name, String value)

  • return a HttpRequest object with the added header (if header exists, it will be updated) Script below will add Header Hash:123 to http request
jsrequest.withHeader("Hash", "123")

Modified request:

POST /?b=1&c=2 HTTP/1.1
Host: localhost:3000
User-Agent: test
Accept: */*
Accept-Language: vi-VN,vi;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Content-Type: application/json
Content-Length: 7
Hash: 123

{"a":1}

withBody(String body)

  • return a HttpRequest object with updated body Script below will update http request body to a=1
jsrequest.withBody("a=1")

Modified request:

POST /?b=1&c=2 HTTP/1.1
Host: localhost:3000
User-Agent: test
Accept: */*
Accept-Language: vi-VN,vi;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Content-Type: application/json
Content-Length: 3

a=1

withMethod(String method)

  • return a HttpRequest object with updated method Script below will update http method to GET
jsrequest.withMethod("GET")

Modified request:

GET /?b=1&c=2 HTTP/1.1
Host: localhost:3000
User-Agent: test
Accept: */*
Accept-Language: vi-VN,vi;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Content-Type: application/json
Content-Length: 7

withPath(String path)

  • return a HttpRequest object with updated path Script below will update http method to path to /?d=1
jsrequest.withPath("/?d=1")

Modified request:

POST /?d=1 HTTP/1.1
Host: localhost:3000
User-Agent: test
Accept: */*
Accept-Language: vi-VN,vi;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Content-Type: application/json
Content-Length: 7

{"a":1}

withRemovedHeader(String name)

  • return a HttpRequest object with removed header Script below will remove User-Agent header
jsrequest.withRemovedHeader("User-Agent")

Modified request:

POST /?b=1&c=2 HTTP/1.1
Host: localhost:3000
Accept: */*
Accept-Language: vi-VN,vi;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Content-Type: application/json
Content-Length: 7

{"a":1}

jsreponse

jsresponse object have many method for user to hook to reponse before it return to user. Like jsrequest, it have many method:

bodyToString()

  • like jsrequest, but return string of Http Response

cookies()

  • return list of cookies

headers()

  • return list of header

httpVersion()

  • return version of HTTP

statusCode()

  • return status code of http response

withAddedHeader(String name, String value)

  • return a HttpResponse object with added header

withBody(String body)

  • return a HttpResponse object with modified body

withHttpVersion(String httpVersion)

  • return a HttpResponse object with modify http version

withReasonPhase(String reasonPhase)

  • return a HttpResponse object with modify http reason phase (Like "OK")

withRemovedHeader(String name)

  • return a HttpResponse object with removed header

withStatusCode(short statusCode)

  • return a HttpResponse object with modified status code

withUpdatedHeader(String name, String value)

  • return a HttpResponse objection with updated header

jsvariable

jsvariable is a object which help save variable in burp project and get variable from burp project

setString(String key, String value)

  • set value with key identify

getString(String key)

  • get value with key

jsresult

jsresult is a object which have to be pass in the end of code to modify request/response.

Struct of jsresult is:

{
"request" : null,
"response" : null
}
  • request is where you pass HttpRequest to modify request
  • responseis where you pass HttpResponse to modify response Example: If you want to modify request with adding a header
jsresult.request= jsrequest.withAddedHeader("hash", "123");
jsresult;