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

add JSON-formatted output mode #31

Closed
williballenthin opened this issue Jun 27, 2020 · 3 comments
Closed

add JSON-formatted output mode #31

williballenthin opened this issue Jun 27, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@williballenthin
Copy link
Collaborator

williballenthin commented Jun 27, 2020

use this JSON as the source data for all formatters. this will ensure it has all data necessary to render complete details of capa matches.

the JSON document will be the primary method of integration for external tools and scripts, rather than supporting a multitude of integrations.

@williballenthin williballenthin added the enhancement New feature or request label Jun 27, 2020
@williballenthin williballenthin self-assigned this Jun 27, 2020
@williballenthin
Copy link
Collaborator Author

williballenthin commented Jun 27, 2020

plan:

{
  $rule-name: {
    "meta": {...copy of rule.meta...},
    "matches": {
      0x401000: { ...TODO: details of logic match...},
      ...
    }
  },
  ...
}

@williballenthin
Copy link
Collaborator Author

williballenthin commented Jun 27, 2020

d0345fc

example output:

{
    "calculate module 256 via x86 assembly": {...},
    "read file via mapping": {
        "matches": {
            "4198560": {
                "children": [
                    {
                        "children": [],
                        "locations": [
                            4198630
                        ],
                        "node": {
                            "feature": {
                                "api": "kernel32.MapViewOfFile",
                                "type": "api"
                            },
                            "type": "feature"
                        },
                        "success": true
                    },
                    {
                        "children": [],
                        "locations": [
                            4198599,
                            4198661
                        ],
                        "node": {
                            "feature": {
                                "number": 4,
                                "type": "number"
                            },
                            "type": "feature"
                        },
                        "success": true
                    },
                    {
                        "children": [
                            {
                                "children": [],
                                "locations": [
                                    4198843
                                ],
                                "node": {
                                    "feature": {
                                        "api": "kernel32.UnmapViewOfFile",
                                        "type": "api"
                                    },
                                    "type": "feature"
                                },
                                "success": true
                            },
                            {
                                "children": [
                                    {
                                        "children": [],
                                        "node": {
                                            "feature": {
                                                "match": "get file size",
                                                "type": "match"
                                            },
                                            "type": "feature"
                                        },
                                        "success": false
                                    },
                                    {
                                        "children": [],
                                        "locations": [
                                            4198608
                                        ],
                                        "node": {
                                            "feature": {
                                                "api": "kernel32.CreateFileMapping",
                                                "type": "api"
                                            },
                                            "type": "feature"
                                        },
                                        "success": true
                                    },
                                    {
                                        "children": [],
                                        "locations": [
                                            4198803
                                        ],
                                        "node": {
                                            "feature": {
                                                "number": 2,
                                                "type": "number"
                                            },
                                            "type": "feature"
                                        },
                                        "success": true
                                    }
                                ],
                                "node": {
                                    "statement": {
                                        "type": "and"
                                    },
                                    "type": "statement"
                                },
                                "success": false
                            }
                        ],
                        "node": {
                            "statement": {
                                "type": "optional"
                            },
                            "type": "statement"
                        },
                        "success": true
                    }
                ],
                "node": {
                    "statement": {
                        "type": "and"
                    },
                    "type": "statement"
                },
                "success": true
            },
            "4199488": {
                "children": [
                    {
                        "children": [],
                        "locations": [
                            4199636,
                            4199717
                        ],
                        "node": {
                            "feature": {
                                "api": "kernel32.MapViewOfFile",
                                "type": "api"
                            },
                            "type": "feature"
                        },
                        "success": true
                    },
                    {
                        "children": [],
                        "locations": [
                            4199633,
                            4199687,
                            4199903,
                            4200316,
                            4200346,
                            4200382
                        ],
                        "node": {
                            "feature": {
                                "number": 4,
                                "type": "number"
                            },
                            "type": "feature"
                        },
                        "success": true
                    },
                    {
                        "children": [
                            {
                                "children": [],
                                "node": {
                                    "feature": {
                                        "api": "kernel32.UnmapViewOfFile",
                                        "type": "api"
                                    },
                                    "type": "feature"
                                },
                                "success": false
                            },
                            {
                                "children": [
                                    {
                                        "children": [],
                                        "node": {
                                            "feature": {
                                                "match": "get file size",
                                                "type": "match"
                                            },
                                            "type": "feature"
                                        },
                                        "success": false
                                    },
                                    {
                                        "children": [],
                                        "locations": [
                                            4199619,
                                            4199692
                                        ],
                                        "node": {
                                            "feature": {
                                                "api": "kernel32.CreateFileMapping",
                                                "type": "api"
                                            },
                                            "type": "feature"
                                        },
                                        "success": true
                                    },
                                    {
                                        "children": [],
                                        "locations": [
                                            4199495,
                                            4199546,
                                            4199549,
                                            4199610,
                                            4199869,
                                            4200156,
                                            4200264,
                                            4200313,
                                            4200335
                                        ],
                                        "node": {
                                            "feature": {
                                                "number": 2,
                                                "type": "number"
                                            },
                                            "type": "feature"
                                        },
                                        "success": true
                                    }
                                ],
                                "node": {
                                    "statement": {
                                        "type": "and"
                                    },
                                    "type": "statement"
                                },
                                "success": false
                            }
                        ],
                        "node": {
                            "statement": {
                                "type": "optional"
                            },
                            "type": "statement"
                        },
                        "success": true
                    }
                ],
                "node": {
                    "statement": {
                        "type": "and"
                    },
                    "type": "statement"
                },
                "success": true
            }
        },
        "meta": {
            "author": "michael.hunhoff@fireeye.com",
            "capa/nursery": true,
            "capa/path": "/home/user/code/capa-pub/capa/../rules/nursery/read-file-via-mapping.yml",
            "name": "read file via mapping",
            "namespace": "host-interaction/file-system/read",
            "scope": "function"
        }
    }
}

@williballenthin
Copy link
Collaborator Author

added in #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant