-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8619228
commit d1a40fd
Showing
9 changed files
with
522 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/pyperanger/gorootcheck | ||
|
||
go 1.14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package gorootcheck | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
func bye(){ | ||
os.Exit(0) | ||
} |
Oops, something went wrong.