Comments (5)
Thank you
from secml_malware.
Hello!
Are you using the tutorial that I have developed, or custom code?
Please, next time, directly paste the code and not screenshots of the problem (otherwise, it is very hard for me to try it and replicate the bug).
from secml_malware.
Yes, I am using the tutorial that I have developed. no execution error is there only real sample's size not increasing. following is the code
import os
import magic
import secml_malware
from secml.array import CArray
from secml_malware.attack.whitebox import CKreukEvasion
from secml_malware.models.malconv import MalConv
from secml_malware.models.c_classifier_end2end_malware import CClassifierEnd2EndMalware, End2EndModel
net = MalConv()
net = CClassifierEnd2EndMalware(net)
net.load_pretrained_model()
from secml_malware.attack.whitebox.c_padding_evasion import CPaddingEvasion
partial_dos = CPaddingEvasion(net, how_many=256,iterations=50,is_debug= False,random_init= False,threshold=0.50,penalty_regularizer= 0)
folder = "secml_malware/data/malware_samples/test_folder"
X = []
y = []
file_names = []
for i, f in enumerate(os.listdir(folder)):
path = os.path.join(folder, f)
if 'petya' not in path:
continue
if "PE32" not in magic.from_file(path):
continue
with open(path, "rb") as file_handle:
code = file_handle.read()
x = End2EndModel.bytes_to_numpy(code, net.get_input_max_length(), 256, False)
_,confidence = net.predict(CArray(x), True)
if confidence[0, 1].item() < 0.5:
continue
print(f"> Added {f} with confidence {confidence[0,1].item()}")
X.append(x)
#print(X)
conf = confidence[1][0].item()
y.append([1 - conf, conf])
file_names.append(path)
for sample, label in zip(X, y):
y_pred, adv_score, adv_ds, f_obj = partial_dos.run(CArray(sample), CArray(label[1]))
print(partial_dos.confidences_)
print(f_obj)
folder1 = "secml_malware/data/malware_samples/test_folder/padding"
for i, f in enumerate(file_names):
head_tail = os.path.split(f)
path1 = os.path.join(folder1, head_tail[1])
adv_x = adv_ds.X[0,:]
real_adv_x = partial_dos.create_real_sample_from_adv(file_names[i], adv_x,path1)
print(file_names[0])
print(len(real_adv_x))
real_x = End2EndModel.bytes_to_numpy(real_adv_x, net.get_input_max_length(), 256, False)
_, confidence = net.predict(CArray(real_x), True)
print(confidence[0,1].item())
from secml_malware.
Ok thank you, I'll investigate.
from secml_malware.
Well, if you call the End2EndModel.bytes_to_numpy
function, it will generate a padded vector of the maximum input dimension of the netwrok.
No surprise that it is as the same length as before.
I am updating the notebook, so you can have a look at the before / after filesize.
from secml_malware.
Related Issues (20)
- How to run lightGBM and SOREL model using secml_malware? HOT 2
- No data preprocessing for SorelNet? HOT 2
- Error while running the sample attack code from blackbox_tutorial.ipynb HOT 4
- can't attack EMBER model HOT 1
- Confidence on Microsoft Malware Classification Challenge HOT 10
- Differences Between WhiteBox Attacks HOT 7
- Adding support for QuoVadis models HOT 2
- AttributeError: 'NoneType' object has no attribute 'dos_header' HOT 4
- No such file or directory: 'secml_malware/data/malware_samples/test_folder' HOT 3
- lightGBM and SOREL model weights? HOT 1
- Support for ensemble models HOT 1
- SOREL ATTACK HOT 1
- CGammaSectionsEvasionProblem attack budget HOT 6
- FGSM Attacking Running for days HOT 1
- Train models HOT 5
- Fix numpy retrocompatibility for CClassifierEmber
- issue installing secml-malware with pip with python 3.12
- Wrong ember prediction
- GAMMA section injections might load sections at random
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from secml_malware.