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变得更加不安全了.网络的通信量日益加大,越来越多的重要交易正在通过网络完成,与此同时数据被损坏.截取和修改的风险也在增加. 只要有值得偷窃的东西就会有想办法窃取它的人 ...
随机推荐
- arxiv-sanity使用指南
使用介绍 https://bookdown.org/wshuyi/intro-to-scientific-writings4/reading.html#find-article-with-ai
- js上传图片获取原始宽高
以vue上传图片为例: <template> <div> <input type="file" @change="uploadFile($e ...
- su: Authentication failure 的解决方法
su命令不能切换root,提示su: Authentication failure 原因是 没有设置过 root密码 sudo passwd root 会提示输入密码 重新输入密码 下次再su的时候只 ...
- css垂直居中布局总结
简介 总结记录一下经常需要用到垂直居中布局,欢迎补充(空手套...O(∩_∩)O) 以下栗子如果未特别标注同一使用这样的html结构 <div class="container&quo ...
- C# async await and state machine
Async Await and the Generated StateMachine https://www.codeproject.com/Articles/535635/Async-Await-a ...
- Flyway:数据库版本迁移工具的介绍
目录 Flyway介绍 Flyway的工作模式 Flyway的使用场景 命令行 使用Maven或Gradle插件 migrate clean info validate baseline Java A ...
- mongdb group聚合操作
1.数据准备 [{"goods_id":1,"cat_id":4,"goods_name":"KD876"," ...
- 六十六:CSRF攻击与防御之CSRF防御之ajax防御和ajax封装
app里面还是要绑定CSRFProtect from flask_wtf import CSRFProtect # flask_wtf 已经提供CSRF的防御手段CSRFProtect(app) # ...
- spring boot 整合redis
spring boot 中配置redis1 在pom.xml中增加相关包依赖:<dependency> <groupId>org.springframework.boot< ...
- 在web项目中获取ApplicationContext上下文的3种主要方式及适用情况
最近在做web项目,需要写一些工具方法,涉及到通过Java代码来获取spring中配置的bean,并对该bean进行操作的情形.而最关键的一步就是获取ApplicationContext,过程中纠结和 ...