LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 04-03-2009, 12:18 PM   #1
romio
LQ Newbie
 
Registered: Mar 2009
Posts: 10

Rep: Reputation: 0
Spammer or a hacker is uploading a file.....


Someone is being able to upload to my /var/www/vhosts/domain a file that sends tons of emails which is causing my server almost to crash, i am not able to understand how this is happening? how can i avoid this? anyone could help with this matter its really series since my clients are not able to use anymore webmail.

I have uploaded a sample of the file, the file usually is located on the root of the directory with the one of the following names:

default.php
_default.php
post.php
home.php

I use fedora
Attached Files
File Type: txt post.txt (969 Bytes, 25 views)

Last edited by romio; 04-03-2009 at 12:26 PM.
 
Old 04-03-2009, 12:54 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by romio View Post
Someone is being able to upload to my /var/www/vhosts/domain a file that sends tons of emails which is causing my server almost to crash, i am not able to understand how this is happening? how can i avoid this? anyone could help with this matter its really series since my clients are not able to use anymore webmail.

I have uploaded a sample of the file, the file usually is located on the root of the directory with the one of the following names:

default.php
_default.php
post.php
home.php

I use fedora
Fedora what? What version? What other software do you have on that box that could be compromised? What kind of firewall/security do you have in place?

Examine the connection logs...look for suspicious traffic. You can block that address/domain via iptables, or through your firewall, and remove the offending files....
 
Old 04-03-2009, 01:03 PM   #3
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 97
How are pages uploaded onto your server?
  • If by FTP, is anonymous FTP blocked? Are passwords strong? Are users kept within a "chroot jail" in their own directory, or can they navigate to other directories on the system? Is FTP denied for root and other privileged users?
  • Do you use have a content management system (or even message board system) that allows file uploads? Does this allow users to enter (any part of) the filepath to which a file should be uploaded?
  • Is your web server configured to allow the HTTP PUT method?

It would be worth looking through your FTP and Apache (I'm assuming you're using Apache) logs. In the FTP logs, assuming anonymous FTP isn't allowed, are there multiple failed login attemtps?

In the main Apache config file, you could include <LIMIT POST> directives for the web root, only allowing POST from localhost / the local domain / trusted hosts (though this is only a temporary solution, as if the user can still upload files, there will be other ways of attacking you). Also, just to be safe, you could <LIMIT PUT> with deny from all

Last edited by Robhogg; 04-03-2009 at 01:08 PM.
 
Old 04-03-2009, 03:17 PM   #4
romio
LQ Newbie
 
Registered: Mar 2009
Posts: 10

Original Poster
Rep: Reputation: 0
Robhogg which file is the ftp log file?

what does this line means:

Apr 3 15:34:17 ip-xxx-xx-xxx-xx named[1734]: client 203.62.195.76#54968: zone transfer 'domainname.com/AXFR/IN' denied


Robhogg what i understood from your previous reply is that we can add a command that rejects any attempt to send emails from vhosts folder?
 
Old 04-03-2009, 03:59 PM   #5
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
A couple of suggestions:

1)Start working your way through the CERT checklist and see if it helps identify how the system has been compromised

2)Pull the network plug. Until you understand what has happened, messing around with bits and pieces of it is only going to tip the spammers that you're on to them and they may get better at hiding their tracks. Besides, if you're clients can't use the server anymore, why should you let the spammers?
 
Old 04-04-2009, 03:22 AM   #6
romio
LQ Newbie
 
Registered: Mar 2009
Posts: 10

Original Poster
Rep: Reputation: 0
I was checking my mail queue list and i found this email:

Received: (qmail 23976 invoked by uid 111); 4 Apr 2009 01:51:25 -0700
Date: 4 Apr 2009 01:51:25 -0700
Message-ID: <20090404085125.23974.qmail@ip-xxx-xx-xxx-xx.ip.secureserver.net>
From: root@ip-xxx-xx-xxx-xx.ip.secureserver.net (Cron Daemon)
To: drweb@ip-xxx-xx-xxx-xx.ip.secureserver.net
Subject: Cron <drweb@ip-xxx-xx-xxx-xx> /opt/drweb/update.pl
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/var/drweb>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=drweb>
X-Cron-Env: <USER=drweb>


i am still waiting if some one could explain the line below which i found on my log file:


Apr 3 15:34:17 ip-xxx-xx-xxx-xx named[1734]: client 203.62.195.76#54968: zone transfer 'domainname.com/AXFR/IN' denied


Thanks
 
