1

I need to understand the log below, my index.php got obfuscated code, and file permissions changed from 644 to 755 as well.

I've got something in my audit but can't really tell what and how it happened. Log is below (I took out everything but the index.php related lines).

----
time->Sun Mar 31 17:19:20 2019
type=PROCTITLE msg=audit(1554067160.319:12831615): proctitle=7068702D66706D3A20706F6F6C207765726F636B746865737065637472756D6B6174795F636F6D
type=PATH msg=audit(1554067160.319:12831615): item=0 name="/home/usersite/public_html/index.php" inode=576615421 dev=09:01 mode=0100644 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:home_root_t:s0 objtype=NORMAL cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1554067160.319:12831615):  cwd="/home/usersite"
type=SYSCALL msg=audit(1554067160.319:12831615): arch=c000003e syscall=2 success=yes exit=5 a0=7ffea4ae5540 a1=0 a2=1b6 a3=4 items=1 ppid=9239 pid=13524 auid=4294967295 uid=1121 gid=1123 euid=1121 suid=1121 fsuid=1121 egid=1123 sgid=1123 fsgid=1123 tty=(none) ses=4294967295 comm="php-fpm" exe="/opt/cpanel/ea-php70/root/usr/sbin/php-fpm" subj=system_u:system_r:unconfined_service_t:s0 key="monitor-hosts"
----
time->Sun Mar 31 17:19:20 2019
type=PROCTITLE msg=audit(1554067160.335:12831626): proctitle=7068702D66706D3A20706F6F6C207765726F636B746865737065637472756D6B6174795F636F6D
type=PATH msg=audit(1554067160.335:12831626): item=0 name="/home/usersite/public_html/index.php" inode=576615421 dev=09:01 mode=0100644 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:home_root_t:s0 objtype=NORMAL cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1554067160.335:12831626):  cwd="/home/usersite"
type=SYSCALL msg=audit(1554067160.335:12831626): arch=c000003e syscall=2 success=yes exit=5 a0=7ffea4ae5540 a1=0 a2=1b6 a3=4 items=1 ppid=9239 pid=13526 auid=4294967295 uid=1121 gid=1123 euid=1121 suid=1121 fsuid=1121 egid=1123 sgid=1123 fsgid=1123 tty=(none) ses=4294967295 comm="php-fpm" exe="/opt/cpanel/ea-php70/root/usr/sbin/php-fpm" subj=system_u:system_r:unconfined_service_t:s0 key="monitor-hosts"
----
time->Sun Mar 31 17:19:20 2019
type=PROCTITLE msg=audit(1554067160.996:12832312): proctitle=7068702D66706D3A20706F6F6C207765726F636B746865737065637472756D6B6174795F636F6D
type=PATH msg=audit(1554067160.996:12832312): item=0 name="/home/usersite/public_html/index.php" inode=576615421 dev=09:01 mode=0100644 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:home_root_t:s0 objtype=NORMAL cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1554067160.996:12832312):  cwd="/home/usersite"
type=SYSCALL msg=audit(1554067160.996:12832312): arch=c000003e syscall=2 success=yes exit=5 a0=7ffea4ae5540 a1=0 a2=1b6 a3=4 items=1 ppid=9239 pid=13531 auid=4294967295 uid=1121 gid=1123 euid=1121 suid=1121 fsuid=1121 egid=1123 sgid=1123 fsgid=1123 tty=(none) ses=4294967295 comm="php-fpm" exe="/opt/cpanel/ea-php70/root/usr/sbin/php-fpm" subj=system_u:system_r:unconfined_service_t:s0 key="monitor-hosts"
----
time->Sun Mar 31 17:19:23 2019
type=PROCTITLE msg=audit(1554067163.223:12837949): proctitle=7068702D66706D3A20706F6F6C207765726F636B746865737065637472756D6B6174795F636F6D
type=PATH msg=audit(1554067163.223:12837949): item=0 name="/home/usersite/public_html/wp-content/themes/twentythirteen/index.php" inode=1135033766 dev=09:01 mode=0100644 ouid=1121 ogid=1123 rdev=00:00 obj=system_u:object_r:home_root_t:s0 objtype=NORMAL cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1554067163.223:12837949):  cwd="/home/usersite/public_html"
type=SYSCALL msg=audit(1554067163.223:12837949): arch=c000003e syscall=2 success=yes exit=5 a0=7ffea4ae3260 a1=0 a2=1b6 a3=4 items=1 ppid=9239 pid=13531 auid=4294967295 uid=1121 gid=1123 euid=1121 suid=1121 fsuid=1121 egid=1123 sgid=1123 fsgid=1123 tty=(none) ses=4294967295 comm="php-fpm" exe="/opt/cpanel/ea-php70/root/usr/sbin/php-fpm" subj=system_u:system_r:unconfined_service_t:s0 key="monitor-hosts"
----
time->Sun Mar 31 17:19:22 2019
type=PROCTITLE msg=audit(1554067162.162:12834748): proctitle=7068702D66706D3A20706F6F6C207765726F636B746865737065637472756D6B6174795F636F6D
type=PATH msg=audit(1554067162.162:12834748): item=0 name="/home/usersite/public_html/wp-content/themes/twentythirteen/index.php" inode=1135033766 dev=09:01 mode=0100644 ouid=1121 ogid=1123 rdev=00:00 obj=system_u:object_r:home_root_t:s0 objtype=NORMAL cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1554067162.162:12834748):  cwd="/home/usersite/public_html"
type=SYSCALL msg=audit(1554067162.162:12834748): arch=c000003e syscall=2 success=yes exit=6 a0=7ffea4ae3260 a1=0 a2=1b6 a3=4 items=1 ppid=9239 pid=13531 auid=4294967295 uid=1121 gid=1123 euid=1121 suid=1121 fsuid=1121 egid=1123 sgid=1123 fsgid=1123 tty=(none) ses=4294967295 comm="php-fpm" exe="/opt/cpanel/ea-php70/root/usr/sbin/php-fpm" subj=system_u:system_r:unconfined_service_t:s0 key="monitor-hosts"
----
time->Sun Mar 31 17:19:22 2019
type=PROCTITLE msg=audit(1554067162.162:12834749): proctitle=7068702D66706D3A20706F6F6C207765726F636B746865737065637472756D6B6174795F636F6D
type=PATH msg=audit(1554067162.162:12834749): item=0 name="/home/usersite/public_html/wp-content/themes/twentythirteen/index.php" inode=1135033766 dev=09:01 mode=0100644 ouid=1121 ogid=1123 rdev=00:00 obj=system_u:object_r:home_root_t:s0 objtype=NORMAL cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1554067162.162:12834749):  cwd="/home/usersite/public_html"
type=SYSCALL msg=audit(1554067162.162:12834749): arch=c000003e syscall=2 success=yes exit=6 a0=7ffea4ae3260 a1=0 a2=1b6 a3=4 items=1 ppid=9239 pid=13526 auid=4294967295 uid=1121 gid=1123 euid=1121 suid=1121 fsuid=1121 egid=1123 sgid=1123 fsgid=1123 tty=(none) ses=4294967295 comm="php-fpm" exe="/opt/cpanel/ea-php70/root/usr/sbin/php-fpm" subj=system_u:system_r:unconfined_service_t:s0 key="monitor-hosts"
----
time->Sun Mar 31 17:19:22 2019
type=PROCTITLE msg=audit(1554067162.700:12836618): proctitle=7068702D66706D3A20706F6F6C207765726F636B746865737065637472756D6B6174795F636F6D
type=PATH msg=audit(1554067162.700:12836618): item=0 name="/home/usersite/public_html/wp-content/themes/twentythirteen/index.php" inode=1135033766 dev=09:01 mode=0100644 ouid=1121 ogid=1123 rdev=00:00 obj=system_u:object_r:home_root_t:s0 objtype=NORMAL cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1554067162.700:12836618):  cwd="/home/usersite/public_html"
type=SYSCALL msg=audit(1554067162.700:12836618): arch=c000003e syscall=2 success=yes exit=5 a0=7ffea4ae3260 a1=0 a2=1b6 a3=4 items=1 ppid=9239 pid=13541 auid=4294967295 uid=1121 gid=1123 euid=1121 suid=1121 fsuid=1121 egid=1123 sgid=1123 fsgid=1123 tty=(none) ses=4294967295 comm="php-fpm" exe="/opt/cpanel/ea-php70/root/usr/sbin/php-fpm" subj=system_u:system_r:unconfined_service_t:s0 key="monitor-hosts"
----
time->Sun Mar 31 17:19:22 2019
type=PROCTITLE msg=audit(1554067162.733:12836797): proctitle=7068702D66706D3A20706F6F6C207765726F636B746865737065637472756D6B6174795F636F6D
type=PATH msg=audit(1554067162.733:12836797): item=0 name="/home/usersite/public_html/wp-content/themes/twentythirteen/index.php" inode=1135033766 dev=09:01 mode=0100644 ouid=1121 ogid=1123 rdev=00:00 obj=system_u:object_r:home_root_t:s0 objtype=NORMAL cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1554067162.733:12836797):  cwd="/home/usersite/public_html"
type=SYSCALL msg=audit(1554067162.733:12836797): arch=c000003e syscall=2 success=yes exit=5 a0=7ffea4ae3260 a1=0 a2=1b6 a3=4 items=1 ppid=9239 pid=13540 auid=4294967295 uid=1121 gid=1123 euid=1121 suid=1121 fsuid=1121 egid=1123 sgid=1123 fsgid=1123 tty=(none) ses=4294967295 comm="php-fpm" exe="/opt/cpanel/ea-php70/root/usr/sbin/php-fpm" subj=system_u:system_r:unconfined_service_t:s0 key="monitor-hosts"
----
time->Sun Mar 31 17:19:22 2019
type=PROCTITLE msg=audit(1554067162.766:12836929): proctitle=7068702D66706D3A20706F6F6C207765726F636B746865737065637472756D6B6174795F636F6D
type=PATH msg=audit(1554067162.766:12836929): item=0 name="/home/usersite/public_html/wp-content/themes/twentythirteen/index.php" inode=1135033766 dev=09:01 mode=0100644 ouid=1121 ogid=1123 rdev=00:00 obj=system_u:object_r:home_root_t:s0 objtype=NORMAL cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1554067162.766:12836929):  cwd="/home/usersite/public_html"
type=SYSCALL msg=audit(1554067162.766:12836929): arch=c000003e syscall=2 success=yes exit=6 a0=7ffea4ae3260 a1=0 a2=1b6 a3=4 items=1 ppid=9239 pid=13524 auid=4294967295 uid=1121 gid=1123 euid=1121 suid=1121 fsuid=1121 egid=1123 sgid=1123 fsgid=1123 tty=(none) ses=4294967295 comm="php-fpm" exe="/opt/cpanel/ea-php70/root/usr/sbin/php-fpm" subj=system_u:system_r:unconfined_service_t:s0 key="monitor-hosts"
----
  • 1
    Is the audit now catching the activity you're concerned about (re: your previous audit question)? – Jeff Schaller Apr 1 at 10:28
  • Hey @JeffSchaller yes, this is the audit that caught the changes made on index.php (i.e. audit rule was set before the change happened). – evul Apr 1 at 10:39
