Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Malware is software, therefore it must be executed. (And, once executed, it must be capable of malice using your privileges alone.)
A true .txt file is not executable, but some operating systems consider only the "magic bytes" within the file, not its extension. If the content appears to be an executable program – regardless of its misleading-to-humans .txt extension – they might conceivably try to execute it.
However, "basically, 'no.'"
Remember: this is not biology we are talking about! While you can "catch" a cold by walking into the wrong elevator, your computer cannot. Unlike, say, a yellow fever organism that's lurking in the ground of a graveyard, malware cannot "hide" anywhere, nor can it "infect" anything.
Last edited by sundialsvcs; 04-24-2017 at 10:26 AM.
No I was aware that malware can "mask" itself as a text file, but I was wondering if there were any more methods so to speak. But yeah thanks guys I'll check out that link, but I have no idea what to do with that code lol (do I put that in a script?). And thanks Sundial good to know, i'll just make sure their not executable and do some online scans, or maybe just keep them on a Raspberry Pie.
Last edited by linux4evr5581; 04-24-2017 at 10:30 AM.
One case I can think of is if a text file has vim commands inside it.
IIRC there is a way one can put vim commands inside of a text file. When you edit the text file with these commands, the commands auto execute from vim.
I forgot how to do that, but I suppose one can do some nasty things that way.
You can also disable this globally in your ~/.vimrc
From the command line, shells can be told to attempt to execute any file with the x (execute) permission set. If this is not a binary file and there isn't a "magic" #! then generally the system will attempt to use the users default shell as the interpreter.
So despite what others have said it is ENTIRELY possible for malware to "hide" within a .txt file. Especially if it's distributed as a tarball or some other archive format that can preserve file permissions.
Whether you actually EXECUTE that file is another matter.
While I'm sure you can work it out, other than it's attempting to create and execute something in /tmp it's not entirely obvious what the actual end result will be.
If I was designing an exploit, I'd aim at somewhere where everyone said it was impossible. Not that I'm that smart, but there are plenty of others who are.
Thanks TenTenths good stuff but that would still be noticeable in a .txt file (unless it's text file of command notes, or something). Nevertheless pretty cool how it lists directories without the ls command, it's like magic... Im gonna concatenate futher into what these and similar commands do, and see what's going on here, thank you!
Note that the "executable" bit does not mean that Linux would automatically attempt to execute it, if merely asked to open the file.
This bit does allow the file to be referenced from the command-line, which is understood to be a request to execute it.
If the file begins with a #!shebang line, this specifically identifies it as a program written in a particular programming language. Otherwise, the shell will attempt to execute it as a script.
And if the file actually contains a copy of Lincoln's Gettysburg Address, it won't get far. (However, famously, there was a COBOL compiler which tried to compile it!)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.