Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 560 Vote(s) - 3.55 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Classic ASP accessing an Array of Byte and converting it into a string

#1
To test, I am sending the data using curl like so:

curl -XPOST

[To see links please register here]

--data "{\"a\":1212321}" -H 'Content-Type: application/json'

In test.asp I have something like this:

var byteArray = Request.BinaryRead(Request.TotalBytes);

From there I try to convert each byte to a character and append it to a string, however accessing the information seems to be the issue.
This is one attempt I have tried:

var str = "";
for (var x = 0; x < Request.TotalBytes; x++) {
str += String.fromCharCode(byteArray[x]);
}

When I check in visual studio, the data looks like this:

[![display of Array of Bytes][1]][1]

Is there a better way to get data from a request?


[1]:
Reply

#2
> Accessing an Array of Byte and converting it into a string

For server-side JScript, and using your curl POST example above, try this:

var postData = null;
with (Server.CreateObject("ADODB.Stream")) {
Type = 1; // adTypeBinary
Open();
Write(Request.BinaryRead(Request.TotalBytes));
Position = 0;
Type = 2; // adTypeText
Charset = "iso-8859-1";
postData = ReadText();
Close();
}
if (postData) {
var json = null;
eval("json = " + postData);
Response.Write(json.a);
}

This solution uses the ADODB.Stream object to write-in the binary data from the Request, reset the position back to the beginning of the stream, then convert the binary data to a properly encoded string by reading it into a variable (postData). If postData exists, evaluate the JSON string as-is, then use it.


----------
> Is there a better way to get data from a request?

Perhaps. You could POST the data as 'application/x-www-form-urlencoded', then simply access the variables using Request.Form("a").

For example, try changing your curl POST command to:

curl -XPOST

[To see links please register here]

--data "a=1212321" -H 'Content-Type:application/x-www-form-urlencoded'

Then update your server-side ASP JScript code to resemble:

var str = Request.Form("a");
Response.Write(str);

Hope this is helpful.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through