@@ -64,7 +64,7 @@ def installCSF():
6464 command = 'yum install bind-utils perl-libwww-perl net-tools perl-LWP-Protocol-https -y'
6565 ProcessUtilities .normalExecutioner (command )
6666 elif ProcessUtilities .decideDistro () == ProcessUtilities .ubuntu :
67- command = 'apt-get install dnsutils libwww-perl -y'
67+ command = 'apt-get install dnsutils libwww-perl net-tools -y'
6868 ProcessUtilities .normalExecutioner (command )
6969 else :
7070
@@ -266,7 +266,19 @@ def installCSF():
266266 # HTACCESS_LOG is ins main error.log
267267 elif items .find ('HTACCESS_LOG =' ) > - 1 and items .find ('=' ) > - 1 and (items [0 ] != '#' ):
268268 writeToConf .writelines ('HTACCESS_LOG = "/usr/local/lsws/logs/error.log"\n ' )
269- elif ProcessUtilities .decideDistro () == ProcessUtilities .ubuntu :
269+ else :
270+ writeToConf .writelines (items )
271+
272+ writeToConf .close ()
273+
274+ ##
275+
276+ # Some Ubuntu initial configurations
277+ if ProcessUtilities .decideDistro () == ProcessUtilities .ubuntu :
278+ data = open ('/etc/csf/csf.conf' , 'r' ).readlines ()
279+ writeToConf = open ('/etc/csf/csf.conf' , 'w' )
280+
281+ for items in data :
270282 if items .find ('SSHD_LOG =' ) > - 1 and items .find ('=' ) > - 1 and (items [0 ] != '#' ):
271283 writeToConf .writelines ('SSHD_LOG = "/var/log/auth.log"\n ' )
272284 elif items .find ('SU_LOG =' ) > - 1 and items .find ('=' ) > - 1 and (items [0 ] != '#' ):
@@ -277,14 +289,16 @@ def installCSF():
277289 writeToConf .writelines ('POP3D_LOG = "/var/log/mail.log"\n ' )
278290 elif items .find ('IMAPD_LOG =' ) > - 1 and items .find ('=' ) > - 1 and (items [0 ] != '#' ):
279291 writeToConf .writelines ('IMAPD_LOG = "/var/log/mail.log"\n ' )
292+ elif items .find ('IPTABLES_LOG =' ) > - 1 and items .find ('=' ) > - 1 and (items [0 ] != '#' ):
293+ writeToConf .writelines ('IPTABLES_LOG = "/var/log/kern.log"\n ' )
280294 elif items .find ('SYSLOG_LOG =' ) > - 1 and items .find ('=' ) > - 1 and (items [0 ] != '#' ):
281295 writeToConf .writelines ('SYSLOG_LOG = "/var/log/syslog"\n ' )
282- else :
283- writeToConf .writelines (items )
296+ else :
297+ writeToConf .writelines (items )
298+ writeToConf .close ()
284299
285- writeToConf . close ()
300+ ##
286301
287- ##
288302
289303 command = 'csf -s'
290304 ProcessUtilities .normalExecutioner (command )
@@ -495,19 +509,11 @@ def blockIP(ipAddress):
495509 except BaseException , msg :
496510 logging .CyberCPLogFileWriter .writeToFile (str (msg ) + "[blockIP]" )
497511
498- @staticmethod
499- def run_command (command ):
500- p = subprocess .Popen (command ,
501- stdout = subprocess .PIPE ,
502- stderr = subprocess .STDOUT )
503- return iter (p .stdout .readline , b'' )
504-
505512 @staticmethod
506513 def checkIP (ipAddress ):
507514 try :
508- command = "sudo csf -g ' + ipAddress.split()"
509- for line in CSF .run_command (command ):
510- print (line )
515+ command = 'sudo csf -g ' + ipAddress
516+ ProcessUtilities .executioner (command )
511517
512518 except BaseException , msg :
513519 logging .CyberCPLogFileWriter .writeToFile (str (msg ) + "[checkIP]" )
0 commit comments