# Polymorphic Adversarial Cyberattacks Using WGAN
## 5 Proposed Framework
### Polymorphic Engine to Generate a Polymorphic Attack
``` Input:  Generator\(-\)Noise, \(S_{\text{attack}}\), \(X_{\text{attack}}\) \(C_{\text{trit}}(\text{Discriminator}-S_{\text{attack}},X_{\text{policy}},S_{\text{ benign}})\) Output:  Tunnel Critic/Discriminator and Generator \(F_{\text{trit}}\) = total number of features  Feature Set = S (I: \(F_{\text{trit}}\)) \(N\) = total number of non-functional features in \(F_{\text{trit}}\) \(g\) = number of non-functional features selected for mutation in the first cycle of polymorphism attacks  steps in range (Nift) \(P\)  Data preparation for the Attack and Polymorphic attack generation \(\gamma\)  for \(i=1\) to steps  Choose a subset \(S\) (I: \(P\)-I) of non-functional features from \(S_{\text{attack}}\). Randomly increase the selected feature values by a small percentage to extract \(X_{\text{attack}}\) for epochs = 1 to MAX EPOCHs do for \(G\)-circulating  Generate constant constant polynomial attack (\(X_{\text{policy}}\



Pandas [59] is a python library that is used to read, manipulate, and analyze the dataset. For example, to read CSV files, we use the read_csv() method from this library. ### Hyperparameter Adjustment

Hyperparameters are essential properties that define the characteristics of the training process of machine learning or a deep learning model. For a deep neural network, hyperparameters are variables that explain its structure. Table 3 depicts hyperparameters that are used to optimize the generator and discriminator in WGAN for this research. We train the WGAN model for a total of 100 epochs with a batch_size of 512, learning_rate set to 0.001, critic_iters equal to 5, and the optimizer selected using trial and error is RMSprop. Batch_size, learning_rate, critic_iters, and epochs are optimization hyperparameters related to the optimization and training process of the model. In comparison, an optimizer is a model-specific hyperparameter. ### Evaluation Metrics

The following metrics are employed to evaluate the performance of IDS in this work:

* **Detection Rate (\(\mathbf{DR}\)) or Precision**--a ratio between the correctly detected attack samples over all the samples classified as an attack by the IDS. It is also known as a ratio between True Positives and the sum of True Positives and False Positives. \[DR=\frac{TP}{TP+FP}\] (8)
* _Recall_--a ratio between the correctly detected attack samples over the total attack sample data. It is also known as a ratio between True Positives and the sum of True Positives and False Negatives. \[Recall=\frac{TP}{TP+FN}\] (9)
* _F1_Score_--represents the harmonic mean of precision and recall. \[F1\_Score=2\times\frac{(precision\ \times\ recall)}{(precision\ +\ recall)}\] (10)
* True Negative Rate (TNR)--a ratio between the correctly detected benign samples over the total benign sample data. It is also known as a ratio between True Negatives and the sum of True Negatives and False Positives. \[TNR=\frac{TN}{TN+FP}\] (11) where \(TP\), \(FP\), \(TN\), and \(FN\) represent True Positives, False Positives, True Negatives, and False Negatives, respectively. The following metric is employed to evaluate the performance of the attacker:

* IDS Evasion Success Rate (\(ESR\))--the rate of increase of undetected adversarial polymorphic attack samples by IDS compared to the original attack samples. \begin{table}
\begin{tabular}{c c} \hline \hline
**Hyperparameter** & **Description** \\ \hline Batch\_Size & Defines the number of samples to consider for one iteration \\ learning\_rate & Controls the weights of a neural network \\ critic\_iters & Critic\_iters for each generator cycle \\ Optimizer & Methods used to update the attributes of the neural networks, \\  & e.g., Adam, Rmsprop, Adagrad \\ Epochs & Number of training cycles \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Hyperparameters. \[ESR=1-\frac{(\textit{Adversarial polymorphic detection rate})}{(\textit{Original detection rate})} \tag{12}\]

## 7 Results and Discussion

This section describes the results of various experiments for different scenarios and the analyses of the findings.