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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.