Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Awilum on October 11, 2010, 10:52:48 AM

Title: Hacking attempt...
Post by: Awilum on October 11, 2010, 10:52:48 AM
I have message Hacking attempt... on this query:

$db_result = $smcFunc['db_query']('',"SELECT DISTINCT *,(select GROUP_CONCAT(`tag_name`) as `tag_name` from {db_prefix}snippets_tags where {db_prefix}snippets_tags.snippet_id = {db_prefix}snippets.id) as tag_name
FROM {db_prefix}snippets
LEFT JOIN {db_prefix}snippets_syntax ON {db_prefix}snippets.syntax_id={db_prefix}snippets_syntax.id");


why?
Title: Re: Hacking attempt...
Post by: Awilum on October 11, 2010, 11:08:48 AM
and why if i do  print_r($context['all_snippets']);

i dont see only data  and query to


Array (
Title: Re: Hacking attempt...
Post by: Awilum on October 11, 2010, 11:58:52 AM
smf is strange
I just wrote

$result = mysql_query("SELECT *, GROUP_CONCAT(t.tag_name SEPARATOR ',') FROM smf_snippets AS p LEFT JOIN smf_snippets_tags as t ON p.id = t.snippet_id GROUP BY 1");
   if (!$result) {die('Invalid query: ' . mysql_error()); }
   while ($row = mysql_fetch_assoc($result)) {
         $f = $row;
   }         
   
print_r($f);

and I have

Array ( [id] => [subject] => Calculate Distance [syntax_id] => 1 [author_id] => 1 [content] => $context['articles_cat'] = array(); while ($row = $smcFunc['db_fetch_assoc']($db_result)) { $context['all_snippets'][] = $row; }    $smcFunc['db_free_result']($dbresult);    [date] => 1286806008 [tag_name] => [snippet_id] => [GROUP_CONCAT(t.tag_name SEPARATOR ',')] => )

******.... what is that ? why ?   


Array ( [id] => [subject] => Calculate Distance [syntax_id] => 1 [author_id] => 1 [content] => $context['articles_cat'] = array(); while ($row = $smcFunc['db_fetch_assoc']($db_result)) { $context['all_snippets'][] = $row; }    $smcFunc['db_free_result']($dbresult);    [date] => 1286806008 [tag_name] => [snippet_id] => [GROUP_CONCAT(t.tag_name SEPARATOR ',')] => )
Title: Re: Hacking attempt...
Post by: KensonPlays on October 11, 2010, 12:30:22 PM
Please do not triple post. Edit previous posts.

"Hacking Attempt..." might be file permission errors, syntax errors, or someone IS trying to hack your site.

also, What SMF version?
Title: Re: Hacking attempt...
Post by: vbgamer45 on October 11, 2010, 12:31:38 PM
SMF does not allow sub queries by default unless you disable query check security.
Example add this line before you call your query

$modSettings['disableQueryCheck'] = 1;


Title: Re: Hacking attempt...
Post by: Yung Roger on October 11, 2010, 12:34:23 PM
What i have found sub queries are not allowed..
I have tried but the error is same..
Are they allowed..??
Title: Re: Hacking attempt...
Post by: Awilum on October 11, 2010, 12:40:58 PM
>also, What SMF version?

SMF 2.0 RC3
Title: Re: Hacking attempt...
Post by: vbgamer45 on October 11, 2010, 12:42:25 PM
I posted two posts how to get around query restrictions. SMF restricts certain mysql functions that are not used in SMF's code base to help prevent sql injection.