Linux安全审计
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安全审计的更多相关文章
- Linux安全审计命令
安全审计 数据分析 capinfos xxx.pcap 产看数据包基本信息 日志分析 who /var/log/wtmp #查看登录用户信息 哈希校验 sha265 文件名 md5sum 文件名 &g ...
- Linux安全审计-基础篇
安全审计这块我能想到的有两种方案可以解决,一种是在Linux中配置实现,一种是使用Python开发堡垒机实现,我先实现了第一种比较简单的:后面会开发堡垒机: 一.首先我们需要在/etc/profi ...
- Linux服务器安全审计工具与流程完全指南
http://Linux.chinaitlab.com/server/860516.html 当今许多linux服务器都不是刚刚部署完毕的新机器,有专业的Linux系统管理员进行定期维护,IT技术人员 ...
- Linux 驱动开发
linux驱动开发总结(一) 基础性总结 1, linux驱动一般分为3大类: * 字符设备 * 块设备 * 网络设备 2, 开发环境构建: * 交叉工具链构建 * NFS和tftp服务器安装 3, ...
- Linux audit安全审计工具
/********************************************************************** * Linux audit安全审计工具 * 说明: * ...
- 详解Linux开源安全审计和渗透测试工具Lynis
转载自FreeBuf.COM Lynis是一款Unix系统的安全审计以及加固工具,能够进行深层次的安全扫描,其目的是检测潜在的时间并对未来的系统加固提供建议.这款软件会扫描一般系统信息,脆弱软件包以及 ...
- linux系统安全审计简单设置
应用安全-安全审计日志目录 /var/log/audit/audit.log [root@localhost audit]# cd /etc/audit/[root@localhost audit] ...
- Linux操作系统之安全审计功能
内核编译时,一般打开NET选项就打开AUDIT选项了.在系统中查看audit是否打开,root 用户执行:service auditd status 我们知道在Linux系统中有大量的日志文件可以用于 ...
- LINUX安全加固规范
1 概述 近几年来Internet变得更加不安全了.网络的通信量日益加大,越来越多的重要交易正在通过网络完成,与此同时数据被损坏.截取和修改的风险也在增加. 只要有值得偷窃的东西就会有想办法窃取它的人 ...
随机推荐
- 我要学习Python
现在是2017年6月7号北京时间20点57分,不知道从什么时候我想学习Python了,我现在做的工作是运维工程师,为了成为一个优秀点的运维人员,也为了以后能有更好的发展机会,我想学习一下Python, ...
- Hbase底层解析
hfile+compaction 原理 用户数据写入先写WAL,再写缓存,满足一定条件后缓存数据会执行flush操作真正落盘,形成一个数据文件HFile.太多数据文件会导致数据查询IO次数增多,因 ...
- 在CentOS 7上搭建WordPress
环境(ECS阿里云服务器) 服务器操作系统:CentOS 7.3 : 博客部署服务器:Apache HTTP: 数据库:MySql: 框架:WordPress: 步骤 一.安装 Apache HTTP ...
- JVM-GC算法(一)-标记清除算法
首先,我们得知道根搜索算法,它可以解决我们应该回收哪些对象的问题,但是它显然还不能承担垃圾搜集的重任,因为我们在程序(程序也就是指我们运行在JVM上的JAVA程序)运行期间如果想进行垃圾回收,就必须让 ...
- (七)C语言之顺序结构
- VNC Viewer配置
VNC概述 VNC (Virtual Network Computing)是虚拟网络计算机的缩写.VNC 是一款优秀的远程控制工具软件,由著名的 AT&T 的欧洲研究实验室开发的.VNC 是在 ...
- mongo数据库的使用
mongodb 是一个非关系型数据库,跟每一个数据库都没有关系,(mysql 是一个关系型数据库)他以集合(collections)问单位,他长得和 json 一样 mongo 数据库的下载,安装 自 ...
- Leaflet - 实现按照路径方向旋转的 Marker
在每帧动画时设置 Marker 的 transform 属性就行,zjffun/Leaflet.MovingMarker at zjf/feature-rotate 我在这个 Fork 中实现了一下. ...
- 数据中心网络架构的问题与演进 — Overlay 网络
目录 文章目录 目录 前文列表 数据中心网络架构演进回顾 Overlay 网络 Overlay 网络的优势 基于 VxLAN Overlay 的 Spine-Leaf 网络架构 参考文章 前文列表 & ...
- 小D课堂 - 零基础入门SpringBoot2.X到实战_第14节 高级篇幅之SpringBoot多环境配置_59、SpringBoot多环境配置介绍和项目实战
笔记 1.SpringBoot多环境配置介绍和项目实战(核心知识) 简介:SpringBoot介绍多环境配置和使用场景 1.不同环境使用不同配置 例如数据库配置,在开发的时候, ...