Detecting crypto-ransomware in IoT networks based on energy consumption footprint

An Internet of Things (IoT) architecture generally consists of a wide range of Internet-connected devices or things such as Android devices, and devices that have more computational capabilities (e.g., storage capacities) are likely to be targeted by ransomware authors. In this paper, we present a machine learning based approach to detect ransomware attacks by monitoring power consumption of Android devices. Specifically, our proposed method monitors the energy consumption patterns of different processes to classify ransomware from non-malicious applications. We then demonstrate that our proposed approach outperforms K-Nearest Neighbors, Neural Networks, Support Vector Machine and Random Forest, in terms of accuracy rate, recall rate, precision rate and F-measure.


Introduction
The Internet of Things (IoT) refers to interrelated connected network of smart devices, sensors, embedded computers and etc. that store,process and communicate heterogeneous data.IoT and its applications propagate to majority of life's infrastructure ranging from health and food production to smart cities and urban management.While efficiency and prevalence of IoT are increasing, security issues remain a necessary concern for industries (Tankard 2015).Internetconnected devices, including those deployed in an IoT architecture, are increasingly targeted by cybercriminals due to their pervasiveness and the ability to use the compromised devices to further attack the underlying architecture (Choo 2014;Pajouh et al. 2016;D'Orazio et al. 2017;Fortino and Trunfio 2014;Watson and Dehghantanha 2016).In the case of ransomware, for example, devices that are capable of storing a reasonably amount of data (e.g., Android and iOS devices) are likely to be targeted (Damshenas et al. 2015;D'Orazio and Choo 2016;Gubbi et al. 2013).Thus, ensuring the security of IoT nodes against threats such as malware is a topic of ongoing interest (Bertino et al. 2016;Sicari et al. 2015;Kumar and Patel 2014;Abomhara and Kien 2015;Daryabar et al. 2012;Teing et al. 2017;Dezfouli et al. 2016).
While malware detection and mitigation research is now new, ransomware detection and mitigation remains challenging.Ransomware is a relatively new malware type that attempts to encrypt a compromised device's data using a strong encryption algorithm (O'Gorman and McDonald 2012).The victim will then have to pay the ransom (usually Abstract An Internet of Things (IoT) architecture generally consists of a wide range of Internet-connected devices or things such as Android devices, and devices that have more computational capabilities (e.g., storage capacities) are likely to be targeted by ransomware authors.In this paper, we present a machine learning based approach to detect ransomware attacks by monitoring power consumption of Android devices.Specifically, our proposed method monitors the energy consumption patterns of different processes to classify ransomware from non-malicious applications.We then demonstrate that our proposed approach outperforms K-Nearest Neighbors, Neural Networks, Support Vector Machine and Random Forest, in terms of accuracy rate, recall rate, precision rate and F-measure.using bitcoins) in order to obtain the password or decryption key (Song et al. 2016).Consequences include temporary or permanent loss of sensitive information, disruption of regular operations, direct/indirect financial losses (e.g., to restore systems and restore an organizations reputation) (FBI 2016).
A popular malware detection approach is the use of machine learning techniques to identify patterns of specific feature(s) within a malware code or behavior to distinguish malware from non-malicious applications (Faruki et al. 2015;Damshenas et al. 2015;Pajouh et al. 2016).For example, Andronio et al. (2015) proposed an Android ransomware detection system, Heldroid, that is based on Natural Language Processing (NLP).The approaches identify ransomware based on their typical characteristics, such as call function and application manifests.EldeRan (Sgandurra et al. 2016) is another machine learning based model for dynamically analyzing and classifying ransomware based on their installation activities.Mercaldo et al. (2016) presented a parser that analyzes a sample code and automatically identifies ransomware related instructions.In Caviglione et al. (2016), malware covert communications are detected using neural networks and decision tree techniques.
Changes in the energy consumption of a typical infected device can also be used as a feature for malware detection (Caviglione et al. 2016), as it could be trivial for a malware developer to change malware function calls or its behaviour but changing its power usage pattern is less likely and more difficult to realise (Shaerpour et al. 2013).Additionally, power usage pattern is relatively similar on different platforms; thus, power consumption based detection methods appear to be a viable approach (Potlapally et al. 2006).Kim et al. (2008) proposed a power-aware malware detection framework based on anomalies in a device energy consumption pattern.Similarly, Merlo et al. (2015) demonstrated the potential of detecting a malware on an Android device based on its energy consumption.
In this paper, we use machine learning techniques to detect ransomware based on their power usage patterns on IoT nodes, and specifically Android devices.The proposed model grinds device's power usage into subsamples, classifies them and aggregates outputs to increase the detection rate to 95.65%.

