LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 03-19-2018, 01:26 PM   #1
euduca
LQ Newbie
 
Registered: Mar 2018
Posts: 2

Rep: Reputation: Disabled
Exclamation How to find and stop coin mining on the web server?


Hello.

I discovered that my web server is being used to mine virtual coins.
I have identified and eliminated other types of threats, but this one for me is new.
Also, there is a process that is using memory and CPU resources, however, I can not access the file that is causing this. It appears as part of an active process, but when trying to access the file and as if it did not exist.

Code:
# ps aux | grep php
apache   30429  0.5  0.1 424248 20288 ?        Sl    2017 661:13 /tmp/phpwOu2Lc_so6tr275vprwjvls -c /tmp/phpwOu2Lc.c
# ls /tmp/phpwOu2Lc_so6tr275vprwjvls
ls: cannot access /tmp/phpwOu2Lc_so6tr275vprwjvls: No such file or directory
# ls /tmp/phpwOu2Lc.c
ls: cannot access /tmp/phpwOu2Lc.c: No such file or directory
Can someone help me understand what's going on?

Thank you.
 
Old 03-19-2018, 03:57 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Maybe you should tell us how and what you "identified"...

Cleaning tips at https://aw-snap.info

Code:
lsof -p 30429
will list the what's open by that apache process.

Last edited by Habitual; 03-19-2018 at 03:59 PM.
 
Old 03-19-2018, 05:58 PM   #3
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
Quote:
Originally Posted by euduca View Post
Hello.

I discovered that my web server is being used to mine virtual coins.
I have identified and eliminated other types of threats, but this one for me is new.
Also, there is a process that is using memory and CPU resources, however, I can not access the file that is causing this. It appears as part of an active process, but when trying to access the file and as if it did not exist.

Code:
# ps aux | grep php
apache   30429  0.5  0.1 424248 20288 ?        Sl    2017 661:13 /tmp/phpwOu2Lc_so6tr275vprwjvls -c /tmp/phpwOu2Lc.c
# ls /tmp/phpwOu2Lc_so6tr275vprwjvls
ls: cannot access /tmp/phpwOu2Lc_so6tr275vprwjvls: No such file or directory
# ls /tmp/phpwOu2Lc.c
ls: cannot access /tmp/phpwOu2Lc.c: No such file or directory
What about this information leads you to believe it is mining coins?
 
Old 03-19-2018, 06:02 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,649
Blog Entries: 4

Rep: Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934
I can pretty much assure you that PHP could never be successfully used for any such compute-intensive task . . .
 
Old 03-19-2018, 08:08 PM   #5
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
Quote:
Originally Posted by sundialsvcs View Post
I can pretty much assure you that PHP could never be successfully used for any such compute-intensive task . . .
I'd like to know more about why you say this. PHP can be used to launch other programs with exec or similar functions in response to a web server request. Given that the path of the executable being executed is in the /tmp folder, that suggests the PHP script might have been used to download and compile something written in C (/tmp/phpwOu2Lc.c). Additionally, functions like pcntl_fork and posix_setsid can be used to fork off multi-threaded/multi-processing programs that persist in memory long after a web server request has timed out.

EDIT: I would further add that a botnet of machines might have sufficient computing power in aggregate to provide meaningful coin-mining power back to a single bot herder. It has been widely reported that some jerks have embedded Javascript bitcoin miners into their websites to hijack CPU power from clueless visitors.

Last edited by sneakyimp; 03-19-2018 at 08:12 PM.
 
Old 03-21-2018, 09:53 AM   #6
euduca
LQ Newbie
 
Registered: Mar 2018
Posts: 2

Original Poster
Rep: Reputation: Disabled
Arrow

Quote:
Originally Posted by Habitual View Post
Maybe you should tell us how and what you "identified"...

Cleaning tips at https://aw-snap.info

Code:
lsof -p 30429
will list the what's open by that apache process.
Hi

I received an alert from the University IT. They found some activities about mining coins in my webserver (thy use a proprietary program).
And I found (netsat -a) so many connections with these url: "monerohash.com" and "monero.farm".

Thanks.
 
Old 03-21-2018, 01:25 PM   #7
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by euduca View Post
Code:
# ps aux | grep php
apache   30429  0.5  0.1 424248 20288 ?        Sl    2017 661:13 /tmp/phpwOu2Lc_so6tr275vprwjvls -c /tmp/phpwOu2Lc.c
# ls /tmp/phpwOu2Lc_so6tr275vprwjvls
ls: cannot access /tmp/phpwOu2Lc_so6tr275vprwjvls: No such file or directory
# ls /tmp/phpwOu2Lc.c
ls: cannot access /tmp/phpwOu2Lc.c: No such file or directory
can you give us a long ls on these files, i.e.
Code:
ls -al
or is it constantly changing?
 
Old 03-21-2018, 03:14 PM   #8
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
Quote:
Originally Posted by euduca View Post
I received an alert from the University IT. They found some activities about mining coins in my webserver (thy use a proprietary program).
And I found (netsat -a) so many connections with these url: "monerohash.com" and "monero.farm".
It's a bit of a hack--and I'm not sure this will help much -- but you might mitigate this problem immediately in the short term by adding a couple of entries to your /etc/hosts file until you get the problem solved:
Code:
0.0.0.0 monerohash.com
0.0.0.0 monero.farm
This should cause any attempts to connect to those domains to fail from your machine.

As for the original question 'what is happening,' the apperance of "php" in your posted details suggests to me that you are running some PHP code that is accessible to the public, probably a website, and that there might be a vulnerability in that website that allows an attacker to write arbitary files to your tmp folder and execute them. You might want to scan your apache logs for some of those unique strings and see if anything comes up.
 
Old 03-21-2018, 05:35 PM   #9
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
Youm might also want to run 'unhide'.
 
Old 03-21-2018, 06:37 PM   #10
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
Quote:
Originally Posted by ondoho View Post
can you give us a long ls on these files, i.e.
Code:
ls -al
or is it constantly changing?
It looks like he's having trouble listing them suggesting that the files don't exist (e.g., they are very short-lived, ephemeral files) or that he doesn't have permission to list them (which seems unlikely). Perhaps something like this executed with root privileges:
Code:
find /tmp -name "php*" -exec ls -al {} \;
 
  


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
LXer: Opera 50 Debuts Cryptocurrency Mining Protection in Web Browser LXer Syndicated Linux News 1 05-08-2020 01:12 PM
[Off-Topic] crypto-mining server under Linux and Tor oxyopes Linux - Server 1 01-31-2018 09:12 AM
LXer: Opera 50 Debuts as World's First Web Browser with Anti-Bitcoin Mining Protection LXer Syndicated Linux News 0 01-04-2018 11:15 PM
[SOLVED] XAMPP fails to start. Another web server with SSL already running, can't stop it Draper Linux - Server 5 08-01-2013 12:09 PM
Data Mining and how to stop it ????? bigjohn Linux - Security 11 10-27-2003 01:50 AM

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

All times are GMT -5. The time now is 04:00 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