Launch Exploits Against Internal Network: sonar.js

A framework for identifying and launching exploits against internal
network hosts. Works via WebRTC IP enumeration, WebSocket host scanning,
and external resource fingerprinting.

How does it work?

Upon loading the sonar.js payload in a modern web browser the following will happen:

  • sonar.js will use WebRTC to enumerate what internal IPs the user loading the payload has.
  • sonar.js then attempts to find live hosts on the internal network via WebSockets.
  • If a live host is found, sonar.js begins to attempt to fingerprint the host by linking to it via <img src=”x”> and <link rel=”stylesheet” type=”text/css” href=”x”> and hooking the onload
    event. If the expected resources load successfully it will trigger the
    pre-set JavaScript callback to start the user-supplied exploit.


sonar.js works off of a database of fingerprints. A fingerprint is
simply a list of known resources on a device that can be linked to and
detected via onload. Examples of this include images, CSS stylesheets, and even external JavaScript.
An example fingerprint database can be seen below:

var fingerprints = [
        ‘name’: “ASUS RT-N66U”,
        ‘resources’: [“/images/New_ui/asustitle.png”,”/images/loading.gif”,”/images/alertImg.png”,”/images/New_ui/networkmap/line_one.png”,”/images/New_ui/networkmap/lock.png”,”/images/New_ui/networkmap/line_two.png”,”/index_style.css”,”/form_style.css”,”/NM_style.css”,”/other.css”],
        ‘callback’: function( ip ) {
            // Insert exploit here
        ‘name’: “Linksys WRT54G”,
        ‘resources’: [“/UILinksys.gif”,”/UI_10.gif”,”/UI_07.gif”,”/UI_06.gif”,”/UI_03.gif”,”/UI_02.gif”,”/UI_Cisco.gif”,”/style.css”],
        ‘callback’: function( ip ) {
            // Insert exploit here

The above database contains fingerprints for two devices, the ASUS RT-N66U WiFi router and the Linksys WRT54G WiFi router.
Each database entry has the following:

  • name: A field to identify what device the fingerprint is for. This could be something like HP Officejet 4500 printer or Linksys WRT54G Router.
  • resources: This is an array of relative links to
    resources such as CSS stylesheets, images, or even JavaScript files. If
    you expect these resources to be on a non-standard port such as 8080, set the resource with the port included: :8080/unique.css.
    Keep in mind using external resources with active content such as
    JavaScript is dangerous as it can interrupt the regular flow of
  • callback: If all of these resources are found to exist on the enumerated host then the callback function is called with a single argument of the device’s IP address.

By creating your own fingerprints you can build custom exploits that
will be launched against internal devices once they are detected by
sonar.js. Common exploits include things such as Cross-site Request
Forgery (CSRF), Cross-site Scripting (XSS), etc. The idea being that you
can use these vulnerabilities to do things such as modifying router DNS
configurations, dumping files from an internal fileserver, and more.

Download & Read More

Ehacking Staff
With more than 50 global partners, we are proud to count the world’s leading cybersecurity training provider. EH Academy is the brainchild of Ehacking, which has been involved in the field of training since the past Five years and continues to help in creating professional IT experts.

Most Popular

How to Become an Expert in Ethical Hacking

This article is mainly addressing the audience who wants to pursue their career in Cybersecurity as a professional that provides ethical hacking services, whether...

5 Cybersecurity Tips to Keep in Mind When Working From Home

  Due to the ongoing global health crisis, more and more people are being forced to work from their homes. In fact, Forbes estimates that about...

The Complete OSINT Tutorial to Find Personal Information About Anyone

This article mainly focuses on how to discover a person's digital footprint and gather personal data by using open-source intelligence (OSINT). So, in its...

How to find the password of hacked email addresses using OSINT

Open-source intelligence or OSINT is a potent technique, and it can give a lot of valuable information, if implemented correctly with the right strategy...