Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some new logs cannot be dumped with archive logs #21

Closed
Gomeow opened this issue Jul 7, 2020 · 5 comments
Closed

Some new logs cannot be dumped with archive logs #21

Gomeow opened this issue Jul 7, 2020 · 5 comments

Comments

@Gomeow
Copy link

Gomeow commented Jul 7, 2020

Hello everyone,

I have some problem with archive evtx logs on windows server 2016(1607).

Some new logs cannot be shown when using evtxdump.

How it happens: Install one 2016 server, set 'Security Log' to Archieve when is full. Then dump the 'Security.evtx' without open it in eventviewer.
I found out the logs canbe correctly dumped when double click on the evtx file (open it with windows eventviewer).
And also the file was changed only by open it with windows eventviewer.(Some times the evtx file sizes changed at all.)
Snap20200707091024
The different dump only with opend the file:
Snap_not_opened
Snap_opened

Here is the evtx file.
Security.zip

Thanks.

@qjerome
Copy link
Contributor

qjerome commented Jul 9, 2020

Hi @Gomeow,

Did you think about comparing the number of events shown in Event Viewer and the number of event dumped with evtxdump ? If that number is the same for a given file it is likely the issue is not on evtxdump side.

Please let me know what is the result of this comparison.

Cheers,

@Gomeow
Copy link
Author

Gomeow commented Jul 9, 2020

Hi @qjerome ,

They do have difference and here are some snap. Just using the file uploaded before.(with 1.2.2 release)

There should be 460 recoreds in the evtx file.

Filesize
Filelines
eventviewercount
SnapCount

Thanks.

@qjerome
Copy link
Contributor

qjerome commented Jul 9, 2020

Thank you for your feedback. This is indeed very strange.
Let me investigate this and I will revert back to you.

@qjerome
Copy link
Contributor

qjerome commented Jul 9, 2020

It seems the Security.evtx file is not consistent.
There is a dump of the file header:

File Header: Security.evtx

Magic: ElfFile
FirstChunkNum: 0
LastChunkNum: 3
NumNextRecord: 320
HeaderSpace: 128
MinVersion: 0x0001
MaxVersion: 0x0003
SizeHeader: 4096
ChunkCount: 4
Flags: 0x00000001
CheckSum: 0x62778716

You can see that there are 4 chunks, a chunk being a structure where several events are encoded.
On the other hand, if we use the carving feature of evtxdump that is looking for chunk header magic number and parse everything looking like a chunk, we see that 6 chunks are actually parsed, and you actually get the expected number of events.

./evtxdump-386 -c Security.evtx | wc -l
2020/07/09 14:01:21 INFO - Parsing Chunk @ Offset: 4096 (0x00001000)
2020/07/09 14:01:22 INFO - Parsing Chunk @ Offset: 69632 (0x00011000)
2020/07/09 14:01:22 INFO - Parsing Chunk @ Offset: 135168 (0x00021000)
2020/07/09 14:01:22 INFO - Parsing Chunk @ Offset: 200704 (0x00031000)
2020/07/09 14:01:22 INFO - Parsing Chunk @ Offset: 266240 (0x00041000)
2020/07/09 14:01:22 INFO - Parsing Chunk @ Offset: 331776 (0x00051000)
460 --> that is the result of wc, so the count of events

So my theory is the following, your file has a wrong header for a reason I ignore. When you open it in Event Viewer, it sees that there is an error and fixes the header. That is why after you have opened the file, it gets modified on disk and then the number of event is correct with evtxdump. So I would not qualify this issue as a bug in evtxdump because the tool parses the data correctly with the data it has, it is just that the header is incorrect. I will not provide any fix to address that issue since there is already the carving option to force chunk parsing when that is needed. Though I am considering implementing a verify option to diagnose this kind of issue more easily.

Thanks for reporting that issue.

@qjerome qjerome closed this as completed Jul 9, 2020
qjerome added a commit that referenced this issue Jul 10, 2020
@qjerome
Copy link
Contributor

qjerome commented Jul 10, 2020

Hey @Gomeow,

After a deeper analysis I noticed that your file was in a "dirty" state.
This information is available in the Flags member of the File Header structure.
So I fixed evtxdump so that when the file is in "dirty" state the Header gets repaired before further processing.
You can use the last release of evtxdump and you will get the expected number of events.

Thanks again for reporting this issue that allowed me to improve the tool.

@qjerome qjerome reopened this Jul 10, 2020
@qjerome qjerome closed this as completed Jul 10, 2020
mireaulf added a commit to refractionPOINT/golang-evtx that referenced this issue Feb 16, 2021
* fixes 0xrawsec#12 - only unmarshal UTF16String when the size is greater than zero

* Update evtx.File to support generic interfaces

* Docs

* Fix issue 0xrawsec#12

* Changed version in makefile

* Fixed issue 0xrawsec#16

* Corrected wrong fix of issue 0xrawsec#16, then also fix issue 0xrawsec#17

* Fixed issues: 0xrawsec#15 and 0xrawsec#21

* Version upgrade

* Version bump for evtxdump and evtxmon

* Fixed issue 0xrawsec#23

* Addressed issue 0xrawsec#25

* Fixed issue 0xrawsec#25

* Fixed issue 0xrawsec#27

* Standardized GoEvtxMap.Del API

* Fixed bug in GoEvtxMap.Del

* Return error from TemplateInstance.ElementToGoEvtx

* Bubble up error from NodeToGoEvtx

* Bubble up error from ElementToGoEvtx

* Bubble up errors from GoEvtxMap

* Update tests

* Panic on error in tests

Co-authored-by: Josh VanderLinden <[email protected]>
Co-authored-by: Quentin JEROME <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants