Join us at IRC!
The important thing is not to stop questioning. - Albert Einstein
Friday, May 25, 2012
Navigation
Members Online
Total Online: 27
Web Spiders: 16
Guests Online: 25
Members Online: 2

Registered Members: 70208
Newest Member: andresuran
Latest Articles
View Thread

HellBound Hackers | Computer General | Increasing Security

Author

No point in addslashes etc

ranma
Member



Posts: 269
Location: Behind a sphere
Joined: 27.08.05
Rank:
HBH Guru
Posted on 15-07-09 21:53
If you use a scblockedript like this:


$user=md5($_POST['user']);
$pass=md5($_POST['pass']);
#sql="Select * from users where md5(user)='".$user."' and md5(pass)='".$pass." LIMIT 1';


It's pointless to use any other security measure maybe except overflow testing. Encoding the input into md5 prevents any malicious characters from sneaking in.

Am I right?


Wisdom spared is wisdom squared.

Edited by ranma on 15-07-09 22:25
Author

RE: No point in addslashes etc

ynori7
Future Emperor of Earth



Posts: 1481
Location: #valhalla
Joined: 08.10.07
Rank:
Diabolical
Posted on 15-07-09 21:56
Nevermind, I misread.






Edited by ynori7 on 15-07-09 21:58
ynori7 http://halls-of-valhalla.org
Author

RE: No point in addslashes etc

ranma
Member



Posts: 269
Location: Behind a sphere
Joined: 27.08.05
Rank:
HBH Guru
Posted on 15-07-09 22:02
I'm not sure what you wrote, but I encode into md5 before putting into query, so it should be fine.

Am I right?


Wisdom spared is wisdom squared.
Author

RE: No point in addslashes etc

ynori7
Future Emperor of Earth



Posts: 1481
Location: #valhalla
Joined: 08.10.07
Rank:
Diabolical
Posted on 15-07-09 22:12
Likely. Why don't you try it and see? That's the best way to find out.




ynori7 http://halls-of-valhalla.org
Author

RE: No point in addslashes etc

spyware
Member



Posts: 4190
Location: The Netherlands
Joined: 14.04.07
Rank:
God
Warn Level: 90
Posted on 15-07-09 22:15
Don't use md5, salted or not salted. Too many collisions.




"The chowner of property." - Zeph
“Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term.”
- Carl Sagan
“Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor?” - Ebert
http://bitsofspy.net
Author

RE: No point in addslashes etc

ranma
Member



Posts: 269
Location: Behind a sphere
Joined: 27.08.05
Rank:
HBH Guru
Posted on 15-07-09 22:17
ynori7 wrote:
Likely. Why don't you try it and see? That's the best way to find out.

That I will. However, I am not as experienced at sql injection as some other people on here.

Also, another question:

Since this method cannot be used for storing forum posts (you want them not-md5 hashed), could you simply use hex encoding to store posts in a db? Or would it increase the volume of the db too much (5 to 6 times as much)?


Wisdom spared is wisdom squared.

Edited by ranma on 15-07-09 22:24
Author

RE: No point in addslashes etc

ranma
Member



Posts: 269
Location: Behind a sphere
Joined: 27.08.05
Rank:
HBH Guru
Posted on 15-07-09 22:20
About collisions: You could check for collisions at time of user creation.

About seeing plaintext, I agree, let me mod the code a bit:


$sql="SELECT * from users where md5(user)='".$user."' and md5(pass)='".$pass."' LIMIT 1;";



Wisdom spared is wisdom squared.
Author

RE: No point in addslashes etc

ynori7
Future Emperor of Earth



Posts: 1481
Location: #valhalla
Joined: 08.10.07
Rank:
Diabolical
Posted on 15-07-09 22:22
ranma wrote:
Since this method cannot be used for storing forum posts (you want them not-md5 hashed), could you simply use hex encoding to store posts in a db?

Why? How is that easier than the alternative? You still have to sanitize the posts anyway since they get printed to the screen.




ynori7 http://halls-of-valhalla.org
Author

RE: No point in addslashes etc

ranma
Member



Posts: 269
Location: Behind a sphere
Joined: 27.08.05
Rank:
HBH Guru
Posted on 15-07-09 22:26
Ok, how about you do strip tags and then you do hex encode?


Wisdom spared is wisdom squared.
Author

RE: No point in addslashes etc

ranma
Member



Posts: 269
Location: Behind a sphere
Joined: 27.08.05
Rank:
HBH Guru
Posted on 15-07-09 22:27
MoshBat wrote:
ranma wrote:
That I will. However, I am not as experienced at sql injection as some other people on here.

Also, another question:

