Comments (5)
I would probably use jq
for this. https://stackoverflow.com/questions/49632521/how-to-add-a-field-to-a-json-object-with-the-jq-command.
It can also handle streams if that's an issue https://stackoverflow.com/questions/62825963/improving-performance-when-using-jq-to-process-large-files.
from evtx.
@OlafHaalstra , you will want to create a custom tool around the evtx
library and do something like this:
let mut evtx_parser = match EvtxParser::from_path(path) {
Ok(p) => p.with_configuration(parser_settings),
Err(e) => {
eprintln!("Error handling {}; {}", path.display(), e);
return;
}
};
for result in evtx_parser.records_json_value() {
let record = match result {
Ok(r) => r,
Err(e) => {
eprintln!("Error serializing event record: {}", e);
continue;
}
};
let mut json_value = record.data;
json_value["source_file"] = json!(path.to_string_lossy());
println!("{}", json_value);
}
I am actually planning to make a YouTube video this week that will showcase just this along with things like recursing and parsing files in parallel. Subscribe and hit the bell so it will alert you when this video comes out (https://www.youtube.com/channel/UCudIWnSPimNaqMyGoKbaneQ)
from evtx.
Preferably I want to have it baked into the code. Not sure where to start. Running into problems with option (2): apparently renaming fields is not trivial.
Replacing values is quite easy with:
*v.get_mut("name").unwrap() = json!("Alice");
As well as adding something:let new_data = r#"{"name":"Alice"}"#; let new_value: JSONValue = serde_json::from_str(new_data)?; v["new"] = new_value;
Baking this into the library is not a good idea. Its better to augment data after you have parsed the raw data as this is personal preference on how you want to structure metadata around the parsed entry.
from evtx.
Preferably I want to have it baked into the code. Not sure where to start. Running into problems with option (2): apparently renaming fields is not trivial.
Replacing values is quite easy with: *v.get_mut("name").unwrap() = json!("Alice");
As well as adding something:
let new_data = r#"{"name":"Alice"}"#;
let new_value: JSONValue = serde_json::from_str(new_data)?;
v["new"] = new_value;
from evtx.
@OlafHaalstra I made a video that I think will answer your question on how to do this and also give you an example of how to create a CLI around this library and tweak the json values. https://www.youtube.com/watch?v=yVeCAMQ5fZo
from evtx.
Related Issues (20)
- pip3 install evtx lead to "ERROR: Command errored out with exit status 1:" HOT 2
- how to use "descending order" parser
- Parser fails if last_event_record_id and free_space_offset are set wrong in the Chunk Header
- # in JSON field name prevents import in GCP Bigquery HOT 2
- Invalid behaviour when parsing Evtx from Windows Event Forwarding HOT 8
- Error while parsing .evtx files with unknown file header flags and chunk flags
- 5111875 is an unknown value for bool, coercing to `true`
- thread 'main' panicked at 'invalid or out-of-range date' HOT 1
- macos 0.7.2 HOT 1
- Warnings will become errors
- Command line flag to skip printing "#attributes" while taking output as JSON
- thread 'main' panicked at 'attempt to subtract with overflow' in `src/binxml/tokens.rs:98:24`
- Problems parsing evtx files originating from NetApp HOT 2
- error on evtx files for header and hexdump
- tailing HOT 2
- Any options to exclude the record # and xml version lines? HOT 1
- RecordId should be public
- Passing a file via stdin?
- wrong ordering in records returned by records() iterator HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from evtx.