Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Jul 28, 2018
1 parent 939ef00 commit c87b081
Show file tree
Hide file tree
Showing 348 changed files with 6,162 additions and 18,524 deletions.
84 changes: 26 additions & 58 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 19 additions & 7 deletions commands/elk.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,35 @@ package commands

import (
log "github.com/Sirupsen/logrus"
"github.com/maliceio/malice/malice/database/elasticsearch"
"github.com/maliceio/go-plugin-utils/database/elasticsearch"
"github.com/maliceio/malice/config"
"github.com/maliceio/malice/malice/database"
"github.com/maliceio/malice/malice/docker/client"
"github.com/maliceio/malice/malice/docker/client/container"
"github.com/maliceio/malice/malice/ui"
"github.com/pkg/errors"
)

func cmdELK(logs bool) error {

docker := client.NewDockerClient()

_, err := elasticsearch.Start(docker, logs)
if err != nil {
log.Error(err)
if _, running, _ := container.Running(docker, config.Conf.DB.Name); !running {
err := database.Start(docker, elasticsearch.Database{Host: config.Conf.DB.Server}, logs)
if err != nil {
return errors.Wrap(err, "failed to start to database")
}
} else {
log.Warnf("container %s is already running", config.Conf.DB.Name)
}

_, err = ui.Start(docker, logs)
if err != nil {
log.Error(err)
if _, running, _ := container.Running(docker, config.Conf.UI.Name); !running {
_, err := ui.Start(docker, logs)
if err != nil {
return errors.Wrap(err, "failed to start to UI")
}
} else {
log.Warnf("container %s is already running", config.Conf.UI.Name)
}

return nil
Expand Down
39 changes: 20 additions & 19 deletions commands/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,36 @@ import (
"fmt"

log "github.com/Sirupsen/logrus"
"github.com/maliceio/go-plugin-utils/database/elasticsearch"
"github.com/maliceio/malice/config"
"github.com/maliceio/malice/malice/database/elasticsearch"
db "github.com/maliceio/malice/malice/database/elasticsearch"
"github.com/maliceio/malice/malice/database"
"github.com/maliceio/malice/malice/docker/client"
"github.com/maliceio/malice/malice/docker/client/container"
er "github.com/maliceio/malice/malice/errors"
"github.com/maliceio/malice/plugins"
"github.com/maliceio/malice/utils"
"github.com/pkg/errors"
)

func cmdLookUp(hash string, logs bool) error {

docker := client.NewDockerClient()
es := elasticsearch.Database{
Host: config.Conf.DB.Server,
Index: "malice",
Type: "samples",
}

// Check that ElasticSearch is running
// Check that database is running
if _, running, _ := container.Running(docker, config.Conf.DB.Name); !running {
log.Error("Elasticsearch is NOT running, starting now...")
_, err := elasticsearch.Start(docker, false)
er.CheckError(err)
log.Error("database is NOT running, starting now...")
err := database.Start(docker, es, logs)
if err != nil {
return errors.Wrap(err, "failed to start to database")
}
// Initialize the malice database
es.Init()
}

// Setup ElasticSearch
dbInfo, err := container.Inspect(docker, config.Conf.DB.Name)
er.CheckError(err)
log.WithFields(log.Fields{
"ip": dbInfo.NetworkSettings.IPAddress,
"network": dbInfo.HostConfig.NetworkMode,
"image": dbInfo.Config.Image,
}).Debug("Elasticsearch is running.")

db.InitElasticSearch(dbInfo.NetworkSettings.IPAddress)

if plugins.InstalledPluginsCheck(docker) {
log.Debug("All enabled plugins are installed.")
} else {
Expand All @@ -49,7 +47,10 @@ func cmdLookUp(hash string, logs bool) error {

/////////////////////////////
// Write hash to the Database
resp := db.WriteHashToDatabase(hash)
resp, err := es.StoreHash(hash)
if err != nil {
return errors.Wrap(err, "cmd lookup failed to store hash")
}

plugins.RunIntelPlugins(docker, hash, resp.Id, true)

Expand Down
Loading

0 comments on commit c87b081

Please sign in to comment.