Client:

OMAudit_agent.py

#!/usr/bin/env python
#coding:utf-
import sys
import socket
import fcntl
import struct
import logging
from config import *
import urllib,httplib
socket.setdefaulttimeout(Connect_TimeOut)
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s [%(levelname)s] %(message)s',
filename=sys.path[]+'/omsys.log',
filemode='a') if len(sys.argv)<:
logging.error('history not configured in /etc/profile!')
sys.exit() def get_local_ip(ethname):
try:
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
addr = fcntl.ioctl(sock.fileno(),0x8915,struct.pack('256s',ethname))
return socket.inet_ntoa( addr[:] )
except Exception,e:
logging.error('get localhost IP address error:'+str(e))
return "127.0.0.1" def pull_history(http_get_param=""):
try:
http_client = httplib.HTTPConnection(OMServer_address,,timeout=Connect_TimeOut)
http_client.request("GET",http_get_param)
response = http_client.getresponse() if response.status != :
logging.error('response http status error:'+str(response.status))
sys.exit() http_content = response.read().strip()
if http_content != "OK":
logging.error('response http content error:'+str(http_content))
sys.exit() except Exception,e:
logging.error('connection django-cgi server error:'+str(e))
sys.exit() finally:
if http_client:
http_client.close()
else:
logging.error('connection django-cgi server unknown error.')
sys.exit() Sysip = get_local_ip(Net_driver)
SysUser = sys.argv[]
History_Id = sys.argv[]
History_date = sys.argv[]
History_time = sys.argv[]
History_command = ""
#print(Sysip)
#print(History_Id)
#print(SysUser)
#print(History_date)
#print(History_time)
#print('test'+sys.argv[])
#print(sys.argv[])
for i in range(,len(sys.argv)):
History_command+=sys.argv[i]+" " #s = "/omaudit_pull/?history_id="+History_Id+"&history_ip="+Sysip+"&history_user="+SysUser+"&history_command="+urllib.quote(History_command.strip())
s = "/omaudit_pull/?history_id="+History_Id+"&history_ip="+Sysip+"&history_user="+SysUser+ \
"&history_datetime="+History_date+urllib.quote(" ")+History_time+"&history_command="+urllib.quote(History_command.strip())
pull_history(s)

config.py:

# -*- coding: utf-8 -*-
#!/user/bin/env python
Net_driver = "eth0"
OMServer_address = "*.*.*.*"
Connect_TimeOut = 3

  

安装脚本:OMAudit_agent_install.sh

#!/bin/bash
# -*- coding: utf- -*-
yum -y install unzip zip
mkdir -p /opt/platform/OMAudit/
touch /opt/platform/OMAudit/omsys.log
unzip OMAudit_agent.zip -d /opt/platform/OMAudit
chmod -R /opt/platform/OMAudit/ cat >> /etc/profile << eof
export HISTFILE=\$HOME/.bash_history
export HISTSIZE=
export HISTFILESIZE=
export HISTCONTROL=ignoredups
export HISTTIMEFORMAT="\`whoami\` %F %T "
export PROMPT_COMMAND="history -a; history -c; history -r;"'/opt/platform/OMAudit/OMAudit_agent.py \$(history 1)'
shopt -s histappend
typeset -r PROMPT_COMMAND
typeset -r HISTTIMEFORMAT
eof
sleep
source /etc/profile

Server:

