Quellcode durchsuchen

File overlays now show a blurred representation of the file in the background.

n1474335 vor 7 Jahren
Ursprung
Commit
f6b2783f8b
5 geänderte Dateien mit 45 neuen und 5 gelöschten Zeilen
  1. 1 1
      README.md
  2. 21 0
      src/web/InputWaiter.js
  3. 10 0
      src/web/OutputWaiter.js
  4. 5 3
      src/web/html/index.html
  5. 8 1
      src/web/stylesheets/layout/_io.css

+ 1 - 1
README.md

@@ -103,4 +103,4 @@ CyberChef is released under the [Apache 2.0 Licence](https://www.apache.org/lice
   [8]: https://gchq.github.io/CyberChef/#recipe=Fork('%5C%5Cn','%5C%5Cn',false)Conditional_Jump('1',false,'base64',10)To_Hex('Space')Return()Label('base64')To_Base64('A-Za-z0-9%2B/%3D')&input=U29tZSBkYXRhIHdpdGggYSAxIGluIGl0ClNvbWUgZGF0YSB3aXRoIGEgMiBpbiBpdA
   [8]: https://gchq.github.io/CyberChef/#recipe=Fork('%5C%5Cn','%5C%5Cn',false)Conditional_Jump('1',false,'base64',10)To_Hex('Space')Return()Label('base64')To_Base64('A-Za-z0-9%2B/%3D')&input=U29tZSBkYXRhIHdpdGggYSAxIGluIGl0ClNvbWUgZGF0YSB3aXRoIGEgMiBpbiBpdA
   [9]: https://gchq.github.io/CyberChef/#recipe=Register('key%3D(%5B%5C%5Cda-f%5D*)',true,false)Find_/_Replace(%7B'option':'Regex','string':'.*data%3D(.*)'%7D,'$1',true,false,true)RC4(%7B'option':'Hex','string':'$R0'%7D,'Hex','Latin1')&input=aHR0cDovL21hbHdhcmV6LmJpei9iZWFjb24ucGhwP2tleT0wZTkzMmE1YyZkYXRhPThkYjdkNWViZTM4NjYzYTU0ZWNiYjMzNGUzZGIxMQ
   [9]: https://gchq.github.io/CyberChef/#recipe=Register('key%3D(%5B%5C%5Cda-f%5D*)',true,false)Find_/_Replace(%7B'option':'Regex','string':'.*data%3D(.*)'%7D,'$1',true,false,true)RC4(%7B'option':'Hex','string':'$R0'%7D,'Hex','Latin1')&input=aHR0cDovL21hbHdhcmV6LmJpei9iZWFjb24ucGhwP2tleT0wZTkzMmE1YyZkYXRhPThkYjdkNWViZTM4NjYzYTU0ZWNiYjMzNGUzZGIxMQ
   [10]: https://gchq.github.io/CyberChef/#recipe=Register('(.%7B32%7D)',true,false)Drop_bytes(0,32,false)AES_Decrypt(%7B'option':'Hex','string':'1748e7179bd56570d51fa4ba287cc3e5'%7D,%7B'option':'Hex','string':'$R0'%7D,'CTR','Hex','Raw',%7B'option':'Hex','string':''%7D)&input=NTFlMjAxZDQ2MzY5OGVmNWY3MTdmNzFmNWI0NzEyYWYyMGJlNjc0YjNiZmY1M2QzODU0NjM5NmVlNjFkYWFjNDkwOGUzMTljYTNmY2Y3MDg5YmZiNmIzOGVhOTllNzgxZDI2ZTU3N2JhOWRkNmYzMTFhMzk0MjBiODk3OGU5MzAxNGIwNDJkNDQ3MjZjYWVkZjU0MzZlYWY2NTI0MjljMGRmOTRiNTIxNjc2YzdjMmNlODEyMDk3YzI3NzI3M2M3YzcyY2Q4OWFlYzhkOWZiNGEyNzU4NmNjZjZhYTBhZWUyMjRjMzRiYTNiZmRmN2FlYjFkZGQ0Nzc2MjJiOTFlNzJjOWU3MDlhYjYwZjhkYWY3MzFlYzBjYzg1Y2UwZjc0NmZmMTU1NGE1YTNlYzI5MWNhNDBmOWU2MjlhODcyNTkyZDk4OGZkZDgzNDUzNGFiYTc5YzFhZDE2NzY3NjlhN2MwMTBiZjA0NzM5ZWNkYjY1ZDk1MzAyMzcxZDYyOWQ5ZTM3ZTdiNGEzNjFkYTQ2OGYxZWQ1MzU4OTIyZDJlYTc1MmRkMTFjMzY2ZjMwMTdiMTRhYTAxMWQyYWYwM2M0NGY5NTU3OTA5OGExNWUzY2Y5YjQ0ODZmOGZmZTljMjM5ZjM0ZGU3MTUxZjZjYTY1MDBmZTRiODUwYzNmMWMwMmU4MDFjYWYzYTI0NDY0NjE0ZTQyODAxNjE1YjhmZmFhMDdhYzgyNTE0OTNmZmRhN2RlNWRkZjMzNjg4ODBjMmI5NWIwMzBmNDFmOGYxNTA2NmFkZDA3MWE2NmNmNjBlNWY0NmYzYTIzMGQzOTdiNjUyOTYzYTIxYTUzZg
   [10]: https://gchq.github.io/CyberChef/#recipe=Register('(.%7B32%7D)',true,false)Drop_bytes(0,32,false)AES_Decrypt(%7B'option':'Hex','string':'1748e7179bd56570d51fa4ba287cc3e5'%7D,%7B'option':'Hex','string':'$R0'%7D,'CTR','Hex','Raw',%7B'option':'Hex','string':''%7D)&input=NTFlMjAxZDQ2MzY5OGVmNWY3MTdmNzFmNWI0NzEyYWYyMGJlNjc0YjNiZmY1M2QzODU0NjM5NmVlNjFkYWFjNDkwOGUzMTljYTNmY2Y3MDg5YmZiNmIzOGVhOTllNzgxZDI2ZTU3N2JhOWRkNmYzMTFhMzk0MjBiODk3OGU5MzAxNGIwNDJkNDQ3MjZjYWVkZjU0MzZlYWY2NTI0MjljMGRmOTRiNTIxNjc2YzdjMmNlODEyMDk3YzI3NzI3M2M3YzcyY2Q4OWFlYzhkOWZiNGEyNzU4NmNjZjZhYTBhZWUyMjRjMzRiYTNiZmRmN2FlYjFkZGQ0Nzc2MjJiOTFlNzJjOWU3MDlhYjYwZjhkYWY3MzFlYzBjYzg1Y2UwZjc0NmZmMTU1NGE1YTNlYzI5MWNhNDBmOWU2MjlhODcyNTkyZDk4OGZkZDgzNDUzNGFiYTc5YzFhZDE2NzY3NjlhN2MwMTBiZjA0NzM5ZWNkYjY1ZDk1MzAyMzcxZDYyOWQ5ZTM3ZTdiNGEzNjFkYTQ2OGYxZWQ1MzU4OTIyZDJlYTc1MmRkMTFjMzY2ZjMwMTdiMTRhYTAxMWQyYWYwM2M0NGY5NTU3OTA5OGExNWUzY2Y5YjQ0ODZmOGZmZTljMjM5ZjM0ZGU3MTUxZjZjYTY1MDBmZTRiODUwYzNmMWMwMmU4MDFjYWYzYTI0NDY0NjE0ZTQyODAxNjE1YjhmZmFhMDdhYzgyNTE0OTNmZmRhN2RlNWRkZjMzNjg4ODBjMmI5NWIwMzBmNDFmOGYxNTA2NmFkZDA3MWE2NmNmNjBlNWY0NmYzYTIzMGQzOTdiNjUyOTYzYTIxYTUzZg
-  [11]: https://gchq.github.io/CyberChef/#recipe=XOR(%7B'option':'Hex','string':'3a'%7D,'',false)To_Hexdump(16,false,false)&input=VGhlIGFuc3dlciB0byB0aGUgdWx0aW1hdGUgcXVlc3Rpb24gb2YgbGlmZSwgdGhlIFVuaXZlcnNlLCBhbmQgZXZlcnl0aGluZyBpcyA0Mi4
+  [11]: https://gchq.github.io/CyberChef/#recipe=XOR(%7B'option':'Hex','string':'3a'%7D,'Standard',false)To_Hexdump(16,false,false)&input=VGhlIGFuc3dlciB0byB0aGUgdWx0aW1hdGUgcXVlc3Rpb24gb2YgbGlmZSwgdGhlIFVuaXZlcnNlLCBhbmQgZXZlcnl0aGluZyBpcyA0Mi4

+ 21 - 0
src/web/InputWaiter.js

@@ -1,4 +1,5 @@
 import LoaderWorker from "worker-loader?inline&fallback=false!./LoaderWorker.js";
 import LoaderWorker from "worker-loader?inline&fallback=false!./LoaderWorker.js";
+import Utils from "../core/Utils.js";
 
 
 
 
 /**
 /**
@@ -263,11 +264,28 @@ InputWaiter.prototype.handleLoaderMessage = function(e) {
     if (r.hasOwnProperty("fileBuffer")) {
     if (r.hasOwnProperty("fileBuffer")) {
         log.debug("Input file loaded");
         log.debug("Input file loaded");
         this.fileBuffer = r.fileBuffer;
         this.fileBuffer = r.fileBuffer;
+        this.displayFilePreview();
         window.dispatchEvent(this.manager.statechange);
         window.dispatchEvent(this.manager.statechange);
     }
     }
 };
 };
 
 
 
 
+/**
+ * Shows a chunk of the file in the input behind the file overlay.
+ */
+InputWaiter.prototype.displayFilePreview = function() {
+    const inputText = document.getElementById("input-text"),
+        fileSlice = this.fileBuffer.slice(0, 2048);
+
+    inputText.style.overflow = "hidden";
+    inputText.classList.add("blur");
+    inputText.value = Utils.printable(Utils.arrayBufferToStr(fileSlice));
+    if (this.fileBuffer.byteLength > 2048) {
+        inputText.value += "[truncated]";
+    }
+};
+
+
 /**
 /**
  * Handler for file close events.
  * Handler for file close events.
  */
  */
@@ -275,6 +293,9 @@ InputWaiter.prototype.closeFile = function() {
     if (this.loaderWorker) this.loaderWorker.terminate();
     if (this.loaderWorker) this.loaderWorker.terminate();
     this.fileBuffer = null;
     this.fileBuffer = null;
     document.getElementById("input-file").style.display = "none";
     document.getElementById("input-file").style.display = "none";
+    const inputText = document.getElementById("input-text");
+    inputText.style.overflow = "auto";
+    inputText.classList.remove("blur");
 };
 };
 
 
 
 

