























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























































































CS 155
Spring 2010
John Mitchell
SQL Injection^ ^ Browser sends malicious input to server^ ^ Bad input checking leads to malicious SQL query
Uses SQL to change meaning of
database command
CSRF – Cross-site request forgery^ ^ Bad web site sends request to good web site, usingcredentials of an innocent victim who “visits” site
Leverage user’s session at
victim sever
credentials of an innocent victim who
visits
site
XSS – Cross-site scripting^ ^ Bad web site sends innocent victim a script that
Inject malicious script into
victim sever
p
steals information from an honest web site
Inject malicious script into
trusted context
Example: PHP server-side code for sending email$email = $_POST[“email”]$subject = $_POST[“subject”]system(“mail
$email –s
$subject < /tmp/joinmynetwork”)
system( mail Attacker can post
$email –s
$subject < /tmp/joinmynetwork )
http://yourdomain.com/[email protected] &subject=foo < /usr/passwd; lsOR http://yourdomain.com/[email protected]&subject=foo;echo “evil::0:0:root:/:/bin/sh">>/etc/passwd; ls
Victim Server
1
unintendedSQL
receive valuable data
2
3
Attacker
SQL query
receive valuable data 3
10
Victim SQL DB
CardSystems^ ^ credit card payment processing company^ ^ SQL injection attack in June 2005^ ^ put out of business^ put out of business The Attack^ ^ 263,000 credit card #s stolen from database^ ^ credit card #s stored unencrypted^ ^ 43 million credit card #s exposed^ 43 million credit card #s exposed
11
Use Google to find sites using a particular ASP stylevulnerable to SQL injection Use SQL injection on these sites to modify the page toinclude a link to a Chinese site
nihaorr1 com
include a link to a Chinese site
nihaorr1.com
Don't visit that site yourself! The site (nihaorr1 com) serves Javascript that exploitsThe site (nihaorr1.com) serves Javascript that exploitsvulnerabilities in IE, RealPlayer, QQ Instant MessengerSteps (1) and (2) are automated in a tool that can be configured toinject whatever you like into vulnerable sites
13
set ok = execute(
"SELECT * FROM Users
WHERE user=' "
form(“user”)
p d ' " & form(“p d”) & “ '” ) AND^
pwd=' " & form(“pwd”) & “ '” );
if not ok.EOF
login success else
fail; I^ thi
l it bl?
14
Is this exploitable?
Suppose
user = “
'^ or 1=1 --
(URL encoded)
Then scripts does:^ ok = execute( SELECTok^
= execute(
WHERE user=
or 1=
The^
causes rest of line to be ignored ^ The
”^ causes
rest of line to be ignored.
^ Now
ok.EOF
is always false and login succeeds.
The bad news:
easy login to many sites this way.
16
Suppose user =^ “
; DROP TABLE Users
Then script does:^ ok = execute( SELECT …WHERE user=
Deletes user table
17
^ Similarly:
attacker can add users,
reset pwds,
etc.
Suppose user =^ ′^
;^ exec cmdshell
′net user badguy badpwd
Then script does:^ ok^
= execute( SELECTok execute(
WHERE username=
If SQL server context runs as “sa”, attacker getsaccount on DB server
19
20