Help restoring website

Discussion regarding Joomla! 3.x security issues.

Moderators: mandville, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant / FPA - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
letourdave
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sat Apr 30, 2016 7:07 am

Help restoring website

Post by letourdave » Sat Apr 30, 2016 7:27 am

Hello, my website was hacked recently and started redirecting people who clicked on the link from search engines.

I decided to restore a backup I made a couple of months ago so deleted all the files on the server. I'm not sure if my backup is joomla 2.5 or 3.5 (the backup was from around the time I was updating).

I made the backup following the process here:
https://docs.joomla.org/Backup_Basics_f ... !_Web_Site

I have a .tar file which is the compressed backup of the site contents which I generated from my (go daddy) host cpanel. I also have a localhost.sql file which should be the sql backup.

I can put the site content back on my server. I"m not quite sure what I have to do with the sql file, but I have gone to phpmyadmin and tried to import the file and I get the long error below. If I open the site I get a 403 forbidden error.

Can anyone help? Is all hope lost?

I would REALLY appreciate some help from someone more knowledgable than me - thanks!!!!



Error
SQL query:

--
-- Database: `ingham_jos2`
--
-- --------------------------------------------------------
--
-- Table structure for table `jos_assets`
--
CREATE TABLE IF NOT EXISTS `jos_assets` (

`id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Primary Key',
`parent_id` INT( 11 ) NOT NULL DEFAULT '0' COMMENT 'Nested set parent.',
`lft` INT( 11 ) NOT NULL DEFAULT '0' COMMENT 'Nested set lft.',
`rgt` INT( 11 ) NOT NULL DEFAULT '0' COMMENT 'Nested set rgt.',
`level` INT( 10 ) UNSIGNED NOT NULL COMMENT 'The cached level in the nested tree.',
`name` VARCHAR( 50 ) NOT NULL COMMENT 'The unique name for the asset.\n',
`title` VARCHAR( 100 ) NOT NULL COMMENT 'The descriptive title for the asset.',
`rules` VARCHAR( 5120 ) NOT NULL COMMENT 'JSON encoded access control.',
PRIMARY KEY ( `id` ) ,
UNIQUE KEY `idx_asset_name` ( `name` ) ,
KEY `idx_lft_rgt` ( `lft` , `rgt` ) ,
KEY `idx_parent_id` ( `parent_id` )
) ENGINE = INNODB DEFAULT CHARSET = utf8 AUTO_INCREMENT =77;

MySQL said: Documentation

#1046 - No database selected

sovainfo
Joomla! Exemplar
Joomla! Exemplar
Posts: 8808
Joined: Sat Oct 01, 2011 7:06 pm

Re: Help restoring website

Post by sovainfo » Sat Apr 30, 2016 7:41 am

The error states that you haven't selected a database yet. In order to import you must have selected a database first for the tables to be created in.
Issue with migrating? Include logs/joomla_update.php in your report!
Blank screen? Verify pagesource for HTML code (javascript error)
Installation failing on populating database? Install with set_time_limit(0)
Document your customizations!

letourdave
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sat Apr 30, 2016 7:07 am

Re: Help restoring website

Post by letourdave » Sat Apr 30, 2016 5:34 pm

That makes sense - thanks so much for your help. I have now tried to import into the name_jos2 database which i'm pretty certain is the one I should be using. I got the following error and the website is still broken. Do you / anyone have any ideas where I am going wrong now? Thanks!

Error
SQL query:

-- -- Dumping data for table `jos_assets` -- INSERT INTO `jos_assets` (`id`, `parent_id`, `lft`, `rgt`, `level`, `name`, `title`, `rules`) VALUES (1, 0, 0, 149, 0, 'root.1', 'Root Asset', '{"core.login.site":{"6":1,"2":1},"core.login.admin":{"6":1},"core.login.offline":{"6":1},"core.admin":{"8":1},"core.manage":{"7":1},"core.create":{"6":1,"3":1},"core.delete":{"6":1},"core.edit":{"6":1,"4":1},"core.edit.state":{"6":1,"5":1},"core.edit.own":{"6":1,"3":1}}'), (2, 1, 1, 2, 1, 'com_admin', 'com_admin', '{}'), (3, 1, 3, 6, 1, 'com_banners', 'com_banners', '{"core.admin":{"7":1},"core.manage":{"6":1},"core.create":[],"core.delete":[],"core.edit":[],"core.edit.state":[]}'), (4, 1, 7, 8, 1, 'com_cache', 'com_cache', '{"core.admin":{"7":1},"core.manage":{"7":1}}'), (5, 1, 9, 10, 1, 'com_checkin', 'com_checkin', '{"core.admin":{"7":1},"core.manage":{"7":1}}'), (6, 1, 11, 12, 1, 'com_config', 'com_config', '{}'), (7, 1, 13, 16, 1, 'com_contact', 'com_contact', '{"core.admin":{"7":1},"core.man[...]

MySQL said: Documentation

#1062 - Duplicate entry '1' for key 'PRIMARY'

sovainfo
Joomla! Exemplar
Joomla! Exemplar
Posts: 8808
Joined: Sat Oct 01, 2011 7:06 pm

Re: Help restoring website

Post by sovainfo » Sat Apr 30, 2016 5:46 pm

Sounds like you are using an existing database with already populated tables. Restoring a backup shouldn't import into existing data. Either change the prefix of the tables or create a new database.
Issue with migrating? Include logs/joomla_update.php in your report!
Blank screen? Verify pagesource for HTML code (javascript error)
Installation failing on populating database? Install with set_time_limit(0)
Document your customizations!

letourdave
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sat Apr 30, 2016 7:07 am

Re: Help restoring website

Post by letourdave » Sat Apr 30, 2016 6:02 pm

Thanks, I'm sure that must be right, but I'm not very techie so I'm not sure what to do next. Do I need to find a way to import my old files so it doesn't create a database, or do I need to somehow delete something before I import a new one?

Is there another way I can recover the content & layout of my site? Thanks for any ideas.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44093
Joined: Sat Apr 05, 2008 9:58 pm

Re: Help restoring website

Post by Webdongle » Sat Apr 30, 2016 8:16 pm

letourdave wrote:Hello, my website was hacked recently and started redirecting people who clicked on the link from search engines.

I decided to restore a backup I made a couple of months ago so deleted all the files on the server. ...
After deleting the files from the server you should have rebuilt with fresh files. Make a backup of your database before you lose your data.
  1. Delete the files from the server (again)
  2. Create a new database
  3. Install Joomla (of the same version) to the new database
  4. Download the the latest versions of trusted 3rd party extensions and install them
    https://vel.joomla.org/live-vel
  5. Edit the configuration.php to connect to the original database
The database is your site ... all the files do is put/get data to/from the database and render it to the browser. By following the steps mentioned you will have clean Joomla (and 3rd party extension) files. See http://forum.joomla.org/viewtopic.php?f=714&t=757645 on how to secure your site.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

letourdave
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sat Apr 30, 2016 7:07 am

Re: Help restoring website

Post by letourdave » Sun May 01, 2016 11:07 am

Thanks so much for trying to help! I'm not quite certain which version of Joomla the backup is using (probably v3.2.1, but I'm not certain). I don't recall which extensions I might have used. I'm not sure how to connect joomla to my database. I really am bit of a beginner.

What I tried, was to delete all my files and sql databases.

Using the godaddy cpanel, I used "Restore a MySQL Database Backup" using the backup file I created to restore my database (interestingly this just created one database, and I had two earlier).

I then restored all the files in my home directory using the go daddy cpanel (hope this didn't overwrite anything??)

When I type my website url I get the following error:

- - - - - - - - - - - - - - - - - - - - - - - -
Forbidden

You don't have permission to access / on this server.
Server unable to read htaccess file, denying access to be safe

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

- - - - - - - - - - - - -

Am I getting closer to a working website do you think? Thanks for any help

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44093
Joined: Sat Apr 05, 2008 9:58 pm

Re: Help restoring website

Post by Webdongle » Sun May 01, 2016 3:10 pm

letourdave wrote:... I'm not quite certain which version of Joomla the backup is using...
Step #3 of my previous post was referring to your live site not the backup. It is so that you have files that match your site database.

letourdave wrote:...
What I tried, was to delete all my files and sql databases....
You have lost all the changes to your site that you made after your last backup.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

letourdave
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sat Apr 30, 2016 7:07 am

Re: Help restoring website

Post by letourdave » Mon May 02, 2016 10:14 pm

Sorted it in the end. I'm pretty sure there must have been something wrong with my site backup, but my sql backup was OK.

Solution: Deleted files, installed clean joomla 3.2.1, Imported database backup from January, assigned a public $user, edited configuration.php in the new install to point to my backup database. Bingo.

Then updated joomla, extensions, changed passwords, took a backup etc.

One question though. I had to add a "Privileged User" to my sql database using mysql databases in the cpanel to be the "public $user =" in the configuration.php file.

Was I right to give this user all privileges? Just want to check i'm not doing anything which isn't secure.

Thanks for your help

User avatar
leolam
Joomla! Master
Joomla! Master
Posts: 20652
Joined: Mon Aug 29, 2005 10:17 am
Location: Netherlands/ Germany/ S'pore/Bogor/ North America
Contact:

Re: Help restoring website

Post by leolam » Wed May 04, 2016 5:50 am

letourdave wrote: One question though. I had to add a "Privileged User" to my sql database using mysql databases in the cpanel to be the "public $user =" in the configuration.php file. Was I right to give this user all privileges?
This is ok. No worries here for you.

Next step: Download Akeebabackup and make sure you create regularly backups and download these to your usb-stick/computer and do not leave them on the server (if account or disk says ' i have gone fishing' you are in deep trouble)

Leo 8)
Joomla's #1 Professional Services Provider:
#Joomla Professional Support: https://gws-desk.com -
#Joomla Specialized Hosting Solutions: https://gws-host.com -

letourdave
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sat Apr 30, 2016 7:07 am

Re: Help restoring website

Post by letourdave » Wed May 04, 2016 6:16 am

Great, thanks for that!


Locked

Return to “Security in Joomla! 3.x”