Skip to content

Commit

Permalink
 Updated with latest version of Gene engine v1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
qjerome committed May 21, 2018
1 parent 53e589f commit 9886ffb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RELEASE=$(GOPATH)/release
MAIN_BASEN_SRC=whids
VERSION=v1.2
VERSION=v1.2.1

# Strips symbols and dwarf to make binary smaller
OPTS=-ldflags "-s -w"
Expand Down
6 changes: 6 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ func EnableDNSLogs() error {
return cmd.Run()
}

// FlushDNSCache executes windows command to flush the DNS cache
func FlushDNSCache() error {
cmd := exec.Command("ipconfig.exe", "/flushdns")
return cmd.Run()
}

/////////////////////////////// Windows Logger ////////////////////////////////

const (
Expand Down
27 changes: 27 additions & 0 deletions whids.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ var (
"all": "All aliased channels",
}
ruleExts = args.ListVar{".gen", ".gene"}
tplExt = ".tpl"
)

func printInfo(writer io.Writer) {
Expand Down Expand Up @@ -253,6 +254,25 @@ func main() {
log.LogErrorAndExit(err, exitFail)
}

// Loading the templates first
templateDir := realPath
if fsutil.IsFile(realPath) {
templateDir = filepath.Dir(realPath)
}
for wi := range fswalker.Walk(templateDir) {
for _, fi := range wi.Files {
ext := filepath.Ext(fi.Name())
templateFile := filepath.Join(wi.Dirpath, fi.Name())
if ext == tplExt {
log.Infof("Loading regexp templates from file: %s", templateFile)
err := e.LoadTemplate(templateFile)
if err != nil {
log.Errorf("Error loading %s: %s", templateFile, err)
}
}
}
}

// Handle both rules argument as file or directory
switch {
case fsutil.IsFile(realPath):
Expand Down Expand Up @@ -316,6 +336,13 @@ func main() {

for i := range listeningChannels {
winChan := listeningChannels[i]

// We flush DNS cache before monitoring DNS channel
if winChan == "dns" || winChan == channelAliases["dns"] {
log.Info("Flushing DNS Cache")
utils.FlushDNSCache()
}

waitGr.Add(1)
// New go routine per channel
go func() {
Expand Down

0 comments on commit 9886ffb

Please sign in to comment.