PDA

View Full Version : Cách loại trừ Proxy vào web của bạn


Miracle
23-03-2007, 17:09
* Dành cho web chạy php

Vì một lý do nào đó, chúng ta không muốn người ta dùng Proxy để truy cập vào cái web của bạn, nhất là các site ecommerce. Vậy phải làm sao để ngăn nó. Tôi có cách như sau.
bạn save cái đoạn code bên dưới thành file checkproxy.php


<?php
$addr = $_SERVER['REMOTE_ADDR'];
$raddr = explode('.', $addr);
$raddr = $raddr[3].'.'.$raddr[2].'.'.$raddr[1].'.'.$raddr[0];
$ip['opm'] = gethostbyname($raddr.'.opm.blitzed.org');
$ip['njabl'] = gethostbyname($raddr.'.dnsbl.njabl.org');
$ip['akill'] = gethostbyname($raddr.'.dnsbl.winbots.org');
$ip['virbl'] = gethostbyname($raddr.'.virbl.dnsbl.bit.nl');
$ip['ircahbl'] = gethostbyname($raddr.'.ircbl.ahbl.org');
$ip['sectoor'] = gethostbyname($raddr.'.tor.dnsbl.sectoor.de');
$ip['torahbl'] = gethostbyname($raddr.'.tor.ahbl.org');
$ip['no-more-funn'] = gethostbyname($raddr.'.no-more-funn.moensted.dk');
$ip['sorbs'] = gethostbyname($raddr.'.dnsbl.sorbs.net');
if ($ip['opm'] == $raddr.'.opm.blitzed.org') { $ip['opm'] = "...n"; }
if ($ip['njabl'] == $raddr.'.dnsbl.njabl.org') { $ip['njabl'] = "...n"; }
if ($ip['akill'] == $raddr.'.dnsbl.winbots.org') { $ip['akill'] = "...n"; }
if ($ip['virbl'] == $raddr.'.virbl.dnsbl.bit.nl') { $ip['virbl'] = "...n"; }
if ($ip['ircahbl'] == $raddr.'.ircbl.ahbl.org') { $ip['ircahbl'] = "...n"; }
if ($ip['sectoor'] == $raddr.'.tor.dnsbl.sectoor.de') { $ip['sectoor'] = "...n"; }
if ($ip['torahbl'] == $raddr.'.tor.ahbl.org') { $ip['torahbl'] = "...n"; }
if ($ip['no-more-funn'] == $raddr.'.no-more-funn.moensted.dk') { $ip['no-more-funn'] = "...n"; }
if ($ip['sorbs'] == $raddr.'.dnsbl.sorbs.net') { $ip['sorbs'] = "...n"; }
$ip['opm'] = explode('.', $ip['opm']);
$ip['njabl'] = explode('.', $ip['njabl']);
$ip['akill'] = explode('.', $ip['akill']);
$ip['virbl'] = explode('.', $ip['virbl']);
$ip['ircahbl'] = explode('.', $ip['ircahbl']);
$ip['sectoor'] = explode('.', $ip['sectoor']);
$ip['torahbl'] = explode('.', $ip['torahbl']);
$ip['no-more-funn'] = explode('.', $ip['no-more-funn']);
$ip['sorbs'] = explode('.', $ip['sorbs']);
$ip['opm'] = $ip['opm'][3];
$ip['njabl'] = $ip['njabl'][3];
$ip['akill'] = $ip['akill'][3];
$ip['virbl'] = $ip['virbl'][3];
if ($ip['ircahbl'] == 'n') { $ip['ircahbl'] = "You Aren't Listed."; }
if ($ip['sectoor'] == 'n') { $ip['sectoor'] = "You Aren't Listed."; }
if ($ip['torahbl'] == 'n') { $ip['torahbl'] = "You Aren't Listed."; }
if ($ip['no-more-funn'] == 'n') { $ip['no-more-funn'] = "You Aren't Listed."; }
if ($ip['sorbs'] == 'n') { $ip['sorbs'] = "You Aren't Listed."; }
if (($ip['njabl'] != '9') and ($ip['njabl'] != "You Aren't Listed.")) { $ip['njabl'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['akill'] != '1') and ($ip['akill'] != "You Aren't Listed.")) { $ip['akill'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['sectoor'] != '1') and ($ip['sectoor'] != "You Aren't Listed.")) { $ip['sectoor'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['torahbl'] != '2') and ($ip['torahbl'] != "You Aren't Listed.")) { $ip['torahbl'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['no-more-funn'] != '10') and ($ip['no-more-funn'] != "You Aren't Listed.")) { $ip['no-more-funn'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['sorbs'] != '2') and ($ip['sorbs'] != '3') and ($ip['sorbs'] != '4') and ($ip['sorbs'] != "You Aren't Listed.")) { $ip['sorbs'] = "Invalid Reply (You Aren't Listed)"; }
if (is_numeric($ip['opm'])) { $listed = 1; }
if (is_numeric($ip['njabl'])) { $listed = 1; }
if (is_numeric($ip['akill'])) { $listed = 1; }
if (is_numeric($ip['virbl'])) { $listed = 1; }
if (is_numeric($ip['ircahbl'])) { $listed = 1; }
if (is_numeric($ip['sectoor'])) { $listed = 1; }
if (is_numeric($ip['torahbl'])) { $listed = 1; }
if (is_numeric($ip['no-more-funn'])) { $listed = 1; }
if (is_numeric($ip['sorbs'])) { $listed = 1; }