Since this method cannot be used for storing forum posts (you want them not-md5 hashed), could you simply use hex encoding to store posts in a db? Or would it increase the volume of the db too much (5 to 6 times as much)?


You're overcomplicating the most simple of things.

" or 1=1--
' or 1=1--

See, I can write those things, and the database it just fine.
I wonder how that's done...
Think!


I can do that easily, but some websites are immune to that but are vulnerable to others.

And my question stands. Could the md5 method be effectively used?


Wisdom spared is wisdom squared.
Author

RE: No point in addslashes etc

ynori7
Future Emperor of Earth



Posts: 1481
Location: #valhalla
Joined: 08.10.07
Rank:
Diabolical
Posted on 15-07-09 22:28
ranma wrote:
Ok, how about you do strip tags and then you do hex encode?

You're not thinking. Why would you waste the server's processor power to hex encode every post? What's the gain?




ynori7 http://halls-of-valhalla.org
Author

RE: No point in addslashes etc

ranma
Member



Posts: 269
Location: Behind a sphere
Joined: 27.08.05
Rank:
HBH Guru
Posted on 15-07-09 22:33
1)

You're not thinking. Why would you waste the server's processor power to hex encode every post? What's the gain?

That's why I was asking.

2) Convert all applicable characters to HTML entities - Applicable doesn't mean ALL. Plus, look at the comments underneath. Some characters are wrongly encoded.


Wisdom spared is wisdom squared.
Author

RE: No point in addslashes etc

S1L3NTKn1GhT
Member



Posts: 468
Location: XXXX
Joined: 03.06.06
Rank:
God
Warn Level: 10
Posted on 16-07-09 01:24
Sounds like overcomplicating a simple topic.


root@wtf.org#su - dumbass

Dude you're AWESOME!
-SystemMeltdown(MSN)
http://isexu.com
Author

RE: No point in addslashes etc

S1L3NTKn1GhT
Member



Posts: 468
Location: XXXX
Joined: 03.06.06
Rank:
God
Warn Level: 10
Posted on 16-07-09 02:30
MoshBat wrote:
S1L3NTKn1GhT wrote:
Sounds like overcomplicating a simple topic.

I've already said that.


stfu. If i say something that you said i sound smart. Now sshhhh.


root@wtf.org#su - dumbass

Dude you're AWESOME!
-SystemMeltdown(MSN)
http://isexu.com
Author

RE: No point in addslashes etc

SySTeM
-=[TheOutlaw]=-

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
The Overlord
Posted on 16-07-09 02:40
MoshBat wrote:
Okay. I'll just mock up some code for you...
$user = addslashes(mysql_real_escape_string($_POST['user']));
$pass = md5($_POST['pass']);
$qwerty = mysql_query("SELECT * FROM users WHERE user = '$user' AND pass = '$pass'");
//next bit.



No point using mysql_real_escape_string AND addslashes, use one or the other (preferably mysql_real_escape_string)




http://www.elites0ft.com/
Author

RE: No point in addslashes etc

spyware
Member



Posts: 4190
Location: The Netherlands
Joined: 14.04.07
Rank:
God
Warn Level: 90
Posted on 16-07-09 03:29
MoshBat wrote:
There are holes in both. I like to be safe.


-_-




"The chowner of property." - Zeph
“Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term.”
- Carl Sagan
“Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor?” - Ebert
http://bitsofspy.net
Author

RE: No point in addslashes etc

ranma
Member



Posts: 269
Location: Behind a sphere
Joined: 27.08.05
Rank:
HBH Guru
Posted on 17-07-09 16:56
That's why I just use md5. Is it way more resource-intensive?


Wisdom spared is wisdom squared.
Author

RE: No point in addslashes etc

pimpim
Member



Posts: 45
Location: Reading your /etc/shadow
Joined: 26.10.08
Rank:
HBH Guru
Posted on 17-07-09 17:33
ranma wrote:
That's why I just use md5. Is it way more resource-intensive?

Yes it is. The algoritm looks like this.
Just use mysql_real_escape_string() and you'll be fine. I don't see any reason not to use the standard function(s) created to prevent SQL-injections.


sa.backman@hotmail.com
Author

RE: No point in addslashes etc

S1L3NTKn1GhT
Member



Posts: 468
Location: XXXX
Joined: 03.06.06
Rank:
God
Warn Level: 10
Posted on 17-07-09 18:10
spyware wrote:
MoshBat wrote:
There are holes in both. I like to be safe.


-_-


personally that made me laugh. :p


root@wtf.org#su - dumbass

Dude you're AWESOME!
-SystemMeltdown(MSN)
http://isexu.com
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.