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变得更加不安全了.网络的通信量日益加大,越来越多的重要交易正在通过网络完成,与此同时数据被损坏.截取和修改的风险也在增加. 只要有值得偷窃的东西就会有想办法窃取它的人 ...
随机推荐
- (五)C语言之表达式
- TCP连接建立 之 同时打开
假设两台设备双方均发送syn给对端,在发送syn之后状态处于SYN_SENT状态,此时双方均收到对端的发来的syn,则立即进入SYN_RECV状态,并且都向对端回复syn+ack,在收到syn+ack ...
- 12 Linux ACL权限
1.查看facl权限 getfacl /home/test.txt [root@localhost ~]# getfacl /home/test.txt getfacl: Removing leadi ...
- Nginx事件管理之定时器事件
1. 缓存时间 1.1 管理 Nginx 中的每个进程都会单独地管理当前时间.ngx_time_t 结构体是缓存时间变量的类型: typedef struct { /* 格林威治时间1970年1月1日 ...
- PL/SQL的命令行窗口中执行脚本
注意脚本路径中不能有空格, 格式如下:SQL>@D:\1211_Export\all.sql 备注: @后面接本地sql文件的路径及执行文件
- ftp相关
已经存在虚拟账户 添加新账户 .在/etc/vsftpd/user.txt里面配置用户名密码 单行是用户名 双行是密码 .导入新用户密码 db_load -T -t hash -f /etc/vsft ...
- springboot非web项目
使用CommandRunner @SpringBootApplication public class CrmApplication implements ApplicationRunner { @A ...
- Hadoop : MapReduce中的Shuffle和Sort分析
地址 MapReduce 是现今一个非常流行的分布式计算框架,它被设计用于并行计算海量数据.第一个提出该技术框架的是Google 公司,而Google 的灵感则来自于函数式编程语言,如LISP,Sch ...
- fastjson反序列化LocalDateTime失败的问题java.time.format.DateTimeParseException: Text '2019-05-24 13:52:11' could not be parsed at index 10
本地java类 import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; ...
- API接口设计的五大公共参数
1.平台参数 2.操作系统参数 iOS.Android.PC等等 3.软件版本参数 4.udid号(设备唯一ID) 每个设备都会有一个唯一udid 5.渠道号 app软件从那个渠道下载