sql-injection

Is validating $_GET id in database match secure enough?

戏子无情 提交于 2019-12-06 02:44:33
I have 2 pages on the website, one is index.php and index page list all posts that exist in database, and other page is post.php and post page display single post when clicked on specific post on index page. Now the code that i used to list all posts on index.php is: $postslist = mysqli_query($db, "SELECT * FROM posts"); while ($post = mysqli_fetch_array($postlist)) { echo '<a href="' .SITEURL.'/post.php?p='.$post['postid'].'>'.$post['title'].'</a>'; } And this works and i have all posts displayed on my index.php page and links link to post on post.php page. And on post.php page i have used

Entity Framework, LinqToSQL and sql injection

浪子不回头ぞ 提交于 2019-12-06 02:18:04
问题 Is it possible for a project using entirely LinqToSQL or Entity Framewok to suffer from SQL Injection. I think that probably not because the SQL that the ORM generates should be sql-injection free. But I'm not sure. 回答1: When you use those frameworks as intended, i.e. the entities/tables directly, then no. All string comparisons (i.e. where name = 'smith' ) are parameterized. The only vulnerable spots are: any string can be executed directly against the context. dbContext.ExecuteQuery(); with

Can PHP's PDO be limited to a single query?

我怕爱的太早我们不能终老 提交于 2019-12-06 01:39:01
问题 PHP's PDO allows multiple querys to be executed at once, either via the query() method or as a prepared statement. Both of the following examples work: // Two SQL queries $query = "SELECT * FROM table; DROP table;" // Execute via query() $pdo->query($query); // Execute via prepared statement $stmt = $pdo->prepare($query); $stmt->execute(); Is there any way to limit PDO to a single query at a time, much like the mysql_query() function is? 回答1: This is a more up-to-date answer to this question.

How can i update a table using SQL Injection?

眉间皱痕 提交于 2019-12-06 01:34:13
How can i able to update a table in a MySQL database using SQL Injection ? I have heard about how we can enter the query in the address bar and it is possible to update a table in the MySQL database. But I am not sure about it. Kindly give me an idea professionals... Daniel Vassallo You may want to try entering Robert'); DROP TABLE students; -- in your form :) In the above xkcd cartoon , Bobby was probably asked to fill in his name in a form, but he mischievously inserted Robert'); DROP TABLE students; -- as his name. Now imagine if that input was used in this query: SELECT * FROM students

Real escape string vs bind param

▼魔方 西西 提交于 2019-12-05 22:48:47
In php, what is the difference and which is better and why, using mysqli. I have a whole project written with real escape string, is it necessary to convert to object oriented prepared statements? From the programmers point of view, the difference between escaping the values manually and parameterized/prepared statements as implemented by PDO is the degree of separation, automation, and a shift of responsibility. With *_escape_string the developer has to ensure that all values: are passed through the corresponding *_escape_string function and are placed within SQL string literals, as the *

Is this an example of an SQL Injection Attack?

橙三吉。 提交于 2019-12-05 20:25:37
问题 I developed a web site for a client where they will post images of their merchandise online. The url is www.domiainname.com/item-details.cfm?sku=125 . Someone tried browsing to www.domiainname.com/item-details.cfm?sku=125%20and%203=3 which produced and error in which I'm notified. I've also received error reports of: item-details.cfm?sku=1291+or+1=@@version-- item-details.cfm?sku=1291'+or+1=@@version item-details.cfm?sku=1291+or+1=@@version The last three examples are definitely of someone

ASP Classic - Recordset Object vs. Command Object

痞子三分冷 提交于 2019-12-05 17:09:56
I am using ASP Classic and SQL Server 2000 to create dynamic websites. I am a bit confused about when to use a recordset object and when to use a command object when querying the database. I was told that if the stored procedure would be returning records from a SELCT statement then I should use a recordset, however if I am up updating or inserting then I should use a command object and pass all data as parameters to the stored procedure. When using a recordset I often pass any required data like so: rs.Source = "spTest " & id I alway validate the data that I am passing to make sure it is what

How is this MySQL query vulnerable to SQL injection?

与世无争的帅哥 提交于 2019-12-05 16:58:45
In a comment on a previous question, someone said that the following sql statement opens me up to sql injection: select ss.*, se.name as engine, ss.last_run_at + interval ss.refresh_frequency day as next_run_at, se.logo_name from searches ss join search_engines se on ss.engine_id = se.id where ss.user_id='.$user_id.' group by ss.id order by ss.project_id, ss.domain, ss.keywords Assuming that the $userid variable is properly escaped, how does this make me vulnerable, and what can I do to fix it? Assuming it is properly escaped, it doesn't make you vulnerable. The thing is that escaping properly

Are sql injection attacks only a threat on a page that has a form?

Deadly 提交于 2019-12-05 16:56:56
问题 I know it's a simple question, but in everything I've read, I've never seen this spelled out specifically. If you do a query on a page, do you need to worry about SQL injection attacks? Or is it only a problem when you ask the user for input? Thanks! 回答1: You don't have to have user input to suffer a SQL injection attack. Let's say you have a product page that is called using a URL such as this: product.aspx?ID=123 And in your code you have a query constructed such as this: string sql =

Understanding input escaping in PHP

前提是你 提交于 2019-12-05 16:04:40
One thing that's always confused me is input escaping and whether or not you're protected from attacks like SQL injection. Say I have a form which sends data using HTTP POST to a PHP file. I type the following in an input field and submit the form: "Hello", said Jimmy O'Toole. If you print/echo the input on the PHP page that receives this POST data, it comes out as: \"Hello\", said Jimmy O\'Toole. This is the point where it gets confusing. If I put this input string into (My)SQL and execute it, it'll go into the database fine (since quotes are escaped), but would that stop SQL injection? If I