Phase 6: AIOS security plugin with conservative login lockdown config (10 attempts)

This commit is contained in:
Hanson.xyz Dev
2025-11-28 17:19:54 -06:00
parent 78a744ef06
commit abbd3502e8
430 changed files with 137111 additions and 7 deletions
@@ -0,0 +1,13 @@
<?php
namespace AIOWPS\Firewall;
/**
* Our list of families
*/
return array(
array('name' => '6G', 'priority' => 10),
array('name' => 'Blacklist', 'priority' => 1),
array('name' => 'Bruteforce', 'priority' => 0),
array('name' => 'General', 'priority' => 20),
array('name' => 'Bots', 'priority' => 2),
);
@@ -0,0 +1,33 @@
<?php
namespace AIOWPS\Firewall;
/**
* Builds all our families
*/
class Family_Builder {
/**
* Get our families sorted by priority
*
* @return array
*/
public static function get_families() {
$family_list = include(AIOWPS_FIREWALL_DIR.'/family/wp-security-firewall-families.php');
//Prioritise the families
usort($family_list, function($member, $member2) {
if ($member['priority'] == $member2['priority']) {
return 0;
}
return ($member['priority'] > $member2['priority']) ? 1 : -1;
});
$families = array();
foreach ($family_list as $member) {
$families[strtolower($member['name'])] = new Family($member['name'], $member['priority']);
}
return $families;
}
}
@@ -0,0 +1,49 @@
<?php
namespace AIOWPS\Firewall;
/**
* Holds all our families
*/
class Family_Collection {
/**
* Holds our families
*
* @var array
*/
protected $families;
/**
* Constructs our family collection object
*
* @param array $families - The sorted families to contain
*/
public function __construct($families = array()) {
$this->families = $families;
}
/**
* Generator method to iterate over the families
*
* @return iterable
*/
public function get_family() {
foreach ($this->families as $family) {
yield $family;
}
}
/**
* Adds a new rule to a family member
*
* @param Rule $rule - an active rule to add to its family
* @return void
*/
public function add_rule_to_member(Rule $rule) {
$key = strtolower($rule->family);
if (array_key_exists($key, $this->families)) {
$this->families[$key]->add_rule($rule);
}
}
}
@@ -0,0 +1,86 @@
<?php
namespace AIOWPS\Firewall;
/**
* Represents a family (a grouping of rules)
*/
class Family {
/**
* Name of the family
*
* @var string
*/
public $name;
/**
* Priority of the family (0 is the highest)
*
* @var int
*/
public $priority;
/**
* List of rules to apply
*
* @var array
*/
protected $rules;
/**
* Builds our family object
*
* @param string $name
* @param integer $priority
*/
public function __construct($name, $priority = 999999) {
$this->name = $name;
$this->priority = $priority;
$this->rules = array();
}
/**
* Adds a rule to the family
*
* @param Rule $rule
* @return void
*/
public function add_rule(Rule $rule) {
$this->rules[] = $rule;
}
/**
* Applies all the rules in the family
*
* @return void
*/
public function apply_all() {
if (empty($this->rules)) {
return;
}
//ensure the rules are ordered by priority
usort($this->rules, function(Rule $rule, Rule $rule2) {
if ($rule->priority == $rule2->priority) {
return 0;
}
return ($rule->priority > $rule2->priority) ? 1 : -1;
});
foreach ($this->rules as $rule) {
$rule->apply();
}
}
/**
* Returns the family name if used as a string
*
* @return string
*/
public function __toString() {
return $this->name;
}
}