How to do it...

In this recipe, you will learn how to create adversarial malware:

  1.  Begin by importing the code for MalGAN, as well as some utility libraries.
import osimport pandas as pdfrom keras.models import load_modelimport MalGAN_utilsimport MalGAN_gen_adv_examples
  1. Specify the input and output paths:
save_path = "MalGAN_output"model_path = "MalGAN_input/malconv.h5"log_path = "MalGAN_output/adversarial_log.csv"pad_percent = 0.1threshold = 0.6step_size = 0.01limit = 0.input_samples = "MalGAN_input/samplesIn.csv"
  1. Set whether you'd like to use a GPU for adversarial sample generation:
MalGAN_utils.limit_gpu_memory(limit)
  1. Read in the csv file containing the names and labels of your samples into a data frame:
df = pd.read_csv(input_samples, ...

Get Machine Learning for Cybersecurity Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.