批量升级 CentOS bash

#! /usr/bin/env python
#coding=utf-8
 
from fabric.api import *
from fabric.state import *
 
env.roledefs = {
    'scan_proc_server': [
                         '172.16.1.15',
                         '172.16.1.12',
                         '172.16.1.18',
                         '172.16.1.19',
                         '172.16.1.10',
                         '172.16.1.11',
                         '172.16.1.12',
                         '172.16.1.13',
                         '172.16.1.14',
                         '172.16.1.15',
                         '172.16.1.16',
                         '172.16.1.17',
                         '172.16.1.18',
                         '172.16.1.19',
                        # '172.16.1.14',
                         '172.16.1.101',
                         '172.16.1.102',
                         '172.16.1.103',
    ],
    'storage_server':[
        '172.16.1.100'
        ],
    'auto_server':[
        ],
}
 
env.user='root'
env.password = '******'
 
 
@roles('scan_proc_server')
def task_scan_source():
    run('mkdir /dev/shm/chan/')
    put('./chan/', '/dev/shm/')
    with cd('/dev/shm/chan/'):
        run('python2.6 change_netmask.py')
 
@roles('scan_proc_server')
def update_bash():
    run('rpm -ivh http://172.16.1.250:60001/packages/bash-4.1.2-15.el6_5.2.x86_64.rpm --force')
    run("env x='() { :;}; echo vulnerable' bash -c "echo this is a test"")
 
 
def dotask():
    execute(update_bash)
 
if __name__ == '__main__'
    dotask()
原文地址:https://www.cnblogs.com/L-H-R-X-hehe/p/4025273.html