Search code examples
ubuntuterminalrootrootkit

Can't save chkrootkit command output to a file (after defining a new root)


When I'm running chkrootkit on specific dir:

sudo chkrootkit -r /vol

I get the right output and everything is okay. But when I'm trying to save the output to a file, like this:

sudo chkrootkit -r /vol > /home/ubuntu/test.txt

I get this error:

unable to open lastlog-file /vol//vol/var/log/lastlog

I've tried with other folders- the chkrootkit command ran fine but every time I try to save it to a file it wont work. Its worth mentioning, sudo chkrootkit > /home/ubuntu/test.txt is working fine. Which means that the problem is just when the root is changed. the question is, how to save chkrootkit output the a file after changing the root dir.

(I'm using ubuntu 20.04)


Solution

  • If someone will face this issue- I wrote a little python script that is doing that:

    import subprocess
    command = "sudo chkrootkit -r /vol"
    chkrootkit_output = subprocess.getoutput(command)
    with open("/home/ubuntu/test.txt",'w') as f:
        f.write(str(chkrootkit_output))
    

    not ideal but working...