日韩欧美人妻无码精品白浆,夜夜嗨AV免费入口,国产欧美官网在线看,高校回应聋哑女生因长相完美被质疑

LOGO OA教程 ERP教程 模切知識(shí)交流 PMS教程 CRM教程 開發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

【C#】查詢Windows服務(wù)器遠(yuǎn)程桌面RDP協(xié)議登錄事件,獲取并導(dǎo)出當(dāng)前服務(wù)器用戶登錄記錄

admin
2025年2月14日 15:32 本文熱度 1194

【C#】查詢Windows服務(wù)器遠(yuǎn)程桌面RDP協(xié)議登錄事件,獲取并導(dǎo)出當(dāng)前服務(wù)器用戶登錄記錄

參考:https://github.com/uknowsec/SharpEventLog

簡介:讀取登錄過本機(jī)的登錄失敗或登錄成功的所有計(jì)算機(jī)信息,在內(nèi)網(wǎng)滲透中快速定位運(yùn)維管理人員。

輸出:登錄時(shí)間、源IP地址、域名、用戶名、是否成功

原理:通過Win API 獲取windows事件安全日志中ID為4624、4625的事件,提取事件中的關(guān)鍵信息。

源碼參考:

using System;

using System.Collections.Generic;

using System.Diagnostics;

using System.Linq;

using System.Text;


namespace SharpEventLog

{

    class Program

    {

        static void Main(string[] args)

        {

            System.Console.WriteLine("");

            System.Console.WriteLine("Author: Uknow");

            System.Console.WriteLine("Github: https://github.com/uknowsec/SharpEventLog");

            System.Console.WriteLine("");

            if (args.Length == 0)

            {

                System.Console.WriteLine("Usage: SharpEventLog.exe -4624");

                System.Console.WriteLine("       SharpEventLog.exe -4625");

            }

            if (args.Length == 1 && (args[0] == "-4624"))

            {

                EventLog_4624();

            }

            if (args.Length == 1 && (args[0] == "-4625"))

            {

                EventLog_4625();

            }

        }


        public static void EventLog_4624()

        {

            EventLog log = new EventLog("Security");

            Console.WriteLine("\r\n========== SharpEventLog -> 4624 ==========\r\n");

            var entries = log.Entries.Cast<EventLogEntry>().Where(x => x.InstanceId == 4624);

            entries.Select(x => new

            {

                x.MachineName,

                x.Site,

                x.Source,

                x.Message,

                x.TimeGenerated

            }).ToList();

            foreach (EventLogEntry log1 in entries)

            {

                string text = log1.Message;

                string ipaddress = MidStrEx(text, " 源網(wǎng)絡(luò)地址: ", " 源端口:");

                string username = MidStrEx(text, "新登錄:", "進(jìn)程信息:");

                username = MidStrEx(username, " 帳戶名: ", " 帳戶域: ");

                DateTime Time = log1.TimeGenerated;

                if (ipaddress.Length >= 7)

                {

                    Console.WriteLine("\r\n-----------------------------------");

                    Console.WriteLine("Time: " + Time);

                    Console.WriteLine("Status: True");

                    Console.WriteLine("Username: " + username.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", ""));

                    Console.WriteLine("Remote ip: " + ipaddress.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", ""));

                }

            }

        }


        public static void EventLog_4625()

        {

            EventLog log = new EventLog("Security");

            Console.WriteLine("\r\n========== SharpEventLog -> 4625 ==========\r\n");

            var entries = log.Entries.Cast<EventLogEntry>().Where(x => x.InstanceId == 4625);

            entries.Select(x => new

            {

                x.MachineName,

                x.Site,

                x.Source,

                x.Message,

                x.TimeGenerated

            }).ToList();

            foreach (EventLogEntry log1 in entries)

            {

                string text = log1.Message;

                string ipaddress = MidStrEx(text, " 源網(wǎng)絡(luò)地址: ", " 源端口:");

                string username = MidStrEx(text, "新登錄:", "進(jìn)程信息:");

                username = MidStrEx(username, " 帳戶名: ", " 帳戶域: ");

                DateTime Time = log1.TimeGenerated;

                if (ipaddress.Length >= 7)

                {

                    Console.WriteLine("\r\n-----------------------------------");

                    Console.WriteLine("Time: " + Time);

                    Console.WriteLine("Status: Flase");

                    Console.WriteLine("Username: " + username.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", ""));

                    Console.WriteLine("Remote ip: " + ipaddress.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", ""));

                }

            }

        }


        public static string MidStrEx(string sourse, string startstr, string endstr)

        {

            string result = string.Empty;

            int startindex, endindex;

            startindex = sourse.IndexOf(startstr);

            if (startindex == -1)

                return result;

            string tmpstr = sourse.Substring(startindex + startstr.Length);

            endindex = tmpstr.IndexOf(endstr);

            if (endindex == -1)

                return result;

            result = tmpstr.Remove(endindex);


            return result;

        }

    }

}

使用說明

打開cmd.exe

> SharpEventLog.exe

Author: Uknow

Github: https://github.com/uknowsec/SharpEventLog

Usage: SharpEventLog.exe -4624

       SharpEventLog.exe -4625


該文章在 2025/2/14 15:36:03 編輯過
關(guān)鍵字查詢
相關(guān)文章
正在查詢...
點(diǎn)晴ERP是一款針對(duì)中小制造業(yè)的專業(yè)生產(chǎn)管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國內(nèi)大量中小企業(yè)的青睞。
點(diǎn)晴PMS碼頭管理系統(tǒng)主要針對(duì)港口碼頭集裝箱與散貨日常運(yùn)作、調(diào)度、堆場、車隊(duì)、財(cái)務(wù)費(fèi)用、相關(guān)報(bào)表等業(yè)務(wù)管理,結(jié)合碼頭的業(yè)務(wù)特點(diǎn),圍繞調(diào)度、堆場作業(yè)而開發(fā)的。集技術(shù)的先進(jìn)性、管理的有效性于一體,是物流碼頭及其他港口類企業(yè)的高效ERP管理信息系統(tǒng)。
點(diǎn)晴WMS倉儲(chǔ)管理系統(tǒng)提供了貨物產(chǎn)品管理,銷售管理,采購管理,倉儲(chǔ)管理,倉庫管理,保質(zhì)期管理,貨位管理,庫位管理,生產(chǎn)管理,WMS管理系統(tǒng),標(biāo)簽打印,條形碼,二維碼管理,批號(hào)管理軟件。
點(diǎn)晴免費(fèi)OA是一款軟件和通用服務(wù)都免費(fèi),不限功能、不限時(shí)間、不限用戶的免費(fèi)OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved