Giter VIP home page Giter VIP logo

Comments (5)

omerbenamram avatar omerbenamram commented on August 16, 2024 1

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.

forensicmatt avatar forensicmatt commented on August 16, 2024 1

@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.

forensicmatt avatar forensicmatt commented on August 16, 2024 1

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.

OlafHaalstra avatar OlafHaalstra commented on August 16, 2024

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.

forensicmatt avatar forensicmatt commented on August 16, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.