How can i use Jalangi framework in my use case
wa-sunlab opened this issue · 16 comments
Hello Sir,
I am student of Master degree and need your help regarding your Jalangi Framework.
My use case is i would like to avail Jalangi API in my chrome extension.
How is it possible to use this frame work in Chrome extension so that i can use Jalangi API functionality to analyse and debug the code bieng executed in currently by browser.
Basically i would like to create chrome dev tool extension where i would like to debug some 3rd party JS libraries. But for that i really need the hooks functionality provided by Jalangi framework.
I shall be very thankfull to you if you can guide me.
Best Regards
Waqas Abbas
I am not too familiar with Chrome extensions, but to use Jalangi, you would need to be able to intercept scripts before they are loaded by the browser, so they can be instrumented before they are loaded. Is this possible?
Depending on your use case, you might be better off using one of the standard methods for instrumenting web apps documented in the README; see the "Analysis in a browser..." examples.
Thanks for quick reply,
Is it possible to instrument js code pure on client side , without node.js ?
I am wondering how this demo is working purely on client
http://people.eecs.berkeley.edu/~gongliang13/jalangi_ff/demo_integrated.htm
The linked demo does perform instrumentation within a browser; that is certainly possible. I thought you wanted to instrument the code of some remote web site before it is loaded by the browser. What exactly is your use case?
If you just want to run instrumentation within the browser, we can try to write some better instructions for that.
Thanks for your reply.
My use case is that I would like to write a an extension to chrome dev tool, Where user will be able to debug JS libraries like "Bacon.js" .
Problem i have is at the runtime i did not have access to local stack / local variables that does not have global access.
For that problem i thought to use Jalangi , So that i will be able to instrument the code in browser and can use Jalangi API to get access to local variables through Jalangi hooks. And i thought this will be done in chrome (only client side , where i will not have node.js)
So in short in my chrome extension i will have all the js loaded to the browser , then i will instrument it through jalangi and will use instrumented code in writing my debugger for 3rd party libraries.
I hope this makes bit clear.
If so then please guide me.
Best Regards
Waqas Abbas
@wa-sunlab No way to do this in Chrome. No APIs for HTTP responses. You have to use mitmproxy or stuff like that.
@csujedihy How this is working in demo ?
http://people.eecs.berkeley.edu/~gongliang13/jalangi_ff/demo_integrated.htm
@JacksonGL can you give some advice here?
It would be great if someone can come up with a robust technique to instrument JavaScript on-the-fly in Chrome. I spent quite a bit of time to find a solution.
Can we get uncompressed JS code used in demo
http://people.eecs.berkeley.edu/~gongliang13/jalangi_ff/demo_integrated.htm
Which is performing instrumentation in demo.
Best Regards
Waqas Abbas
@wa-sunlab The demo does not instrument all code on the entire web page, it only dynamically instruments user's input code and those predefined example code snippets. The demo page's logic already contains Jalangi's framework code. In your case, you need to dynamically insert Jalangi's framework code before the web page is loaded. Like @csujedihy said, there is probably no APIs for HTTP responses for now. So you cannot insert Jalangi's framework code before running any JS code in a web page by just using the Chrome API (Jalangi2 provides an option to instrument browser code through mitmproxy). Firefox provides API to intercept and modify HTTP responses though.
@JacksonGL i need to use Jalangi to just instrument js code as it is bieng done in demo. The logic to intercept web page js will be done separetly. This is how i am doing it already.
- with window.stop i am pausing loading of web page .
- with my own script i call the same url with xml http request. Then i inert ( change ) the type of js source to something else so that it will not run.
- i instrument the js code with jalangi
- insert the instrumented code back to page with eval.
You can see code here in the stackoverflow answer
http://stackoverflow.com/a/40400038
The problem i have is on step 3 currently i am using compressed version of jalangi js code that i have took from jalangi demo page. I need the uncopressed code so that i can make enhansments if required.
I hope this will clear my use case more.
Please help. Many thanks in advance.
@JacksonGL you said that demo page logic already contains jalangi framework code . I see that but that is minified code . Is it possible to get orignal code that corrspond to that minified code ?
@wa-sunlab hello, I want to analyze the javascript files in the chrome extension, but when I was debugging in the browser, I met this error:"chrome" is not defined. The reason is using the chrome.extension.sendmessage
function in the js file. Do you know how to deal with this problem and how do you analyze the 3th party JS with jalangi2 ?
Thank you very much!
Xufen Mei.
meixufen@whu.edu.cn
@meixufen https://github.com/csujedihy/jalangi2-Chrome
Check out this one, a chrome extension for jalangi2.
@csujedihy thank you so much!