Browse Source

adding #17

release/0.1
Björn 4 years ago
parent
commit
28f8ceffd6
16 changed files with 209 additions and 51 deletions
  1. +0
    -51
      app/Commands/Fail2banCommand.php
  2. +55
    -0
      app/Commands/Fail2banDisableCommand.php
  3. +59
    -0
      app/Commands/Fail2banEnableCommand.php
  4. +2
    -0
      install.sh
  5. +3
    -0
      resources/fail2ban/filter.d/gitea-auth.conf
  6. +8
    -0
      resources/fail2ban/filter.d/woocommerce-auth.conf
  7. +8
    -0
      resources/fail2ban/filter.d/wordpress-auth.conf
  8. +9
    -0
      resources/fail2ban/jail.d/gitea.conf
  9. +9
    -0
      resources/fail2ban/jail.d/nginx-badbots.conf
  10. +7
    -0
      resources/fail2ban/jail.d/nginx-botsearch.conf
  11. +9
    -0
      resources/fail2ban/jail.d/nginx-http-auth.conf
  12. +7
    -0
      resources/fail2ban/jail.d/nginx-nohome.conf
  13. +7
    -0
      resources/fail2ban/jail.d/nginx-noscript.conf
  14. +10
    -0
      resources/fail2ban/jail.d/nginx-req-limit.conf
  15. +9
    -0
      resources/fail2ban/jail.d/woocommerce.conf
  16. +7
    -0
      resources/fail2ban/jail.d/wordpress.conf

+ 0
- 51
app/Commands/Fail2banCommand.php View File

@ -1,51 +0,0 @@
<?php
namespace App\Commands;
use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
use Illuminate\Support\Facades\File;
use App\Facades\Install;
use Log;
/**
*
*
*
*/
class Fail2banCommand extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'fail2ban {--add} {--remove} {configuration}';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'add and remove configuration';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->line('kk');
if ($configuration) {
$this->error('Configuration...not found!');
} else {
exec('service fail2ban restart');
}
}
}

+ 55
- 0
app/Commands/Fail2banDisableCommand.php View File

@ -0,0 +1,55 @@
<?php
namespace App\Commands;
use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
/**
*
*
*
*/
class Fail2banDisableCommand extends Command
{
const FAIL2BAN_JAIL_DIRECTORY = '/etc/fail2ban/jail.d';
const RESOURCES_JAIL_DIRECTORY = '/resources/fail2ban/jail.d';
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'fail2ban:disable {configuration}';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'disable fail2ban configuration';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// getting configuration
$configuration = $this->argument('configuration');
$source = base_path().self::RESOURCES_JAIL_DIRECTORY.'/'.$configuration.'.conf';
// configuration not found
if (!file_exists($source)) {
$this->error('fail2ban...configuration not found');
exit();
}
unlink(self::FAIL2BAN_JAIL_DIRECTORY.'/'.$configuration.'.conf');
exec('service fail2ban restart');
$this->info('fail2ban...'.$configuration.' disabled');
}
}

+ 59
- 0
app/Commands/Fail2banEnableCommand.php View File

@ -0,0 +1,59 @@
<?php
namespace App\Commands;
use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
use Log;
/**
*
*
*
*/
class Fail2banEnableCommand extends Command
{
const FAIL2BAN_JAIL_DIRECTORY = '/etc/fail2ban/jail.d';
const RESOURCES_JAIL_DIRECTORY = '/resources/fail2ban/jail.d';
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'fail2ban:enable {configuration}';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'enable fail2ban configuration';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// getting configuration
$configuration = $this->argument('configuration');
$source = base_path().self::RESOURCES_JAIL_DIRECTORY.'/'.$configuration.'.conf';
// configuration not found
if (!file_exists($source)) {
$this->error('fail2ban...configuration not found');
exit();
}
$destination = self::FAIL2BAN_JAIL_DIRECTORY.'/'.$configuration.'.conf';
copy($source, $destination);
$this->info('fail2ban...'.$configuration.' enabled');
exec('service fail2ban restart');
}
}

