Threat detection with Sysmon .csv log using Sigma Rules

I’m not sure whether my approach is completely wrong, so please let me know if it is.

So basically I have a .csv file that contains sysmon logs in this format:

"TimeCreated","EventId","Message"
"15.08.2024 22:24:12",     "11",    "File created:
RuleName: Downloads
UtcTime: 2024-08-15 20:24:12.886
ProcessGuid: {processGuid}
ProcessId: ID
Image: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
TargetFilename: C:UsersDownloadsSysmonSysmonLogs.csv
CreationUtcTime: 2024-08-15 13:51:58.523
User: Username"

And I have a few Sigma Rules specifically for sysmon, for example:

title: Suspicious Outbound RDP Connections
id: ed74fe75-7594-4b4b-ae38-e38e3fd2eb23
status: experimental
description: Detects Non-Standard Tools Connecting to TCP port 3389 indicating possible lateral movement
references:
    - https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2019-0708
author: Markus Neis - Swisscom
date: 2019/05/15
tags:
    - attack.lateral_movement
    - attack.t1210
    - car.2013-07-002
logsource:
    product: windows
    service: sysmon
detection:
    selection:
        EventID: 3
        DestinationPort: 3389
        Initiated: 'true'
    filter:
        Image:
            - '*mstsc.exe'
            - '*RTSApp.exe'
            - '*RTS2App.exe'
            - '*RDCMan.exe'
            - '*ws_TunnelService.exe'
            - '*RSSensor.exe'
            - '*RemoteDesktopManagerFree.exe'
            - '*RemoteDesktopManager.exe'
            - '*RemoteDesktopManager64.exe'
            - '*mRemoteNG.exe'
            - '*mRemote.exe'
            - '*Terminals.exe'
            - '*spiceworks-finder.exe'
            - '*FSDiscovery.exe'
            - '*FSAssessment.exe'
            - '*MobaRTE.exe'
            - '*chrome.exe'
            - '*thor.exe'
            - '*thor64.exe'
    condition: selection and not filter 
falsepositives:
    - Other Remote Desktop RDP tools
level: high

Now, I wanted to scan my .csv files and find whether there is any match in the logs with any sigma rule that I have.

I tried using pysigma with python, for example:

import os
import pandas as pd
from sigma.collection import SigmaCollection

sigma_rules_dir = 'path_to_rules'

def load_sigma_rules(directory):
    rules = []
    for filename in os.listdir(directory):
        if filename.endswith('.yml') or filename.endswith('.yaml'):
            with open(os.path.join(directory, filename), 'r') as file:
                rule_yaml = file.read()
                sigma_collection = SigmaCollection.from_yaml(rule_yaml)
                rules.extend(sigma_collection.rules)
    return rules

def process_detection_items(detection_items):
    # do detections

# Load the CSV log file
def load_logs(csv_path):
    return pd.read_csv(csv_path)

def evaluate_rule(rule, log_entry):
    # evaluate

def check_matches(df, rules):
    

csv_log_path = 'path_to_csv'
sigma_rules = load_sigma_rules(sigma_rules_dir)
df = load_logs(csv_log_path)

check_matches(df, sigma_rules)

I’ve been trying hours to get this right but I can’t make it work. And what’s worse is that I can’t find much online either with this approach.

Am I doing this wrongly? For example, how do sandboxes generally do what I’m trying to do? Is there a simpler approach that I am missing for exactly this?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật