Skip to content

Commit

Permalink
initial structure and arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
pyperanger committed Apr 25, 2020
1 parent 8619228 commit d1a40fd
Show file tree
Hide file tree
Showing 9 changed files with 522 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/gorootcheck/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

import (
"github.com/pyperanger/gorootcheck/internal/gorootcheck"
)

// Call the package gorootcheck Main
func main(){
if gorootcheck.Args() {
gorootcheck.Main();
}
}
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/pyperanger/gorootcheck

go 1.14
37 changes: 37 additions & 0 deletions internal/gorootcheck/args.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package gorootcheck

import (
"flag"
"fmt"
)

var (
workdir = flag.String("w", "./", "Path with database datails and signatures")
version = flag.Bool("version", false, "Show version")
debug = flag.Bool("v", false, "Debug mode")
help = flag.Bool("h", false, "This massage")
)

func argsUsage() {
fmt.Println(`GoRootCheck - OSSEC Standalone RootCheck in GO
v0.1.0 - github.com/pyperanger/gorootcheck
`)
}

func Args() bool {
argsUsage()
flag.Parse()
if *help {
flag.Usage()
bye()
}

if !dirExist(*workdir) {
fmt.Println(*workdir, ": Not found")
return false
}

if !dbCheck(*workdir)

return true
}
15 changes: 15 additions & 0 deletions internal/gorootcheck/database.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package gorootcheck


// Check if workdir exist
// and if at least rootkit_files,
// rootkit_trojans.txt is in there
// for basic scan in rule #1 and #2
func dbCheck(p string) bool {
if !dirExist(*p) {
fmt.Println(*p, ": Not found")
return false
}


}
16 changes: 16 additions & 0 deletions internal/gorootcheck/directories.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package gorootcheck

import (
"os"
)

func dirExist(p string) (bool) {
f, err := os.Stat(p)
if err != nil {
return false
}
if f.IsDir() {
return true
}
return false
}
22 changes: 22 additions & 0 deletions internal/gorootcheck/gorootcheck.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package gorootcheck

/*
OSSEC Rootcheck features
#1 Read the rootkit_files.txt which contains a database of rootkits and files commonly used by them. It will try to stats, fopen and opendir each specified file. We use all these system calls because some kernel-level rootkits hide files from some system calls. The more system calls we try, the better the detection. This method is more like an anti-virus rule that needs to be updated constantly. The chances of false-positives are small, but false negatives can be produced by modifying the rootkits.
#2 Read the rootkit_trojans.txt which contains a database of signatures of files trojaned by rootkits. This technique of modifying binaries with trojaned versions was commonly used by most of the popular rootkits available. This detection method will not find any kernel level rootkit or any unknown rootkit.
#3 Scan the /dev directory looking for anomalies. The /dev should only have device files and the Makedev script. A lot of rootkits use the /dev to hide files. This technique can detect even non-public rootkits.
#4 Scan the whole filesystem looking for unusual files and permission problems. Files owned by root, with write permission to others are very dangerous, and the rootkit detection will look for them. Suid files, hidden directories and files will also be inspected.
#5 Look for the presence of hidden processes. We use getsid() and kill() to check if any pid is being used or not. If the pid is being used, but “ps” can’t see it, it is the indication of kernel-level rootkit or a trojaned version of “ps”. We also verify that the output of kill and getsid are the same.
#6 Look for the presence of hidden ports. We use bind() to check every tcp and udp port on the system. If we can’t bind to the port (it’s being used), but netstat does not show it, we probably have a rootkit installed
#7 Scan all interfaces on the system and look for the ones with “promisc” mode enabled. If the interface is in promiscuous mode, the output of “ifconfig” should show that. If not, we probably have a rootkit installed.
*/

// Main struture of gorootcheck code
// Make call for checks and arguments
func Main() {


}
9 changes: 9 additions & 0 deletions internal/gorootcheck/util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package gorootcheck

import (
"os"
)

func bye(){
os.Exit(0)
}
Binary file added main
Binary file not shown.
Loading

0 comments on commit d1a40fd

Please sign in to comment.