Created
October 13, 2021 01:03
-
-
Save p4p1/32dbc358595752c4fb0855f5610e99cf to your computer and use it in GitHub Desktop.
💽💽💽💽
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* mitsocket.js | |
* Created on: Tue, 12 Oct 2021 | |
* ____ __ ____ __ | |
* ( _ \ /. |( _ \/ ) | |
* )___/(_ _))___/ )( | |
* (__) (_)(__) (__) | |
* | |
* Description: | |
* A reimplementation of WebSocket for MITM | |
* Licensed under GPLv3 and should not be used | |
* for illegal activity. Inside this file you | |
* will see multiple [ICH] tags for Insert Code | |
* Here. Those tags can be used to handle the different | |
* implementations :) This script can be used as a | |
* chrome extention to infect pages just place this file | |
* in a directory create a 2nd file named manifest.json, | |
* copy from bellow, and remove the <REMOVEME> tags. | |
* Then do your edit to the file copy the class minify | |
* it and edit the end of the file to have the minify | |
* version inside of the ss.innerHTML variable. | |
* | |
* Read more here: https://leosmith.xyz/blog/websocket-mitm.html | |
* | |
* Manifest file: | |
* { | |
* "manifest_version": 2, | |
* "name": "web_socket_mitm", | |
* "description":"A websocket man in the middle extention", | |
* "version": "0.1", | |
* "author": "p4p1", | |
* "content_scripts": [{ | |
* "matches": ["http://*<REMOVEME>/*", "https://*<REMOVEME>/*"], | |
* "run_at":"document_start", | |
* "js": ["./mitsocket.js"] | |
* }] | |
* } | |
*/ | |
"use strict"; | |
class WebSocket { | |
constructor(url, protocols) { | |
/* This will create the websocket to send data to */ | |
this.ws = new window.WebSocket(url, protocols); | |
/* All of the functions set by the user are saved here */ | |
this.user_onmessage = undefined; | |
this.user_onerror = undefined; | |
this.user_onopen = undefined; | |
} | |
set onopen(eventfunc) { | |
this.user_onopen = eventfunc; | |
this.ws.onopen = function(event) { | |
// [ICH] | |
eventfunc(event); | |
}; | |
} | |
set onerror(eventfunc) { | |
this.user_onerror = eventfunc; | |
this.ws.onerror = function(event) { | |
// [ICH] | |
eventfunc(event); | |
}; | |
} | |
close(code, reason) { | |
this.ws.close(code, reason); | |
} | |
send(msg) { | |
// [ICH] | |
this.ws.send(msg); | |
} | |
set onmessage(eventfunc) { | |
this.user_onmessage = eventfunc; | |
this.ws.onmessage = function(event) { | |
// [ICH] | |
eventfunc(event); | |
}; | |
} | |
/* | |
* The rest is here for compatibility but can be edited as much as the others | |
*/ | |
get onopen() { | |
return this.user_onopen; | |
} | |
get onerror() { | |
return this.user_onerror; | |
} | |
get onmessage() { | |
return this.user_onmessage | |
} | |
get url() { | |
return this.ws.url; | |
} | |
get readyState() { | |
return this.ws.readyState; | |
} | |
get protocol() { | |
return this.ws.protocol; | |
} | |
set binaryType(type) { | |
this.ws.binaryType = type; | |
} | |
get binaryType() { | |
return this.ws.binaryType; | |
} | |
get bufferedAmount() { | |
return this.ws.bufferedAmount; | |
} | |
get extensions() { | |
return this.ws.extensions; | |
} | |
} | |
/* WARNING | |
* Take above code parse it to a one liner to then be used inside of a chrome | |
* extention! To parse it to a one liner use the following website: | |
* https://jsminify.org | |
*/ | |
//var ss = document.createElement("script"); | |
//ss.innerHTML= "class WebSocket{constructor(url,protocols){this.ws=new window.WebSocket(url,protocols);this.user_onmessage=undefined;this.user_onerror=undefined;this.user_onopen=undefined}set onopen(eventfunc){this.user_onopen=eventfunc;this.ws.onopen=function(event){eventfunc(event)}}set onerror(eventfunc){this.user_onerror=eventfunc;this.ws.onerror=function(event){eventfunc(event)}}close(code,reason){this.ws.close(code,reason)}send(msg){this.ws.send(msg)}set onmessage(eventfunc){this.user_onmessage=eventfunc;this.ws.onmessage=function(event){eventfunc(event)}}get onopen(){return this.user_onopen}get onerror(){return this.user_onerror}get onmessage(){return this.user_onmessage}get url(){return this.ws.url}get readyState(){return this.ws.readyState}get protocol(){return this.ws.protocol}set binaryType(type){this.ws.binaryType=type}get binaryType(){return this.ws.binaryType}get bufferedAmount(){return this.ws.bufferedAmount}get extensions(){return this.ws.extensions}}"; | |
//document.documentElement.appendChild(ss); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment