Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/cakturk/go-netstat v0.0.0-20200220111822-e5b49efee7a5
github.com/fsnotify/fsnotify v1.6.0
github.com/gdamore/tcell/v2 v2.5.2
github.com/google/gopacket v1.1.19
github.com/sbinet/pstree v0.5.1
)

Expand Down
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo
github.com/gdamore/tcell/v2 v2.2.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
github.com/gdamore/tcell/v2 v2.5.2 h1:tKzG29kO9p2V++3oBY2W9zUjYu7IK1MENFeY/BzJSVY=
github.com/gdamore/tcell/v2 v2.5.2/go.mod h1:wSkrPaXoiIWZqW/g7Px4xc79di6FTcpB8tvaKJ6uGBo=
github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
Expand All @@ -24,6 +26,16 @@ github.com/rivo/uniseg v0.3.1 h1:SDPP7SHNl1L7KrEFCSJslJ/DM9DT02Nq2C61XrfHMmk=
github.com/rivo/uniseg v0.3.1/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/sbinet/pstree v0.5.1 h1:B29DPDk22c35W+q9NY92VLBL4DUHwCNgNNp6HPwqzbM=
github.com/sbinet/pstree v0.5.1/go.mod h1:G208WfJOi4oxq4++w97Y4AeuydVuoOz7tPKCEm8y1oE=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210309040221-94ec62e08169/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -40,3 +52,5 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
24 changes: 11 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
func main() {
// Define the Application
app := cview.NewApplication()
defer app.HandlePanic()

// Enable Using Mouse
app.EnableMouse(true)
Expand All @@ -21,7 +22,6 @@ func main() {
panels.SetBorderColor(tcell.ColorYellow)
panels.SetTitle("Vindicta")
panels.SetTitleColor(tcell.ColorBlue)
panels.SetTabTextColor(tcell.ColorPurple)
panels.SetBorderAttributes(tcell.AttrBold)
panels.SetTabBackgroundColor(tcell.ColorBlueViolet)
panels.SetTabTextColor(tcell.ColorWhite)
Expand All @@ -37,15 +37,17 @@ func main() {
file := monitor.FileSystemPanel(app)
// Network Connections and Process Monitoring Tab
netproc := monitor.DisplaySocks(app)
// Packet Monitoring Tab
pkt := monitor.PacketMonitor(app)
// Web Logs
web := monitor.MonitorWebLogs(app)

// Attach The Tabs Above To The Panels
panels.AddTab("ssh", "[1] SSH", ssh)
panels.AddTab("NetAndProc", "[2] Network and Processes", netproc)
panels.AddTab("filesystem", "[3] Filesystem", file)
// panels.AddTab("firewall", "[4] Firewall", cview.NewTextView())
// panels.AddTab("webserver", "[5] Webserver", cview.NewTextView())
// panels.AddTab("services", "[6] Services", cview.NewTextView())
// panels.AddTab("kill", "[7] Kill Process", cview.NewTextView())
panels.AddTab("packet", "[4] Packet Monitoring", pkt)
panels.AddTab("web", "[5] Web", web)

app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
if event.Rune() == 113 { // 113 means q
Expand All @@ -56,14 +58,10 @@ func main() {
panels.SetCurrentTab("NetAndProc")
} else if event.Rune() == 51 {
panels.SetCurrentTab("filesystem")
// } else if event.Rune() == 52 {
// panels.SetCurrentTab("firewall")
// } else if event.Rune() == 53 {
// panels.SetCurrentTab("webserver")
// } else if event.Rune() == 54 {
// panels.SetCurrentTab("services")
// } else if event.Rune() == 55 {
// panels.SetCurrentTab("kill")
} else if event.Rune() == 52 {
panels.SetCurrentTab("packet")
} else if event.Rune() == 53 {
panels.SetCurrentTab("web")
} else if event.Rune() == 35 { // Uppercase # for editing
// Call the CreateInput function and get the callback function
inputCallback := monitor.CreateInput(panels, app)
Expand Down
6 changes: 3 additions & 3 deletions monitor/fileSystemView.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func CreateInput(panels *cview.TabbedPanels, app *cview.Application) func() {
func FileSystemPanel(cviewApp *cview.Application) *cview.TextView {
view := cview.NewTextView()
view.SetDynamicColors(true)
view.SetTitle("[black:green:blr]File System Activities")
view.SetTitle("[black:violet:blr]File System Activities")
view.SetBorder(true)
view.SetBorderColor(tcell.ColorPurple)
view.SetTextAlign(cview.AlignLeft)
Expand Down Expand Up @@ -117,9 +117,9 @@ func FileSystemPanel(cviewApp *cview.Application) *cview.TextView {

// Prepare the string to display in the view
if perms != "Deleted" {
result = fmt.Sprintf("[black:violet:br]%s: %s %s", time.Now().Format("2006-01-02 15:04:05"), perms, event.String())
result = fmt.Sprintf("[black:green:br]%s: %s %s", time.Now().Format("2006-01-02 15:04:05"), perms, event.String())
} else {
result = fmt.Sprintf("[black:violet:br]%s: %-10s %s", time.Now().Format("2006-01-02 15:04:05"), "", event.String())
result = fmt.Sprintf("[black:red:brl]%s: %-10s %s", time.Now().Format("2006-01-02 15:04:05"), "", event.String())
}

// Add the new event to the beginning of the events slice
Expand Down
14 changes: 13 additions & 1 deletion monitor/networkConnections.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,26 @@ func DisplaySocks(cviewApp *cview.Application) *cview.TextView {

go func() {
for {
tabs, err := netstat.TCPSocks(func(s *netstat.SockTabEntry) bool {

// TCP Established Connections
tcpTabs, err := netstat.TCPSocks(func(s *netstat.SockTabEntry) bool {
return s.State == netstat.Established
})
if err != nil {
log.Fatal(err)
}

// UDP Established Connections
udpTabs, err := netstat.UDPSocks(func(s *netstat.SockTabEntry) bool {
return s.State == netstat.Established
})
if err != nil {
log.Fatal(err)
}

// All Established Connections
tabs := append(tcpTabs, udpTabs...)

var result string

for _, v := range tabs {
Expand Down
108 changes: 108 additions & 0 deletions monitor/packetMonitoring.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package monitor

import (
"code.rocketnine.space/tslocum/cview"
"github.com/gdamore/tcell/v2"
"github.com/google/gopacket/pcap"
)

// To Be Used Later
func JustTextBoxForNow(title string, textColor tcell.Color) *cview.TextView {
b := cview.NewTextView()
b.SetBorder(true)
b.SetTitle(title)
b.SetTextColor(textColor)
b.SetBorderColor(tcell.ColorOrange)
b.SetTitleAlign(cview.AlignLeft)
return b
}

func interfaceInfo() *cview.DropDown {

// Some styling
dropDown := cview.NewDropDown()
dropDown.SetDropDownBackgroundColor(tcell.ColorBlue)
dropDown.SetDropDownTextColor(tcell.ColorBlack)
dropDown.SetBorder(true)
dropDown.SetBorderColor(tcell.ColorRed)
dropDown.SetPadding(1, 0, 0, 0)
dropDown.SetTitle("[black:aqua]Interface")
dropDown.SetTitleAlign(cview.AlignLeft)
dropDown.SetFieldWidth(0)
dropDown.SetFieldBackgroundColor(tcell.ColorDarkOliveGreen)
dropDown.SetFieldTextColor(tcell.ColorBlack)
dropDown.SetDropDownSelectedBackgroundColor(tcell.ColorPurple)
dropDown.SetAlwaysDrawDropDownSymbol(false)

// Find all available network interfaces
ifaces, err := pcap.FindAllDevs()
if err != nil {
panic(err)
}

// Create options for the DropDown using the network interface names
var options []*cview.DropDownOption

// Range through all available interfaces
for _, iface := range ifaces {
options = append(options, cview.NewDropDownOption(" "+iface.Name))
}

// Set the options in the dropdown
dropDown.SetOptions(nil, options...)

// Return the names of those interfaces
return dropDown

}

func filterInfo() *cview.InputField {
// Just some styling
vw := cview.NewInputField()
vw.SetTitle("[black:aqua]Filter")
vw.SetBorder(true)
vw.SetBorderColor(tcell.ColorRed)
vw.SetTitleAlign(cview.AlignLeft)
vw.SetFieldWidth(0)
vw.SetFieldBackgroundColor(tcell.ColorBlueViolet)
vw.SetFieldBackgroundColorFocused(tcell.ColorOrange)
vw.SetFieldTextColorFocused(tcell.ColorBlack)
vw.SetFieldTextColor(tcell.ColorWhite)
vw.SetPlaceholderTextColor(tcell.ColorWhite)
vw.SetPlaceholderTextColorFocused(tcell.ColorBlack)
vw.SetPlaceholder("tcp port 80")
vw.SetDoneFunc(func(key tcell.Key) {
if key == tcell.KeyEnter {
return
}
})

return vw
}

func PacketMonitor(cviewApp *cview.Application) *cview.Flex {
// Main Flex UI
view := cview.NewFlex()
view.SetBorder(true)
view.SetBorderColor(tcell.ColorBlue)
view.SetDirection(cview.FlexRow)

// Create SubFlex for first row
firstRow := cview.NewFlex()
firstRow.SetBorderColor(tcell.ColorAquaMarine)
firstRow.SetDirection(cview.FlexColumn)

// Call Em
iff := interfaceInfo()
rF := filterInfo()

// Add interfaces info and packet filter rules
firstRow.AddItem(iff, 0, 1, false)
firstRow.AddItem(rF, 0, 4, false)

// Add them to main Flex
view.AddItem(firstRow, 0, 1, false)
view.AddItem(JustTextBoxForNow("[aqua:black] Packet Dump Goes Here With Network Layers [1-4]", tcell.ColorGreenYellow), 0, 10, false)

return view
}
2 changes: 1 addition & 1 deletion monitor/sshConnections.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func monitorLogs(app *cview.Application, successLogs *cview.TextView, errorLogs

for _, line := range strings.Split(strContent, "\n") {
b, _ := regexp.MatchString("\\bID\\b", line)
if b == true {
if b {
name := strings.Split(line, "=")
osType = name[1]
break
Expand Down
27 changes: 27 additions & 0 deletions monitor/webLogs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package monitor

import (
"code.rocketnine.space/tslocum/cview"
"github.com/gdamore/tcell/v2"
)

func MonitorWebLogs(cviewApp *cview.Application) *cview.TabbedPanels {
// Web Server Logs Filtering
view := cview.NewTabbedPanels()

view.SetBorder(true)
view.SetBorderColor(tcell.ColorYellow)
view.SetBorderAttributes(tcell.AttrBold)
view.SetTabBackgroundColor(tcell.ColorPurple)
view.SetTabTextColor(tcell.ColorWhite)
view.SetTabBackgroundColorFocused(tcell.ColorGreen)

// Todo: Defined Text Primitive Below in this file and call it in their respective tabs
view.AddTab("1xx", "1xx", cview.NewTextView())
view.AddTab("2xx", "2xx", cview.NewTextView())
view.AddTab("3xx", "3xx", cview.NewTextView())
view.AddTab("4xx", "4xx", cview.NewTextView())
view.AddTab("5xx", "5xx", cview.NewTextView())

return view
}