Jump to content

Shell security


Manixat
Go to solution Solved by boompa,

Recommended Posts

Hello, I'm concerned about the security of this code because I am not really familiar with shell and OS stuff. I needed to add this function because filter_var wasn't enough to filter bullshit emails out like john@crack.house. I need to verify domain existence and I grabbed a hold of this function from eHow, which is a pretty trustworthy site, but I need to be 100% sure before using it. Are there any possible issues with this function:

function checkDomainAvailability($domain) {
    if(preg_match('/[;\&\|\>\<]/', $domain)) exit; //Could be a hack attempt
    exec("whois " . escapeshellarg($domain), $output); //:CAREFUL:
    $result = implode("\n", $output);
    return (strpos($result, 'No match') !== false);
}

Thank you in advance!

 

EDIT: I just noticed that this won't  work on windows. Is there any cross-OS command I can use?

Edited by Manixat
Link to comment
Share on other sites

Really useful, thanks! Even though in the comments section it is said that this function can return various values which may evaluate to true even if the domain is nonexistent, I tried it myself and didn't experience this issue!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.