Old 04-04-2009, 04:35 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by romio View Post
Apr 3 15:34:17 ip-xxx-xx-xxx-xx named[1734]: client 203.62.195.76#54968: zone transfer 'domainname.com/AXFR/IN' denied
Like the cronjob email output you posted, denied DNS record transfers are not your main problem. If your current setup allows people to upload files then you should investigate what you're exactly running in terms of "plain" services (SSH, FTP, HTTP, .*SQL, et cetera), accessability (users running shell, open dirs, misconfiguration of services), software (webserver, PHP, PHP-based software), the software being up to date and configured well.
* If files are mysterioulsy appearing, then if you are running any PHP-based software, then the first thing to look at would be if a user might have found a hole (like remote file inclusion aka RFI) because you run either outdated software or it's misconfigured. I suggest you firewall off public access until you have investigated this. If you can't figure things out for yourself then log all in and outbound public traffic ports you run services on and post the software names and versions of services you run as well as any CMS or other PHP-based software, as verbose as possible, as well as anything you've tried to mitigate this situation. Understand this is not an exercise in futility but the more we know the more efficient it would be for us to help you.
 
Old 04-04-2009, 03:14 PM   #8
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 97
Quote:
Originally Posted by romio View Post
Robhogg which file is the ftp log file?
Depends on which FTP server you're using and how it's configured. Look for a file / directory in /var/log with ftp in the name, or use grep to search for "ftp" in /var/log/messages and other system logs.

Quote:
Robhogg what i understood from your previous reply is that we can add a command that rejects any attempt to send emails from vhosts folder?
No, <limit POST> is used to restrict HTTP POST requests (used to upload data to the server). Looking at the script you attached, the attacker is using POST to control it:
Quote:
if (isset($_POST['action']))
However, if you do not require mail to be sent from the server, the best thing to do would be to stop whatever mail transfer agent you've got running (sendmail, exim4 or whatever).

Last edited by Robhogg; 04-04-2009 at 03:16 PM.
 
Old 04-04-2009, 06:46 PM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by Robhogg View Post
However, if you do not require mail to be sent from the server, the best thing to do would be to stop whatever mail transfer agent you've got running (sendmail, exim4 or whatever).
Some systems might rely on having a MTA around for sending local mail (cronjob output, reporting), so making it unavailable might kill that off as well. Besides, and with all due respect, at this point (where still nothing is clarified by the OP), isn't that more like addressing symptoms instead of addressing the cause? After all it's not the MTA that's the problem. Restricting access and finding the attack vector should be the first task.
 
Old 04-04-2009, 08:16 PM   #10
Crito
Senior Member
 
Registered: Nov 2003
Location: Knoxville, TN
Distribution: Kubuntu 9.04
Posts: 1,168

Rep: Reputation: 53
Quote:
Originally Posted by romio View Post
i am still waiting if some one could explain the line below which i found on my log file:

Apr 3 15:34:17 ip-xxx-xx-xxx-xx named[1734]: client 203.62.195.76#54968: zone transfer 'domainname.com/AXFR/IN' denied
Someone tried an anonymous zone transfer. Crackers gather this sort of information in the reconnaissance phase to identify potential targets. Phase 2 is active probing/scanning for vulnerabilities. Phase 3 is gaining access (exploiting the vulnerability). Phase 4 is maintaining access (installing rootkits/backdoors). And last but not least is phase 5, covering one's tracks (deleting or altering logs).


Sounds to me like you're between phase 3 and 4 still. Once you've been rootkited the only way to be 100% sure you're clean again is the three Rs: repartition, reformat, reinstall. If it were me I'd pull the plug now.
 
Old 04-05-2009, 09:58 AM   #11
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
Once you've been rootkited the only way to be 100% sure you're clean again is the three Rs: repartition, reformat, reinstall. If it were me I'd pull the plug now.
With all due respect, unless the OP understands how the machine was cracked in the first place, this could result in a clean machine with the same vulnerabilities as before. I'm all for pulling the network plug, and maybe the power plug, but unless the OP is going to invest in figuring out the problem, the rest is just wasted time.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
uploading file using ftp amit_kalipur Linux - Server 7 04-04-2009 06:11 AM
[perl] uploading a file using POST s0l1dsnak3123 Programming 2 05-12-2008 02:38 PM
PHP and File Uploading Tomasfuego Linux - Software 6 08-12-2004 09:20 AM
uploading a file and cant resume skog Slackware 0 03-08-2004 10:11 PM
C++ client application for uploading a file ciocoiuf Programming 1 06-02-2003 06:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 09:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration