Firebug binary variable - javascript

Hy,
I have a binary array that comes from deflating a string using this library.
I want to see the contents of the array in hex in firebug's console.
It's possible to do this? If it's possible, how can I do?
Of course, I tried console.log(array) in raw_deflating.js but it shows some garbage(of course, because it's binary)
I searched a lot on net, and surprisingly no one has asked this before.
Thank you,

I'll answer to my own question, if someone will have the same question:
Unfortunately, Firebug hasn't this feature. You can't see in debugger the hex value of a variable.
But, in my particular case, I was able to see the dec value of the variables directly from JavaScript, because the char array comes from String.fromCharCode(buff[j]);.
So, if you have a byte array, you can inspect the content using JS function String.charCodeAt()

Related

How to decompile this?

I am decompiling a google chrome extension, because it seems suspicious.
The extension was written in javascript, but can somebody tell me exactly what symbols like this are, and how to "translate" them back to normal strings?
"\x63\x68\x61\x72\x43\x6F\x64\x65"
Jsbin of the full file:
http://jsbin.com/OnEviRa/1/
the code seems to be using an array to hide all the strings, and they seemed to have changed variable names to hide their meaning.
I can't give you a good automated way to change variable names to something meaningful, but the strings are easy.
you can evaluate the array, then use a regex to replace all occurences of _0x13d2[number] with "evaluated result".
here is a fiddle of it

What is the maximum length that $.parseJSON() can handle?

I have a long json array that needs to be sent to an html5 mobile app and parsed. The whole array has around 700kb (gziped to 150kb) and it's 554976 characters long at the moment. But it will increase on time.
Using jquery to parse the json, my app crashes while trying to parse it. And so does jsonlint, json parser.fr and any other online json validator I try, so I'm guessing eval() is not an option either.
Might be a broad question but what is the maximum "acceptable" length for a json array?
I have already removed as much data as I can from the array, the only option I can think of is to split the array in 3-4 server calls and parse it separately in the app. Is there any other option?
EDIT
Thanks to #fabien for pointing that if jsonlint crashes there is a problem on the json. There was a hidden "space" character in one of the nodes. It was parsed correctly on the server but not on the client.
I've parsed way bigger arrays with jquery.
My first guess is that there's an error in your json.
You have many ways to find it (sublime text could highlight the error but some time, it's a bit long). Try to paste it in a web tool like http://www.jsoneditoronline.org/. and use any of the buttons (to format or to send to the right view). It'll tell you where the error is.

How to find, where the Javascript keeps an Object I am interested in?

There is a website, which does POST, and I want to know, where parameters are stored. I need it to hack them, edit before posting. Scripts are huge and obfuscated, so I can't find the Objects I need just by reading the source code.
I've tried to serialize the window with JSON.prune from this answer. The keyword, which I use to find, where the string I need is stored, was found near 40 times in 28 megabytes of text. And it is not very readable even after I found substrings. So maybe it is not the way to go.
I need something which would tell me:
this substr has been detected in:
-- the String window.bla_bla_bla.deepobject.bla[5].blabla.msg_to_post
-- the String window.bla_bla_bla.deepobject.bla[3].and_here
-- the String window.and_even_here
-- etc.
First, find the function that send POST request.
Is request sent when you click button? visual event can help you find it.
Next, Read the function and overwrite it with your own.
If scripts are minified, use beautifier like this
Normally, with Chrome developer tool and visual event I got all thing want to know.

Unable to debug an encodded javascript?

I’m having some problems debugging an encoded javacscript. This script I’m referring to given in this link over here.
The encoding here is simple and it works by shifting the unicodes values to whatever Codekey was use during encoding. The code that does the decoding is given here in plain English below:-
<script language="javascript">
function dF(s){
var s1=unescape(s.substr(0,s.length-1)); var t='';
for(i=0;i<s1.length;i++)t+=String.fromCharCode(s1.charCodeAt(i)-s.substr(s.length- 1,1));
document.write(unescape(t));
}
</script>
I’m interested in knowing or understanding the values (e.g s1,t). Like for example when the value of i=0 what values would the following attributes / method would hold
s1.charCodeAt(i) and s.substr(s.length-1,1)
The reason I’m doing this is to understand as to how a CodeKey function really works. I don’t see anything in the code above which tells it to decode on the basis of codekey value. The only thing I can point in the encoding text is the last character which is set to 1 , 2 ,3 or 4 depending upon the codekey selected during encoding process. One can verify using the link I have given above.
However, to debug, I’m using firebug addon with the script running as localhost on my wamp server. I’m able to put a breakpoint on the js using firebug but I’m unable to retrieve any of the user defined parameters or functions I mentioned above.
I want to know under this context what would be best way to debug this encoded js.

Where to start with JSON? (Closed)

I'm trying to get started with JSON. I've set the link to the JSON.js file using a script link, and I've set my objects using JSON, but it returns no results at all when I try to refer to the object. The JSON doesn't seem to be working at all. If anyone could point me in the right direction it'd be appreciated. I've looked all over the internet and haven't found much to help me.
Thanks guys. The JSON website helped me figure it out
Get Firefox, get Firebug, learn to use it to see what javascript is being loaded, and where the errors are.
Oh, and post some code.
Take a look-see at this
http://json.org/
basically you need to understand that json is a way to stream javascript object literals and arrays from a server to the client (and vice-versa). Open up firebug/webkit and in the console try
var obj = JSON.parse('{"test": 1}')
and you will see that obj is an object literal with a test property.
edit -- note that the link I provided mentions that json is a "is a lightweight data-interchange format" -- so its does not need to be javascript specific. But I think in practice you will get the most mileage using json in conjunction with javascript.
Here's a couple of links that might help:
http://secretgeek.net/json_3mins.asp
http://www.hunlock.com/blogs/Mastering_JSON_(_JavaScript_Object_Notation_)

Categories

Resources