473,399 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to avoid script database hacking?

RA
If I get the user info from an aso.net, and based on that execute some query
against the database, how can I avoid issues like this one:

Client entered in user name text box the following: "new;delect from users"

On server side I have:

sql = "select * from users where username = " + txtUser.Text;
Thanks,
Ronen
Nov 18 '05 #1
12 1757
You should always check for dodgy characters in the string and use stored
procedures with parameters.
"RA" <ro****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
If I get the user info from an aso.net, and based on that execute some query against the database, how can I avoid issues like this one:

Client entered in user name text box the following: "new;delect from users"
On server side I have:

sql = "select * from users where username = " + txtUser.Text;
Thanks,
Ronen

Nov 18 '05 #2
RA
How would a store procedure help if the parameter passed to it is the input
from the text box?

"Wes Jackson" <we********@hotmail.com> wrote in message
news:eD**************@tk2msftngp13.phx.gbl...
You should always check for dodgy characters in the string and use stored
procedures with parameters.
"RA" <ro****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
If I get the user info from an aso.net, and based on that execute some

query
against the database, how can I avoid issues like this one:

Client entered in user name text box the following: "new;delect from

users"

On server side I have:

sql = "select * from users where username = " + txtUser.Text;
Thanks,
Ronen


Nov 18 '05 #3
You can also Use Stored Procs


"Wes Jackson" <we********@hotmail.com> wrote in message
news:eD**************@tk2msftngp13.phx.gbl...
You should always check for dodgy characters in the string and use stored
procedures with parameters.
"RA" <ro****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
If I get the user info from an aso.net, and based on that execute some

query
against the database, how can I avoid issues like this one:

Client entered in user name text box the following: "new;delect from

users"

On server side I have:

sql = "select * from users where username = " + txtUser.Text;
Thanks,
Ronen


Nov 18 '05 #4
SqlCommand cmd=new SqlCommand("select * from employees where
employeeid=@id",conn);
cmd.Parameters.Add("@id",TextBox1.Text);
cmd.Execute...

"RA" <ro****@hotmail.com> дÈëÓʼþ
news:%2****************@TK2MSFTNGP09.phx.gbl...
If I get the user info from an aso.net, and based on that execute some query against the database, how can I avoid issues like this one:

Client entered in user name text box the following: "new;delect from users"
On server side I have:

sql = "select * from users where username = " + txtUser.Text;
Thanks,
Ronen

Nov 18 '05 #5

"RA" <ro****@hotmail.com> wrote in message
news:eF**************@TK2MSFTNGP12.phx.gbl...
How would a store procedure help if the parameter passed to it is the input from the text box?


In the stored procedure you don't build a sqlstring to execute, but supply a
parameter
as "placeholder" of the value:
select * from mytable where name = @nameparam

If you supply a value 'new;delete from users' then the table is searched
for that exact value. The "delete" part is never treated as a command.

Hans Kesting

Nov 18 '05 #6
They are also faster when executing against SQL as the code is already
compiled.

Double bonus!

"RA" <ro****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
If I get the user info from an aso.net, and based on that execute some query against the database, how can I avoid issues like this one:

Client entered in user name text box the following: "new;delect from users"
On server side I have:

sql = "select * from users where username = " + txtUser.Text;
Thanks,
Ronen

Nov 18 '05 #7
A Google search such as "sql code injection" will retrieve a number of
detailed papers.

In short you could :
- validate your parameters
- use parameterized queries
- use stored procedures
- others ?

Patrice

--

"RA" <ro****@hotmail.com> a écrit dans le message de
news:%2****************@TK2MSFTNGP09.phx.gbl...
If I get the user info from an aso.net, and based on that execute some query against the database, how can I avoid issues like this one:

Client entered in user name text box the following: "new;delect from users"
On server side I have:

sql = "select * from users where username = " + txtUser.Text;
Thanks,
Ronen


Nov 18 '05 #8
Hi,

One thing that using an SP doesn't necessarily guard against is:

What happens if an SP parameter is Text and you pass in a comma separated
list of numbers,
which you then use in the SP like:

[some sql here - to do a temp table]

EXEC('SELECT FieldX, FieldY INTO #Temp FROM TableX WHERE TableID IN(' +
@Param + ')')

[some more sql here]

Admittedly the person doing the hack would have to know what the SP was
doing in order to
ensure proper SQL syntax, but, for example, a disgruntled employee might
know this and wreck
havoc.

For a comma separated list of numbers I got around this by using a regular
expression to ensure
that the value I would use only contained numbers, a comma or a space
anything else would be
discarded.

Regards,
Peter
"Patrice Scribe" <no****@nowhere.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
A Google search such as "sql code injection" will retrieve a number of
detailed papers.

In short you could :
- validate your parameters
- use parameterized queries
- use stored procedures
- others ?

Patrice

--

"RA" <ro****@hotmail.com> a écrit dans le message de
news:%2****************@TK2MSFTNGP09.phx.gbl...
If I get the user info from an aso.net, and based on that execute some

query
against the database, how can I avoid issues like this one:

Client entered in user name text box the following: "new;delect from

users"

On server side I have:

sql = "select * from users where username = " + txtUser.Text;
Thanks,
Ronen

Nov 18 '05 #9

hi! goodmorning can you send me on how to avoid computer hacking?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #10
ASP.NET has special features to automaticly catch things like people
embedding ;DELETE FROM; and other trick SQL commands that would normally be
"hacked" on web sites
"girlie hinggo" <gi******@yahoo.com> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...

hi! goodmorning can you send me on how to avoid computer hacking?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #11
"girlie hinggo" <gi******@yahoo.com> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...
hi! goodmorning can you send me on how to avoid computer hacking?


Make sure your computer is secure... :-)

Seriously, can you be a bit more specific...?
Nov 18 '05 #12
Turn it off.

--
;-),
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"girlie hinggo" <gi******@yahoo.com> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...

hi! goodmorning can you send me on how to avoid computer hacking?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Phil Powell | last post by:
Where can I find an online PHP form validator script library to use? I have tried hacking the one here at work for weeks now and it's getting more and more impossible to customize, especially now...
4
by: Chuck Amadi | last post by:
Has anyone got a simple python script that will parse a linux mbox and create a large file to view . Cheers Chu
7
by: Rune Strand | last post by:
What would it take to create a Firefox extension that enables Python as a script language in the browser - just like Javascript? Is it at all possible? Are the hundred good reasons not to bother? ...
0
by: ChangAya | last post by:
I use binary log on mysql system. Yesterday i found some hacking attempt on my machine. ( I found some unknown queries on binary log) But i don't get any information about hacking query...
2
by: Frank Louden | last post by:
Hi. Infrequent hacker here. (Originally posted to alt.comp.lang.perl. Not much happening over there!) I've spent the last two days trying to hack H. Churchyard's makemenu.pl so it will work on...
0
by: masterjuan | last post by:
Networks Hacking (hack C:/ drives, severs...)and security holes all on my website & hacking commands and I explain ways of erasing your tracks so you dont get caught doing "bad" things... What do...
14
by: DavidNorep | last post by:
I do not know PHP, consider to write a CGI with this technology and have the following question. Is it possible to invoke a PHP script and let it endlessly wait for requests from a website (a...
8
by: michael | last post by:
Hi all A client of mine is having a problem with their site and when I looked into the SQL database, I found that most text fields have been altered and appended with script...
2
rahulephp
by: rahulephp | last post by:
Hi there, First of all i want to let you know that, my experience with this forum is really very good. I am new php programmer and i have intend knowledge of PHP & mysql. Before some days, i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.