sql-injection

Wordpress Database Output - Remove SQL Injection Escapes

不羁岁月 提交于 2019-12-04 13:56:47
I'm having a problem using $wbdb. When I insert or update data using $wpdb->insert or $wpdb->update, the SQL injection protection actually inserts the \' into the database, and when outputting that information it has the SQL escape with it. (ie: My Value\'s Escaped). I know there's gotta be a way to escape this using a wordpress function, but I haven't been able to find it searching google and the wordpress codex. ...So what's that function, or what am I doing wrong (seems like the '\' shouldn't really get to the database in the first place) Thanks! jason It looks as if magic_quotes are

Best Way to Prevent SQL Injection Using Javascript or C#?

馋奶兔 提交于 2019-12-04 13:49:20
I'm currently writing an application which uses ajax on the front end and ASP.NET (C#) on the back end.. A Small Part of the application does an AJAX call to the backend code (to get entries from the SQL database) How can i prevent SQL of JScript injection? I know it is generally unsecure to validate with javascript because javascript can be turned off but as this is an AJAX call so if the user has javascript turned off the AJAX will never run. Whats the best way of validating or escaping the input? Like Add_Slashes() in PHP? Thanks Daniel Use parametrized queries, never build SQL code strings

How to prevent Sql-Injection on User-Generated Sql Queries

做~自己de王妃 提交于 2019-12-04 13:17:50
问题 I have a project (private, ASP.net website, password protected with https) where one of the requirements is that the user be able to enter Sql queries that will directly query the database. I need to be able to allow these queries, while preventing them from doing damage to the database itself, and from accessing or updating data that they shouldn't be able to access/update. I have come up with the following rules for implementation: Use a db user that only has permission for Select Table

Is this Sql-injection-proof Asp.net code?

谁说我不能喝 提交于 2019-12-04 12:13:34
Problem: I have a form with text values, and a function that must return a string query based on the values of the text values too. Solution: I created a SQLCommand query with parameters, then I put the SQLCommand.CommandText to a string and I returned it (to the business logic that is going to handle the query) Main Question: Is it sql-injection proof? Code Example: sQuery = "select * from xy where x like '%@txtNameParameter%'"; SqlCommand cmd = new SqlCommand(sQuery); cmd.Parameters.Add("@txtNameParameter", SqlDbType.VarChar); cmd.Parameters["@txtNameParameter"].Value = txtName.Text; string

Does using the WordPress get_results() database function prevent sql injection

妖精的绣舞 提交于 2019-12-04 10:42:02
Couldn't seem to find a answer but wondering if the following query to the database is vulnerable to sql injection. $searchPostResults = $wpdb->get_results($querySearchVals, OBJECT); This is the query which is used: global $wpdb; $offset = (isset($_POST["moreSearchResults"])) ? $_POST["searchOffset"] : 0; $querySearchVals = " SELECT DISTINCT post_title, ID FROM {$wpdb->prefix}posts WHERE ("; $sVals = array(); $sVals = explode(" ", $searchVal); $lastIndex = intval(count($sVals)) - 1; $orderByCaseVals = ""; for($i = 0; $i<count($sVals);$i++) { $querySearchVals .= " post_title LIKE '%$sVals[$i]%'

How can I get a username and password from my database in C#?

谁说我不能喝 提交于 2019-12-04 10:41:15
I have the following code in my btn_click event: Sqlconnection con = new Sqlconnection("server=.;database=bss;user id=ab;pwd=ab"); con.open(); SqlCommand cmd = new Sqlcommand("select * from login where username='" + txt4name.Text + "' and pwd='" + txt4pwd.Text + "'", con); SqlDataReader reader = cmd.execute Reader(); Where login is the table and username and pwd are its fields. After this code all the values are stored in the reader object. I want to store username and pwd in the separate variables. How can I accomplish this? In general, when accessing your DB, you should be using something

how does codeigniter sanitize inputs?

橙三吉。 提交于 2019-12-04 09:17:33
问题 I'm building a Codeigniter application and I'm trying my hardest to prevent SQL injections. I'm using the Active Record method to construct all my queries. I know Active Record automatically sanitizes the input, but I'm wondering exactly to what extent? Does it simply escape all the quotes, or does it do more? What about preventing obfuscated SQL injections, or other more advanced kinds? Basically, I'm looking for an in-depth explanation of how CI sanitizes data. Anyone know? 回答1: Exactly

Is hexing input sufficient to sanitize SQL Queries?

痴心易碎 提交于 2019-12-04 08:35:01
I was reading last night on preventing SQL injections, and I ran across this answer: How can I prevent SQL injection in PHP? The comments from 'Your Common Sense' made it sound like that was dysfunctional/unsafe. However, in my (albeit limited) testing, I found that php's "bin2hex($var)" worked with anything I threw at it - literal number, number string, string of text - even when matching a numerical (tinyint) column. My question is this: Is there a way to inject SQL when every user input is sanitized via hexing it? In essence, any time a query was made, it would look something like this:

Preventing SQL injection on insert

安稳与你 提交于 2019-12-04 07:32:53
问题 I am looking for some tips to prevent SQL injection. I was told on a forum my code is not safe and am looking for someone nice enough to help me fix that. I have a webform and on submit it goes to the aspx.cs page and inserts the data into a ms sql database. protected void Submit_Click(object sender, EventArgs e) { string FullStartTime = StartTimeHourList.SelectedValue + ":" + StartTimeMinuteList.SelectedValue + " " + StartTimeAMList.SelectedValue; string FullEndTime = EndTimeHourList

Entity Framework, LinqToSQL and sql injection

人盡茶涼 提交于 2019-12-04 07:07:49
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. 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 any kind of destructive string. a stored procedure executing dynamic SQL using any parameters given "It