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变得更加不安全了.网络的通信量日益加大,越来越多的重要交易正在通过网络完成,与此同时数据被损坏.截取和修改的风险也在增加. 只要有值得偷窃的东西就会有想办法窃取它的人 ...
随机推荐
- 如何用Sha256进行简单的加密或者解密
个人是今天第一次使用Sha256对数据进行加密操作,以往都是直接使用MD5加密最多也就是加盐之后再进行加密 不过可能是个人应用的只是简单的一个对数据的加密,所以感觉目前和MD5差距并不是很大. 1.首 ...
- 使用Telnet访问端口发送数据
什么是Telnet? 对于Telnet的认识,不同的人持有不同的观点,可以把Telnet当成一种通信协议,但是对于入侵者而言,Telnet只是一种远程登录的工具.一旦入侵者与远程主机建立了Telnet ...
- cropper.js
https://github.com/fengyuanchen/cropper/blob/master/README.md Options See the available options of C ...
- 前端使用pdf.js预览pdf文件,超级简单
现在的浏览器基本都支持直接把pdf文件拖到浏览器就可以打开了,不用安装额外的插件.但是不同的浏览器显示的页面不一样.如果我们想在网页上统一预览pdf怎样实现呢? Mozilla开源了一个插件pdf.j ...
- 使用data_flow_ops构造batch数据集
1. tf.unstack(number, axis=0) 表示对数据进行拆分 import tensorflow as tf import numpy as np data = np.array( ...
- ubuntu下如何检查nvidia显卡驱动是否安装OK?
答:使用sudo lshw -c video即可,笔者的输出如下: jello~$ sudo lshw -c video*-display description: VGA compatible co ...
- cocos creator发布win10全屏缩放问题
当前2.2.1版本cocos creator发布的win32版本不是全屏的, https://forum.cocos.org/t/win-exe/80429 https://blog.csdn.net ...
- Redis ==> 高级
一.发布订阅 Redis 发布订阅(pub/sub)是一种消息通信模式:发送者(pub)发送消息,订阅者(sub)接收消息. Redis 客户端可以订阅任意数量的频道. 下图展示了频道 channel ...
- 利用python列出当前目录下的所有文件
问题 当一个目录下有很多文件夹或者文件,我们想分析各个文件的名字,这时就可以写一个函数,列出当前目录下所有文件名字. 代码 src_dir = r'./' # 源文件目录地址 def list_all ...
- Django>ORM字段和参数
Django之ORM字段和参数 字段 常用字段 AutoField 自增int自增列,必须填入参数 primary_key=True. 当model中如果没有自增列,则自动会创建一个列名为id的列 ...