Skip to content

Commit 79db80b

Browse files
committed
Added option to define target subnet or size of subnet
1 parent 3154e97 commit 79db80b

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

example.htm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
<script>
99
// sonar.js loading a fingerprint database from fingerprint_db.js
1010
sonar.load_fingerprints( fingerprints );
11-
// If 'true' is passed to the start() function sonar will run in debug mode. This causes an alert() on device enumeration.
11+
// If 'true' is passed to the start() function sonar will run in debug mode. This causes an alert() on device enumeration and for the IP range to be scanned.
1212
sonar.start(true, 2000 );
13+
14+
// It's also possible to specify a target or subnet size
15+
//sonar.start(true, 2000, 192.168.0.1/24);
16+
//sonar.start(true, 2000, /24);
1317
</script>
1418
</body>
1519
</html>

sonar.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var sonar = {
88
/*
99
* Start the exploit
1010
*/
11-
'start': function(debug, interval_scan) {
11+
'start': function(debug, interval_scan, target) {
1212
if( debug !== undefined ) {
1313
sonar.debug = true;
1414
}
@@ -17,16 +17,27 @@ var sonar = {
1717
interval_scan = 1000;
1818
}
1919

20+
if( target === undefined ) {
21+
target = "/24";
22+
}
23+
2024
if( sonar.fingerprints.length == 0 ) {
2125
return false;
2226
}
2327

28+
// Separate IP and range, target[0] is the IP and target[1] is the range
29+
target = target.split( '/' );
30+
2431
// This calls sonar.process_queue() every
2532
setInterval( function() {
2633
sonar.process_queue();
2734
}, interval_scan );
2835

29-
sonar.enumerate_local_ips();
36+
if( target[0] == "" ) {
37+
sonar.enumerate_local_ips( target[1] );
38+
} else{
39+
sonar.ip_to_range( target[0], target[1] );
40+
}
3041
},
3142

3243
/*
@@ -123,7 +134,7 @@ var sonar = {
123134

124135
for( var tmp = 0; tmp < 4; tmp++ ) {
125136

126-
// Calculate the number of bits of each part
137+
// Calculate the number of bits that change of each part
127138
if ( range > 8 + 8 * tmp){
128139
r = 0;
129140
} else {
@@ -213,15 +224,15 @@ var sonar = {
213224
//console.log( 'Dead IP', ip );
214225
},
215226

216-
'enumerate_local_ips': function() {
227+
'enumerate_local_ips': function(range) {
217228
var RTCPeerConnection = window.webkitRTCPeerConnection || window.mozRTCPeerConnection;
218229
if (!RTCPeerConnection) return false;
219230
var addrs = Object.create(null);
220231
addrs['0.0.0.0'] = false;
221232
function addAddress(newAddr) {
222233
if (newAddr in addrs) return;
223234
addrs[newAddr] = true;
224-
sonar.ip_to_range(newAddr, 24); // We assume that we are on a /24
235+
sonar.ip_to_range(newAddr, range);
225236
}
226237
function grepSDP(sdp) {
227238
var hosts = [];

0 commit comments

Comments
 (0)