Commits

Cédric Bonhomme committed d2e52bc

Bitmessage integration.

  • Participants
  • Parent commits 9cc3dc2

Comments (0)

Files changed (3)

File conf.cfg-sample

 smtp = SMTP_server
 username = your_username
 password = your_password
+[bitmessage]
+from = BM-2DCutnUZG16WiW3mdAm66jJUSCUv88xLgS
+to = BM-Gtsm7PUabZecs3qTeXbNPmqx3xtHCSXF
+enabled = 0
+apiport = 8442
+apiinterface = 127.0.0.1
+apiusername = chelsea 
+apipassword = YourSuperPassw6rd-ChangeThIs-022w3eksssoQAWfasddswwWIU
 [files]
 file1 = /etc/crontab
 file2 = /boot/grub/grub.cfg
 USERNAME =  config.get('email','username')
 PASSWORD =  config.get('email','password')
 
+BITMESSAGE_ENABLED = bool(int(config.get('bitmessage','enabled')))
+BITMESSAGE_FROM = config.get('bitmessage','from')
+BITMESSAGE_TO = config.get('bitmessage','to')
+API_PORT = int(config.get('bitmessage','apiport'))
+API_INTERFACE = config.get('bitmessage','apiinterface')
+BITMESSAGE_USERNAME =  config.get('bitmessage','apiusername')
+BITMESSAGE_PASSWORD =  config.get('bitmessage','apipassword')
+
 # address of the log file :
 LOGS = os.path.join(PATH, "log")
 # address of the database of hash values :
 __author__ = "Cedric Bonhomme"
 __version__ = "$Revision: 0.4 $"
 __date__ = "$Date: 2010/03/06 $"
-__revesion__ = "$Date: 2013/07/23 $"
-__copyright__ = "Copyright (c) 2010-2013 Cedric Bonhomme"
+__revision__ = "$Date: 2014/01/07 $"
+__copyright__ = "Copyright (c) 2010-2014 Cedric Bonhomme"
 __license__ = "GPL v3"
 
 import os
 
 import conf
 
+if conf.BITMESSAGE_ENABLED:
+    import xmlrpclib
+    BITMESSAGE_API = xmlrpclib.ServerProxy("http://" + conf.BITMESSAGE_USERNAME + ":" + \
+                        conf.BITMESSAGE_PASSWORD + "@" + conf.API_INTERFACE + ":" + conf.API_PORT)
+
 # lock object to protect the log file during the writing
 lock = threading.Lock()
 # lock object used when sending alerts via irc
             # reporting alert via IRC
             log_irker(conf.IRC_CHANNEL, message)
 
-        if conf.MAIL_ENABLED:
+        if conf.MAIL_ENABLED or conf.BITMESSAGE_ENABLED:
             Q.put(message + "\n")
 
 @contextmanager
         print("Base of hash values can not be loaded.")
         exit(0)
 
-    email_report = ""
+    report = ""
 
     # Check the integrity of monitored files
     list_of_threads = []
         th.join()
 
     while not Q.empty():
-        email_report += Q.get(True, 0.5)
+        report += Q.get(True, 0.5)
 
     local_time = time.strftime("[%d/%m/%y %H:%M:%S]", time.localtime())
     log(local_time + " Error(s) : " + str(error))
         log_file.close()
 
     if conf.MAIL_ENABLED:
-        if email_report != "":
+        if report != "":
             # reporting alert via mail
             # this list contains the admins to prevent
             for admin in conf.MAIL_TO:
                 log_mail(conf.MAIL_FROM, \
                         admin, \
-                        email_report+"\n\nHave a nice day !\n\n" + \
+                        report+"\n\nHave a nice day !\n\n" + \
                         "\nThis mail was sent to :\n"+"\n".join(conf.MAIL_TO))
         message = "A system check successfully terminated at " + local_time + "."
         for admin in conf.MAIL_TO:
                         admin, \
                         message+"\n\nHave a nice day !\n\n" + \
                         "\nThis mail was sent to :\n"+"\n".join(conf.MAIL_TO))
+    if conf.BITMESSAGE_ENABLED:
+        if report != "":
+            # reporting alert via Bitessage
+            BITMESSAGE_API.sendMessage(conf.BITMESSAGE_TO, conf.BITMESSAGE_FROM, \
+                                'pyHIDS : Alert', \
+                                report+"\n\nHave a nice day !\n\n" + \
+                                "\nThis mail was sent to :\n"+"\n".join(conf.MAIL_TO))