Related literature
Securing IoT nodes is an active research area.For example, Sicari et al. (2015) and Jing et al. (2014) discussed several key research challenges and identified potential solutions and research opportunities for IoT security, and Abomhara and Kien (2015) provided a categorisation of IoT related threats.
Malware detection and mitigation for IoT nodes is one of several research challenges and opportunities identified, and is an ongoing research topic (Faruki et al. 2015;Suarez-Tangil et al. 2014).Detection methods include those based on malware's properties (e.g., application signatures), and tracking of malicious activity and their energy consumption (Shaerpour et al. 2013).Malware detection based on energy consumption footprint is known to be more robust against malware anti-forensic techniques as changing a malware power consumption pattern is much more challenging in practice, compared to changing its function calls or application codes (Damshenas et al. 2013).Kim et al. (2008) proposed a power-aware malware detection framework that detects previously unknown battery-draining malware.Their framework comprises a power monitoring tool and a data analyzer which generates a power signature to identify a malware.Merlo et al. (2015) presented an energy-related measurement at a different levels of abstraction for Android devices in order to achieve a trade-off between measurement precision and effective energy based profiling of malware.Yang and Tang (2016) used the frequencies of energy consumption waveform to generate a Gaussian Mixture Model (GMM) based on Mel frequency cepstral coefficients (MFCC) to detect malicious software.In Yang and Tang (2016), authors use a complex statistical approach to make decision based on power usage.This, however, is generally too computationally expensive for IoT nodes.The authors also employed frequencies of waveform in their approach; therefore, changes in the CPU's specification would have a substantial impact on the results even though the waveform's visual form remains invariant.
Machine learning algorithm, as previously discussed, has been widely employed in cyber security research, including malware detection.Andronio et al. (2015) presented Heldroid to detect Android ransomware Heldroid based on file encryption activities using a NLP-based text classifier, locking detector and a tracker.Heldroid utilises extracted features from malware application such as alert messages, function call and etc. Sgandurra et al. (2016) proposed EldeRan for dynamically analysing and classifying ransomware based on the set of actions performed by the applications in their installation phase.EldeRan is designed for Windows platform and the most relevant feature to the class label is Registry Keys Operations, which is not applicable for Android devices.Mercaldo et al. (2016) presented a three-step process to detect Android ransomware family.Similar to other static malware detection approaches, techniques such as code metamorphism could be used to evade detection.
We then use PowerTutor to monitor and record the device processes' power usage (while running the applications and ransomware, separately) for 5 min.While running the applications (also referred to as goodware), the user interactions mirrored a real world usage.This procedure was repeated five times per device; thus, we obtained 5 repeation × 3 device = 15 power usage samples for each and every application and ransomware.
As each device's CPU has its own power usage specification, the energy consumption of all devices were mapped to a specific range in order to have a meaningful evaluation.So, we normalised the CPU power consumption for all monitored processes on the devices to [0, 1], where 0 indicates no power usage and 1 presents the maximum CPU power utilisation.Scripts were written to process logfiles, extract and normalize power usage values, and generate a row-normalized dataset.Each row includes a label (i.e., goodware or ransomware) and a normalized sequence of energy consumption for five minutes of activity.

