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