Beispiel #1
0
def construct_msg_file_changed(file_info_list, alert_lvl):
    """
    Construct:
    1. email message from an email txt template
    2. txt email attachment contains list of files that is changed
    :param file_info_list: number of files has been changed
    :param alert_lvl: Alert level Enum
    :return: dict{subject, body, attachment}
    """

    # Message subject
    message_subject = "{} - File Change has been detected".format(alert_lvl)

    # Message body
    message_body = read_template_file(TEMPLATE.FILE_CHANGED)
    message_body = message_body.replace("%VIOLATION_COUNT%",
                                        str(len(file_info_list)))

    # Message attachment
    attachment_str = ""
    for file_info in file_info_list:
        attachment_str += "File Path: '{}'\n".format(file_info["path"])
        attachment_str += "Old Size: {}\n".format(file_info["previous_size"])
        attachment_str += "New Size: {}\n".format(file_info["new_size"])
        attachment_str += "Old Hash: {}\n".format(file_info["previous_hash"])
        attachment_str += "New Hash: {}\n".format(file_info["new_hash"])
        attachment_str += "Event time: {}\n".format(
            file_info["detection_time"])
        attachment_str += "-" * 50
        attachment_str += '\n'

    attachment_str = functions.encode_base64(attachment_str)
    email_msg_dict = {
        "subject": message_subject,
        "body": message_body,
        "attachment": attachment_str
    }
    return email_msg_dict
Beispiel #2
0
def construct_msg_file_renamed(file_info_list, alert_lvl):
    """
           Construct:
           1. email message from an email txt template
           2. txt email attachment contains list of deleted files
           :param file_info_list: number of files has been deleted
           :param alert_lvl: Alert level Enum
           :return: dict{subject, body, attachment}
           """

    # Message subject
    message_subject = "{} - File Rename has been detected".format(alert_lvl)

    # Message body
    message_body = read_template_file(TEMPLATE.FILE_RENAMED)
    message_body = message_body.replace("%RENAME_COUNT%",
                                        str(len(file_info_list)))

    # Message attachment
    attachment_str = ""
    for file_info in file_info_list:
        attachment_str += "Old Path: '{}'\n".format(file_info["old_path"])
        attachment_str += "New Path: '{}'\n".format(file_info["new_path"])
        attachment_str += "Hash: {}\n".format(file_info["hash"])
        attachment_str += "Event time: {}\n".format(
            file_info["detection_time"])
        attachment_str += "-" * 50
        attachment_str += '\n'

    attachment_str = functions.encode_base64(attachment_str)
    email_msg_dict = {
        "subject": message_subject,
        "body": message_body,
        "attachment": attachment_str
    }
    return email_msg_dict
string2 = functions.decode_dec(string)
end = time()
print("decodeDec()   : %lf us" % ((end - start) * 1000000))

start = time()
string = functions.encode_hex(help_message)
end = time()
print("encodeHex()   : %lf us" % ((end - start) * 1000000))

start = time()
string2 = functions.decode_hex(string)
end = time()
print("decodeHex()   : %lf us" % ((end - start) * 1000000))

start = time()
string = functions.encode_base64(help_message)
end = time()
print("encodeBase64(): %lf us" % ((end - start) * 1000000))

start = time()
string2 = functions.decode_base64(string)
end = time()
print("decodeBase64(): %lf us" % ((end - start) * 1000000))

start = time()
string2 = functions.rot5(string)
end = time()
print("rot5()        : %lf us" % ((end - start) * 1000000))

start = time()
string2 = functions.rot13(string)
         comment.reply(functions.rot13(target))
         print("reply sent: ROT13.")
     if service_requested & constants.MASK_CODE == constants.CODE_ROT5:
         comment.reply(functions.rot5(target))
         print("reply sent: ROT5.")
     if service_requested & constants.MASK_CODE == constants.CODE_ROT18:
         comment.reply(
             functions.rot13(
                 functions.rot5(target)))
         print("reply sent: ROT18.")
     if service_requested & constants.MASK_CODE == constants.CODE_ROT47:
         comment.reply(functions.rot47(target))
         print("reply sent: ROT47.")
     if service_requested & constants.MASK_CODE == constants.CODE_BASE64:
         comment.reply(
             functions.encode_base64(target))
         print("reply sent: base-64.")
     if service_requested & constants.MASK_CODE == constants.CODE_UNKNOWN:
         comment.reply(
             (constants.err_code_unknown %
              code) +
             constants.usage_instructions)
         print(
             "reply sent: error message, code unknown."
         )
     cache += comment.id
     posts_replied_to.append(comment.id)
     replySent = True
 elif service_requested & constants.MASK_CMD == constants.CMD_DECODE:
     if service_requested & constants.MASK_CODE == constants.CODE_BIN:
         comment.reply(