+ 10 - 0
src/web/OutputWaiter.js

@@ -128,6 +128,13 @@ OutputWaiter.prototype.setFile = function(buf) {
 
 
     fileOverlay.style.display = "block";
     fileOverlay.style.display = "block";
     fileSize.textContent = file.size.toLocaleString() + " bytes";
     fileSize.textContent = file.size.toLocaleString() + " bytes";
+
+    // Display preview slice in the background
+    const outputText = document.getElementById("output-text"),
+        fileSlice = this.dishBuffer.slice(0, 2048);
+
+    outputText.classList.add("blur");
+    outputText.value = Utils.printable(Utils.arrayBufferToStr(fileSlice));
 };
 };
 
 
 
 
@@ -137,6 +144,7 @@ OutputWaiter.prototype.setFile = function(buf) {
 OutputWaiter.prototype.closeFile = function() {
 OutputWaiter.prototype.closeFile = function() {
     this.dishBuffer = null;
     this.dishBuffer = null;
     document.getElementById("output-file").style.display = "none";
     document.getElementById("output-file").style.display = "none";
+    document.getElementById("output-text").classList.remove("blur");
 };
 };
 
 
 
 
@@ -163,6 +171,7 @@ OutputWaiter.prototype.displayFileSlice = function() {
         sliceTo = parseInt(sliceToEl.value, 10),
         sliceTo = parseInt(sliceToEl.value, 10),
         str = Utils.arrayBufferToStr(this.dishBuffer.slice(sliceFrom, sliceTo));
         str = Utils.arrayBufferToStr(this.dishBuffer.slice(sliceFrom, sliceTo));
 
 
+    document.getElementById("output-text").classList.remove("blur");
     showFileOverlay.style.display = "block";
     showFileOverlay.style.display = "block";
     this.set(str, "string", new Date().getTime() - startTime, true);
     this.set(str, "string", new Date().getTime() - startTime, true);
 };
 };
@@ -177,6 +186,7 @@ OutputWaiter.prototype.showFileOverlayClick = function(e) {
     const outputFile = document.getElementById("output-file"),
     const outputFile = document.getElementById("output-file"),
         showFileOverlay = e.target;
         showFileOverlay = e.target;
 
 
+    document.getElementById("output-text").classList.add("blur");
     outputFile.style.display = "block";
     outputFile.style.display = "block";
     showFileOverlay.style.display = "none";
     showFileOverlay.style.display = "none";
     this.setOutputInfo(this.dishBuffer.byteLength, null, 0);
     this.setOutputInfo(this.dishBuffer.byteLength, null, 0);

+ 5 - 3
src/web/html/index.html

@@ -183,8 +183,9 @@
                         </div>
                         </div>
                         <div class="textarea-wrapper no-select">
                         <div class="textarea-wrapper no-select">
                             <div id="input-highlighter" class="no-select"></div>
                             <div id="input-highlighter" class="no-select"></div>
-                            <textarea id="input-text"></textarea>
+                            <textarea id="input-text" spellcheck="false"></textarea>
                             <div id="input-file">
                             <div id="input-file">
+                                <div class="file-overlay"></div>
                                 <div style="position: relative; height: 100%;">
                                 <div style="position: relative; height: 100%;">
                                     <div class="card">
                                     <div class="card">
                                         <img aria-hidden="true" src="<%- require('../static/images/file-128x128.png') %>" alt="File icon"/>
                                         <img aria-hidden="true" src="<%- require('../static/images/file-128x128.png') %>" alt="File icon"/>
@@ -218,9 +219,10 @@
                         <div class="textarea-wrapper">
                         <div class="textarea-wrapper">
                             <div id="output-highlighter" class="no-select"></div>
                             <div id="output-highlighter" class="no-select"></div>
                             <div id="output-html"></div>
                             <div id="output-html"></div>
-                            <textarea id="output-text" readonly="readonly"></textarea>
+                            <textarea id="output-text" readonly="readonly" spellcheck="false"></textarea>
                             <img id="show-file-overlay" aria-hidden="true" src="<%- require('../static/images/file-32x32.png') %>" alt="Show file overlay" title="Show file overlay"/>
                             <img id="show-file-overlay" aria-hidden="true" src="<%- require('../static/images/file-32x32.png') %>" alt="Show file overlay" title="Show file overlay"/>
                             <div id="output-file">
                             <div id="output-file">
+                                <div class="file-overlay"></div>
                                 <div style="position: relative; height: 100%;">
                                 <div style="position: relative; height: 100%;">
                                     <div class="card">
                                     <div class="card">
                                         <img aria-hidden="true" src="<%- require('../static/images/file-128x128.png') %>" alt="File icon"/>
                                         <img aria-hidden="true" src="<%- require('../static/images/file-128x128.png') %>" alt="File icon"/>
@@ -233,7 +235,7 @@
                                                 </span>
                                                 </span>
                                                 <input type="number" class="form-control" id="output-file-slice-from" placeholder="From" value="0" step="1024" min="0">
                                                 <input type="number" class="form-control" id="output-file-slice-from" placeholder="From" value="0" step="1024" min="0">
                                                 <div class="input-group-addon">to</div>
                                                 <div class="input-group-addon">to</div>
-                                                <input type="number" class="form-control" id="output-file-slice-to" placeholder="To" value="1024" step="1024" min="0">
+                                                <input type="number" class="form-control" id="output-file-slice-to" placeholder="To" value="2048" step="1024" min="0">
                                             </div>
                                             </div>
                                         </div>
                                         </div>
                                     </div>
                                     </div>

+ 8 - 1
src/web/stylesheets/layout/_io.css

@@ -84,10 +84,17 @@
     top: 0;
     top: 0;
     width: 100%;
     width: 100%;
     height: 100%;
     height: 100%;
-    background-color: var(--title-background-colour);
     display: none;
     display: none;
 }
 }
 
 
+.file-overlay {
+    position: absolute;
+    opacity: 0.8;
+    background-color: var(--title-background-colour);
+    width: 100%;
+    height: 100%;
+}
+
 #show-file-overlay {
 #show-file-overlay {
     position: absolute;
     position: absolute;
     right: 15px;
     right: 15px;