Sunday 14 April 2013

Mengamankan web dengan Auto Blacklist

By dxCyberz ISD   Posted at  Sunday, April 14, 2013   Security No comments

Ok,, langsung ke topik,,
Pertama buatlah sebuah tabel pada database kamu, contoh tabel blacklist

Kode:
CREATE TABLE `blacklist` (
`ip_attacker` varchar(50) NOT NULL
)

Sekarang kita akan membuat sebuah file yang akan mendeteksi gerak-gerik sang attacker tersebut, dan apabila terdeteksi melakukan sesuatu hal yang dianggap melakukan Pengijeksiaan maka akan otomatis menyalin IP attacker tersebut

file "blacklist.php"
Kode:
<?
//Deteksi user yang memasukan sebuah perintah penginjesian terhadap web kita
if(strpos($_SERVER['REQUEST_URI'], "%27") || strpos($_SERVER['REQUEST_URI'], "union") || strpos($_SERVER['REQUEST_URI'], "http://") || strpos($_SERVER['REQUEST_URI'], "www.") || strpos($_SERVER['REQUEST_URI'], "../") || strpos($_SERVER['REQUEST_URI'], "etc/passwd")) {

//Apabila terdeteksi melakukan penginjeksian, ambil IP mereka
$ip = $_SERVER['REMOTE_ADDR'];

//Kirim IP ke database kita
$kirim_ip = mysql_query("INSERT INTO blacklist VALUE ('$ip')");
}
?>

Setelah itu masuk ke file yang kamu rasa dapat di injeksi, saya contohkan file index.php

Contoh Penginjeksian oleh attacker

http://www.web.kamu/index.php?id=1' (SQL Injection)
http://www.web.kamu/index.php?page=http:.../shell.txt (RFI/LFI)
http://www.web.kamu/index.php?page=../../etc/passwd (RFI/LFI)

Untuk penjelasan tehnik diatas mungkin bisa di googling sendiri atau mungkin sudah banyak yang tahu,, karena disini kita akan membahas mengenai Auto Blacklist maka saya juga tidak akan memfokuskan dalam penjelasan tekhnik diatas,, CheerCheer

Oke Next..

Setelah masuk ke file index.php lakukan pengonekan pada file blacklist.php, gunakan fungsi include()

Kode:
include "blacklist.php";
Terus jangan lupa lakukan penganalisian IP, untuk mengalihkan attacker ke tempat lain apabila attacker mengakses web kita lagi

Kode:
<?
//Periksa IP attacker tersebut apa pernah masuk ke database kita
$ipattacker = mysql_query("SELECT * FROM blacklist where ip_attacker = '".$_SERVER['REMOTE_ADDR']."'");
$konfirmasi_attacker = mysql_num_rows($ipattacker);

//Apabila IP telah terdeteksi pernah masuk ke database maka alihkan attacker ke halaman lain, contoh :google.com
if ($konfirmasi_attacker !== 0) {
header('Location:http://google.com');
}
?>


Sumber : http://forum.indonesiansecuritydown.org/thread-26-post-44.html#pid44

About the Author

Nulla sagittis convallis arcu. Sed sed nunc. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.
View all posts by: BT9

0 comments:

Back to top ↑
Connect with Us

Site Rank

Total Pageviews

© 2013 dxCyberz Blog. WP Mythemeshop Converted by Bloggertheme9
Blogger templates. Proudly Powered by Blogger.