Linux安全审计的更多相关文章

  1. Linux安全审计命令

    安全审计 数据分析 capinfos xxx.pcap 产看数据包基本信息 日志分析 who /var/log/wtmp #查看登录用户信息 哈希校验 sha265 文件名 md5sum 文件名 &g ...

  2. Linux安全审计-基础篇

    安全审计这块我能想到的有两种方案可以解决,一种是在Linux中配置实现,一种是使用Python开发堡垒机实现,我先实现了第一种比较简单的:后面会开发堡垒机:   一.首先我们需要在/etc/profi ...

  3. Linux服务器安全审计工具与流程完全指南

    http://Linux.chinaitlab.com/server/860516.html 当今许多linux服务器都不是刚刚部署完毕的新机器,有专业的Linux系统管理员进行定期维护,IT技术人员 ...

  4. Linux 驱动开发

    linux驱动开发总结(一) 基础性总结 1, linux驱动一般分为3大类: * 字符设备 * 块设备 * 网络设备 2, 开发环境构建: * 交叉工具链构建 * NFS和tftp服务器安装 3, ...

  5. Linux audit安全审计工具

    /********************************************************************** * Linux audit安全审计工具 * 说明: * ...

  6. 详解Linux开源安全审计和渗透测试工具Lynis

    转载自FreeBuf.COM Lynis是一款Unix系统的安全审计以及加固工具,能够进行深层次的安全扫描,其目的是检测潜在的时间并对未来的系统加固提供建议.这款软件会扫描一般系统信息,脆弱软件包以及 ...

  7. linux系统安全审计简单设置

    应用安全-安全审计日志目录  /var/log/audit/audit.log [root@localhost audit]# cd /etc/audit/[root@localhost audit] ...

  8. Linux操作系统之安全审计功能

    内核编译时,一般打开NET选项就打开AUDIT选项了.在系统中查看audit是否打开,root 用户执行:service auditd status 我们知道在Linux系统中有大量的日志文件可以用于 ...

  9. LINUX安全加固规范

    1 概述 近几年来Internet变得更加不安全了.网络的通信量日益加大,越来越多的重要交易正在通过网络完成,与此同时数据被损坏.截取和修改的风险也在增加. 只要有值得偷窃的东西就会有想办法窃取它的人 ...

随机推荐

  1. RTS打卡计划第四周

    Algorithms: https://leetcode-cn.com/problems/subarray-sum-equals-k/comments/ 此问题开始考虑空间换时间,结果完全不用空间,不 ...

  2. 【Spring】mvc:annotation-driven 使用

    关注此标签,是在项目中有使用 <!-- 解决@ResponseBody 的实现类其默认的编码是 iso-8859-1的问题 --> <mvc:annotation-driven> ...

  3. Python中列表的使用

    python中的列表与java中的数组非常类似,但使用方法比java中数组简单很多,python中的数据类型不需要显示声明,但在使用时必须赋值,列表元素下标从0开始 初始化列表(初始化一个包含五个元素 ...

  4. hive 使用笔记(table format;lateral view横表转纵表)

    1. create table 创建一张目标表,指定分隔符和存储格式: create table tmp_2 (resource_id bigint ,v int) ROW FORMAT DELIMI ...

  5. 【转】composer proc_open(NUL)报错问题

    composer  执行的时候报错错误信息如下: [ErrorException] proc_open(NUL): failed to open stream: No such file or dir ...

  6. 理解Dubbo

    1.Dubbo应用场景 2.Dubbo支持的协议 3.Dubbo性能比较 4.负载均衡策略 5.容错方案 6.Dubbo vs SpringCloud 7.深入Dubbo需要的技能

  7. 测试的sql

    幼教视频全部 '''sql中需传的参数为:phone_no,phone_no(当前登录账号),cid(视频分类),video_type(1 幼教视频, 2 合作方视频,3校方视频),del_flag( ...

  8. 过滤器demo-编码统一处理

    package com.loaderman.demo.a_loginFilter; import java.io.IOException; import java.lang.reflect.Invoc ...

  9. 自定义ViewPager+RadioGroup联动效果的实现

    package com.loaderman.myviewpager; import android.os.Bundle; import android.support.v7.app.AppCompat ...

  10. 通过TCODE查找SPRO路径

    1.SE11:CUS_ACTOBJ,根据OBJECTNAME(对象名称),即视图名称,获取Customizing activity(ACT_ID) 2.根据ACT_ID在表CUS_IMGACT获取说明 ...