*/
// Function to aquire a database link
-function aquireCrackerTrackerDatabaseLink () {
+function aquireCrackerTrackerDatabaseLink (): void {
// Is the link up?
if ((!isCrackerTrackerDatabaseLinkUp()) && (!empty($GLOBALS['ctracker_host'])) && (!empty($GLOBALS['ctracker_dbname'])) && (!empty($GLOBALS['ctracker_user']))) {
// Then connect to the database
}
// Inits a fake configurtation
-function crackerTrackerInitFakeConfig () {
+function crackerTrackerInitFakeConfig (): void {
// Set the array
$GLOBALS['ctracker_config'] = [
'ctracker_alert_user' => 'Y',
}
// Checks if the link is up
-function isCrackerTrackerDatabaseLinkUp () {
+function isCrackerTrackerDatabaseLinkUp (): bool {
// Is the instance at least set?
if (isset($GLOBALS['ctracker_link'])) {
// Debug message
}
// Database error detected
-function crackerTrackerDatabaseError (string $file, int $line) {
+function crackerTrackerDatabaseError (string $file, int $line): void {
// Should we debug?
if (isCrackerTrackerDebug()) {
// Output error
}
// Closes a maybe open database link
-function crackerTrackerCloseDatabaseLink () {
+function crackerTrackerCloseDatabaseLink (): void {
// The link should be up here
if (!isCrackerTrackerDatabaseLinkUp()) {
// Throw exception
}
// Inserts given array, if IP/check_get combination was not found
-function crackerTrackerInsertArray (string $table, array $rowData) {
+function crackerTrackerInsertArray (string $table, array $rowData): void {
// Is it found?
if (!isCrackerTrackerEntryFound($rowData)) {
// Reset insert id
}
// Updates a given entry by just counting it up
-function updateCrackerTrackerEntry (array $rowData, string $countColumn = 'count') {
+function updateCrackerTrackerEntry (array $rowData, string $countColumn = 'count'): void {
// The link should be up here
if (!isCrackerTrackerDatabaseLinkUp()) {
// Throw exception
}
// Checks if an entry with IP/check_get/domain combination is there
-function isCrackerTrackerEntryFound (array $rowData) {
+function isCrackerTrackerEntryFound (array $rowData): bool {
// The link should be up here
if (!isCrackerTrackerDatabaseLinkUp()) {
// Throw exception
}
// Escapes the string
-function crackerTrackerEscapeString (string $string) {
+function crackerTrackerEscapeString (string $string): string {
// Is the link up?
if (!isCrackerTrackerDatabaseLinkUp()) {
// Then we cant use mysqli_real_escape_string!
}
// Checks wether a table was found
-function isCrackerTrackerTableCreated (string $table) {
+function isCrackerTrackerTableCreated (string $table): bool {
// Default is not found
$found = false;
}
// Creates the given table with columns
-function crackerTrackerCreateTable (string $table, array $columns, array $keys) {
+function crackerTrackerCreateTable (string $table, array $columns, array $keys): void {
// Begin the SQL
$sqlString = 'CREATE TABLE IF NOT EXISTS `' . $table . '` (';
}
// Inits a table by inserting
-function crackerTrackerInitTable (string $table) {
+function crackerTrackerInitTable (string $table): void {
// Prepare SQL and run it
runCrackerTrackerSql(sprintf("INSERT INTO `%s` (`%s`) VALUES (NULL)'",
$table,
}
// Updates the database scheme automatically
-function crackerTrackerUpdateDatabaseScheme () {
+function crackerTrackerUpdateDatabaseScheme (): void {
// Is a link there?
if (!isCrackerTrackerDatabaseLinkUp()) {
// Abort here silently
}
// Load the configuration
-function crackerTrackerLoadConfig () {
+function crackerTrackerLoadConfig (): void {
// Construct SQL command and run it
$result = runCrackerTrackerSql('SELECT * FROM `ctracker_config` WHERE `ctracker_config`=1 LIMIT 1', __FUNCTION__, __LINE__);
}
// Did the current IP already generated blocked attempts?
-function isCrackerTrackerIpSuspicious () {
+function isCrackerTrackerIpSuspicious (): bool {
// Skip this silently if we have not config
if (!isCrackerTrackerDatabaseLinkUp()) {
// Skip this step silently, all is not suspicious
}
// Does the current IP have a ticket?
-function ifCrackerTrackerIpHasTicket () {
+function ifCrackerTrackerIpHasTicket (): bool {
// We only give one ticket per IP!
$result = runCrackerTrackerSql("SELECT * FROM `ctracker_ticket` WHERE `ctracker_ticket_remote_addr`='" . determineCrackerTrackerRealRemoteAddress() . "' OR `ctracker_ticket_proxy_addr`='" . getenv('REMOTE_ADDR') . "' LIMIT 1", __FUNCTION__, __LINE__);
}
// Adds a ticket based on given (mostly $_POST) data
-function addCrackerTrackerTicket (array $data) {
+function addCrackerTrackerTicket (array $data): void {
// Prepare the array
$GLOBALS['ctracker_last_ticket'] = [
'ctracker_ticket_remote_addr' => determineCrackerTrackerRealRemoteAddress(),
}
// Frees given result instance
-function freeCrackerTrackerResult (mysqli_result $result) {
+function freeCrackerTrackerResult (mysqli_result $result): void {
// Free result
$result->free();
}
*/
// Initializes all detector arrays
-function initCrackerTrackerArrays () {
+function initCrackerTrackerArrays (): void {
// Set error_reporting
if (isCrackerTrackerDebug()) {
// For debugging purposes, this is fine
}
// Checks for worms
-function isCrackerTrackerWormDetected () {
+function isCrackerTrackerWormDetected (): bool {
// Check against the whole list
$GLOBALS['ctracker_checked_get'] = urldecode(str_ireplace($GLOBALS['ctracker_get_blacklist'], '*', crackerTrackerQueryString(true)));
$GLOBALS['ctracker_checked_ua'] = urldecode(str_ireplace($GLOBALS['ctracker_ua_blacklist'], '*', crackerTrackerUserAgent(true)));
}
// Checks POST data
-function isCrackerTrackerPostAttackDetected () {
+function isCrackerTrackerPostAttackDetected (): bool {
// Implode recursive the whole $_POST array
$GLOBALS['ctracker_post_track'] = urldecode(implode_r('&', $_POST));
}
// Prepares a mail and send it out
-function sendCrackerTrackerMail () {
+function sendCrackerTrackerMail (): void {
// Log the attack
crackerTrackerLogAttack();
}
// Sends the ticket emails out
-function sendCrackerTrackerTicketMails () {
+function sendCrackerTrackerTicketMails (): void {
// Load user template
$mail = crackerTrackerLoadEmailTemplate('user_add_ticket', $GLOBALS['ctracker_last_ticket']);
}
// Sends a mail out
-function crackerTrackerSendMail (string $mail, string $recipient = NULL, string $subject = NULL) {
+function crackerTrackerSendMail (string $mail, string $recipient = NULL, string $subject = NULL): bool {
// Construct dummy array
$rowData = [
'remote_addr' => determineCrackerTrackerRealRemoteAddress(),
}
// Sends a detected POST attack mail
-function sendCrackerTrackerPostMail () {
+function sendCrackerTrackerPostMail (): void {
// Log the attack
crackerTrackerLogAttack();
}
// Sleeps for a random time and aborts the script
-function crackerTrackerDie () {
+function crackerTrackerDie (): void {
// Check if link is up
if (isCrackerTrackerDatabaseLinkUp()) {
// Close database link
}
// Logs the attack attempt
-function crackerTrackerLogAttack () {
+function crackerTrackerLogAttack (): void {
// Aquire database link
aquireCrackerTrackerDatabaseLink();
}
// Increases count of spam-bot accesses for the current IP
-function ctrackerIncreaseAntiSpambotCount () {
+function ctrackerIncreaseAntiSpambotCount (): void {
// Init row data
$rowData = [
'remote_addr' => determineCrackerTrackerRealRemoteAddress(),
}
// Alerts the current user about malicious/suspicious traffic
-function crackerTrackerAlertCurrentUser () {
+function crackerTrackerAlertCurrentUser (): void {
// Is there some data?
if (isset($GLOBALS['ctracker_last_suspicious_entry'])) {
// Does the user have a ticket?
* @link http://support.microsoft.com/kb/q176113/
* @author Andreas Gohr <andi@splitbrain.org>
*/
-function crackerTrackerSendRawRedirect (string $url) {
+function crackerTrackerSendRawRedirect (string $url): void {
// Better remove any data by ctracker
unsetCtrackerData();
}
// Removes all ctracker-related data from global space
-function unsetCtrackerData () {
+function unsetCtrackerData (): void {
// Debug message
//* DEBUG: */ error_log(__FUNCTION__ . ': CALLED!');
}
// Sanitizes string
-function crackerTrackerSanitize (string $str) {
+function crackerTrackerSanitize (string $str): string {
return str_replace(array('//', '/./'), array('/', '/'), $str);
}
-function crackerTrackerIsConsole () {
+function crackerTrackerIsConsole (): bool {
return (php_sapi_name() == 'cli');
}
// Add anti-spam field in contact form
-function ctrackerAntiSpamField () {
+function ctrackerAntiSpamField (): string {
// Get all fields
$fields = ctrackerGetAntiSpamFields();
return $fieldName;
}
-function ctrackerGetAntiSpamFields () {
+function ctrackerGetAntiSpamFields (): array {
return [
// URLs
'ctracker_blog',
];
}
-function ifCtrackerTrackerAntiSpamFieldGiven () {
+function ifCtrackerTrackerAntiSpamFieldGiven (): bool {
// Is request method POST?
if (crackerTrackerRequestMethod() != 'POST') {
// Cannot be given