if ($listed == 1) { die("Your ip, ".$addr.", is listed in one or more of the proxy/abusive lists we check."); }
?>

Sau đó bạn dán đoạn code như sau vào ngay đầu file php của bạn muốn check:
include("/path/to/your/checkproxy.php");

support
12-04-2007, 10:23
Nhỡ người ta sài chương trình của hãng thứ 3 (proxifier chẳng hạn) thì sao hả bạn, có vào được hong? ^_^

Miracle
14-04-2007, 10:10
Nếu bạn muốn chặn thì thêm proxifier nào list trên

support
14-04-2007, 10:16
Vậy làm theo cách bạn thì không tài nào Hacker có thể vượt qua PayGate phải không (dùng sock, hay ghostsurl ...) :waaaht:

Miracle
14-04-2007, 10:21
Thông thường thì sock là do hacker cài vào các servers mà mình hack được, những IP của servers đó mình đâu có biết trước được thì làm sao mà chặn ?

ghostsurl < mới nghe từ này !

support
14-04-2007, 19:33
Thông thường thì sock là do hacker cài vào các servers mà mình hack được, những IP của servers đó mình đâu có biết trước được thì làm sao mà chặn ?

ghostsurl < mới nghe từ này !

Nói vậy thì tui sài Sock or Prisock >>>>xong, khỏi chặn >>>> bài của bạn ko áp dụng được :smile:

zeroonea
24-04-2007, 00:53
{@:

- Thường mí cgi-proxy, php-proxy, sock, prisock... ko chú ý đến user agent, bạn chỉ cần check và cho phép user agent của vài loại browser phổ biến (IE, FF, OP.....).

- Check lun referer khi process 1 số page quan trọng như login, check out....

- Tất nhiên chỉ có thể chống gà nào chỉ biết xài tool mà ko hiểu rõ cấu trúc bên trong thoai ^_~.

:@}

Miracle
24-04-2007, 00:56
Nói vậy thì tui sài Sock or Prisock >>>>xong, khỏi chặn >>>> bài của bạn ko áp dụng được :smile:

Sock, Prisock thường rất khó kiếm (hack được server thì may ra có !)
Nếu làm site thương mại thì cách kiểm tra tốt nhất là phone hỏi thăm khách hàng !