Version Notes
Monitor admin login failure and block admin for IP
Download this release
Release Info
Developer | Marcin Frymark |
Extension | anti_bruteforce |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/community/Alekseon/AntiBruteforce/Block/Adminhtml/Blocked.php +20 -0
- app/code/community/Alekseon/AntiBruteforce/Block/Adminhtml/Blocked/Grid.php +54 -0
- app/code/community/Alekseon/AntiBruteforce/Block/System/Config/Form/Field/Ip.php +18 -0
- app/code/community/Alekseon/AntiBruteforce/Helper/Data.php +10 -0
- app/code/community/Alekseon/AntiBruteforce/Model/Attemp.php +14 -0
- app/code/community/Alekseon/AntiBruteforce/Model/Blocked.php +14 -0
- app/code/community/Alekseon/AntiBruteforce/Model/Observer.php +84 -0
- app/code/community/Alekseon/AntiBruteforce/Model/Resource/Attemp.php +14 -0
- app/code/community/Alekseon/AntiBruteforce/Model/Resource/Attemp/Collection.php +14 -0
- app/code/community/Alekseon/AntiBruteforce/Model/Resource/Blocked.php +14 -0
- app/code/community/Alekseon/AntiBruteforce/Model/Resource/Blocked/Collection.php +14 -0
- app/code/community/Alekseon/AntiBruteforce/controllers/Adminhtml/AntiBruteforce/BlockedController.php +56 -0
- app/code/community/Alekseon/AntiBruteforce/etc/adminhtml.xml +58 -0
- app/code/community/Alekseon/AntiBruteforce/etc/config.xml +92 -0
- app/code/community/Alekseon/AntiBruteforce/etc/system.xml +75 -0
- app/code/community/Alekseon/AntiBruteforce/sql/alekseon_antibruteforce_setup/install-0.1.0.php +41 -0
- app/design/adminhtml/default/default/layout/alekseon/antiBruteforce.xml +16 -0
- app/etc/modules/Alekseon_AntiBruteforce.xml +9 -0
- package.xml +22 -0
app/code/community/Alekseon/AntiBruteforce/Block/Adminhtml/Blocked.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Lukasz Linczewski
|
4 |
+
* @email contact@alekseon.com
|
5 |
+
* @company Alekseon
|
6 |
+
* @website www.alekseon.com
|
7 |
+
*/
|
8 |
+
class Alekseon_AntiBruteforce_Block_Adminhtml_Blocked extends Mage_Adminhtml_Block_Widget_Grid_Container
|
9 |
+
{
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
$this->_blockGroup = 'alekseon_antibruteforce';
|
14 |
+
$this->_controller = 'adminhtml_blocked';
|
15 |
+
$this->_headerText = Mage::helper('alekseon_antibruteforce')->__('Anti Bruteforce Blocked');
|
16 |
+
parent::__construct();
|
17 |
+
$this->removeButton('add');
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
app/code/community/Alekseon/AntiBruteforce/Block/Adminhtml/Blocked/Grid.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Lukasz Linczewski
|
4 |
+
* @email contact@alekseon.com
|
5 |
+
* @company Alekseon
|
6 |
+
* @website www.alekseon.com
|
7 |
+
*/
|
8 |
+
class Alekseon_AntiBruteforce_Block_Adminhtml_Blocked_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
9 |
+
{
|
10 |
+
|
11 |
+
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
parent::__construct();
|
15 |
+
$this->setId('anti_bruteforce_blocked_grid');
|
16 |
+
$this->setSaveParametersInSession(true);
|
17 |
+
$this->setUseAjax(true);
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _prepareColumns()
|
21 |
+
{
|
22 |
+
$this->addColumn('ip',
|
23 |
+
array(
|
24 |
+
'header' => Mage::helper('alekseon_antibruteforce')->__('Ip'),
|
25 |
+
'index' => 'ip',
|
26 |
+
'type' => 'text',
|
27 |
+
)
|
28 |
+
);
|
29 |
+
|
30 |
+
return parent::_prepareColumns();
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function _prepareCollection()
|
34 |
+
{
|
35 |
+
$collection = Mage::getModel('alekseon_antibruteforce/blocked')->getCollection();
|
36 |
+
$this->setCollection($collection);
|
37 |
+
|
38 |
+
return parent::_prepareCollection();
|
39 |
+
}
|
40 |
+
|
41 |
+
protected function _prepareMassaction()
|
42 |
+
{
|
43 |
+
$this->setMassactionIdField('bruteforce_blocked_delete');
|
44 |
+
$this->getMassactionBlock()->setFormFieldName('blocked_id');
|
45 |
+
|
46 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
47 |
+
'label'=> Mage::helper('tax')->__('Delete'),
|
48 |
+
'url' => $this->getUrl('*/*/massDelete', array('' => '')), // public function massDeleteAction() in Mage_Adminhtml_Tax_RateController
|
49 |
+
'confirm' => Mage::helper('tax')->__('Are you sure?')
|
50 |
+
));
|
51 |
+
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Alekseon/AntiBruteforce/Block/System/Config/Form/Field/Ip.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Alekseon_AntiBruteforce_Block_System_Config_Form_Field_Ip
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
5 |
+
{
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->addColumn('ip', array(
|
9 |
+
'label' => Mage::helper('adminhtml')->__('IP'),
|
10 |
+
'style' => 'width:100px',
|
11 |
+
));
|
12 |
+
|
13 |
+
$this->_addAfter = false;
|
14 |
+
$this->_addButtonLabel = Mage::helper('adminhtml')->__('Add IP');
|
15 |
+
parent::__construct();
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
app/code/community/Alekseon/AntiBruteforce/Helper/Data.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Lukasz Linczewski
|
4 |
+
* @email contact@alekseon.com
|
5 |
+
* @company Alekseon
|
6 |
+
* @website www.alekseon.com
|
7 |
+
*/
|
8 |
+
class Alekseon_AntiBruteforce_Helper_Data extends Mage_Core_Helper_Abstract {
|
9 |
+
|
10 |
+
}
|
app/code/community/Alekseon/AntiBruteforce/Model/Attemp.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Lukasz Linczewski
|
4 |
+
* @email contact@alekseon.com
|
5 |
+
* @company Alekseon
|
6 |
+
* @website www.alekseon.com
|
7 |
+
*/
|
8 |
+
class Alekseon_AntiBruteforce_Model_Attemp extends Mage_Core_Model_Abstract
|
9 |
+
{
|
10 |
+
protected function _construct()
|
11 |
+
{
|
12 |
+
$this->_init('alekseon_antibruteforce/attemp');
|
13 |
+
}
|
14 |
+
}
|
app/code/community/Alekseon/AntiBruteforce/Model/Blocked.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Lukasz Linczewski
|
4 |
+
* @email contact@alekseon.com
|
5 |
+
* @company Alekseon
|
6 |
+
* @website www.alekseon.com
|
7 |
+
*/
|
8 |
+
class Alekseon_AntiBruteforce_Model_Blocked extends Mage_Core_Model_Abstract
|
9 |
+
{
|
10 |
+
protected function _construct()
|
11 |
+
{
|
12 |
+
$this->_init('alekseon_antibruteforce/blocked');
|
13 |
+
}
|
14 |
+
}
|
app/code/community/Alekseon/AntiBruteforce/Model/Observer.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Lukasz Linczewski
|
4 |
+
* @email contact@alekseon.com
|
5 |
+
* @company Alekseon
|
6 |
+
* @website www.alekseon.com
|
7 |
+
*/
|
8 |
+
class Alekseon_AntiBruteforce_Model_Observer
|
9 |
+
{
|
10 |
+
public function handleAttemp(){
|
11 |
+
if(!Mage::getStoreConfig('alekseon_antibruteforce/anti_bruteforce/enabled')){
|
12 |
+
return;
|
13 |
+
}
|
14 |
+
$ip = Mage::helper('core/http')->getRemoteAddr();
|
15 |
+
if($ip == '127.0.0.1' || $this->_isWhiteListed($ip)){
|
16 |
+
return;
|
17 |
+
}
|
18 |
+
|
19 |
+
$this->_addAttemp($ip);
|
20 |
+
$this->_checkIfBlock($ip);
|
21 |
+
}
|
22 |
+
|
23 |
+
private function _addAttemp($ip){
|
24 |
+
$attemp = Mage::getModel('alekseon_antibruteforce/attemp');
|
25 |
+
$attemp->setData(array(
|
26 |
+
'ip' => $ip,
|
27 |
+
'created_at' => Mage::getModel('core/date')->gmtDate()
|
28 |
+
)
|
29 |
+
);
|
30 |
+
$attemp->save();
|
31 |
+
}
|
32 |
+
|
33 |
+
private function _checkIfBlock($ip){
|
34 |
+
$time = time();
|
35 |
+
$to = date('Y-m-d H:i:s', $time);
|
36 |
+
$hours = (int)Mage::getStoreConfig('alekseon_antibruteforce/anti_bruteforce/hours_of_attemping');
|
37 |
+
$seconds = 60*60*$hours; //TODO Make 5 it dynamic configuration
|
38 |
+
$lastTime = $time - $seconds;
|
39 |
+
$from = date('Y-m-d H:i:s', $lastTime);
|
40 |
+
|
41 |
+
$collection = Mage::getModel('alekseon_antibruteforce/attemp')->getCollection()
|
42 |
+
->addFieldToFilter('ip', $ip)
|
43 |
+
->addFieldToFilter('created_at', array('from' => $from, 'to' => $to));
|
44 |
+
$count = $collection->count();
|
45 |
+
|
46 |
+
$numberOfTries = (int)Mage::getStoreConfig('alekseon_antibruteforce/anti_bruteforce/number_of_attemps');
|
47 |
+
if($count > $numberOfTries){
|
48 |
+
$this->_blockUser($ip);
|
49 |
+
}
|
50 |
+
return;
|
51 |
+
}
|
52 |
+
|
53 |
+
private function _blockUser($ip){
|
54 |
+
$model = Mage::getModel('alekseon_antibruteforce/blocked');
|
55 |
+
$model->setIp($ip);
|
56 |
+
$model->save();
|
57 |
+
}
|
58 |
+
|
59 |
+
public function checkIfBlocked(){
|
60 |
+
if(!Mage::getStoreConfig('alekseon_antibruteforce/anti_bruteforce/enabled')){
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
$ip = Mage::helper('core/http')->getRemoteAddr();
|
64 |
+
if($this->_isWhiteListed($ip)){
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
$blocked = Mage::getModel('alekseon_antibruteforce/blocked')->getCollection()
|
68 |
+
->addFieldToFilter('ip', $ip)
|
69 |
+
->getFirstItem();
|
70 |
+
if($blocked->getId()){
|
71 |
+
throw new Mage_Core_Exception(Mage::helper('enterprise_pci')->__('This IP is locked by Alekseon AntiBruteForce module'));
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
private function _isWhiteListed($ip){
|
76 |
+
$whiteList = unserialize(Mage::getStoreConfig('alekseon_antibruteforce/anti_bruteforce/white_list'));
|
77 |
+
foreach($whiteList as $whiteIp){
|
78 |
+
if(trim($whiteIp['ip']) == $ip){
|
79 |
+
return true;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
return false;
|
83 |
+
}
|
84 |
+
}
|
app/code/community/Alekseon/AntiBruteforce/Model/Resource/Attemp.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Lukasz Linczewski
|
4 |
+
* @email contact@alekseon.com
|
5 |
+
* @company Alekseon
|
6 |
+
* @website www.alekseon.com
|
7 |
+
*/
|
8 |
+
class Alekseon_AntiBruteforce_Model_Resource_Attemp extends Mage_Core_Model_Resource_Db_Abstract
|
9 |
+
{
|
10 |
+
protected function _construct()
|
11 |
+
{
|
12 |
+
$this->_init('alekseon_antibruteforce/attemp', 'attemp_id');
|
13 |
+
}
|
14 |
+
}
|
app/code/community/Alekseon/AntiBruteforce/Model/Resource/Attemp/Collection.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Lukasz Linczewski
|
4 |
+
* @email contact@alekseon.com
|
5 |
+
* @company Alekseon
|
6 |
+
* @website www.alekseon.com
|
7 |
+
*/
|
8 |
+
class Alekseon_AntiBruteforce_Model_Resource_Attemp_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
$this->_init('alekseon_antibruteforce/attemp');
|
13 |
+
}
|
14 |
+
}
|
app/code/community/Alekseon/AntiBruteforce/Model/Resource/Blocked.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Lukasz Linczewski
|
4 |
+
* @email contact@alekseon.com
|
5 |
+
* @company Alekseon
|
6 |
+
* @website www.alekseon.com
|
7 |
+
*/
|
8 |
+
class Alekseon_AntiBruteforce_Model_Resource_Blocked extends Mage_Core_Model_Resource_Db_Abstract
|
9 |
+
{
|
10 |
+
protected function _construct()
|
11 |
+
{
|
12 |
+
$this->_init('alekseon_antibruteforce/blocked', 'blocked_id');
|
13 |
+
}
|
14 |
+
}
|
app/code/community/Alekseon/AntiBruteforce/Model/Resource/Blocked/Collection.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Lukasz Linczewski
|
4 |
+
* @email contact@alekseon.com
|
5 |
+
* @company Alekseon
|
6 |
+
* @website www.alekseon.com
|
7 |
+
*/
|
8 |
+
class Alekseon_AntiBruteforce_Model_Resource_Blocked_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
$this->_init('alekseon_antibruteforce/blocked');
|
13 |
+
}
|
14 |
+
}
|
app/code/community/Alekseon/AntiBruteforce/controllers/Adminhtml/AntiBruteforce/BlockedController.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Lukasz Linczewski
|
4 |
+
* @email contact@alekseon.com
|
5 |
+
* @company Alekseon
|
6 |
+
* @website www.alekseon.com
|
7 |
+
*/
|
8 |
+
class Alekseon_AntiBruteforce_Adminhtml_AntiBruteforce_BlockedController extends Mage_Adminhtml_Controller_Action
|
9 |
+
{
|
10 |
+
|
11 |
+
protected function _isAllowed()
|
12 |
+
{
|
13 |
+
return Mage::getSingleton('admin/session')->isAllowed('system/alekseon_tools/sent_emails_history');
|
14 |
+
}
|
15 |
+
|
16 |
+
public function indexAction()
|
17 |
+
{
|
18 |
+
if ($this->getRequest()->getQuery('ajax')) {
|
19 |
+
$this->_forward('grid');
|
20 |
+
return;
|
21 |
+
}
|
22 |
+
|
23 |
+
$this->loadLayout();
|
24 |
+
$this->renderLayout();
|
25 |
+
}
|
26 |
+
|
27 |
+
public function gridAction()
|
28 |
+
{
|
29 |
+
$this->loadLayout();
|
30 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('alekseon_antibruteforce/adminhtml_blocked_grid')->toHtml());
|
31 |
+
}
|
32 |
+
|
33 |
+
public function massDeleteAction()
|
34 |
+
{
|
35 |
+
$blockedIds = $this->getRequest()->getParam('blocked_id'); // $this->getMassactionBlock()->setFormFieldName('tax_id'); from Mage_Adminhtml_Block_Tax_Rate_Grid
|
36 |
+
if(!is_array($blockedIds)) {
|
37 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('Please select ip(s).'));
|
38 |
+
} else {
|
39 |
+
try {
|
40 |
+
$blockedModel = Mage::getModel('alekseon_antibruteforce/blocked');
|
41 |
+
foreach ($blockedIds as $blockedId) {
|
42 |
+
$blockedModel->load($blockedId)->delete();
|
43 |
+
}
|
44 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
45 |
+
Mage::helper('tax')->__(
|
46 |
+
'Total of %d record(s) have been deleted.', count($blockedIds)
|
47 |
+
)
|
48 |
+
);
|
49 |
+
} catch (Exception $e) {
|
50 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
$this->_redirect('*/*/index');
|
55 |
+
}
|
56 |
+
}
|
app/code/community/Alekseon/AntiBruteforce/etc/adminhtml.xml
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @author Lukasz Linczewski
|
5 |
+
* @email contact@alekseon.com
|
6 |
+
* @company Alekseon
|
7 |
+
* @website www.alekseon.com
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<menu>
|
12 |
+
<system>
|
13 |
+
<children>
|
14 |
+
<alekseon_tools translate="title" module="alekseon_antibruteforce">
|
15 |
+
<title>Alekseon Tools</title>
|
16 |
+
<sort_order>89</sort_order>
|
17 |
+
<children>
|
18 |
+
<anti_bruteforce>
|
19 |
+
<title>Anti-Bruteforce Blocked</title>
|
20 |
+
<sort_order>20</sort_order>
|
21 |
+
<action>adminhtml/antiBruteforce_blocked</action>
|
22 |
+
</anti_bruteforce>
|
23 |
+
</children>
|
24 |
+
</alekseon_tools>
|
25 |
+
</children>
|
26 |
+
</system>
|
27 |
+
</menu>
|
28 |
+
<acl>
|
29 |
+
<resources>
|
30 |
+
<admin>
|
31 |
+
<children>
|
32 |
+
<system>
|
33 |
+
<children>
|
34 |
+
<config>
|
35 |
+
<children>
|
36 |
+
<alekseon_antibruteforce translate="title" module="alekseon_antibruteforce">
|
37 |
+
<title>Anti Bruteforce</title>
|
38 |
+
<sort_order>40</sort_order>
|
39 |
+
</alekseon_antibruteforce>
|
40 |
+
</children>
|
41 |
+
</config>
|
42 |
+
<alekseon_tools translate="title" module="alekseon_antibruteforce">
|
43 |
+
<title>Alekseon Tools</title>
|
44 |
+
<sort_order>89</sort_order>
|
45 |
+
<children>
|
46 |
+
<anti_bruteforce>
|
47 |
+
<title>Anti-Bruteforce Blocked</title>
|
48 |
+
<sort_order>20</sort_order>
|
49 |
+
</anti_bruteforce>
|
50 |
+
</children>
|
51 |
+
</alekseon_tools>
|
52 |
+
</children>
|
53 |
+
</system>
|
54 |
+
</children>
|
55 |
+
</admin>
|
56 |
+
</resources>
|
57 |
+
</acl>
|
58 |
+
</config>
|
app/code/community/Alekseon/AntiBruteforce/etc/config.xml
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @author Lukasz Linczewski
|
5 |
+
* @email contact@alekseon.com
|
6 |
+
* @company Alekseon
|
7 |
+
* @website www.alekseon.com
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<modules>
|
12 |
+
<Alekseon_AntiBruteforce>
|
13 |
+
<version>0.1.0</version>
|
14 |
+
</Alekseon_AntiBruteforce>
|
15 |
+
</modules>
|
16 |
+
<global>
|
17 |
+
<models>
|
18 |
+
<alekseon_antibruteforce>
|
19 |
+
<class>Alekseon_AntiBruteforce_Model</class>
|
20 |
+
<resourceModel>alekseon_antibruteforce_resource</resourceModel>
|
21 |
+
</alekseon_antibruteforce>
|
22 |
+
<alekseon_antibruteforce_resource>
|
23 |
+
<class>Alekseon_AntiBruteforce_Model_Resource</class>
|
24 |
+
<entities>
|
25 |
+
<attemp>
|
26 |
+
<table>alekseon_antibruteforce_attemp</table>
|
27 |
+
</attemp>
|
28 |
+
<blocked>
|
29 |
+
<table>alekseon_antibruteforce_blocked</table>
|
30 |
+
</blocked>
|
31 |
+
</entities>
|
32 |
+
</alekseon_antibruteforce_resource>
|
33 |
+
</models>
|
34 |
+
<blocks>
|
35 |
+
<alekseon_antibruteforce>
|
36 |
+
<class>Alekseon_AntiBruteforce_Block</class>
|
37 |
+
</alekseon_antibruteforce>
|
38 |
+
</blocks>
|
39 |
+
<helpers>
|
40 |
+
<alekseon_antibruteforce>
|
41 |
+
<class>Alekseon_AntiBruteforce_Helper</class>
|
42 |
+
</alekseon_antibruteforce>
|
43 |
+
</helpers>
|
44 |
+
<resources>
|
45 |
+
<alekseon_antibruteforce_setup>
|
46 |
+
<setup>
|
47 |
+
<module>Alekseon_AntiBruteforce</module>
|
48 |
+
</setup>
|
49 |
+
</alekseon_antibruteforce_setup>
|
50 |
+
</resources>
|
51 |
+
</global>
|
52 |
+
<adminhtml>
|
53 |
+
<layout>
|
54 |
+
<updates>
|
55 |
+
<alekseon_antibruteforce>
|
56 |
+
<file>alekseon/antiBruteforce.xml</file>
|
57 |
+
</alekseon_antibruteforce>
|
58 |
+
</updates>
|
59 |
+
</layout>
|
60 |
+
<events>
|
61 |
+
<admin_session_user_login_failed>
|
62 |
+
<observers>
|
63 |
+
<alekseon_antibruteforce>
|
64 |
+
<type>singleton</type>
|
65 |
+
<class>alekseon_antibruteforce/observer</class>
|
66 |
+
<method>handleAttemp</method>
|
67 |
+
</alekseon_antibruteforce>
|
68 |
+
</observers>
|
69 |
+
</admin_session_user_login_failed>
|
70 |
+
<adminhtml_controller_action_predispatch_start>
|
71 |
+
<observers>
|
72 |
+
<alekseon_antibruteforce>
|
73 |
+
<type>singleton</type>
|
74 |
+
<class>alekseon_antibruteforce/observer</class>
|
75 |
+
<method>checkIfBlocked</method>
|
76 |
+
</alekseon_antibruteforce>
|
77 |
+
</observers>
|
78 |
+
</adminhtml_controller_action_predispatch_start>
|
79 |
+
</events>
|
80 |
+
</adminhtml>
|
81 |
+
<admin>
|
82 |
+
<routers>
|
83 |
+
<adminhtml>
|
84 |
+
<args>
|
85 |
+
<modules>
|
86 |
+
<alekseon_antibruteforce before="Mage_Adminhtml">Alekseon_AntiBruteforce_Adminhtml</alekseon_antibruteforce>
|
87 |
+
</modules>
|
88 |
+
</args>
|
89 |
+
</adminhtml>
|
90 |
+
</routers>
|
91 |
+
</admin>
|
92 |
+
</config>
|
app/code/community/Alekseon/AntiBruteforce/etc/system.xml
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @author Lukasz Linczewski
|
5 |
+
* @email contact@alekseon.com
|
6 |
+
* @company Alekseon
|
7 |
+
* @website www.alekseon.com
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<tabs>
|
12 |
+
<alekseon>
|
13 |
+
<label>Alekseon</label>
|
14 |
+
<sort_order>450</sort_order>
|
15 |
+
</alekseon>
|
16 |
+
</tabs>
|
17 |
+
<sections>
|
18 |
+
<alekseon_antibruteforce translate="label" module="alekseon_antibruteforce">
|
19 |
+
<label>Anti Bruteforce</label>
|
20 |
+
<tab>alekseon</tab>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort_order>30</sort_order>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>1</show_in_website>
|
25 |
+
<show_in_store>1</show_in_store>
|
26 |
+
<groups>
|
27 |
+
<anti_bruteforce translate="label">
|
28 |
+
<label>Anti Bruteforce</label>
|
29 |
+
<frontend_type>text</frontend_type>
|
30 |
+
<sort_order>20</sort_order>
|
31 |
+
<show_in_default>1</show_in_default>
|
32 |
+
<show_in_website>0</show_in_website>
|
33 |
+
<show_in_store>0</show_in_store>
|
34 |
+
<fields>
|
35 |
+
<enabled translate="label comment">
|
36 |
+
<label>Enabled</label>
|
37 |
+
<frontend_type>select</frontend_type>
|
38 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
39 |
+
<sort_order>10</sort_order>
|
40 |
+
<show_in_default>1</show_in_default>
|
41 |
+
<show_in_website>0</show_in_website>
|
42 |
+
<show_in_store>0</show_in_store>
|
43 |
+
</enabled>
|
44 |
+
<hours_of_attemping translate="label comment">
|
45 |
+
<label>Time of attacking for being blocked</label>
|
46 |
+
<sort_order>20</sort_order>
|
47 |
+
<show_in_default>1</show_in_default>
|
48 |
+
<show_in_website>0</show_in_website>
|
49 |
+
<show_in_store>0</show_in_store>
|
50 |
+
<comment>In hours.</comment>
|
51 |
+
</hours_of_attemping>
|
52 |
+
<number_of_attemps translate="label comment">
|
53 |
+
<label>Number of attamps</label>
|
54 |
+
<sort_order>30</sort_order>
|
55 |
+
<show_in_default>1</show_in_default>
|
56 |
+
<show_in_website>0</show_in_website>
|
57 |
+
<show_in_store>0</show_in_store>
|
58 |
+
<comment>User will be blocked if apply this number of attemps in last x hours defined in previous parameter</comment>
|
59 |
+
</number_of_attemps>
|
60 |
+
<white_list>
|
61 |
+
<label>IP White list</label>
|
62 |
+
<frontend_model>alekseon_antibruteforce/system_config_form_field_ip</frontend_model>
|
63 |
+
<backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
|
64 |
+
<sort_order>33</sort_order>
|
65 |
+
<show_in_default>1</show_in_default>
|
66 |
+
<show_in_website>0</show_in_website>
|
67 |
+
<show_in_store>0</show_in_store>
|
68 |
+
<comment>These ips won't be checked</comment>
|
69 |
+
</white_list>
|
70 |
+
</fields>
|
71 |
+
</anti_bruteforce>
|
72 |
+
</groups>
|
73 |
+
</alekseon_antibruteforce>
|
74 |
+
</sections>
|
75 |
+
</config>
|
app/code/community/Alekseon/AntiBruteforce/sql/alekseon_antibruteforce_setup/install-0.1.0.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Lukasz Linczewski
|
4 |
+
* @email contact@alekseon.com
|
5 |
+
* @company Alekseon
|
6 |
+
* @website www.alekseon.com
|
7 |
+
*/
|
8 |
+
$installer = $this;
|
9 |
+
|
10 |
+
$installer->startSetup();
|
11 |
+
|
12 |
+
$table = $installer->getConnection()
|
13 |
+
->newTable($installer->getTable('alekseon_antibruteforce/attemp'))
|
14 |
+
->addColumn('attemp_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
15 |
+
'identity' => true,
|
16 |
+
'unsigned' => true,
|
17 |
+
'nullable' => false,
|
18 |
+
'primary' => true,
|
19 |
+
), 'Id')
|
20 |
+
->addColumn('ip', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
|
21 |
+
'nullable' => false,
|
22 |
+
), 'Ip')
|
23 |
+
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
|
24 |
+
'nullable' => false,
|
25 |
+
), 'Created at');
|
26 |
+
$installer->getConnection()->createTable($table);
|
27 |
+
|
28 |
+
$table2 = $installer->getConnection()
|
29 |
+
->newTable($installer->getTable('alekseon_antibruteforce/blocked'))
|
30 |
+
->addColumn('blocked_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
31 |
+
'identity' => true,
|
32 |
+
'unsigned' => true,
|
33 |
+
'nullable' => false,
|
34 |
+
'primary' => true,
|
35 |
+
), 'Id')
|
36 |
+
->addColumn('ip', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
|
37 |
+
'nullable' => false,
|
38 |
+
), 'Ip');
|
39 |
+
$installer->getConnection()->createTable($table2);
|
40 |
+
|
41 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/alekseon/antiBruteforce.xml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @author Lukasz Linczewski
|
5 |
+
* @email contact@alekseon.com
|
6 |
+
* @company Alekseon
|
7 |
+
* @website www.alekseon.com
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<layout>
|
11 |
+
<adminhtml_antibruteforce_blocked_index>
|
12 |
+
<reference name="content">
|
13 |
+
<block type="alekseon_antibruteforce/adminhtml_blocked" name="anti_bruteforce_grid_conatiner" />
|
14 |
+
</reference>
|
15 |
+
</adminhtml_antibruteforce_blocked_index>
|
16 |
+
</layout>
|
app/etc/modules/Alekseon_AntiBruteforce.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Alekseon_AntiBruteforce>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Alekseon_AntiBruteforce>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>anti_bruteforce</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Monitor admin login failure and block admin for IP</summary>
|
10 |
+
<description>Module gives possibility to monitor and log admin login failure.
|
11 |
+

