Attak from the Web - need help with hook order
Posted: Fri Mar 03, 2023 12:56 pm
Hi All
i have since a couple of days alot request from strange (abusive) ip's
i have made a hook in the shop/system/_block_ip_range.php
and the idea is to block ip's on the "startApplication" so it should block BEFORE everything else will happen but i see there is alot of executed before my hook is firing. Can somebody tell me how i can make the hook that it fires +- at the beginning (but that i can make a DB Query to check ip)
that's my hook
to name a example, the ACTION = Wishlist_add from the request: /index.php?products_id=449109&action=wishlist_add is executed before my hook to block it
UPDATE: i renamed it to hook_shop_system__001_block_ip_range and it seems that it solves the problem, is that correct like this, or other name recomandations?
i have since a couple of days alot request from strange (abusive) ip's
i have made a hook in the shop/system/_block_ip_range.php
and the idea is to block ip's on the "startApplication" so it should block BEFORE everything else will happen but i see there is alot of executed before my hook is firing. Can somebody tell me how i can make the hook that it fires +- at the beginning (but that i can make a DB Query to check ip)
that's my hook
Code: Select all
class hook_shop_system__block_ip_range {
public function listen_startApplication() {
//Block ip Ranges
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
if(!empty($ip)){
$block_ip_query_range = tep_db_query("SELECT ip_start FROM `ip_range_block` WHERE INET_ATON('".$ip."') between ip_start and ip_end limit 1");
if (mysqli_num_rows($block_ip_query_range) > 0) {
$block_ip_range = tep_db_fetch_array($block_ip_query_range);
if(!empty($block_ip_range['ip_start'])){
//Whitelist exkluden von Block
$whitelist_ip_query_range = tep_db_query("SELECT ip_start FROM `ip_range_whitelist` WHERE INET_ATON('".$ip."') between ip_start and ip_end limit 1");
if (mysqli_num_rows($whitelist_ip_query_range) > 0) {
//Blocken
}else{
header('HTTP/1.0 403 Forbidden');
echo "Ihre IP (".$ip.") wurden aufgrund Ihrer Zugriffe gesperrt";
exit();
}
}
}else{
tep_db_query("INSERT INTO ip_log (ip_address, views, time) VALUES (INET_ATON('" . $ip . "'), views + 1, ".time().") ON DUPLICATE KEY UPDATE views = views + 1");
}
}
}
}UPDATE: i renamed it to hook_shop_system__001_block_ip_range and it seems that it solves the problem, is that correct like this, or other name recomandations?