Is this hackable

Codex561
10 years ago | edited 10 years ago

0

Lets say a simple php code:

<?
if ($_POST[‘password"]==“Thisismypassword”){
//Grant access
} Else {
//Deny Access
}

Would a page like this be possible to hack in some way?

11replies
4voices
229views
Holographic
10 years ago | edited 10 years ago

1

well, first it should be $POST[“something”], otherwise it’s just an array.
second, you should put three signs of equal, ===, as that also checks the type. Otherwise, I can input 0, so $
POST[“something”]=0 and as a result of that, $_POST[“something”]==“Thisismypassword” evaluates to true.

edit: seriously, wtf is wrong with the spacing?

Codex561
10 years ago

0

@holographic Oh whoops, I forgot to add the [“x”] thingy.
And I do not really understand what you do with the second part of your post… seems like a major security threat. Can you tell me more?

@elhitch That would only work if you already know the password

Codex561
10 years ago

0

It only seems to affect when it gets hashed.

Elhitch
10 years ago

0

@Codex561 If the PHP code is written within the HTML, it’s totally hackable. Also it’s not completely impossible to try and guess the password, especially if the admin uses the same password for multiple services and one of them gets infiltrated by the attacker.

Keeper
10 years ago | edited 10 years ago

0

[quote=Holographic]
Otherwise, I can input 0, so $POST[“something”]=0 and as a result of that, $POST[“something”]==“Thisismypassword” evaluates to true.
[/quote]

Pardon?

if($_POST[?'input'?] == 'Something'){  
    echo 'True';  
} else {  
    echo 'False';  
}  

Are you saying that if I send 0 as a value, it would echo ‘True’ or have I misunderstood you?

[quote=Elhitch]
If the PHP code is written within the HTML, it’s totally hackable
[/quote]

And if it’s not? What’s the difference, I’d really like to know. You don’t only refer to form submissions right? Are you trying to say PHP code is not vulnerable when it’s not combined with HTML?

Elhitch
10 years ago

0

@Keeper Totally not. What I mean is that if it’s integrated within the HTML document itself, it’ll be plainly visible and open to exploits limited only by the imagination of the attacker. Yes, it’s possible to get the PHP file in other ways if it’s in a separate file, but that’s something only a determined person would do, which makes it… Less ‘hackable’.

Keeper
10 years ago

0

Okay, that being said I agree with you.

Holographic
10 years ago | edited 10 years ago

0

@Keeper yes I was wrong in my message.

I confused it with the PHP declared variables.
If I have
$a='asdf'; if($a==0) //or directly if('asdf'==0) echo "true"; else echo "false";

It will echo true, but it doesn’t work if I send a post request with a param equal to 0

Codex561
10 years ago

0

@Keeper a bit off topic but did you get all of the grammar right in your signature or is it just me? Cause I read it twice and still get lost after the 3rd phrase.

You must be logged in to reply to this discussion. Login
1 of 12

This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.

By using our site, you acknowledge that you have read and understand our Privacy Policy, and Terms of Service.

Dismiss