-4

I have this virus that came from an npm package and I want to read the code. My problem is that I cannot read the contents of the file.

Trying to make it readable, I took the drastic step of allowing all permissions on the file. (Yes, I know. Kids, don't play with matches or set random things to 777.) I chmoded it to 777 and moved it to my Desktop. I'm the owner of the file. I changed the extension to .txt, and its icon is now a bunch of characters.

I've tried sudo cat as well. No, I'm not about to execute it as the superuser or anything like that. I thought that the superuser would bypass the permissions problem.

But no; any kind of read command gets a permission denied.

I'm using a Mac.

How on Earth is this file unreadable with 777 permissions and cat running as the superuser?

closed as unclear what you're asking by Ipor Sircer, DopeGhoti, Christopher, Rui F Ribeiro, Jesse_b Nov 29 '18 at 16:03

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    If you have a binary you know (or believe) to be malware, why in the world would you set the executable bit on it? – DopeGhoti Nov 29 '18 at 15:32
  • 3
    Wow, thats incredibly reckless. Why not put the permissions as 600 instead? That way your not accidentally executing the file and killing your computer. – ryekayo Nov 29 '18 at 15:37
  • Wow... that is reckless. Why? – Michael Prokopec Nov 29 '18 at 15:39
  • Include your OS and whether or not you are running SELinux or any kind of security software – cutrightjm Nov 29 '18 at 15:44
  • 1
    And, you know, the error you are seeing when you try to cat the file. SELinux is unlikely on a Mac (:. – DopeGhoti Nov 29 '18 at 15:46
1

Do not set this file's permissions to 777 if you believe it to be malicious in nature. You should probably set them to 600 so that only the file's owner can interact with it but not inadvertantly execute it.

If you are the owner, you should not need to sudo cat it (and indeed if you believe it to be malicious you should not sudo anything (other than rm) it.

Once you own the file and its permissions are 600, you should be able to simply:

$ cat file
  • my whole question is that i get a perms error on something with readable permissions that i own. – user183415 Nov 29 '18 at 15:41
  • 1
    In that case please edit your question to actually ask the actual question, and include the actual error you are seeing. We can't answer questions you are not actually asking. – DopeGhoti Nov 29 '18 at 15:43