Home » Questions » Questions

Posts by demo

1
0 votes

My anservas demo user

  • demo answered 5 years ago
1
0 votes
0 answers
13k views
1
0 votes
9k views
The first time in the last
  • demo asked 5 years ago
  • last active 5 years ago
1
0 votes
16k views
This is paragraph list: 1 2 3 This is quote This is link
  • demo asked 5 years ago
  • last active 5 years ago
1
1 vote
97k views
What would you recommend using between a datetime and a timestamp field, and why? (using mysql). ...
  • Maria asked 17 years ago
  • last active 9 years ago
1
0 votes
In reply to: questao

minha resposta

  • demo answered 6 years ago
1
0 votes
In reply to: this is just for test

It’s only test

  • demo answered 5 years ago
1
0 votes
0 answers
7k views
 Дымосос Дымосос Дымосос Дымосос Дымосос Дымосос Дымосос Дымосос Дымосос Дымосос Дымосос Дымосос ...
  • demo asked 5 years ago
  • last active 5 years ago
1
0 votes
In reply to: this is just for test
  • demo answered 5 years ago
1
0 votes
12k views
gfyjhten t 4w5y 56y 6yh fyn nh
  • demo asked 5 years ago
  • last active 5 years ago
1
0 votes
In reply to: km look

He

  • demo answered 5 years ago
1
0 votes
In reply to: ADS test Q

yhuturtuytru

  • demo answered 6 years ago
1
0 votes
15k views
  • demo asked 5 years ago
  • last active 5 years ago
1
1 vote

As you can see, people suggest you to use prepared statements at the most. Its not wrong, but when your query is executed just once per process, there would be a slightly performance penalty. I was facing this issue but I think i solved it very very sophisticated way – the way hackers use to avoid using quotes. I use it to prevent all possible sql injection attacks.

My approach:

  • if you are expect input to be integer make sure its really integer. In variable-type language like is php is this very important. You can use for example very simple but powerful solution: sprintf("SELECT 1,2,3 FROM table WHERE 4 = %u", $input);
  • if you are except anything else from integer hex it. If you hex it, you will perfectly escape all input. In C/C++ there’s a function called mysql_hex_string(), in php use bin2hex(). Dont worry about that the escaped string will have 2x size of its original length because even if you use mysql_real_escape_string or bin2hex, php have to allocate same capacity ((2*input_length)+1). This hex method is often used when you transfer binary data but I see no reason why not use it to all data to prevent sql injection attacks. Note that you have to prepend 0x or use mysql function UNHEX.

So for example query:

SELECT password FROM users WHERE name = 'root'

Will become:

SELECT password FROM users WHERE name = 0x726f6f74

Perfect escape. No way to inject.

Note that this hex is often used as a sql injection attacks where integers are just like strings and escaped just with mysql_real_escape_string, then you can avoid of use of quotes. For example if you just do something like this:

"SELECT title FROM article WHERE id = " . mysql_real_escape_string($_GET["id"])

attack will very easy inject you. Consider the following injected code returned from your script:

SELECT ... WHERE id = -1 union all select table_name from information_schema.tables

SELECT ... WHERE id = -1 union all select table_name from information_schema.tables where table_name = 0x61727469636c65

But if would the coder of injectable site hex it, no injection would be possible:

SELECT ... WHERE id = 0x2d3120756e696f6e20616c6c2073656c656374207461626c655f6e616d652066726f6d20696e666f726d6174696f6e5f736368656d612e7461626c6573207768657265207461626c65203d2030783631373237343639363336633635

NOTE: This answer was originally posted at StackOverflow.com by Zaffy

1
0 votes

download free Bangla pdf ebooks at freebook.asia

  • demo answered 6 years ago
1
0 votes
1
0 votes

Here is my answer!

  • demo answered 6 years ago
1
0 votes
In reply to: Wow.. ahtead

Answer

  • demo answered 7 years ago
1
0 votes
0 answers
19k views
무엇이?
  • demo asked 6 years ago
1
0 votes
0 answers
9k views
utjjutyyti
  • demo asked 6 years ago
Showing 61 - 80 of 379 results