3S Labs Banner

Sunday, September 2, 2012

Keystroke Logging within the Browser

During a recent PenTest, we had to exploit a typical Cross Site Scripting vulnerability in a Rich Internet Application which was making heavy use of Javascript and Ajax to present an almost Desktop like UI. The objective was to prove the severity of XSS vulnerabilities, as the client was not satisfied with a mere /XSS/ popup - even though so many examples exist on the open web.

The result of our effort was to show the client an almost real time keystroke logging by exploiting a Cross Site Scripting vulnerability in his application's console. Although there is a fairly stable Javascript Keylogger available here, we wrote our own as our requirement was quite specific, something as below:


The log transfer code is intentionally removed however it is trivial to transfer the data to any predefined location by injecting iframe or img tag or perhaps even with Ajax and CORS.

Although it is perhaps trivial to write a JavaScript Key Logger and in most cases probably it is unnecessary to use such payload as using an XSS bug a target user's session can itself be hijacked, however it might be useful in certain unconventional cases.

  • Consider the case of Rich Internet Applications where the entire UX is Javascript driven and the page is never refreshed or re-loaded. Considering various near real-time use-cases like Chat, Message Ticker, Notification Message etc in the web console, it is sometime desirable to sniff user's activities which otherwise is not recorded by the application. In such a case, it might be useful to have a JS Keylogger payload handy for use with an XSS bug.
  • Major browser plugins are written in Javascript and hence one cannot rule out the possibility of infecting plugins with malicious code. Perhaps this is particularly desirable for various banking trojans as a stealth alternative.
  • Conventionally a keylogger for Win32 platform is written using the SetWindowsHookEx API. A defensive application such as an AV or an HIPS can reliably detect keyloggers at runtime by inspecting SetWindowsHookEx API. However if the objective is to log keystrokes on the browser only then it might be possible to use Form Grabbing like technique to inject malicious JS code by using eval like APIs.



7 comments:

  1. Good Screen monitoring software will help you to log and trace all your computer's activities and IP address even though you are away from your computer.

    ReplyDelete
  2. Here, I will portray the full arrangement of fundamental activities to effectively kill substantial tainting. It is improbable that you should play out each of these focuses, however there is such a plausibility. Along these lines, we should continue to the evacuation!
    https://how-to-remove.org/malware/browser-hijacker-removal/gotowebs-com-removal/

    ReplyDelete
  3. I think that all the programmers should learn this part of programming due to the fact it grants understanding of how do all the security systems work.

    ReplyDelete
  4. My programmer in my company told recently we had the same problem. But he solved it quickly )) Thank you for sharing! Do you know this keylogger software https://www.refog.com/keylogger/ ? I found it yesterday and a lot of people say it is very good!

    ReplyDelete
  5. View some hacking apps and security related tips at this page http://topspying.com/ikeymonitor/

    ReplyDelete
  6. I really loved reading your blog. It was very well authored and easy to undertand. Unlike additional blogs I have read which are really not tht good. I also found your posts very interesting. In fact after reading, I had to go show it to my friend and he ejoyed it as well! UC mini

    ReplyDelete
  7. I just found this blog and have high hopes for it to continue. Keep up the great work, its hard to find good ones. I have added to my favorites. Thank You. Search Bar Firefox 57 Quantum addon

    ReplyDelete