VaultChem commited on
Commit
5f40068
β€’
1 Parent(s): 16e8933
Files changed (2) hide show
  1. app.py +37 -2
  2. smallexe64.exe β†’ harmless.exe +0 -0
app.py CHANGED
@@ -15,6 +15,22 @@ import pickle
15
  import numpy as np
16
  import pdb
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  # This repository's directory
19
  REPO_DIR = Path(__file__).parent
20
  subprocess.Popen(["uvicorn", "server:app"], cwd=REPO_DIR)
@@ -302,16 +318,22 @@ if __name__ == "__main__":
302
  interactive=False,
303
  )
304
 
 
 
 
 
 
305
  gr.Markdown("# πŸ“€ Step 2: Upload a file for scanning")
306
  gr.Markdown("## Client side")
307
  gr.Markdown(
308
  "Upload a file you want to scan for malware. ClairVault will encrypt it locally before sending it to the cloud."
309
  )
310
- file_input = gr.File(label="Upload a file:", file_count = "single", value="./smallexe64.exe")
311
 
312
  gr.Markdown("# πŸ“₯ Step 3: Extract executable file features")
313
 
314
- b_extract = gr.Button("πŸ“₯ Extract features and save")
 
315
 
316
  extracted_vector = gr.JSON(
317
  label="Extracted vector:",
@@ -355,12 +377,25 @@ if __name__ == "__main__":
355
 
356
  encodings_input = gr.Textbox(value=encodings, visible=False)
357
  # Button to extract vector
 
 
358
  b_extract.click(
359
  fn=encode_quantize,
360
  inputs=[file_input, eval_key_input, encodings_input],
361
  outputs=[extracted_vector],
362
  )
363
 
 
 
 
 
 
 
 
 
 
 
 
364
  # Button to encrypt file
365
  b_encrypt_file.click(
366
  fn=encrypt_encoded_quantize,
 
15
  import numpy as np
16
  import pdb
17
 
18
+ import json
19
+
20
+ def load_data_from_file(filename):
21
+ """
22
+ Load data from a JSON file in the current directory.
23
+
24
+ Parameters:
25
+ filename (str): The name of the file to load.
26
+
27
+ Returns:
28
+ data: The data loaded from the file.
29
+ """
30
+ with open(filename, 'r') as file:
31
+ data = json.load(file)
32
+ return data
33
+
34
  # This repository's directory
35
  REPO_DIR = Path(__file__).parent
36
  subprocess.Popen(["uvicorn", "server:app"], cwd=REPO_DIR)
 
318
  interactive=False,
319
  )
320
 
321
+
322
+ #load
323
+ malware_data = load_data_from_file('malware_features.txt')
324
+ print(data)
325
+
326
  gr.Markdown("# πŸ“€ Step 2: Upload a file for scanning")
327
  gr.Markdown("## Client side")
328
  gr.Markdown(
329
  "Upload a file you want to scan for malware. ClairVault will encrypt it locally before sending it to the cloud."
330
  )
331
+ file_input = gr.File(label="Upload a harmless exe file or use default:", file_count = "single", value="./harmless.exe")
332
 
333
  gr.Markdown("# πŸ“₯ Step 3: Extract executable file features")
334
 
335
+ b_extract = gr.Button("πŸ“₯ Extract features from harmless file and save")
336
+ c_extract = gr.Button("Load features from malware file and save")
337
 
338
  extracted_vector = gr.JSON(
339
  label="Extracted vector:",
 
377
 
378
  encodings_input = gr.Textbox(value=encodings, visible=False)
379
  # Button to extract vector
380
+
381
+
382
  b_extract.click(
383
  fn=encode_quantize,
384
  inputs=[file_input, eval_key_input, encodings_input],
385
  outputs=[extracted_vector],
386
  )
387
 
388
+
389
+
390
+
391
+ c_extract.click(
392
+ fn=encrypt_encoded_quantize,
393
+ inputs =[malware_data, user_id_input, eval_key_input],
394
+ outputs=[encrypted_file],
395
+ )
396
+
397
+
398
+
399
  # Button to encrypt file
400
  b_encrypt_file.click(
401
  fn=encrypt_encoded_quantize,
smallexe64.exe β†’ harmless.exe RENAMED
File without changes