News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

SMF get attacked or hacked by SQL

Started by sombra, August 26, 2009, 12:42:26 PM

Previous topic - Next topic

sombra

Hello,
my SMF get attacked i get around 200 SQL process like this one:

147694 todoile_ localhost todoile_ Query 77 Sending data SELECT\n\t\t\t\t\tid,\n\t\t\t\t\tuserID,\n\t\t\t\t\tuserName,\n\t\t\t\t\tuserRole,\n\t\t\t\t\tchannel AS channelID,\n\t\t\t\t\tUNIX_TIME

every 10/15 second, for around 20 minute then the servers load goes to skyrocket, this got solved itself but same thing happen like every hour.

Norv

Please post your webserver access log and error log, if possible.

Also, note that if you think it is a security issue in SMF, it may be better to fill a security report at Security. In case you do, attach your logs there, rather. Thank you!
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github



sombra

founded them already ;D

will they reply back to me how do i know if theres a fix or if this problem is comiing from smf or the server?

sombra

sorry for the bump now i got an

This Account Has Been Suspended.

cuz they think the problem its smf how much time i need to wait to see if there any solution

Norv

I don't know the answer to that, sorry.
Do you have only SMF installed?
Do you still have FTP access and database access, so you can eventually send SMF files/database for us to check? It may help also.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

sombra

yes i have but i did the report you guys told me and send the errors and acses logs but  how do i know they got it and if theres any problem or solution?
the host tried again to bring up my page and it made the server went ofline so they suspended my account

i have wordpress on the same account but its online and working fine the problem in the logs says its the database of smf

like you can see i dont know what to do :(


Norv

I can try to take a look at your SMF files and database, as well. In case you agree, let me know, I will PM you a FTP account to use and get back to you as soon as possible.

EDIT: However, you can try in any case to completely reinstall SMF. Make first a full backup of files and database.
Then, delete all your SMF files in ./Themes, ./Sources, even ./Packages, and ./Smileys, also delete files like index.php, SSI.php, SSI_examples.php from your SMF directory (actually almost all). Don't delete directly the ./attachments and ./avatars directories, because you may lose all your attachments.
Only try to check them, see if there's anything that looks out of place.
Don't delete Settings.php and Settings.bak.php, you'll need them, rather... though you should look at them in a text editor, see if they only contain a few settings, nothing too long, nothing hidden.
If you have folders like media gallery, keep them... but rather, keep a backup for now, and remove it from the live server.
Delete the rest.
Then upload the files from a fresh installation package for SMF, same version, except install.php.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

sombra

ok thanks for the help

the problem from a clean install is that i worked in this forum for like 6 months i dont know nothing about php and programing everithing i did was reading and asking for help for 6 months i dont want to loose all that the modifications i did


sombra

page crash after the index.php is put to work well the entire server crash wen the forum is enable will this be a smf vulnerability or just an error

i have a blog on the same host same account and its working great

but the forum crashes the server any ideas i just sended a report today to see if i have some luck

sombra

this is my index.php

<?php
/**********************************************************************************
* index.php                                                                       *
***********************************************************************************
* SMF: Simple Machines Forum                                                      *
* Open-Source Project Inspired by Zef Hemel ([email protected])                    *
* =============================================================================== *
* Software Version:           SMF 2.0 RC1-1                                       *
* Software by:                Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006-2009 by:     Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
* Support, News, Updates at:  http://www.simplemachines.org                       *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version can always be found at http://www.simplemachines.org.        *
**********************************************************************************/


/* This, as you have probably guessed, is the crux on which SMF functions.
Everything should start here, so all the setup and security is done
properly.  The most interesting part of this file is the action array in
the smf_main() function.  It is formatted as so:

'action-in-url' => array('Source-File.php', 'FunctionToCall'),

Then, you can access the FunctionToCall() function from Source-File.php
with the URL index.php?action=action-in-url.  Relatively simple, no?
*/

$forum_version 'SMF 2.0 RC1-1';

// Get everything started up...
define('SMF'1);
if (
function_exists('set_magic_quotes_runtime'))
@set_magic_quotes_runtime(0);
error_reporting(defined('E_STRICT') ? E_ALL E_STRICT E_ALL);
$time_start microtime();

// Do some cleaning, just in case.
foreach (array('db_character_set''cachedir') as $variable)
if (isset($GLOBALS[$variable]))
unset($GLOBALS[$variable]);

// Load the settings...
require_once(dirname(__FILE__) . '/Settings.php');

// Make absolutely sure the cache directory is defined.
if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir '/cache'))
$cachedir $boarddir '/cache';

