Linux下应急工具

Linux下的应急工具



在Linux下,应急的查看点无非那个几个,一是看表现(宕机、高CPU、高内存、高IO、高网络通信),二看连接、三看进程、四看日志、五看文件(Linux一切皆文件),再者结合起来看。所以针对常见的应急操作自己写了两个小工具。目前支持CentOS和RedHat,其实由于基于Python,基本是跨平台,绝大部分功能支持其他发行版本的Linux甚至Windows。

工具的安装


#要求root权限
git clone https://github.com/cisp/LinuxEmergency.git
cd LinuxEmergency
sh ./install.sh

工具的使用


查看操作系统信息:


[[email protected] emergency]# python emergency.py -o

        内核版本 : Linux-3.10.0-514.26.2.el7.v7.4.qihoo.x86_64-x86_64-with-centos-7.2.1511-Core
        CORE数量 : 16
        CPU数量 : 16
        CPU使用率 : scputimes(user=1.0, nice=0.0, system=0.0, idle=15.0, iowait=0.0, irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0)
        内存总量  : 33736994816
        内存使用率 : 5.1

[[email protected] emergency]#

查看内核模块信息:


[[email protected] emergency]# python emergency.py -k
内核模块 : nfnetlink_queue  来源  :
内核模块 : nfnetlink_log  来源  :
内核模块 : nfnetlink  来源  :  nfnetlink_log,nfnetlink_queue
内核模块 : bluetooth  来源  :

查看所有登录成功失败的IP地址:


[[email protected] emergency]# python emergency.py -l
192.168.100.35  失败
192.168.100.31  失败
127.0.0.1  失败
192.168.100.20  成功

查看登录成功和失败日志


#  成功的 -s
[[email protected] emergency]# python emergency.py -s | more
账户 : emergency    时间 : 2017-08-09-11:20  来源 : (192.168.100.24)
账户 : emergency    时间 : 2017-08-09-14:34  来源 : (192.168.100.24)
账户 : root    时间 : 2017-09-28-12:38  来源 : (192.168.100.65)
账户 : root    时间 : 2017-09-28-12:46  来源 : (192.168.100.65)
账户 : root    时间 : 2017-09-28-13:13  来源 : (192.168.100.65)

# 失败的 -f
[[email protected] emergency]# python emergency.py -f | more
账户 : emergency    时间 : 192.168.100.34  来源 : Jul-6-21:27---21:27
账户 : emergency    时间 : 192.168.100.34  来源 : Jul-6-21:25---21:25
账户 : admin    时间 : 127.0.0.1  来源 : Jul-5-15:32---15:32

#  如果需要指定IP 加-i参数 ,例如 -i 192.168.100.34;

查看进程列表和详细信息


#  列表信息
[[email protected] emergency]# python emergency.py -a
***********************************************************************************************************
进程ID号: 2     进程名称: kthreadd     进程用户: root     启动时间: 2018-06-16 07:40:48
CPU占比: 0.0%     内存占比: 0.0%
网络连接:
***********************************************************************************************************
***********************************************************************************************************
进程ID号: 3     进程名称: ksoftirqd/0     进程用户: root     启动时间: 2018-06-16 07:40:48
CPU占比: 0.0%     内存占比: 0.0%
网络连接:
***********************************************************************************************************
...

##  详细信息
[[email protected] emergency]# python emergency.py -p 28344
***********************************************************************************************************
进程ID号: 28344     进程名称: screen     进程用户: emergency     启动时间: 2018-06-22 13:25:30
工作路径: /home/emergency/
进程命令: SCREEN
父母进程: 1
亲子进程: [28345]
CPU占比: 0.0%     内存占比: 0.0046135703802%
网络连接:
进程环境:
        终端会话    :  /bin/bash
        安全会话    :
        登录账户    :  emergency
        工作账户    :  emergency
        权限路径    :  /usr/lib64/ccache:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/emergency/tools:/usr/local/bin:/usr/local/sbin:/usr/local/python3/bin:/home/emergency/.local/bin:/home/emergency/bin
        用户目录    :  /home/emergency

***********************************************************************************************************

添加virustotal基本查询功能


# 检查样本
[[email protected] emergency]# python virustotal.py -f ./LICENSE
******************************************
检测时间: 2018-07-09 07:31:04
报毒数量: 0
报毒引擎: []
引擎总数: 59
******************************************

# 检查URL
[[email protected] emergency]# python virustota.py -u http://1.1.1.2/bmi/docs.autodesk.com
******************************************
检测时间: 2018-07-09 16:33:29
关联样本: 0
关联连接: 0
关联域名: 0
******************************************

# 检查域名
[[email protected] emergency]# python virustota.py -d baidu.com
******************************************
检测时间: 2018-07-09 16:33:35
关联样本: 202
关联连接: 100
关联域名: 8
******************************************

# 检查IP
[[email protected] emergency]# python virustota.py -a 114.114.114.114
******************************************
检测时间: 2018-07-09 16:34:05
关联样本: 135
关联连接: 93
关联域名: 592
******************************************

增加查看whois信息的功能


[[email protected] emergency]# python mywhois.py -d baidu.com
Domain Name: baidu.com
Registry Domain ID: 11181110_DOMAIN_COM-VRSN
Registrar WHOIS Server: whois.markmonitor.com
Registrar URL: http://www.markmonitor.com
Updated Date: 2017-07-27T19:36:28-0700
Creation Date: 1999-10-11T04:05:17-0700
Registrar Registration Expiration Date: 2026-10-11T00:00:00-0700
Registrar: MarkMonitor, Inc.
Registrar IANA ID: 292
Registrar Abuse Contact Email: [email protected]
Registrar Abuse Contact Phone: +1.2083895740
Domain Status: clientUpdateProhibited (https://www.icann.org/epp#clientUpdateProhibited)
Domain Status: clientTransferProhibited (https://www.icann.org/epp#clientTransferProhibited)
Domain Status: clientDeleteProhibited (https://www.icann.org/epp#clientDeleteProhibited)
Domain Status: serverUpdateProhibited (https://www.icann.org/epp#serverUpdateProhibited)
Domain Status: serverTransferProhibited (https://www.icann.org/epp#serverTransferProhibited)
Domain Status: serverDeleteProhibited (https://www.icann.org/epp#serverDeleteProhibited)
Registrant Organization: Beijing Baidu Netcom Science Technology Co., Ltd.
Registrant State/Province: Beijing
Registrant Country: CN
Admin Organization: Beijing Baidu Netcom Science Technology Co., Ltd.
Admin State/Province: Beijing
Admin Country: CN
Tech Organization: Beijing Baidu Netcom Science Technology Co., Ltd.
Tech State/Province: Beijing
Tech Country: CN
Name Server: ns4.baidu.com
Name Server: ns3.baidu.com
Name Server: dns.baidu.com
Name Server: ns2.baidu.com
Name Server: ns7.baidu.com
DNSSEC: unsigned
URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/
>>> Last update of WHOIS database: 2018-07-09T02:21:59-0700 <<<

If certain contact information is not shown for a Registrant, Administrative,
or Technical contact, and you wish to send a message to these contacts, please
send your message to [email protected] and specify the domain name in
the subject line. We will forward that message to the underlying contact.

If you have a legitimate interest in viewing the non-public WHOIS details, send
your request and the reasons for your request to [email protected]
and specify the domain name in the subject line. We will review that request and
may ask for supporting documentation and explanation.

The Data in MarkMonitor.com‘s WHOIS database is provided by MarkMonitor.com for
information purposes, and to assist persons in obtaining information about or
related to a domain name registration record.  MarkMonitor.com does not guarantee
its accuracy.  By submitting a WHOIS query, you agree that you will use this Data
only for lawful purposes and that, under no circumstances will you use this Data to:
 (1) allow, enable, or otherwise support the transmission of mass unsolicited,
     commercial advertising or solicitations via e-mail (spam); or
 (2) enable high volume, automated, electronic processes that apply to
     MarkMonitor.com (or its systems).
MarkMonitor.com reserves the right to modify these terms at any time.
By submitting this query, you agree to abide by this policy.

MarkMonitor is the Global Leader in Online Brand Protection.

MarkMonitor Domain Management(TM)
MarkMonitor Brand Protection(TM)
MarkMonitor AntiPiracy(TM)
MarkMonitor AntiFraud(TM)
Professional and Managed Services

Visit MarkMonitor at http://www.markmonitor.com
Contact us at +1.8007459229
In Europe, at +44.02032062220

For more information on Whois status codes, please visit
 https://www.icann.org/resources/pages/epp-status-codes-2014-06-16-en
--

关于web攻击日志的检测


程序下载:


git clone https://github.com/cisp/AccessLogAnylast.git

关于使用:


    parser.add_option("-f", "--floder",dest="filepath",help="access log file path")
    parser.add_option("-t", "--time",dest="accesstime",help="set search time")
    parser.add_option("-d", "--date",dest="accessdate",help="set search date")
    parser.add_option("-c", "--count",action=‘store_true‘,dest="count",help="show count information")
    parser.add_option("-p", "--payload",dest="payload",help="set search payload")
    parser.add_option("-a","--address",dest="ipaddress",help="set search ipaddress")
    parser.add_option("-v", "--version",action=‘store_true‘,dest="version",help="show document")
    parser.add_option("-i","--detail",action=‘store_true‘,dest="detail",help="show detail")
    parser.add_option("-s","--shell",action=‘store_true‘,dest="webshell",help="show suspicious webshell")
    parser.add_option("-g","--ipflag",dest="ipposition",help="ip position in logfile")
    parser.add_option("-n","--name",dest="filename",help="filename flag")

原文地址:https://www.cnblogs.com/KevinGeorge/p/9285883.html

时间: 2024-08-25 06:52:49

Linux下应急工具的相关文章

二十八、Linux下Vim工具常用命令

在linux下做开发,甚至是只做管理维护工作,也少不了Vim的使用.作为一个新手,我也是刚刚接触,本节将我日常使用或收集的Vim常用命令记录下来. 当然,直接在命令行上输入:vimtutor,就可以学习到Vim的所有命令了.Vim很强大,很多牛人在vim里集成很多插件什么的,但这里只介绍基本vim命令 移动命令 h "左 j "下 k "上 l "右 w "光标移动到下一个单词的首字符 a word forward b "光标移动到上一个单词的首

Linux下同步工具inotify+rsync使用详解

Linux下同步工具inotify+rsync使用详解 Posted on 2014-12-12 |  In Linux|  9|  Visitors 438 1. rsync 1.1 什么是rsync rsync是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件.它使用所谓的"Rsync演算法"来使本地和远程两个主机之间的文件达到同步,这个算法只传送两个文件的不同部分,而不是每次都整份传送,因此速度相当快.所以通常可以作为备份工具来使用. 运行Rsync serve

linux下rsync工具使用与配置

这篇文章基本介绍全了:http://www.2cto.com/os/201308/238733.html 几点简单备忘: 1. ubuntu下通过apt-get即可安装: 2. 配置文件/etc/rsync.conf默认不存在,需要手动创建: 3. 可以通过守护进程xinetd来启动rsync,在/etc/default/rsync中配置: 4. 服务器在/etc/rsync.passwd中配置登录名和密码,不一定非得这个文件,可以在/etc/rsync.conf中配置每一个共享模块的密码文件:

linux如何ARP嗅探 Linux下嗅探工具Dsniff安装记录

先来下载依赖包 和一些必须要用到的工具 我这里用的是 dsniff-2.3 的版本 wget http://www.monkey.org/~dugsong/dsniff/dsniff-2.3.tar.gz wget http://www.8090sec.com/uploads/soft/dsniff-2.3.tar.gz 备用下载 一.安装gcc # yum -y install gcc 二.安装 openssl 直接yum安装也可以的 # tar zxvf openssl-0.9.7i.tar

linux下rsync工具的使用

上节我们详细了解了磁盘的结构和磁盘的管理,我们知道Linux磁盘的管理是通过fdisk命令加参数来实现的,然后格式化是mkfs.ext4命令.最后在通过mount命令挂载到相应的目录下就可以使用了.今天我们讲解一个比较常用的工具-rsync.记得是比较常用!下面我为他做个简单的介绍: rsync是一个备份工具可以实现增量与全量备份 rsync 有三种工作模式 第一种是本地的CP 使用方法: cp功能: rsync -avzfenfawenjian fenfawenjian2 第二种是局域网之间的

linux下常用工具安装

1.安装rz sz上传下载   yum install lrzsz 2.安装jdk 下载jdk放在指定目录 vim /etc/profileexport JAVA_HOME=linux下jdk路径export PATH=$PATH:$JAVA_HOME/binsource /etc/profileecho $PATH 3.安装mysql数据库 MySQL-client-5.6.21-1.rhel5.x86_64.rpm MySQL-devel-5.6.21-1.rhel5.x86_64.rpm

Linux下SSH工具 PAC Manager的安装

PAC Manager, Liux下类似SecureCRT Xshell的SSH工具,该工具功能上相当的不错,完全可以代替SecureCRT Xshell的功能. PAC (Perl Auto Connector) Manager is a open source tool in Linux like operating system, which provides GUI (graphical user interface) to manage ssh,telnet, sftp, rdeskt

linux下 htop 工具简介

今天我们介绍一下 htop 工具的使用,这是个很实用的工具,可以查看系统进程.cpu占用率,内存使用等情况. 对于我们运维人员来说使用它可以快速定位是哪一个进程造成了系统堵塞:哪些进程长期霸占了CPU使得任务队列过长:哪些进程处于僵死状态没办法退出内存造成内存溢出. htop是实时显示系统情况的,不同于ps.pstree.pidof.vmsta等这些快照工具,快照工具只能显示命令执行前一秒系统的情况.htop 对关键信息实行高亮显示,对于我们用肉眼查看进程信息的情况还是很友好的.再写这篇博客前我

linux下性能测试工具netperf使用

一.功能简介 netperf是一款针对网络性能的测试工具,主要基于TCP或UDP的传输.根据应用的不同,可以进行批量数据传输(bulk data transfer)模式和请求/应答(request/reponse)模式的性能测试. netperf以Client/Server方式工作.Server端是netserver,用来侦听来自client端的连接,Client端是netperf,用来向Server发起网络测试.在Client与Server之间,首先建立一个控制连接,传递有关测试配置的信息,以