|
12 |
+
It's possible to setup how many attemps and for how long time is allowed before this ip is added to blacklist.
|
13 |
+

|
14 |
+
It also gives possibility to create whitelist and manage blocked ips.</description>
|
15 |
+
<notes>Monitor admin login failure and block admin for IP</notes>
|
16 |
+
<authors><author><name>Lukasz Linczewski</name><user>alekseon</user><email>contact@alekseon.com</email></author></authors>
|
17 |
+
<date>2016-05-06</date>
|
18 |
+
<time>14:45:49</time>
|
19 |
+
<contents><target name="magecommunity"><dir name="Alekseon"><dir name="AntiBruteforce"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Blocked"><file name="Grid.php" hash="8330f294a14a53e30d546629ecef10b5"/></dir><file name="Blocked.php" hash="f97930b24e479fd21d0966599ce9da87"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Ip.php" hash="9d7984f2a8b05fc47cbd2cdd7d87ace8"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="048642a2eb4729c81c2890f1d53858cb"/></dir><dir name="Model"><file name="Attemp.php" hash="59a0cb085f0cf4b06bf42b926cac6b05"/><file name="Blocked.php" hash="aade6868cec4fda97aa054cd3f918a07"/><file name="Observer.php" hash="0bcb61027292333f5a7f28f32361165c"/><dir name="Resource"><dir name="Attemp"><file name="Collection.php" hash="d2dba80ea636bd454033c1a55db24fe1"/></dir><file name="Attemp.php" hash="b3137208977b97231707fb354bb88547"/><dir name="Blocked"><file name="Collection.php" hash="9101390149fe7c0efc5146e10f3761bd"/></dir><file name="Blocked.php" hash="d5eeb0b6b69ffad41bf220cd4b5bf5ee"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="AntiBruteforce"><file name="BlockedController.php" hash="8a20edf2a6695ab91cf9c3c1918192b7"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="c857f30f4e073c5ac26ec99e852df020"/><file name="config.xml" hash="4882cfce945d4f8f1ad0caf9572077b6"/><file name="system.xml" hash="36aa1d5d5a7bb5cd93d4ebba42f718ef"/></dir><dir name="sql"><dir name="alekseon_antibruteforce_setup"><file name="install-0.1.0.php" hash="4e2b808e92cf1088adbd68f131832a53"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Alekseon_AntiBruteforce.xml" hash="d8b8434d6b49bd47bff37cb80c4fbc81"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="alekseon"><file name="antiBruteforce.xml" hash="3c6951cdc49fe2c90d9fb9a66eb17cac"/></dir></dir></dir></dir></dir></target></contents>
|
20 |
+
<compatible/>
|
21 |
+
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
22 |
+
</package>
|