Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用pandas分析Windows事件日志(安全性)的消息字段_Python_Windows_Python 3.x_Pandas - Fatal编程技术网

Python 使用pandas分析Windows事件日志(安全性)的消息字段

Python 使用pandas分析Windows事件日志(安全性)的消息字段,python,windows,python-3.x,pandas,Python,Windows,Python 3.x,Pandas,我有一个安全事件日志的数据框架,如下所示: "machinename","eventid","entrytype","source","timegenerated","timewritten","username","message" "MyMachineName","4656","failureaudit","microsoft-windows-security-auditing","3/7/2017 3:34:09 pm","3/7/2017 3:34:09 pm",,"a handle t

我有一个安全事件日志的数据框架,如下所示:

"machinename","eventid","entrytype","source","timegenerated","timewritten","username","message"
"MyMachineName","4656","failureaudit","microsoft-windows-security-auditing","3/7/2017 3:34:09 pm","3/7/2017 3:34:09 pm",,"a handle to an object was requested.    subject:   security id:  s-1-5-21-123456789-123456789-123456789-1381912   account name:  account.name.matt   account domain:  mydomain   logon id:  0x0d4d0d1d    object:   object server:  security   object type:  key   object name:  \registry\machine\system\controlset001\control\class\{1d36e972-f315-1111-b2d3-09112bf10211}\properties   handle id:  0x0    process information:   process id:  0x35f4   process name:  c:\windows\system32\wbem\wmiprvse.exe    access request information:   transaction id:  {00000000-0000-0000-0000-000000000000}   accesses:  %%1538      %%4432      %%4435      %%4436         access reasons:  -   access mask:  0x20019   privileges used for access check: -   restricted sid count: 0"
"MyMachineName","4688","successaudit","microsoft-windows-security-auditing","1/1/2011 3:34:09 pm","1/1/2011 3:34:09 pm",,"a new process has been created.    subject:   security id:  s-1-5-18   account name:  account.name.matt    account domain:  mydomain  logon id:  0x3e5    process information:   new process id:  0x1e98   new process name: c:\windows\system32\conhost.exe   token elevation type: %%1936   creator process id: 0x1b8   process command line:     token elevation type indicates the type of token that was assigned to the new process in accordance with user account control policy.    type 1 is a full token with no privileges removed or groups disabled.  a full token is only used if user account control is disabled or if the user is the built-in administrator account or a service account.    type 2 is an elevated token with no privileges removed or groups disabled.  an elevated token is used when user account control is enabled and the user chooses to start the program using run as administrator.  an elevated token is also used when an application is configured to always require administrative privilege or to always require maximum privilege, and the user is a member of the administrators group.    type 3 is a limited token with administrative privileges removed and administrative groups disabled.  the limited token is used when user account control is enabled, the application does not require administrative privilege, and the user does not choose to start the program using run as administrator."
如何展开“Message”字段并基于每个键值对创建一组列,使句子与键值对分开

本质上,我希望获取任何事件,并根据消息中的键值对进行转换

我已经像下面那样拆分了消息,但是输出将项目放入列表中。不知道如何添加正确的列

print(security.message.str.split(":\\s"))

任何帮助都会很好。谢谢

我真的很想发表评论,但不能这么说。您是否检查邮件是否正确拆分?
一旦有了项目列表,就可以使用join、append或concat添加其他列。请参见

我已尝试以多种方式拆分。我看到的问题是,我得到了一个拆分的内容列表,但是我需要专门创建一个列标题,或者根据前面有:的字段扩展到一个列名。在安全消息字段中,有许多不同的格式。我想看看是否有人专门解决了这个问题。我想你需要将这些值拆分成一个字典,检查一下这一点一旦你有了键值对,键就可以成为列名。@johnnyb Regex可能是一个解决方案,但我认为你的数据不适合轻松拆分。大多数键都是两个词,但有些不是这样。通过自动捕获内容,您将最终捕获部分数据作为键,反之亦然。