Windowsサービスが削除されたときに検出されます

BillyDay:

Windowsサービスが削除されたときを検出する方法はありますか?私は、イベントログをチェックしましたが、それは唯一の追加、削除アクションをピックアップしていません。

私は、監査ログを使用した方法があるかもしれないと考えているが、私はこれを行う方法がわからないんですか?

すべてのヘルプははるかに高く評価されます。

感謝

クリント:

サービス削除の痕跡がでありませんが、イベントまたは監査ログ、何ができるサービスが存在し、このアプリを添付する場合はやっていることを検知することを小さなコンソールアプリケーションを作成しているWindows Task Scheduler、周波数またはに基づいて実行されるようにスケジュールされるようにトリガしますことをあなたにカスタマイズすることができ要件サービスがされた場合は、アラートを受信するような追加削除など。

コンソールアプリケーションは、最初の実行時に、それはシステム上で、それが経由してサービスに加えられた変更を追跡されます以降の実行上のすべてのサービスをログに記録するように設計されているservicesRemovedと、servicesAddedこれで我々はサービスが持っているときにとるべきアクションを決めることができ、されて修正

コンソールアプリケーション:ServiceDetector.exe

static void Main(string[] args)
{
    var path = @"C:\AdminLocation\ServicesLog.txt";

    var currentServiceCollection = ServiceController.GetServices().Select(s => s.ServiceName).ToList(); //Queries the most current Services from the machine

    if (!File.Exists(path)) //Creates a Log file with current services if not present, usually means the first run
    {
        // Assumption made is that this is the first run
        using (var text = File.AppendText(path))
        {
            currentServiceCollection.ForEach((s) => text.WriteLine(s));
        }
        return;
    }

    // Fetches the recorded services from the Log
    var existingServiceCollection = File.ReadAllLines(path).ToList();

    var servicesRemoved = existingServiceCollection.Except(currentServiceCollection).ToList();
    var servicesAdded = currentServiceCollection.Except(existingServiceCollection).ToList();

    if (!servicesAdded.Any() && !servicesRemoved.Any())
    { Console.WriteLine("No services have been added or removed"); return; }

    //If any services has been added
    if (servicesAdded.Any())
    {
        Console.WriteLine("One or more services has been added");
        using (var text = File.AppendText(path))
        {
            servicesAdded.ForEach((s) => text.WriteLine(s));
        }
        return;
    }
    //Service(s) may have been deleted, you can choose to record it or not based on your requirements
    Console.WriteLine("One or more services has been removed");

}

スケジュール設定タスク

Windowsの[スタート]> [タスクスケジューラ]> [基本タスクの作成>トリガの設定は>あなたのexeファイル]> [完了]をアタッチ

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=369150&siteId=1