学完python后需要学以致用,但平时还真没有这个环境,也不搞自动化,但语言这玩意必需要用,就拿secureCRT来练手吧,也算是和工作擦点边

对话框加按扭

CONFIRM_REPLACE = """\ #为数不多的button判断

Do you want to replace the contents of "%(FILE)s" with the selected text?

Yes = overwrite

No = append

Cancel = end script"""

message = CONFIRM_REPLACE % { 'FILE' : "filename" }

prompt = "Replace contents"

buttons = BUTTON_YESNOCANCEL

result = crt.Dialog.MessageBox(message, prompt, buttons)

if result == IDYES:

fileMode = "w"

elif result == IDNO:

fileMode = "a"

crt.Dialog.Prompt( #超级有用的在用户这获取数据的方式

"Save selected text to File:",

"SecureCRT - Save selected text to file",

"MyFile.txt")

获取log文件名在SecureCRT

tab = crt.GetScriptTab()

tab.Session.LogFileName

#如果在CRT中设置了log文件名,这个函数可以把它读取出来

#可以直接取到log的文件名 获取系统当前的前缀名

SCRIPT_TAB = crt.GetScriptTab()

rowIndex = SCRIPT_TAB.Screen.CurrentRow

colIndex = SCRIPT_TAB.Screen.CurrentColumn - 1

prompt = SCRIPT_TAB.Screen.Get(rowIndex, 0, rowIndex, colIndex)

#获取当前行,当前列的数据,即该服务器的前缀,与waitfor配套

prompt = prompt.strip()

获取打印值

def CaptureOutputOfCommand(command, prompt):

if not crt.Session.Connected:

return "[ERROR: Not Connected.]"

# First, send the command to the remote.

SCRIPT_TAB.Screen.Send(command + '\r')

#输入命令 cmmand 然后回车

# Second, wait for the carriage return to be echoed by the remote device.

# This allows us to capture only the output of the command, not the line

# on which the command was issued (which would include the prompt + cmd).

# If you want to capture the command that was issued, simply comment out

# the following line of code.

SCRIPT_TAB.Screen.WaitForString('\r'

#等待命令输完后,服务器给的回应,这样可以不是获取行,而是获取输出

# Now that the command has been sent, use Screen.ReadString to capture

# all the data that is received up to the point at which the shell

# prompt appears (the captured data does not include the shell prompt).

return SCRIPT_TAB.Screen.ReadString(prompt)

#获取直到prompt出现时的所有数据

屏幕取词

filename = os.path.join(os.path.expanduser('~'), 'output.txt') #~/output.txt

fp = open(filename, "wb+")

screenrow = crt.Screen.CurrentRow - 1

readline = crt.Screen.Get(screenrow, 1, screenrow, 20)

#把当前行的1~20个字符取出来

fp.write(readline + os.linesep)

#把取出的那一行加行尾符写到文件中

写到excel

import os

import csv #excel module

fileobj = open(filename, 'wb')

worksheet = csv.writer(fileobj)

worksheet.writerow(items[:2])

fileobj.close(

连接

SSH:

cmd = "/SSH2 /L %s /PASSWORD %s /C 3DES /M MD5 %s" % (user, passwd, host)

crt.Session.Connect(cmd) #ssh -L user password host

Telnet:

crt.Session.Connect("/TELNET 127.0.0.1 2034") # telnet 127.0.0.1:2034

crt.Session.Connect("/S \"" + session + "\"")

#如果这个session在CRT里存在,无论是Telnet还是SSH都能连

调试工具 CRT中的print

crt.Dialog.MessageBox("Nothing to save!")

参考:

http://www.vandyke.com/support/securecrt/python_examples.html

crt python_SecureCRT Python相关推荐

  1. python 列表比较不同物质的吸热能力_飘着雪花的冬天

    这两天在折腾这个问题,google中英文的介绍都只提到一部分,所以决定写一篇blog讲一下整个配置过程,全当做笔记. SSL连接(HTTPS)是普遍使用的安全的HTTP连接方式,它通过证书认证的方式来 ...

  2. SecureCRT python 脚本

    记录编写CRT的python脚本遇到的问题 向CRT的脚本传递参数的两种方式 一种是命令行的方式 /path/CRT.exe <filename>.py /ARG arguments  / ...

  3. SecureCRT自动化脚本

    本文目录 脚本文件头 crt的属性 Dialog 介绍 Dialog的方法 FileOpenDialog MessageBox Prompt Screen 介绍 Screen的属性 CurrentCo ...

  4. 远控免杀专题(16)-Unicorn免杀

    0x01 免杀能力一览表 几点说明: 1.上表中标识 √ 说明相应杀毒软件未检测出病毒,也就是代表了Bypass. 2.为了更好的对比效果,大部分测试payload均使用msf的windows/met ...

  5. 远控免杀专题(16)-Unicorn免杀(VT免杀率29/56)

    声明:文中所涉及的技术.思路和工具仅供以安全为目的的学习交流使用,任何人不得将其用于非法用途以及盈利等目的,否则后果自行承担! 本专题文章导航 1.远控免杀专题(1)-基础篇:https://mp.w ...

  6. 星河杯“黑名单共享查询”赛题基于隐语实现baseline

    赛题情况介绍 星河杯隐私计算大赛"黑名单共享查询-多方安全计算"赛题,要求参赛者基于多方安全计算技术实现多家企业黑名单数据的安全共享查询功能,完成以下两项任务: 计算两方黑名单ID ...

  7. 实战: unicorn生成免杀木马,绕过win10防火墙和windows defender

    实战: unicorn生成免杀木马,绕过win10防火墙和windows defender 简介 原理 步骤 攻击 总结 简介 随着操作系统的安全等级越来越高,对能免杀,无视防火墙的木马需求也越来越高 ...

  8. python调用crt自动登录_Python 脚本实现 SecureCRT 命令自动化

    摘要 因为在串口交互中,SecureCRT使用的频率是比较高的,因此我们就用这个工具来实现脚本自动化,现在分享一个简单的,就是每一秒钟发送一条命令即可. 为了获取数据,需要一秒钟输入一条命令,持续可能 ...

  9. python中国余数定理_中国剩余定理CRT(孙子定理)

    则解为$x\equiv(a_1M_1M_1^{-1}+a_2M_2M_2^{-1}+--+a_nM_nM_n^{-1})mod\ M$ 证明: 因为$x\equiv(a_iM_iM_i^{-1})mo ...

最新文章

  1. @Ignore_JUnit - Ignore Test
  2. ethercard php_使用Arduino和ENC28J60以太网LAN网络模块发送HTTP POST请求
  3. 记一次ssh登录异常
  4. bzoj 2809 Apio2012 dispatching
  5. 其他系统 对外接口设计_领导:项目有个接口要对外开放,小张你来设计一下?...
  6. 调试实战 | 通过转储文件分析程序无响应之使用 windbg + IDA 逆向篇
  7. kafka rabbitmq优劣对比_Kafka、RabbitMQ、RocketMQ等消息中间件的对比
  8. cte sql_为什么我的CTE这么慢?
  9. JAVA代码实现hive连接mysql_Java采用JDBC的方式连接Hive(SparkSQL)
  10. H264/AVC-NALU解析
  11. 霍尔电流传感器ACS758/ACS770/CH704应用于三相四桥臂逆变器的电流检测装置
  12. mysql和虚拟主机区别_虚拟主机mysql
  13. Python 爬取微博热搜页面
  14. 网易云课堂课程下载教程
  15. UFS 3.1协议分析(第一至四章) -- UFS概述
  16. 2020-04-13
  17. python opencv 入门 绘图函数 (3)
  18. java音频剪切_Java使用IO流实现音频的剪切和拼接
  19. Openstack 虚拟机云盘扩容
  20. python编写sql注入工具毕业设计_Python编写SQL注入工具(2)

热门文章

  1. Getting Started with Node.js LoopBack Framework and IBM Cloudant
  2. ISP_MPLS *** 理论笔记
  3. java编写提升性能的代码
  4. Linux -- ***检测系统(IDS)介绍及应用(1)
  5. ZOJ-2571 Big String Outspread 模拟
  6. 【每日算法】C语言8大经典排序算法(2)
  7. Spring中IoC的入门实例
  8. Hadoop伪集群环境搭建
  9. java集合框架类源代码阅读体会
  10. JAVA线程池(ThreadPoolExecutor)源码分析