Spaces:
Runtime error
Runtime error
santialferez
commited on
Commit
•
6ffab9d
1
Parent(s):
659595a
update to last methodology of paper
Browse files- __pycache__/binary2image.cpython-310.pyc +0 -0
- _codecs_cn.cp39-mingw_i686.pyd +0 -0
- app.py +8 -9
- entropy_tester_classifier.pkl +2 -2
- model.pkl → model_non_obfuscated.pkl +0 -0
- resnet18_obfuscated_samples.pkl +3 -0
- tempfile.png +0 -0
__pycache__/binary2image.cpython-310.pyc
ADDED
Binary file (2.49 kB). View file
|
|
_codecs_cn.cp39-mingw_i686.pyd
DELETED
Binary file (140 kB)
|
|
app.py
CHANGED
@@ -5,6 +5,7 @@ from fastai.vision.all import load_learner
|
|
5 |
from binary2image import get_size, save_file, get_binary_data
|
6 |
import gradio as gr
|
7 |
import numpy as np
|
|
|
8 |
import plotly.express as px
|
9 |
|
10 |
from scipy import stats
|
@@ -12,14 +13,14 @@ import pickle
|
|
12 |
|
13 |
## Loading the models
|
14 |
entropy_classifier = pickle.load(open('entropy_tester_classifier.pkl', 'rb'))
|
15 |
-
model_NonObf = load_learner("
|
16 |
-
|
17 |
-
model_XOR = load_learner("model.pkl", cpu=True) # change to "model_XOR.pkl"
|
18 |
|
19 |
def entropy_tester(bin_data):
|
20 |
entropy = stats.entropy(bin_data,base=2)
|
21 |
pred = entropy_classifier.predict(
|
22 |
-
|
|
|
23 |
return pred[0]
|
24 |
|
25 |
def process_file(file):
|
@@ -35,10 +36,8 @@ def process_file(file):
|
|
35 |
# Make prediction depending on the type of obfuscation
|
36 |
if pred_entropy == "NonObf":
|
37 |
prediction, _, probas = model_NonObf.predict(converted_filename)
|
38 |
-
elif pred_entropy == "
|
39 |
-
prediction, _, probas =
|
40 |
-
elif pred_entropy == "XOR":
|
41 |
-
prediction, _, probas = model_XOR.predict(converted_filename)
|
42 |
|
43 |
message = f"Your file is {prediction}!!!"
|
44 |
|
@@ -64,7 +63,7 @@ with gr.Blocks() as demo:
|
|
64 |
prob_dist_img = gr.Plot(label="Probability Distribution")
|
65 |
with gr.Column():
|
66 |
text0 = gr.Textbox(label="Type of Obfuscation")
|
67 |
-
converted_img = gr.Image(label="Converted Image", height=300)
|
68 |
|
69 |
button = gr.Button(value="Process File")
|
70 |
button.click(process_file, inputs=[file], outputs=[text0, text1, prob_dist_img, converted_img])
|
|
|
5 |
from binary2image import get_size, save_file, get_binary_data
|
6 |
import gradio as gr
|
7 |
import numpy as np
|
8 |
+
import pandas as pd
|
9 |
import plotly.express as px
|
10 |
|
11 |
from scipy import stats
|
|
|
13 |
|
14 |
## Loading the models
|
15 |
entropy_classifier = pickle.load(open('entropy_tester_classifier.pkl', 'rb'))
|
16 |
+
model_NonObf = load_learner("model_non_obfuscated.pkl", cpu=True) # change to "model_NonObf.pkl"
|
17 |
+
model_Obf = load_learner("resnet18_obfuscated_samples.pkl", cpu=True) # change to "model_Shikata.pkl"
|
|
|
18 |
|
19 |
def entropy_tester(bin_data):
|
20 |
entropy = stats.entropy(bin_data,base=2)
|
21 |
pred = entropy_classifier.predict(
|
22 |
+
pd.DataFrame(data = entropy.reshape(1,-1), columns=['Entropy'])
|
23 |
+
)
|
24 |
return pred[0]
|
25 |
|
26 |
def process_file(file):
|
|
|
36 |
# Make prediction depending on the type of obfuscation
|
37 |
if pred_entropy == "NonObf":
|
38 |
prediction, _, probas = model_NonObf.predict(converted_filename)
|
39 |
+
elif pred_entropy == "Obfuscated":
|
40 |
+
prediction, _, probas = model_Obf.predict(converted_filename)
|
|
|
|
|
41 |
|
42 |
message = f"Your file is {prediction}!!!"
|
43 |
|
|
|
63 |
prob_dist_img = gr.Plot(label="Probability Distribution")
|
64 |
with gr.Column():
|
65 |
text0 = gr.Textbox(label="Type of Obfuscation")
|
66 |
+
converted_img = gr.Image(label="Converted Image", height=300, width=300)
|
67 |
|
68 |
button = gr.Button(value="Process File")
|
69 |
button.click(process_file, inputs=[file], outputs=[text0, text1, prob_dist_img, converted_img])
|
entropy_tester_classifier.pkl
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b0f23a2b4a5404b6f86f896854c128b54ed69edefbdaf4b77167b03f464e0c91
|
3 |
+
size 2008273
|
model.pkl → model_non_obfuscated.pkl
RENAMED
File without changes
|
resnet18_obfuscated_samples.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b3a57dd13ebbcda60d1f393d5aed2f442861a41def4fc052ec4e52a6e2bd5330
|
3 |
+
size 47955320
|
tempfile.png
DELETED
Binary file (80.1 kB)
|
|