// And important includes.
require_once($sourcedir '/QueryString.php');
require_once(
$sourcedir '/Subs.php');
require_once(
$sourcedir '/Errors.php');
require_once(
$sourcedir '/Load.php');
require_once(
$sourcedir '/Security.php');
require_once(
$sourcedir '/SPortal2.php');
if (
file_exists($sourcedir '/LoadAds.php'))
require_once($sourcedir '/LoadAds.php');
// Hack's Park Shoutbox -->
require_once($sourcedir '/Subs-Shoutbox.php');
// <-- Hack's Park Shoutbox

// Using an pre-PHP5 version?
if (@version_compare(PHP_VERSION'5') == -1)
require_once($sourcedir '/Subs-Compat.php');

// If $maintenance is set specifically to 2, then we're upgrading or something.
if (!empty($maintenance) && $maintenance == 2)
db_fatal_error();

// Create a variable to store some SMF specific functions in.
$smcFunc = array();

// Initate the database connection and define some database functions to use.
loadDatabase();

// Load the settings from the settings table, and perform operations like optimizing.
reloadSettings();
// Unserialize the array of pretty board URLs
$context = array('pretty' => array(
'action_array' => unserialize($modSettings['pretty_action_array']),
'board_urls' => unserialize($modSettings['pretty_board_urls']),
'db_count' => 0,
));
// Clean the request variables, add slashes, etc.
cleanRequest();

// Seed the random generator.
if (empty($modSettings['rand_seed']) || mt_rand(1250) == 69)
smf_seed_generator();

// Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out!
if (isset($_GET['scheduled']))
{
require_once($sourcedir '/ScheduledTasks.php');
AutoTask();
}

// Check if compressed output is enabled, supported, and not already being done.
if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0)
{
// If zlib is being used, turn off output compression.
if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler' || @version_compare(PHP_VERSION'4.2.0') == -1)
$modSettings['enableCompressedOutput'] = '0';
else
ob_start('ob_gzhandler');
}
// This makes it so headers can be sent!
if (empty($modSettings['enableCompressedOutput']))
ob_start();

// Register an error handler.
set_error_handler('error_handler');

// Start the session. (assuming it hasn't already been.)
loadSession();

// Determine if this is using WAP, WAP2, or imode.  Technically, we should check that wap comes before application/xhtml or text/html, but this doesn't work in practice as much as it should.
if (isset($_REQUEST['nowap']))
$_SESSION['nowap'] = true;
elseif (!isset(
$_SESSION['nowap']))
{
if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/vnd.wap.xhtml+xml') !== false)
$_REQUEST['wap2'] = 1;
elseif (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'text/vnd.wap.wml') !== false)
{
if (strpos($_SERVER['HTTP_USER_AGENT'], 'DoCoMo/') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'portalmmm/') !== false)
$_REQUEST['imode'] = 1;
else
$_REQUEST['wap'] = 1;
}
}

if (!
defined('WIRELESS'))
define('WIRELESS', isset($_REQUEST['wap']) || isset($_REQUEST['wap2']) || isset($_REQUEST['imode']));

// Some settings and headers are different for wireless protocols.
if (WIRELESS)
{
define('WIRELESS_PROTOCOL', isset($_REQUEST['wap']) ? 'wap' : (isset($_REQUEST['wap2']) ? 'wap2' : (isset($_REQUEST['imode']) ? 'imode' '')));

// Some cellphones can't handle output compression...
$modSettings['enableCompressedOutput'] = '0';
// !!! Do we want these hard coded?
$modSettings['defaultMaxMessages'] = 5;
$modSettings['defaultMaxTopics'] = 9;

// Wireless protocol header.
if (WIRELESS_PROTOCOL == 'wap')
header('Content-Type: text/vnd.wap.wml');
}