Classification
Assigning correct label to a sample based on previous observations is a key element of Supervised Learning and Classification (Michalski et al. 2013).We applied four stateof-the-art classifiers, namely: k-Nearest Neighbor (KNN), Neural Network (NN), Support Vector Machine (SVM) and Random Forest (RF), on the power usage samples to recognise the class of each sequence of power consumption.KNN is a simple and powerful classifier which seeks K nearest sample(s) and assigns the majority of neighbor's label to the given samples (Cover and Hart 1967).NN (Haykin 1998) is an implementation of human brain networks and mostly used to approximate the function between inputs and output.Another popular technique for supervised learning is SVM (Burges 1998), which is based on the concept of decision planes that define decision boundaries.A decision plane differentiates a set of objects based on their class memberships.Ensemble learning has been the motivation of developing RF (Verikas et al. 2011) that operates by constructing a multitude of decision trees at training time and generating the class label.
Power usage sequence of each process can be considered as time-series data.A wide range of methods have been proposed to classify time-series data (Xing et al. 2010;Fu 2011).In this study, a distance based time-series classification approach based on Dynamic Time Warping (DTW) (Müller 2007) is used for distance measure, and KNN is used as a classifier.Similarity distance is a key element in KNN classification and we apply two different distances to find the closest neighbor as follows: • Euclidean distance: Euclidean distance or Euclidean metric is the intuitive distance between two vectors in Euclidean space and calculated as follow: • Dynamic time warping (DTW): DTW is a recognized technique for finding an optimal alignment between two time-dependent sequences (see Fig. 1).According to DTW's ability to deal with time deformations and issues associated with speed differences in time-dependent data, it is also employed to calculate distance or similarity between time series (Müller 2007).Let us denote two sequences that display two discrete subsamples as indi- cates the distance between x i and y j (see Fig. 2).DTW's purpose is to discover an optimal alignment between X and Y having a minimal entirely distance.As an intuitive explanation, an optimal alignment traverse across a valley of low cost cells within the cost matrix C. A warping path is specified as a sequence p = {p 1 , … , p L } with p l = (n l , m l ) [1:N] × [1:M], l [1:L] satisfying the following conditions: -Boundary condition: p 1 = (1, 1) and p L = (N, M).
-Monotonicity condition: The summation of all local distances of a warping path's elements outcomes the total cost of path and in order to find optimal warping path p * , the path having minimum total cost among all possible paths is selected.Finally, to measure similarity or distance between two sequences X and Y, their total cost of optimal warping path are evaluated.The total cost c p (X, Y) of a warping path p between X and Y with respect to the local cost measure c is defined as: The DTW distance DTW(X, Y) between X and Y is then defined as the total cost of p * : Figure 3 illustrates how DTW aligns two power usage subsamples in order to find optimal path between them for distance calculation.

Metrics and cross-validation
Similar to the approach in (Buczak and Guven 2016), we use the following four common performance indicators for malware detection: • True positive (TP): indicates that a ransomware is correctly predicted as a malicious application.• True negative (TN): indicates that a goodware is detected as a non-malicious application correctly.• False positive (FP): indicates that a goodware is mistakenly detected as a malicious application.• False negative (FN): indicates that a ransomware is not detected and labelled as a non-malicious application.
To evaluate the effectiveness of our proposed method, we used machine learning performance evaluation metrics that are commonly used in the literature, namely: Accuracy, Recall, Precision and F-Measure.
Accuracy is the number of samples that a classifier correctly detects, divided by the number of all ransomware and goodware applications:  Precision is the ratio of predicted ransomware that are correctly labelled a malware.Thus, Precision is defined as follows: Recall or detection rate is the ratio of ransomware samples that are correctly predicted, and is defined as follows: (5) Precision = TP TP + FP .
F-Measure is the harmonic mean of precision and recall, and is defined as follows: Cross-validation (Kohavi et al. 1995) is a fundamental technique in machine learning to assess the extent that the findings of an experiment can be generalized into an independent dataset.In order to evaluate the performance of the proposed method, we used the leave-one-out cross validation.We are aware that in order to implement this validation method, all subsamples of a sample need to be excluded  We will evaluate the performance of the classification algorithms in the next section.

Performance of classification algorithms
Table 2 displays the findings of applying classification algorithms on our dataset.As previously discussed, we will now use the leave-one-out technique for cross validation.Comparison of Figs. 5 and 4 reflects a significant difference between patterns of power consumption of ransomware versus benign applications.However, as patterns of power consumptions are not predictable and depend on many factors such as files content, encryption algorithm etc. samples are highly distributed in the feature space.
It appears that direct application of conventional classification algorithms namely NN, KNN and SVM, is not promising.For example, the KNN classifier that uses DTW as a similarity measure outperformed other techniques while conventional KNN (with parameter setting of K = 1, 5, 10) is ranked lowest among the classification approaches.
Since Euclidean method calculates similarity by summing distances between corresponding points of samples, the calculated distance could be far when the position of occurring power usage patterns varies (even if samples are visually cognate).On the other hand, DTW attempts to align samples based on the distance between pieces of samples that are more similar regardless of the position of similar energy usage pattern.Consequently, the performance of KNN classifier is significantly influenced by the distance criteria.The second place belongs to RF that selects subset of features and works in splitted feature spaces instead of using a complete feature space.These observations led us to hypothesis that a subset of features (i.e., a specific interval within Ransomware infection period) may improve performance of classification techniques.

