-
Notifications
You must be signed in to change notification settings - Fork 1
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
7a2904c
commit 7c1a6db
Showing
3 changed files
with
73 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,71 @@ | ||
#!/bin/bash | ||
|
||
function audit_wrn() { | ||
echo -e "[${Yellow}code-audit${Reset}] $1" | ||
} | ||
|
||
function audit_code_popen() { | ||
local match | ||
match="$(grep -rPn 'popen' src)" | ||
if [ "$match" != "" ] | ||
then | ||
audit_wrn "$(tput bold)WARNING$(tput sgr0): found popen" | ||
echo "$match" | awk '{ print "\t" $0}' | ||
fi | ||
} | ||
|
||
function audit_code_system() { | ||
local match | ||
match="$(grep -rPn '(system[\s]*$|system\()' src | grep -v '//.*system')" | ||
if [ "$match" != "" ] | ||
then | ||
audit_wrn "$(tput bold)WARNING$(tput sgr0): found system call" | ||
echo "$match" | awk '{ print "\t" $0}' | ||
fi | ||
} | ||
|
||
function audit_code_exec() { | ||
local match | ||
match="$(grep -Prn '(execl|execle|execlp|execv(?!e\(\))|execve(?!\(\))|execvp|fexecve)' src)" | ||
if [ "$match" != "" ] | ||
then | ||
audit_wrn "$(tput bold)WARNING$(tput sgr0): found exec call" | ||
echo "$match" | awk '{ print "\t" $0}' | ||
fi | ||
} | ||
|
||
function audit_code_shell() { | ||
local match | ||
match="$(grep -iErn '(bin/|env )(sh|bash|fish|zsh|csh)' src)" | ||
if [ "$match" != "" ] | ||
then | ||
audit_wrn "$(tput bold)WARNING$(tput sgr0): found possible reverse shell" | ||
echo "$match" | awk '{ print "\t" $0}' | ||
fi | ||
} | ||
|
||
function audit_code_rcon() { | ||
local match | ||
match="$(grep -iErn '(print|log|say|sendchat|broadcast).*config.*SvRconPassword' src)" | ||
if [ "$match" != "" ] | ||
then | ||
audit_wrn "$(tput bold)WARNING$(tput sgr0): found possible rcon password leak" | ||
echo "$match" | awk '{ print "\t" $0}' | ||
fi | ||
} | ||
|
||
function audit_code() { | ||
if [ ! -d "$CFG_GIT_PATH_MOD" ] | ||
then | ||
return | ||
fi | ||
( | ||
cd "$CFG_GIT_PATH_MOD" || exit 1 | ||
audit_code_rcon | ||
audit_code_shell | ||
audit_code_exec | ||
audit_code_system | ||
audit_code_popen | ||
) | ||
} | ||
|
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
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ fi | |
source lib/lib.sh | ||
|
||
check_warnings | ||
audit_code | ||
|
||
if pgrep -f "$SERVER_UUID" > /dev/null | ||
then | ||
|