Skip to content

Commit

Permalink
BreachWatch
Browse files Browse the repository at this point in the history
  • Loading branch information
SUmidcyber committed Sep 22, 2024
1 parent daa56da commit fb33627
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 0 deletions.
13 changes: 13 additions & 0 deletions DockerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Base image olarak Ubuntu kullanıyoruz
FROM ubuntu:latest

# Gerekli paketleri yüklüyoruz
RUN apt-get update && apt-get install -y \
snort \
&& apt-get clean

# Snort konfigürasyon dosyasını kopyalıyoruz
COPY snort.conf /etc/snort/snort.conf

# Snort'u başlatıyoruz
CMD ["sh", "-c", "./network && snort -i $interface_name -c /etc/snort/snort.conf -l /var/log/snort -A console"]
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/SUmidcyber/BreachWatch

go 1.23.1
Empty file added interface.log
Empty file.
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package main

import "github.com/SUmidcyber/BreachWatch/network"

func main() {
network.Interface()
network.Network_name()
}
57 changes: 57 additions & 0 deletions network/interface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package network

import (
"bufio"
"fmt"
"log"
"os"
"os/exec"
"strings"
)

func Interface() {
file, err := os.OpenFile("interface.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Fatal(err)
}
defer file.Close()

logger := log.New(file, "INFO: ", log.Ldate|log.Ltime|log.Lshortfile)

reader := bufio.NewReader(os.Stdin)
fmt.Print("Learn the interface [Y/n]: ")
input, _ := reader.ReadString('\n')
input = strings.TrimSpace(input)

if strings.EqualFold(input, "Y") {
fmt.Print("Enter command (Windows [ipconfig] | Linux [ifconfig]): ")
command, _ := reader.ReadString('\n')
command = strings.TrimSpace(command)

var cmd *exec.Cmd
if command == "ifconfig" {
cmd = exec.Command("ifconfig")
} else if command == "ipconfig" {
cmd = exec.Command("ipconfig")
} else {
fmt.Println("Unknown command...")
logger.Println("Unknown command entered.")
return
}

output, err := cmd.Output()
if err != nil {
fmt.Println("Failed to execute command:", err)
logger.Println("Failed to execute command:", err)
return
}

logger.Println("Command executed successfully:", command)
logger.Println("Output:\n", string(output))

fmt.Println("Command executed successfully. Check the log file for details.")
} else {
fmt.Println("Interface learning not initiated.")
logger.Println("Interface learning not initiated.")
}
}
25 changes: 25 additions & 0 deletions network/packet.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package network

import (
"bufio"
"fmt"
"os"
"os/exec"
)

func Network_name() {
reader := bufio.NewReader(os.Stdin)
fmt.Print("Enter the interface name: ")
interfaceName, _ := reader.ReadString('\n')
interfaceName = interfaceName[:len(interfaceName)-1]

os.Setenv("INTERFACE_NAME", interfaceName)

cmd := exec.Command("snort", "-i", interfaceName, "-c", "/etc/snort/snort.conf", "-A", "console")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

if err := cmd.Run(); err != nil {
fmt.Println("Snort failed to run:", err)
}
}

0 comments on commit fb33627

Please sign in to comment.