0

I was going to comment, but got too long. Looking at the log, I am seeing the file context of subj=system_u:system_r:unconfined_service_t:s0 This would indicate that SELinux is enabled. Check SELinux status with sestatus or getenforce. If you see enforcing, then the file context from above is not what I would expect to see. I would ask that you go to the DIR /home/usersite and run ls -Z. This will be a good ole ls plus file context. Here is ls -Z output on my dev box:

    [user@localhost]$ ls -Z ~ | grep -i Music
    drwxr-xr-x. user user unconfined_u:object_r:audio_home_t:s0 Music

Compare file context with other files in same DIR. I would expect to see a file context of unconfined_u:object_r:httpd_sys_content_t:s0 for files that your web server is running. I have, in the past, moved files with SELinux enforcing and caused problem because the file context does not change when you move files, and with SELinux enforcing and incorrect context, you will have issues that auditd will catch. To change file context, use the chcon as root to change context. I work with mostly RHEL/CentOS, and here is a link that might help clear up some of your questions and how to use chcon to get the file context correct.

0

You have nine audit entries, all of which happened in less than three seconds, on Sunday March 31st (at epoch time 1554067160 through 1554067162; see your local time for those with date -d @1554067160; date -d @1554067162). These audit entries were generated from an audit rule that you tagged with the name "monitor-hosts".

The entries are all very similar, mainly differing in pid values, but also differing in name values.

A process started from /opt/cpanel/ea-php70/root/usr/sbin/php-fpm with parent pid 9239, a UID of 1121, and a GID of 1123. That process opened (syscall=2 on x86_64) "/home/usersite/public_html/index.php" (inode 576615421) three times, then opened "/home/usersite/public_html/wp-content/themes/twentythirteen/index.php" (inode 1135033766) six times. Both of those files reside on device 09:01, which translates to /dev/md1 -- presumably you have a filesystem built on /dev/md1. The current working directory for the first three opens was "/home/usersite" while the working directory for the last six open was "/home/usersite/public_html". The open calls were successful, and returned various file handles (5 or 6).

At this point in time, both files had a mode (permission set) of 644, as seen in mode=0100644.

Unfortunately, none of these audit entries indicate (at a higher level) "what" happened or "how". If you suspect corruption of these index.php files by a bad actor, it's highly likely that they're using this php-fpm file (or an underlying vulnerability) to access the files.


The following link was helpful to me as I analyzed the logs:

Red Hat Enterprise Linux - 7 - Security Guide - 6.6. Understanding Audit Log Files


Also useful was this python snippet I built up to convert the hex-encoded fields, such as proctitle:

python -c 'import binascii; print binascii.a2b_hex("636174002F6574632F7373682F737368645F636F6E666967")'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.