Giter Club home page Giter Club logo

bash2rsyslog's Introduction

bash2rsyslog

bash2rsyslog

# 下载最新版Bash
wget http://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz -P /usr/local/src/

# 修改源码 bashhist.c
vi bashhist.c +716  716行左右修改成下面内容
     syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY: PID=%d PPID=%d SID=%d  User=%s CMD=%s", getpid(), getppid(), getsid(getpid()),  current_user.user_name, line);
  else
    {
      strncpy (trunc, line, SYSLOG_MAXLEN);
      trunc[SYSLOG_MAXLEN - 1] = '\0';
      syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY (TRUNCATED): PID=%d  PPID=%d SID=%d User=%s CMD=%s", getpid(), getppid(), getsid(getpid()),  current_user.user_name, trunc);
    }
# 修改源码 bashhist.c
vi config-top.h  取消/*#define SYSLOG_HISTORY*/这行的注释

# 解压、编译、安装
tar xvf bash-4.3.tar.gz -C /usr/local/src/
cd /usr/local/src/bash-4.3
./configure --prefix=/usr/local/
make
make install

# 替换
mv /bin/bash /bin/bash.$(date +%F)
\cp /usr/local/bin/bash /bin/bash
chattr -i /etc/passwd /etc/shadow
sed -i 's#/bin/bash#/usr/local/bin/bash#g' /etc/passwd
chattr +i /etc/passwd /etc/shadow
cd -
rm -rf bash-4.3.tar.gz /usr/local/src/bash-4.3/

# 加固
rm ~/.bash_history
ln -s /dev/null  ~/.bash_history
chattr +a ~/.bash_history   【sappnd /home/bob/.bash_history (freebsd)】
chattr +a ~/.bash_profile  
chattr +a ~/.bash_login
chattr +a ~/.profile 
chattr +a ~/.bash_logout
chattr +a ~/.bashrc

bash2rsyslog's People

Contributors

mruse avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.