diff --git a/blocker b/blocker old mode 100644 new mode 100755 index 32535bc..dae17c2 Binary files a/blocker and b/blocker differ diff --git a/blocker.c b/blocker.c index 3d11f12..d23ad08 100644 --- a/blocker.c +++ b/blocker.c @@ -8,7 +8,7 @@ #define iptables /sbin/iptables #define ipset /sbin/ipset #define username "simpleguardian" -#define indexCommand 1 +#define indexCommand 1 #define indexIp 2 /** @@ -65,7 +65,7 @@ int is_already_blocked(char **argv) { Returns 0 if not blocked, 1 if already blocked */ char command_check_if_blocked[] = "ipset test simpleguardian %s > /dev/null 2>&1"; - char *command_check_if_blocked_formatted = (char*)malloc(sizeof(command_check_if_blocked) + sizeof(argv[indexIp])); + char *command_check_if_blocked_formatted = (char*)malloc(50 + sizeof(command_check_if_blocked) + sizeof(argv[indexIp])); sprintf(command_check_if_blocked_formatted, command_check_if_blocked, argv[indexIp]); return system(command_check_if_blocked_formatted) == 0; } @@ -107,7 +107,7 @@ int main(int argc, char **argv){ printf("blocking %s\n", argv[indexIp]); char command[] = "ipset add simpleguardian %s > /dev/null 2>&1"; - char *command_formatted = (char*)malloc(sizeof(command) + sizeof(argv[indexIp])); + char *command_formatted = (char*)malloc(50 + sizeof(command) + sizeof(argv[indexIp])); sprintf(command_formatted, command, argv[indexIp]); system(command_formatted); @@ -122,7 +122,7 @@ int main(int argc, char **argv){ printf("unblocking %s\n", argv[indexIp]); char command[] = "ipset del simpleguardian %s > /dev/null 2>&1"; - char *command_formatted = (char*)malloc(sizeof(command) + sizeof(argv[indexIp])); + char *command_formatted = (char*)malloc(50 + sizeof(command) + sizeof(argv[indexIp])); sprintf(command_formatted, command, argv[indexIp]); system(command_formatted); @@ -130,4 +130,4 @@ int main(int argc, char **argv){ exit(0); } help(1); -} \ No newline at end of file +} diff --git a/build-deb.py b/build-deb.py index 9a74ef4..5891fe2 100755 --- a/build-deb.py +++ b/build-deb.py @@ -152,7 +152,7 @@ Essential: no Section: security Priority: optional -Depends: python3, systemd, python3-pip, python3-venv +Depends: python3, systemd, python3-pip, python3-venv, iptables, ipset Maintainer: Adam Hlaváček Installed-Size: %d Description: Protection against brute force attacks diff --git a/simple-guardian.py b/simple-guardian.py index 9c0f730..3c056e0 100644 --- a/simple-guardian.py +++ b/simple-guardian.py @@ -648,7 +648,7 @@ def load_config(dict_src=None, dict_target=None): # type: (dict, dict) -> None :return: None """ if dict_src is None: - with open('config.json', 'r') as f: + with open('data/config.json', 'r') as f: dict_src = json.load(f) dict_target = CONFIG for k, v in dict_src.items():