// What function shall we execute? (done like this for memory's sake.)
// Hack's Park Shoutbox -->
call_user_func(Shoutbox_Load(smf_main()));
// <-- Hack's Park Shoutbox

// Call obExit specially; we're coming from the main area ;).
obExit(nullnulltrue);

// The main controlling function.
function smf_main()
{
global $modSettings$settings$user_info$board$topic$board_info$maintenance$sourcedir;

// Special case: session keep-alive, output a transparent pixel.
if (isset($_GET['action']) && $_GET['action'] == 'keepalive')
{
header('Content-Type: image/gif');
die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B");
}

// Load the user's cookie (or set as guest) and load their settings.
loadUserSettings();

// Load the current board's information.
loadBoard();

// Load the current user's permissions.
loadPermissions();

// Favicon Edits
global $context;
if (!empty($settings['header_favicon_url']))
{
if(preg_match('~http://(?:.*?)\.(png|ico|gif)(?:\?(?:.*?)|)~i'$settings['header_favicon_url'], $type))
{
// Append to html headers
$context['html_headers'] .= '
<link rel="'
. (!empty($context['browser']['is_ie']) ? 'shortcut icon' 'icon' ) .'" href="'$settings['header_favicon_url'] . '" type="'. (($type[1] == 'ico') ? 'image/vnd.microsoft.icon' 'image/'.$type[1] ) .'" />';
unset($type);
}

}

// Load all the ads up
if (function_exists("loadAds"))
loadAds();

// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
loadTheme();

// Check if the user should be disallowed access.
is_not_banned();

// If we are in a topic and don't have permission to approve it then duck out now.
if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest']))
fatal_lang_error('not_a_topic'false);

// Do some logging, unless this is an attachment, avatar, theme option or XML feed.
if (empty($_REQUEST['action']) || !in_array($_REQUEST['action'], array('dlattach''jsoption''.xml''xmlhttp''verificationcode')))
{
// Log this user as online.
writeLog();

// Track forum statistics and hits...?
if (!empty($modSettings['hitStats']) && $_REQUEST['action'] != 'shoutbox')
trackStats(array('hits' => '+'));
}

// Load SimplePortal.
sportal_init();

// Is the forum in maintenance mode? (doesn't apply to administrators.)
if (!empty($maintenance) && !allowedTo('admin_forum'))
{
// You can only login.... otherwise, you're getting the "maintenance mode" display.
if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'login2' || $_REQUEST['action'] == 'logout'))
{
require_once($sourcedir '/LogInOut.php');
return $_REQUEST['action'] == 'login2' 'Login2' 'Logout';
}
// Don't even try it, sonny.
else
{
require_once($sourcedir '/Subs-Auth.php');
return 'InMaintenance';
}
}
// If guest access is off, a guest can only do one of the very few following actions.
elseif (empty($modSettings['allow_guestAccess']) && !(!empty($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && !empty($_REQUEST['type']) && $_REQUEST['type'] == 'avatar') && !(empty($_REQUEST['action']) && empty($board) && empty($topic) && $modSettings['sp_portal_mode'] == 1) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa''login''login2''register''register2''reminder''activate''help''smstats''mailq''verificationcode''openidreturn',))))
{
require_once($sourcedir '/Subs-Auth.php');
return 'KickGuest';
}
elseif (empty($_REQUEST['action']))
{
// Action and board are both empty... SPortal!
if (empty($board) && empty($topic) && $modSettings['sp_portal_mode'] == 1)
{
require_once($sourcedir '/SPortal2.php');
return 'SPortal';
}
// Action and board are still both empty but no portal... BoardIndex
elseif (empty($board) && empty($topic))
{
require_once($sourcedir '/BoardIndex.php');
return 'BoardIndex';
}
// Topic is empty, and action is empty.... MessageIndex!
elseif (empty($topic))
{
require_once($sourcedir '/MessageIndex.php');
return 'MessageIndex';
}
// Board is not empty... topic is not empty... action is empty.. Display!
else
{
require_once($sourcedir '/Display.php');
return 'Display';
}
}

// Here's the monstrous $_REQUEST['action'] array - $_REQUEST['action'] => array($file, $function).
$actionArray = array(
'activate' => array('Register.php''Activate'),
'admin' => array('Admin.php''AdminMain'),
'ads' => array('Ads.php''Ads'),
'announce' => array('Post.php''AnnounceTopic'),
'announcements' => array('Announcements.php''AnnouncementsMain'),

'attachapprove' => array('ManageAttachments.php''ApproveAttach'),
'buddy' => array('Subs-Members.php''BuddyListToggle'),
'calendar' => array('Calendar.php''CalendarMain'),
'clock' => array('Calendar.php''clock'),
'collapse' => array('BoardIndex.php''CollapseCategory'),
'coppa' => array('Register.php''CoppaForm'),
'credits' => array('Who.php''Credits'),
'deletemsg' => array('RemoveTopic.php''DeleteMessage'),
'display' => array('Display.php''Display'),
'dlattach' => array('Display.php''Download'),
'editpoll' => array('Poll.php''EditPoll'),
'editpoll2' => array('Poll.php''EditPoll2'),
'emailuser' => array('SendTopic.php''EmailUser'),
'findmember' => array('Subs-Auth.php''JSMembers'),
'forum' => array('BoardIndex.php''BoardIndex'),
'groups' => array('Groups.php''Groups'),
'help' => array('Help.php''ShowHelp'), 'globalhf' => array('globalhf.php''globalhf'),
'helpadmin' => array('Help.php''ShowAdminHelp'),
'im' => array('PersonalMessage.php''MessageMain'),
'jseditor' => array('Subs-Editor.php''EditorMain'),
'jsmodify' => array('Post.php''JavaScriptModify'),
'jsoption' => array('Themes.php''SetJavaScript'),
'lock' => array('LockTopic.php''LockTopic'),
'lockvoting' => array('Poll.php''LockVoting'),
'login' => array('LogInOut.php''Login'),
'login2' => array('LogInOut.php''Login2'),
'logout' => array('LogInOut.php''Logout'),
'markasread' => array('Subs-Boards.php''MarkRead'),
'mascot' => array('Who.php''Mascot'),
'mergetopics' => array('SplitTopics.php''MergeTopics'),
'mlist' => array('Memberlist.php''Memberlist'),
'moderate' => array('ModerationCenter.php''ModerationMain'),
'modifycat' => array('ManageBoards.php''ModifyCat'),
'modifykarma' => array('Karma.php''ModifyKarma'),
'movetopic' => array('MoveTopic.php''MoveTopic'),
'movetopic2' => array('MoveTopic.php''MoveTopic2'),
'notify' => array('Notify.php''Notify'),
'notifyboard' => array('Notify.php''BoardNotify'),
'openidreturn' => array('Subs-OpenID.php''smf_openID_return'),'paypal' => array('Paypal.php''Paypal'),
'pm' => array('PersonalMessage.php''MessageMain'),
'post' => array('Post.php''Post'),
'post2' => array('Post.php''Post2'),
'printpage' => array('Printpage.php''PrintTopic'),
'profile' => array('Profile.php''ModifyProfile'),
'quotefast' => array('Post.php''QuoteFast'),
'quickmod' => array('MessageIndex.php''QuickModeration'),
'quickmod2' => array('Display.php''QuickInTopicModeration'),
'recent' => array('Recent.php''RecentPosts'),
'register' => array('Register.php''Register'),
'register2' => array('Register.php''Register2'), 'related' => array('Subs-Related.php''Related'),
'reminder' => array('Reminder.php''RemindMe'),
'removepoll' => array('Poll.php''RemovePoll'),
'removetopic2' => array('RemoveTopic.php''RemoveTopic2'),
'reporttm' => array('SendTopic.php''ReportToModerator'),
'requestmembers' => array('Subs-Auth.php''RequestMembers'),
'restoretopic' => array('RemoveTopic.php''RestoreTopic'),
'rules' => array('Rules.php''Rules'),
'search' => array('Search.php''PlushSearch1'),
'search2' => array('Search.php''PlushSearch2'),
'sendtopic' => array('SendTopic.php''EmailUser'),
// Hack's Park Shoutbox -->
'shoutbox' => array('Shoutbox.php''Shoutbox'),
// <-- Hack's Park Shoutbox
'sitemap' => array('Sitemap.php''ShowSiteMap'),
'smstats' => array('Stats.php''SMStats'),
'suggest' => array('Subs-Editor.php''AutoSuggestHandler'),
'spellcheck' => array('Subs-Post.php''SpellCheck'),
'splittopics' => array('SplitTopics.php''SplitTopics'),
'stats' => array('Stats.php''DisplayStats'),
'sticky' => array('LockTopic.php''Sticky'),
'thankyou' => array('ThankYouPost.php''ThankYou'),
'thankyouajax' => array('ThankYouPost.php''ThankYouPostAJAX'),
'thankyoupostlock' => array('ThankYouPost.php''ThankYouPostLock'),
'thankyoupostlist' => array('ThankYouPost.php''ThankYouPostListShow'),
'thankyoupostdelete' => array('ThankYouPost.php''ThankYouPostDelete'),
'thankyoupostdm' => array('ThankYouPost.php''ThankYouPostDeletePost'),
'thankyoupostcloseall' => array('ThankYouPost.php''ThankYouPostCloseAll'),
'thankyoupostunlockall' => array('ThankYouPost.php''ThankYouPostUnlockAllPosts'),
'theme' => array('Themes.php''ThemesMain'),
'topicsolved' => array('Subs-TopicSolved.php''TopicSolved'),
'trackip' => array('Profile-View.php''trackIP'),
'about:mozilla' => array('Karma.php''BookOfUnknown'),
'about:unknown' => array('Karma.php''BookOfUnknown'),
'unread' => array('Recent.php''UnreadTopics'),
'unreadreplies' => array('Recent.php''UnreadTopics'),
'verificationcode' => array('Register.php''VerificationCode'),
'viewprofile' => array('Profile.php''ModifyProfile'),
'vote' => array('Poll.php''Vote'),
'viewquery' => array('ViewQuery.php''ViewQuery'),
'viewsmfile' => array('Admin.php''DisplayAdminFile'),
'who' => array('Who.php''Who'),
'.xml' => array('News.php''ShowXmlFeed'),
'xmlhttp' => array('Xml.php''XMLhttpMain'),
);

// Get the function and file to include - if it's not there, do the board index.
if (!isset($_REQUEST['action']) || !isset($actionArray[$_REQUEST['action']]))
{
// Catch the action with the theme?
if (!empty($settings['catch_action']))
{
require_once($sourcedir '/Themes.php');
return 'WrapAction';
}

// Fall through to the board index then...
require_once($sourcedir '/BoardIndex.php');
return 'BoardIndex';
}

// Otherwise, it was set - so let's go to that action.
require_once($sourcedir '/' $actionArray[$_REQUEST['action']][0]);
return $actionArray[$_REQUEST['action']][1];
}

?>


karlbenson

The query you identified is not one from core smf.

It is related to AjaxChat Integration mod
http://custom.simplemachines.org/mods/index.php?mod=1319

I don't see anything that makes it look like an attempted hack or vulnerability.
Although the \n\t definately shouldn't be in there, I'm not sure whether that is a bug of the mod and they are being included in the query or whether it is as a result of the logging software.

sombra

thanks how do i turn of this ajax chat?

Relemar

Uninstall it buddy in your packages.

Norv

To try uninstalling the mod, and see if it works better, replace a few of your files with those in this archive.

Also, remove the folders ./chat, ./shoutBox,
and the files ./Themes/default/Shout.template.php, ./Themes/default/languages/Shout.english.php, ./Themes/default/languages/Shout.persian.php and ./Themes/default/chat/css/shoutbox.css.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

sombra

i just remore that files and thats all?

for what its the atachment you left there?

Norv

Quote from: Norv on August 27, 2009, 06:35:02 PM
replace a few of your files with those in this archive.


That is, please open the archive and you will see: there are the modified SMF files, those from ./Sources are in ./Sources, those from ./Themes/default are in ./Themes/default and so on.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

karlbenson

Also the reason your getting hammered with it, because the ajax mod refreshes every 10 seconds (or whatever you have it set to).
It is a common complaint of hosts about ajax chat type mods.

Advertisement: