Home » Questions » Questions

Posts by demo

1
0 votes
In reply to: this is just for test
  • demo answered 4 years ago
1
0 votes
9k views
gfyjhten t 4w5y 56y 6yh fyn nh
  • demo asked 4 years ago
  • last active 4 years ago
1
0 votes
In reply to: km look

He

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

yhuturtuytru

  • demo answered 5 years ago
1
0 votes
12k views
  • demo asked 4 years ago
  • last active 4 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 5 years ago
1
0 votes
1
0 votes

Here is my answer!

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

Answer

  • demo answered 6 years ago
1
0 votes
0 answers
15k views
무엇이?
  • demo asked 5 years ago
1
0 votes
0 answers
8k views
utjjutyyti
  • demo asked 5 years ago
1
0 votes

Where can I add images?

  • demo answered 10 years ago
1
0 votes
0 answers
15k views
Test Test 1 2 3?
  • demo asked 10 years ago
1
0 votes

lol cat

 

  • demo answered 5 years ago
1
0 votes
0 answers
13k views
RISMA SOFA bengkel reparasi kursi sofa terpercaya di bekasi.Hubungi kami di : HP 0857-1621-9119 ...
  • risma sofa asked 8 years ago
1
0 votes
0 answers
14k views
He had foretold to die young. Either an overdose, suicide. He was known to have a severe mood swi...
  • demo asked 7 years ago
1
0 votes
In reply to: What is Sabai Discuss?

Sabai Discuss is a premium questions and answers plugin for WordPress. The plugin features the ability for users to ask and answer questions similar to Stack Overflow or Yahoo Answers.

Sabai Discuss is an ideal tool not only for building a community driven question-and-answer website but also for building a discussion forum, a knowledge base, or even a helpdesk portal for WordPress.

  • demo answered 5 years ago
1
0 votes
7k views
چرا برای فارسی سازی ورد پرس
  • demo asked 5 years ago
  • last active 5 years ago
1
0 votes
0 answers
11k views
Does this script prevent duplicate questions and answers?
  • demo asked 6 years ago
Showing 61 - 80 of 371 results