+ 2
- 0
install.sh View File

@ -50,6 +50,8 @@ filter = sshd
logpath = /var/log/auth-fail2ban.log
EOF
cp resources/fail2ban/filter.d/* /etc/fail2ban/filter.d
touch /var/log/fail2ban.log
service fail2ban start
echo -e "MCP installed"

+ 3
- 0
resources/fail2ban/filter.d/gitea-auth.conf View File

@ -0,0 +1,3 @@
[Definition]
failregex = .*Failed authentication attempt for .* from <HOST>
ignoreregex =

+ 8
- 0
resources/fail2ban/filter.d/woocommerce-auth.conf View File

@ -0,0 +1,8 @@
# woocommerce auth failed
[INCLUDES]
before = common.conf
[Definition]
failregex = <HOST>.*POST.*(/account/).* 200
ignoreregex =

+ 8
- 0
resources/fail2ban/filter.d/wordpress-auth.conf View File

@ -0,0 +1,8 @@
# wordpress login failed
[INCLUDES]
before = common.conf
[Definition]
failregex = <HOST>.*POST.*(wp-login\.php|xmlrpc\.php).* 200
ignoreregex =

+ 9
- 0
resources/fail2ban/jail.d/gitea.conf View File

@ -0,0 +1,9 @@
#
[gitea]
enabled = true
filter = gitea
port = http,https
logpath = /var/lib/gitea/log/gitea.log
maxretry = 3

+ 9
- 0
resources/fail2ban/jail.d/nginx-badbots.conf View File

@ -0,0 +1,9 @@
# stop some known malicious bot request patterns
[nginx-badbots]
enabled = true
port = http,https
filter = apache-badbots
logpath = /var/log/nginx/*access.log
maxretry = 2

+ 7
- 0
resources/fail2ban/jail.d/nginx-botsearch.conf View File

@ -0,0 +1,7 @@
[nginx-botsearch]
enabled = true
port = http,https
filter = nginx-botsearch
logpath = /var/log/nginx/*access.log
maxretry = 2

+ 9
- 0
resources/fail2ban/jail.d/nginx-http-auth.conf View File

@ -0,0 +1,9 @@
# ban clients that are searching for scripts on the website to execute and exploit,
# only using if php not in use
[nginx-http-auth]
enabled = true
filter = nginx-http-auth
port = http,https
logpath = /var/log/nginx/*error.log

+ 7
- 0
resources/fail2ban/jail.d/nginx-nohome.conf View File

@ -0,0 +1,7 @@
[nginx-nohome]
enabled = true
port = http,https
filter = apache-nohome
logpath = /var/log/nginx/*access.log
maxretry = 2

+ 7
- 0
resources/fail2ban/jail.d/nginx-noscript.conf View File

@ -0,0 +1,7 @@
[nginx-noscript]
enabled = true
port = http,https
filter = apache-noscript
logpath = /var/log/nginx/*access.log
maxretry = 2

+ 10
- 0
resources/fail2ban/jail.d/nginx-req-limit.conf View File

@ -0,0 +1,10 @@
# dos
[nginx-req-limit]
enabled = true
filter = nginx-req-limit
logpath = /var/log/nginx/*error.log
findtime = 600
bantime = 7200
maxretry = 10

+ 9
- 0
resources/fail2ban/jail.d/woocommerce.conf View File

@ -0,0 +1,9 @@
#
[woocommerce]
enabled = true
port = http,https
filter = woocommerce-auth
logpath = /var/log/nginx/*access.log
maxretry = 3

+ 7
- 0
resources/fail2ban/jail.d/wordpress.conf View File

@ -0,0 +1,7 @@
[wordpress]
enabled = true
port = http,https
filter = wordpress-auth
logpath = /var/log/nginx/*access.log
maxretry = 3

Loading…
Cancel
Save