Skip to content

Commit

Permalink
Add option useEmbeddedData in config file to allow to use external …
Browse files Browse the repository at this point in the history
…data (Issue #75)

Add menu to extract embedded data (Issue #75)
Firewall test logs are not written if the directory does not exist
Change the color of the menus for last items
  • Loading branch information
crazy-max committed Mar 27, 2018
1 parent 38a8b7e commit 8e6e077
Show file tree
Hide file tree
Showing 23 changed files with 225 additions and 41 deletions.
30 changes: 25 additions & 5 deletions Gopkg.lock

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

3 changes: 2 additions & 1 deletion app.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"version": "4.11.0",
"version": "4.12.0",
"debug": false,
"useEmbeddedData": true,
"proxifier": {
"logPath": "C:/Users/[username]/Documents/Proxifier/Log.txt"
},
Expand Down
40 changes: 20 additions & 20 deletions app/bindata/bindata.go

Large diffs are not rendered by default.

55 changes: 49 additions & 6 deletions app/cmds/dev/dev.go
Original file line number Diff line number Diff line change
@@ -1,42 +1,63 @@
package dev

import (
"fmt"
"os"
"path"
"strings"
"time"

"github.com/crazy-max/WindowsSpyBlocker/app/bindata"
"github.com/crazy-max/WindowsSpyBlocker/app/cmds/dev/diff"
"github.com/crazy-max/WindowsSpyBlocker/app/cmds/dev/firewall"
"github.com/crazy-max/WindowsSpyBlocker/app/cmds/dev/merge"
"github.com/crazy-max/WindowsSpyBlocker/app/cmds/dev/proxifier"
"github.com/crazy-max/WindowsSpyBlocker/app/cmds/dev/sysmon"
"github.com/crazy-max/WindowsSpyBlocker/app/cmds/dev/wireshark"
"github.com/crazy-max/WindowsSpyBlocker/app/menu"
"github.com/crazy-max/WindowsSpyBlocker/app/utils/pathu"
"github.com/crazy-max/WindowsSpyBlocker/app/utils/print"
"github.com/fatih/color"
)

// Menu of Dev
func Menu(args ...string) (err error) {
menuCommands := []menu.CommandOption{
{
Description: "> Proxifier : Extract events from log file",
Description: "> Proxifier : Extract events from log file",
Color: color.FgYellow,
Function: proxifier.Menu,
},
{
Description: "> Sysmon : Install / uninstall Sysmon and extract events from EVTX file",
Description: "> Sysmon : Install / uninstall Sysmon and extract events from EVTX file",
Color: color.FgYellow,
Function: sysmon.Menu,
},
{
Description: "> Wireshark : Extract events from PCAPNG file filtered by IPv4 hosts",
Description: "> Wireshark : Extract events from PCAPNG file filtered by IPv4 hosts",
Color: color.FgYellow,
Function: wireshark.Menu,
},
{
Description: "> Firewall : Test Firewall IPs rules with multiple Whois and DNS Resolutions",
Description: "> Firewall : Test Firewall IPs rules with multiple Whois and DNS Resolutions",
Color: color.FgYellow,
Function: firewall.Menu,
},
{
Description: "> Diff : Generates a diff log based on CSV data",
Description: "> Diff : Generates a diff log based on CSV data",
Color: color.FgYellow,
Function: diff.Menu,
},
{
Description: "> Merge : Merge firewall and hosts data to multi format (DNSCrypt, OpenWrt, etc...)",
Description: "> Merge : Merge firewall and hosts data to multi format (DNSCrypt, OpenWrt, etc...)",
Color: color.FgYellow,
Function: merge.Menu,
},
{
Description: "Extract data : Extract embedded data in the current folder",
Color: color.FgHiYellow,
Function: extractData,
},
}

menuOptions := menu.NewOptions("Dev", "'menu' for help [dev]> ", 0, "")
Expand All @@ -45,3 +66,25 @@ func Menu(args ...string) (err error) {
menuN.Start()
return
}

func extractData(args ...string) (err error) {
fmt.Println()

if _, err := os.Stat(pathu.Data); err == nil {
dataBackupPath := path.Join(pathu.Current, fmt.Sprintf("%s.%s", "data", time.Now().Format("20060102150405")))
fmt.Printf("Backing current data folder in %s... ", strings.TrimLeft(dataBackupPath, pathu.Current))
if err := os.Rename(pathu.Data, dataBackupPath); err != nil {
print.Error(err)
return nil
}
print.Ok()
}

fmt.Printf("Extracting data in %s... ", pathu.Data)
if err := bindata.RestoreAssets(pathu.Current, "data"); err != nil {
print.Error(err)
}
print.Ok()

return nil
}
3 changes: 3 additions & 0 deletions app/cmds/dev/diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,17 @@ func Menu(args ...string) (err error) {
menuCommands := []menu.CommandOption{
{
Description: "Windows 7",
Color: color.FgHiYellow,
Function: menuWin7,
},
{
Description: "Windows 8.1",
Color: color.FgHiYellow,
Function: menuWin81,
},
{
Description: "Windows 10",
Color: color.FgHiYellow,
Function: menuWin10,
},
}
Expand Down
5 changes: 5 additions & 0 deletions app/cmds/dev/diff/win10.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,29 @@ package diff
import (
"github.com/crazy-max/WindowsSpyBlocker/app/menu"
"github.com/crazy-max/WindowsSpyBlocker/app/utils/data"
"github.com/fatih/color"
)

func menuWin10(args ...string) (err error) {
menuCommands := []menu.CommandOption{
{
Description: "All",
Color: color.FgHiYellow,
Function: allWin10,
},
{
Description: "Proxifier",
Color: color.FgHiYellow,
Function: proxifierWin10,
},
{
Description: "Sysmon",
Color: color.FgHiYellow,
Function: sysmonWin10,
},
{
Description: "Wireshark",
Color: color.FgHiYellow,
Function: wiresharkWin10,
},
}
Expand Down
5 changes: 5 additions & 0 deletions app/cmds/dev/diff/win7.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,29 @@ package diff
import (
"github.com/crazy-max/WindowsSpyBlocker/app/menu"
"github.com/crazy-max/WindowsSpyBlocker/app/utils/data"
"github.com/fatih/color"
)

func menuWin7(args ...string) (err error) {
menuCommands := []menu.CommandOption{
{
Description: "All",
Color: color.FgHiYellow,
Function: allWin7,
},
{
Description: "Proxifier",
Color: color.FgHiYellow,
Function: proxifierWin7,
},
{
Description: "Sysmon",
Color: color.FgHiYellow,
Function: sysmonWin7,
},
{
Description: "Wireshark",
Color: color.FgHiYellow,
Function: wiresharkWin7,
},
}
Expand Down
5 changes: 5 additions & 0 deletions app/cmds/dev/diff/win81.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,29 @@ package diff
import (
"github.com/crazy-max/WindowsSpyBlocker/app/menu"
"github.com/crazy-max/WindowsSpyBlocker/app/utils/data"
"github.com/fatih/color"
)

func menuWin81(args ...string) (err error) {
menuCommands := []menu.CommandOption{
{
Description: "All",
Color: color.FgHiYellow,
Function: allWin81,
},
{
Description: "Proxifier",
Color: color.FgHiYellow,
Function: proxifierWin81,
},
{
Description: "Sysmon",
Color: color.FgHiYellow,
Function: sysmonWin81,
},
{
Description: "Wireshark",
Color: color.FgHiYellow,
Function: wiresharkWin81,
},
}
Expand Down
33 changes: 32 additions & 1 deletion app/cmds/dev/firewall/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package firewall

import (
"fmt"
"net"
"os"
"path"
"strings"
Expand All @@ -10,28 +11,31 @@ import (
"github.com/crazy-max/WindowsSpyBlocker/app/dnsres"
"github.com/crazy-max/WindowsSpyBlocker/app/menu"
"github.com/crazy-max/WindowsSpyBlocker/app/utils/data"
"github.com/crazy-max/WindowsSpyBlocker/app/utils/file"
"github.com/crazy-max/WindowsSpyBlocker/app/utils/netu"
"github.com/crazy-max/WindowsSpyBlocker/app/utils/pathu"
"github.com/crazy-max/WindowsSpyBlocker/app/utils/print"
"github.com/crazy-max/WindowsSpyBlocker/app/utils/timeu"
"github.com/crazy-max/WindowsSpyBlocker/app/whois"
"github.com/fatih/color"
"net"
)

// Menu of Firewall
func Menu(args ...string) (err error) {
menuCommands := []menu.CommandOption{
{
Description: "Test Windows 7 IPs",
Color: color.FgHiYellow,
Function: testIpsWin7,
},
{
Description: "Test Windows 8.1 IPs",
Color: color.FgHiYellow,
Function: testIpsWin81,
},
{
Description: "Test Windows 10 IPs",
Color: color.FgHiYellow,
Function: testIpsWin10,
},
}
Expand All @@ -44,17 +48,44 @@ func Menu(args ...string) (err error) {
}

func testIpsWin7(args ...string) error {
logsPath := path.Join(pathu.Logs, data.OS_WIN7)
if err := file.CreateSubfolder(logsPath); err != nil {
print.Error(err)
return nil
}

testIps(data.OS_WIN7)
fmt.Printf("\nLogs available in ")
color.New(color.FgCyan).Printf("%s\n", strings.TrimLeft(logsPath, pathu.Current))

return nil
}

func testIpsWin81(args ...string) error {
logsPath := path.Join(pathu.Logs, data.OS_WIN81)
if err := file.CreateSubfolder(logsPath); err != nil {
print.Error(err)
return nil
}

testIps(data.OS_WIN81)
fmt.Printf("\nLogs available in ")
color.New(color.FgCyan).Printf("%s\n", strings.TrimLeft(logsPath, pathu.Current))

return nil
}

func testIpsWin10(args ...string) error {
logsPath := path.Join(pathu.Logs, data.OS_WIN10)
if err := file.CreateSubfolder(logsPath); err != nil {
print.Error(err)
return nil
}

testIps(data.OS_WIN10)
fmt.Printf("\nLogs available in ")
color.New(color.FgCyan).Printf("%s\n", strings.TrimLeft(logsPath, pathu.Current))

return nil
}

Expand Down
3 changes: 3 additions & 0 deletions app/cmds/dev/merge/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ func Menu(args ...string) (err error) {
menuCommands := []menu.CommandOption{
{
Description: "Windows 7",
Color: color.FgHiYellow,
Function: win7,
},
{
Description: "Windows 8.1",
Color: color.FgHiYellow,
Function: win81,
},
{
Description: "Windows 10",
Color: color.FgHiYellow,
Function: win10,
},
}
Expand Down
1 change: 1 addition & 0 deletions app/cmds/dev/proxifier/proxifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func Menu(args ...string) (err error) {
menuCommands := []menu.CommandOption{
{
Description: "Extract log",
Color: color.FgHiYellow,
Function: extractLog,
},
}
Expand Down
Loading

0 comments on commit 8e6e077

Please sign in to comment.