Newer
Older
DirtyScripts / WSSSnoop.html
  1. <html>
  2. <head>
  3. <title>WSSSnoop</title>
  4. <style type="text/css">
  5. body{
  6. background-color: #333;
  7. color:#bbb;
  8. margin:0;
  9.  
  10. }
  11. .topBar {
  12. background-color: #444;
  13. position:fixed;
  14. top:0;
  15. width:100%;
  16. z-index:100;
  17. padding: 10px;
  18. }
  19. .topTitle{
  20. position:absolute;
  21. top:10px;
  22. left:10px;
  23. color:#7fffd4;
  24. }
  25. .topcorner{
  26. position:absolute;
  27. top:10px;
  28. right:30px;
  29. }
  30. #cswsh-output{
  31. margin-top: 50px !important;
  32. font-family: 'Source Code Pro',
  33. sans-serif;font-size: 0.7em;
  34. padding-bottom: 65px;
  35. padding-left: 10px;
  36. }
  37. .sendBar {
  38. background-color: #333;
  39. position:fixed;
  40. bottom:30px;
  41. width:100%;
  42. z-index:100;
  43. padding: 0px;
  44. height: 30px;
  45. font-family: 'Source Code Pro', sans-serif;
  46. }
  47. .sendBar #label {
  48. margin-right: 20px;
  49. width: 110px;
  50. }
  51. /*.sendBar #wssCommand {
  52. width: 100%;
  53. }*/
  54. .sendBar #wssSendText {
  55. display: flex;
  56. width:100%;
  57. flex-grow: 1;
  58. margin-left: 20px;
  59. margin-top: -20px;
  60. background-color: #333;
  61. color:#DDD;
  62. font-family: 'Source Code Pro', sans-serif;
  63. border:none;
  64. text-decoration: none;
  65. }
  66. *:focus {
  67. outline: none;
  68. }
  69. .bottomBar {
  70. background-color: #444;
  71. position:fixed;
  72. bottom:0;
  73. width:100%;
  74. z-index:100;
  75. padding: 10px;
  76. height: 20px;
  77. }
  78. .bottomClear{
  79. position:absolute;
  80. bottom:10px;
  81. right:30px;
  82. }
  83. a:link,a:visited {
  84. color: #00ccff;
  85. text-decoration: none;
  86. }
  87. /* mouse over link */
  88. a:hover, a:active {
  89. color: #99ebff;
  90. text-decoration: none;
  91. }
  92. </style>
  93. <link href='http://fonts.googleapis.com/css?family=Source+Code+Pro' rel='stylesheet' type='text/css'>
  94. </head>
  95. <body>
  96. <div class="topBar">
  97. <div class="topTitle">
  98. WSSSnoop
  99. </div>
  100. <center>
  101. <input type="text" name="cswshURL" id="cswshURL" value="" placeholder="wss://snoop.me">
  102. <input type="button" id="startSnoop" value="start snooping" onclick="startSnooping()"/>
  103. <input type="button" id="stopSnoop" value="stop snooping" style="display:none" onclick="stopSnooping()"/>
  104. <br />
  105. <div class="topcorner">
  106. Status: <div id="status" style="display:inline-block; color:red"/>Offline</div>
  107. </div>
  108. </center>
  109. </div>
  110.  
  111. <div id="cswsh-output" ></div>
  112. <div class="sendBar" style="display:none">
  113. <form name="wssCommand" id="wssCommand" action="" onsubmit="return false">
  114. <label id="label">$></label>
  115. <input type="text" name="wssSendText" id="wssSendText" value="" placeholder="">
  116. <!--<input type="submit" id="wssSendbutton" value="" />-->
  117. </form>
  118. </div>
  119.  
  120. <div class="bottomBar">
  121. By <a href="https://rossmarks.uk" target="_new">Ross Marks</a>
  122. <div class="bottomClear">
  123. <input type="button" id="clearPage" value="clear page" onclick="clearPage();"/>
  124. </div>
  125. </div>
  126.  
  127. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  128. <script>
  129. function clearPage(){
  130. $('#cswsh-output').empty();
  131. $('html, body').scrollTop($(document).height());
  132. }
  133.  
  134. function startSnooping(){
  135. $('#startSnoop').hide();
  136. $('#stopSnoop').show();
  137. $('.sendBar').show();
  138. $('#wssSendText').focus();
  139. writeToScreen("Start snooping: " + $("#cswshURL").val());
  140. checkCSWSH();
  141. }
  142.  
  143. function stopSnooping(){
  144. $('#startSnoop').show();
  145. $('#stopSnoop').hide();
  146. $('.sendBar').hide();
  147. websocket.close();
  148. writeToScreen("Stop snooping");
  149. }
  150.  
  151. function checkCSWSH(){
  152. var wsUri = $("#cswshURL").val();
  153. statusWaiting();
  154. websocket = new WebSocket(wsUri);
  155. websocket.onopen = function(evt) { onOpen(evt) };
  156. websocket.onclose = function(evt) { onClose(evt) };
  157. websocket.onmessage = function(evt) { onMessage(evt) };
  158. websocket.onerror = function(evt) { onError(evt) };
  159. }
  160.  
  161. function onOpen(evt){
  162. writeToScreen("CONNECTED");
  163. statusConnected()
  164. doSend("origin policy unchecked!");
  165. }
  166.  
  167. function onClose(evt){
  168. writeToScreen("DISCONNECTED");
  169. statusOffline()
  170. if( $('#stopSnoop').css('display') != 'none' ){
  171. checkCSWSH()
  172. }
  173. }
  174.  
  175. function onMessage(evt){
  176. writeToScreen('<span style="color: #A7E734;">RESPONSE: ' + evt.data+'</span>');
  177. //websocket.close();
  178. }
  179.  
  180. function onError(evt){
  181. writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data);
  182. }
  183.  
  184. function doSend(message){
  185. writeToScreen("SENT: " + message);
  186. websocket.send(message);
  187. }
  188.  
  189. function writeToScreen(message){
  190. output = document.getElementById("cswsh-output");
  191. var pre = document.createElement("div");
  192. pre.style.wordWrap = "break-word";
  193. pre.innerHTML = message;
  194. output.appendChild(pre);
  195. $('html, body').scrollTop($(document).height());
  196. }
  197.  
  198. $("#wssCommand").submit(function(e) {
  199. doSend( $('#wssSendText').val() );
  200. $('#wssSendText').val("");
  201. $('#wssSendText').focus();
  202. e.preventDefault();
  203. });
  204.  
  205. function statusConnected(){
  206. $('#status').html("Connected");
  207. $('#status').css("color","lightgreen");
  208. }
  209. function statusOffline(){
  210. $('#status').html("Offline");
  211. $('#status').css("color","red");
  212. }
  213. function statusWaiting(){
  214. $('#status').html("Waiting...");
  215. $('#status').css("color","yellow");
  216. }
  217. </script>
  218. </body>
  219. </html>
Buy Me A Coffee