Proposed method
In the proposed method to overcome high distribution of features, power usage samples are divided into subsamples prior to using different classification techniques to identify the subsamples' labels.
To divide the power usage samples, we assume a fix window size (interval) and move it forward from the starting point of each sample (when the process has actually started), while we append a new subsample to a set of subsamples in each step as depicted in Fig. 6.Algorithm 1 describes the algorithm we used to receive a set of samples and a window size w and generate the subsample's database.Subsample (window) size is a time-value.For example, w = 6 means that the subsample contains values for 6 intervals of PowerTutor; therefore, its time-length is 6 × 500 ms = 3000 ms .
A label should be assigned to each and every subsample to determine the sample class.As shown in Algorithm 2, a classifier is trained using the subsample database DB.The sample is then splitted into a set of subsamples and the Sample Grinding algorithm (1) is used to identify each subsample's label by the trained classifier.This approach identifies the samples class based on the pattern of most similar item in the subsample's database and sets its final label by aggregating all subsamples' labels.Figure 7    In the next section, we will discuss our findings.

Findings and discussion
We experimented with different window sizes, ranging from 5 to 50 each an increment of 5 in each experiment.Hence, the window size of each dataset includes subsamples with length w.
As discussed in Sect.5, all subsamples of each sample should be classified.We evaluated grinded data using SVM (see Table 5; Fig. 11), NN (see Table 6; Fig. 12), RF (see Table 7; Fig. 13) and KNN with K = 1 classifiers.Table 3 and Fig. 9 show the result for KNN employing the Euclidean distance.Similar setting was applied for KNN using DTW distance and the findings are presented in Table 4 and Fig. 10.In order to summarise the findings and since K = 1 is the setting with higher efficiency, other settings (K = 5, 10 ) for KNN are excluded.
As shown in Fig. 14, the KNN classifier that uses DTW distance with a subsample size of 7.5 s outperformed all other methods in terms of detection rate 95.65% and perfor- mance of 94.27%.Although KNN is the least sophisticated classification approach, it outperformed other rival classification techniques since it only relies on the formation and distribution of goodware's and ransomware's subsamples.The performance of KNN using DTW for all evaluation metrics peaks at window size = 15.However, the remaining clas- sifiers were not able to achieve an optimal performance at the specified window size.For example, NN's best accuracy, precision and F-measure occurred at w = 20, while highest recall was achieved at w = 15.The numerical results indi- cate that subsamples are not from specified and exact data  Furthermore and in practice, KNN's requirement for concurrent distance calculations between training and testing objects can be implemented using parallel processing (so distances can be independently computed).Subsamples dictionary can be partitioned into sperate IoT nodes and each subsample is sent to nodes.They return a label and a similarity value and the label having less similarity value is final subsample's label.This approach reduces the classification time and mitigates the need for storage capacity in every node.

Conclusion
With increasing prevalence of Internet-connected devices and things in our data-centric society, ensuring the security of IoT networks is vital.Successfully compromised IoT nodes could hold the network to ransom (D 'Orazio et al. 2017;Choo 2014).For example, in the case of ransomware, denying availability to data in an IoT network could    adversely affect the operation of an organisation and result in significant financial loss and reputation damage.
In this paper, we presented an approach to detect ransomware, using their power consumption.Specifically, we utilise the unique local fingerprint of ransomware's energy consumption to distinguish ransomware from non-malicious applications.The sequence of applications' energy consumption is splitted into several sequences of power usage subsamples, which are then classified to build aggregated subsample's class labels.Our set of experiments demonstrated that our approach achieved a detection rate of 95.65% and a precision rate of 89.19%.
Future works include prototyping the proposed approach for deploying in a real-world IoT network, with the aims of evaluation and refinement.

Fig. 4 Fig. 5
Fig. 4 Power consumption graph for Simplocker ransomware Figures 4 and 5 illustrate the power usage graph of Simplocker ransomware and Facebook application, respectively.
illustrates the training phase, and Fig. 8 depicts classification phase of the proposed method.

Fig. 10
Fig. 10 Evaluation metrics for different window sizes, KNN and DTW distance: a comparative summary

Fig. 11
Fig. 11 Evaluation metrics for different window sizes and SVM: a comparative summary

Fig. 12
Fig. 12 Evaluation metrics for different window sizes and neural network: a comparative summary

Fig. 13
Fig. 13 Evaluation metrics for different window sizes and random forest: a comparative summary

Table 3
Evaluation metrics for different window sizes, KNN and Euclidean distance: a comparative summary Best (optimal) values are highlighted in bold Fig. 9 Evaluation Metrics for different Window Sizes, KNN and Euclidean distance: A Comparative Summary

Table 4
Evaluation metrics for different window sizes, KNN and DTW distance: a comparative summary

Table 5
Evaluation metrics for different window sizes and SVM: a comparative summary

Table 6
Evaluation metrics for different window sizes and neural network: a comparative summary Best (optimal) values are highlighted in bold

Table 7
Evaluation metrics for different window sizes and random forest: a comparative summary Best (optimal) values are highlighted in bold