Python bulk modifies securecrt session password

Source: Internet
Author: User

Tag:python   crt   securecrt    bulk change password    

#利用python批量修改SecureCRT   Session Password # -*- coding:utf-8 -*-import os,redef crt_path (path,* Args,**kwargs):    for  (dirpath, dirnames, filenames)  in os.walk ( Path):        for file in filenames:             fullname = os.path.join (Dirpath, file)             f1 = open (FullName, ' R ', encoding= "Utf-8")             alllines =  F1.readlines ()             f1.close ()              f2 = open (fullname,  ' W ', encoding= " Utf-8 ")             pw_r = re.compile (R ' ( "Password v2" =) (.*) '             if  ' admin '  in  alllines[0]:  #  determine if the username is admin (can be modified as needed)                  for eachline in alllines:                     a =  Re.sub (Pw_r, ' \g<1> ' +admin_pwd,eachline)                      f2.writelines (a)              elif  ' Root '  in alllines[0]: # Determine if the user name is root (can be modified as needed), there are other additions to the line                  for eachline in alllines:                  &Nbsp;  a = re.sub (Pw_r, ' \g<1> ' +root_pwd,eachline)                      f2.writelines (a)             else:                 f2.writelines (Alllines)              f2.close () if __name__ ==  ' __main__ ':     # admin  password encryption string     admin_pwd =  ' Xxooxxoo '     # root  password encryption string     root_pwd =  ' Xxooxxooxxoo '     path = r ' C:\Users\root\Desktop\Sessions '   # crt seesions   Path

GitHub Link Address:

https://github.com/babyshen/Python/blob/master/%E6%89%B9%E9%87%8F%E4%BF%AE%E6%94%B9SecureCRT%E5%AF%86%E7%A0%81.py

This article is from the "Baby God" blog, make sure to keep this source http://babyshen.blog.51cto.com/8405584/1873322

Python bulk modifies securecrt session password

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.