sql-injection

In ADO.NET, are there restrictions where SQL parameters can be used in the SQL query?

笑着哭i 提交于 2019-12-02 06:02:33
问题 This question is merely for educational purposes, as I'm not currently building any application that builds SQL queries with user input. That said, I know that in ADO.NET you can prevent SQL Injection by doing something like this: OleDbCommand command = new OleDbCommand("SELECT * FROM Table WHERE Account = @2", connection); command.Parameters.AddWithValue("@2", "ABC"); But assuming that your application is designed in such a way that the user can actually enter the name of the table, can you

PHP: While loop not working after adjusting SELECT for SQL injection prevention

拜拜、爱过 提交于 2019-12-02 05:16:31
I am trying to set up PHP queries for MySQL in a way to prevent SQL injection (standard website). I had a couple of INSERT queries where changing this worked well but on the following SELECT I keep getting an error since the update and it looks like the while loop doesn't work with the changes I made (it works well without using the statement as in the old code). Can someone tell me what I am doing wrong here ? New PHP: $stmt = $conn->prepare("SELECT ? FROM TranslationsMain WHERE location LIKE '%calendar weekday%' ORDER BY sortOrder, ?"); $stmt->bind_param('s', $selectedLang); $stmt->execute()

Should we always use prepared statements in MySQL and php or when to use these?

空扰寡人 提交于 2019-12-02 04:47:58
I read so many articles saying that using prepared statements is very secure and good to prevent SQL injections. I built a few websites without using prepared statements. But after read all those articles, I am thinking to change whole codes using prepared statements. My Question Is it necessary to use prepared statements always? or is there any scenario whereby normal statement will be sufficient over prepared statements? Non-prepared statements are sufficient if you have an SQL query that is entirely hard-coded, and needs no PHP variables in the SQL. Here's an example: $result = $mysqli-

How do PyMySQL prevent user from sql injection attack?

感情迁移 提交于 2019-12-02 04:43:33
Sorry for ask here but I cannot found much reference about pymysql's security guide about how do we prevent sql injection, When I do PHP develope I know use mysql preparedstatement(or called Parameterized Query or stmt),but I cannot found reference about this in pymysql simple code use pymysql like sqls="select id from tables where name=%s" attack="jason' and 1=1" cursor.execute(sqls,attack) How do I know this will prevent sql injection attack or not?if prevent succeed,how do pymysql prevent?Is cursor.execute already use preparedstatement by default? Python drivers do not use real query

bind_param() only necessary on user-inputted values or all?

我是研究僧i 提交于 2019-12-02 04:26:55
问题 I've been reading up on SQL injections and I couldn't find an answer to this question. I understand if I a query like this prepare("SELECT id, foo, bar FROM table WHERE username = ?"); Then I should use bind_param('s', $username) to avoid SQL injection possibilities. But what if I running my query on something that is not user-inputted but something like an auto-generated ID. Example: prepare("SELECT username, foo, bar from table where id = ?"); Where id is self-generated (auto-incremented

Does md5 stop SQL Injection

自古美人都是妖i 提交于 2019-12-02 04:09:23
Ok, So, i'm a little unsure on this. I have a url parameter username . and I have this statement SELECT * FROM users WHERE user_hash = md5($_GET['username']) Is this secure? Upon account creation an md5 hashed version of the username and the password are stored. I'm confused as this seems so simple, if md5 stops sql injection why isn't username and password always saved in hash form? Yes, this will avoid SQL injection, because md5() always returns a string of hex code. But it isn't a general solution to SQL-injection. You would have to encode almost all the data in your tables in MD5 format.

SQLite query restrictions

谁说我不能喝 提交于 2019-12-02 03:44:15
问题 I am building a little interface where I would like users to be able to write out their entire sql statement and then see the data that is returned. However, I don't want a user to be able to do anything funny ie delete from user_table; . Actually, the only thing I would like users to be able to do is to run select statements. I know there aren't specific users for SQLite, so I am thinking what I am going to have to do, is have a set of rules that reject certain queries. Maybe a regex string

MySQL injection query

北城以北 提交于 2019-12-02 03:12:59
问题 I'm familiar with prepared statements and I know that they are best practice when it comes to protecting against MySQL injection. But I'm wondering how this PHP/MySQL statement could be at risk of an injection attack: $result = mysqli_query($db,"SELECT name FROM users WHERE id = '".$_POST['name']."';"); It seems to me like the input from the user would be contained inside the single quotes. Can you execute more than one query in one mysqli_query statement? Also, is making the above safe just

No user interactivity Can I still get SQL Injection

白昼怎懂夜的黑 提交于 2019-12-02 02:47:54
I have pages that only display data from DB tables, the php pages only display the information they don't have any buttons, links, drop down menus, or forms. Im using the old mysql and not the mysqli or PDO for syntax Can I still get a SQl injection hack? In order for SQL Injection to work, they need a way to send SQL Code to your server, as there is no input, it is in theory impossible for them to Inject SQL. (Although I am not an expert in the subject) I would still recommend you to use a framework like mysqli or PDO, you should familiarize yourself with such frameworks as they became the

MySQL injection query

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 02:30:31
I'm familiar with prepared statements and I know that they are best practice when it comes to protecting against MySQL injection. But I'm wondering how this PHP/MySQL statement could be at risk of an injection attack: $result = mysqli_query($db,"SELECT name FROM users WHERE id = '".$_POST['name']."';"); It seems to me like the input from the user would be contained inside the single quotes. Can you execute more than one query in one mysqli_query statement? Also, is making the above safe just as easy as this... $result = mysqli_query($db,"SELECT name FROM users WHERE id = '".mysqli_real_escape