-
-
Save arunk-s/a5814d7faded57420e35338514ce38d2 to your computer and use it in GitHub Desktop.
Run Mig Audit module directly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"bytes" | |
"encoding/json" | |
"fmt" | |
"mig.ninja/mig/modules" | |
"mig.ninja/mig/modules/audit" | |
) | |
func main() { | |
var ( | |
paramargs = `{"class":"parameters", "parameters":{"rulefilepath": "audit.rules.json", "outputsockets": ["/tmp/unix.sock"], "serveraddress": "http://requestb.in/10ebgkt1"}}` | |
out string | |
pretty = true | |
) | |
infd := bufio.NewReader(bytes.NewBuffer([]byte(paramargs))) | |
// instantiate and call module | |
// run := modules.Available["audit"].NewRun() | |
moduler := audit.GetInstance() | |
run := moduler.NewRun() | |
out = run.Run(infd) | |
if pretty { | |
var modres modules.Result | |
err := json.Unmarshal([]byte(out), &modres) | |
if err != nil { | |
panic(err) | |
} | |
out = "" | |
if _, ok := run.(modules.HasResultsPrinter); ok { | |
outRes, err := run.(modules.HasResultsPrinter).PrintResults(modres, false) | |
if err != nil { | |
panic(err) | |
} | |
for _, resLine := range outRes { | |
out += fmt.Sprintf("%s\n", resLine) | |
} | |
} else { | |
out = fmt.Sprintf("[error] no printer available for module '%s'\n", "audit") | |
} | |
} | |
fmt.Println(out) | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment