Skip to content

Commit 8e6e077

Browse files
committed
Add option useEmbeddedData in config file to allow to use external 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
1 parent 38a8b7e commit 8e6e077

File tree

23 files changed

+225
-41
lines changed

23 files changed

+225
-41
lines changed

Gopkg.lock

+25-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app.conf

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"version": "4.11.0",
2+
"version": "4.12.0",
33
"debug": false,
4+
"useEmbeddedData": true,
45
"proxifier": {
56
"logPath": "C:/Users/[username]/Documents/Proxifier/Log.txt"
67
},

app/bindata/bindata.go

+20-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/cmds/dev/dev.go

+49-6
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,63 @@
11
package dev
22

33
import (
4+
"fmt"
5+
"os"
6+
"path"
7+
"strings"
8+
"time"
9+
10+
"github.com/crazy-max/WindowsSpyBlocker/app/bindata"
411
"github.com/crazy-max/WindowsSpyBlocker/app/cmds/dev/diff"
512
"github.com/crazy-max/WindowsSpyBlocker/app/cmds/dev/firewall"
613
"github.com/crazy-max/WindowsSpyBlocker/app/cmds/dev/merge"
714
"github.com/crazy-max/WindowsSpyBlocker/app/cmds/dev/proxifier"
815
"github.com/crazy-max/WindowsSpyBlocker/app/cmds/dev/sysmon"
916
"github.com/crazy-max/WindowsSpyBlocker/app/cmds/dev/wireshark"
1017
"github.com/crazy-max/WindowsSpyBlocker/app/menu"
18+
"github.com/crazy-max/WindowsSpyBlocker/app/utils/pathu"
19+
"github.com/crazy-max/WindowsSpyBlocker/app/utils/print"
20+
"github.com/fatih/color"
1121
)
1222

1323
// Menu of Dev
1424
func Menu(args ...string) (err error) {
1525
menuCommands := []menu.CommandOption{
1626
{
17-
Description: "> Proxifier : Extract events from log file",
27+
Description: "> Proxifier : Extract events from log file",
28+
Color: color.FgYellow,
1829
Function: proxifier.Menu,
1930
},
2031
{
21-
Description: "> Sysmon : Install / uninstall Sysmon and extract events from EVTX file",
32+
Description: "> Sysmon : Install / uninstall Sysmon and extract events from EVTX file",
33+
Color: color.FgYellow,
2234
Function: sysmon.Menu,
2335
},
2436
{
25-
Description: "> Wireshark : Extract events from PCAPNG file filtered by IPv4 hosts",
37+
Description: "> Wireshark : Extract events from PCAPNG file filtered by IPv4 hosts",
38+
Color: color.FgYellow,
2639
Function: wireshark.Menu,
2740
},
2841
{
29-
Description: "> Firewall : Test Firewall IPs rules with multiple Whois and DNS Resolutions",
42+
Description: "> Firewall : Test Firewall IPs rules with multiple Whois and DNS Resolutions",
43+
Color: color.FgYellow,
3044
Function: firewall.Menu,
3145
},
3246
{
33-
Description: "> Diff : Generates a diff log based on CSV data",
47+
Description: "> Diff : Generates a diff log based on CSV data",
48+
Color: color.FgYellow,
3449
Function: diff.Menu,
3550
},
3651
{
37-
Description: "> Merge : Merge firewall and hosts data to multi format (DNSCrypt, OpenWrt, etc...)",
52+
Description: "> Merge : Merge firewall and hosts data to multi format (DNSCrypt, OpenWrt, etc...)",
53+
Color: color.FgYellow,
3854
Function: merge.Menu,
3955
},
56+
{
57+
Description: "Extract data : Extract embedded data in the current folder",
58+
Color: color.FgHiYellow,
59+
Function: extractData,
60+
},
4061
}
4162

4263
menuOptions := menu.NewOptions("Dev", "'menu' for help [dev]> ", 0, "")
@@ -45,3 +66,25 @@ func Menu(args ...string) (err error) {
4566
menuN.Start()
4667
return
4768
}
69+
70+
func extractData(args ...string) (err error) {
71+
fmt.Println()
72+
73+
if _, err := os.Stat(pathu.Data); err == nil {
74+
dataBackupPath := path.Join(pathu.Current, fmt.Sprintf("%s.%s", "data", time.Now().Format("20060102150405")))
75+
fmt.Printf("Backing current data folder in %s... ", strings.TrimLeft(dataBackupPath, pathu.Current))
76+
if err := os.Rename(pathu.Data, dataBackupPath); err != nil {
77+
print.Error(err)
78+
return nil
79+
}
80+
print.Ok()
81+
}
82+
83+
fmt.Printf("Extracting data in %s... ", pathu.Data)
84+
if err := bindata.RestoreAssets(pathu.Current, "data"); err != nil {
85+
print.Error(err)
86+
}
87+
print.Ok()
88+
89+
return nil
90+
}

app/cmds/dev/diff/diff.go

+3
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,17 @@ func Menu(args ...string) (err error) {
6262
menuCommands := []menu.CommandOption{
6363
{
6464
Description: "Windows 7",
65+
Color: color.FgHiYellow,
6566
Function: menuWin7,
6667
},
6768
{
6869
Description: "Windows 8.1",
70+
Color: color.FgHiYellow,
6971
Function: menuWin81,
7072
},
7173
{
7274
Description: "Windows 10",
75+
Color: color.FgHiYellow,
7376
Function: menuWin10,
7477
},
7578
}

app/cmds/dev/diff/win10.go

+5
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,29 @@ package diff
33
import (
44
"github.com/crazy-max/WindowsSpyBlocker/app/menu"
55
"github.com/crazy-max/WindowsSpyBlocker/app/utils/data"
6+
"github.com/fatih/color"
67
)
78

89
func menuWin10(args ...string) (err error) {
910
menuCommands := []menu.CommandOption{
1011
{
1112
Description: "All",
13+
Color: color.FgHiYellow,
1214
Function: allWin10,
1315
},
1416
{
1517
Description: "Proxifier",
18+
Color: color.FgHiYellow,
1619
Function: proxifierWin10,
1720
},
1821
{
1922
Description: "Sysmon",
23+
Color: color.FgHiYellow,
2024
Function: sysmonWin10,
2125
},
2226
{
2327
Description: "Wireshark",
28+
Color: color.FgHiYellow,
2429
Function: wiresharkWin10,
2530
},
2631
}

app/cmds/dev/diff/win7.go

+5
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,29 @@ package diff
33
import (
44
"github.com/crazy-max/WindowsSpyBlocker/app/menu"
55
"github.com/crazy-max/WindowsSpyBlocker/app/utils/data"
6+
"github.com/fatih/color"
67
)
78

89
func menuWin7(args ...string) (err error) {
910
menuCommands := []menu.CommandOption{
1011
{
1112
Description: "All",
13+
Color: color.FgHiYellow,
1214
Function: allWin7,
1315
},
1416
{
1517
Description: "Proxifier",
18+
Color: color.FgHiYellow,
1619
Function: proxifierWin7,
1720
},
1821
{
1922
Description: "Sysmon",
23+
Color: color.FgHiYellow,
2024
Function: sysmonWin7,
2125
},
2226
{
2327
Description: "Wireshark",
28+
Color: color.FgHiYellow,
2429
Function: wiresharkWin7,
2530
},
2631
}

app/cmds/dev/diff/win81.go

+5
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,29 @@ package diff
33
import (
44
"github.com/crazy-max/WindowsSpyBlocker/app/menu"
55
"github.com/crazy-max/WindowsSpyBlocker/app/utils/data"
6+
"github.com/fatih/color"
67
)
78

89
func menuWin81(args ...string) (err error) {
910
menuCommands := []menu.CommandOption{
1011
{
1112
Description: "All",
13+
Color: color.FgHiYellow,
1214
Function: allWin81,
1315
},
1416
{
1517
Description: "Proxifier",
18+
Color: color.FgHiYellow,
1619
Function: proxifierWin81,
1720
},
1821
{
1922
Description: "Sysmon",
23+
Color: color.FgHiYellow,
2024
Function: sysmonWin81,
2125
},
2226
{
2327
Description: "Wireshark",
28+
Color: color.FgHiYellow,
2429
Function: wiresharkWin81,
2530
},
2631
}

app/cmds/dev/firewall/firewall.go

+32-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package firewall
22

33
import (
44
"fmt"
5+
"net"
56
"os"
67
"path"
78
"strings"
@@ -10,28 +11,31 @@ import (
1011
"github.com/crazy-max/WindowsSpyBlocker/app/dnsres"
1112
"github.com/crazy-max/WindowsSpyBlocker/app/menu"
1213
"github.com/crazy-max/WindowsSpyBlocker/app/utils/data"
14+
"github.com/crazy-max/WindowsSpyBlocker/app/utils/file"
1315
"github.com/crazy-max/WindowsSpyBlocker/app/utils/netu"
1416
"github.com/crazy-max/WindowsSpyBlocker/app/utils/pathu"
1517
"github.com/crazy-max/WindowsSpyBlocker/app/utils/print"
1618
"github.com/crazy-max/WindowsSpyBlocker/app/utils/timeu"
1719
"github.com/crazy-max/WindowsSpyBlocker/app/whois"
1820
"github.com/fatih/color"
19-
"net"
2021
)
2122

2223
// Menu of Firewall
2324
func Menu(args ...string) (err error) {
2425
menuCommands := []menu.CommandOption{
2526
{
2627
Description: "Test Windows 7 IPs",
28+
Color: color.FgHiYellow,
2729
Function: testIpsWin7,
2830
},
2931
{
3032
Description: "Test Windows 8.1 IPs",
33+
Color: color.FgHiYellow,
3134
Function: testIpsWin81,
3235
},
3336
{
3437
Description: "Test Windows 10 IPs",
38+
Color: color.FgHiYellow,
3539
Function: testIpsWin10,
3640
},
3741
}
@@ -44,17 +48,44 @@ func Menu(args ...string) (err error) {
4448
}
4549

4650
func testIpsWin7(args ...string) error {
51+
logsPath := path.Join(pathu.Logs, data.OS_WIN7)
52+
if err := file.CreateSubfolder(logsPath); err != nil {
53+
print.Error(err)
54+
return nil
55+
}
56+
4757
testIps(data.OS_WIN7)
58+
fmt.Printf("\nLogs available in ")
59+
color.New(color.FgCyan).Printf("%s\n", strings.TrimLeft(logsPath, pathu.Current))
60+
4861
return nil
4962
}
5063

5164
func testIpsWin81(args ...string) error {
65+
logsPath := path.Join(pathu.Logs, data.OS_WIN81)
66+
if err := file.CreateSubfolder(logsPath); err != nil {
67+
print.Error(err)
68+
return nil
69+
}
70+
5271
testIps(data.OS_WIN81)
72+
fmt.Printf("\nLogs available in ")
73+
color.New(color.FgCyan).Printf("%s\n", strings.TrimLeft(logsPath, pathu.Current))
74+
5375
return nil
5476
}
5577

5678
func testIpsWin10(args ...string) error {
79+
logsPath := path.Join(pathu.Logs, data.OS_WIN10)
80+
if err := file.CreateSubfolder(logsPath); err != nil {
81+
print.Error(err)
82+
return nil
83+
}
84+
5785
testIps(data.OS_WIN10)
86+
fmt.Printf("\nLogs available in ")
87+
color.New(color.FgCyan).Printf("%s\n", strings.TrimLeft(logsPath, pathu.Current))
88+
5889
return nil
5990
}
6091

app/cmds/dev/merge/merge.go

+3
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@ func Menu(args ...string) (err error) {
3030
menuCommands := []menu.CommandOption{
3131
{
3232
Description: "Windows 7",
33+
Color: color.FgHiYellow,
3334
Function: win7,
3435
},
3536
{
3637
Description: "Windows 8.1",
38+
Color: color.FgHiYellow,
3739
Function: win81,
3840
},
3941
{
4042
Description: "Windows 10",
43+
Color: color.FgHiYellow,
4144
Function: win10,
4245
},
4346
}

app/cmds/dev/proxifier/proxifier.go

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func Menu(args ...string) (err error) {
3333
menuCommands := []menu.CommandOption{
3434
{
3535
Description: "Extract log",
36+
Color: color.FgHiYellow,
3637
Function: extractLog,
3738
},
3839
}

0 commit comments

Comments
 (0)