Black Hat Programming Application Python2

[ TOC]

0 x00 Foreword####

Description: Through the study of the first chapter, we have basically mastered the basics of Python for black hat development and programming, let's learn about the scanning, login and identification of services and ports;

0 x01 port service command execution

#! /usr/bin/env python
# - *- coding:utf-8-*-
# description: Use Python to implement SSH command execution and return the execution result, then use pyinstaller to convert to executable exe

import paramiko 
import argparse

if __name__ =='__main__':
 parser = argparse.ArgumentParser(description='ssh commands author: wilson ')
 parser.add_argument('--ip',action="store",required=True,dest="ip",type=str,help='ip')
 parser.add_argument('--user',action="store",required=True,dest="username",type=str,help='username')
 parser.add_argument('--pass',action="store",required=True,dest="password",type=str,help='password')
 parser.add_argument("--port",action="store",required=False,dest="port",type=int,default='22',help='port')
 parser.add_argument("--cmd",action="store",required=False,dest="cmd",type=str,default='w',help='shell command')
 args = parser.parse_args()
 ip = args.ip
 port = args.port
 cmd = args.cmd
 username = args.username
 password = args.password

 try:
  client = paramiko.SSHClient()
  client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  client.connect(ip, port, username=username, password=password, timeout=10)
  stdin, stdout, stderr = client.exec_command(cmd)for std in stdout.readlines():
   print std,
  client.close()
 except Exception as e:
  print e
  pass

Recommended Posts

Black Hat Programming Application Python2
Black hat programming application of Python1
Python network programming
12. Network Programming in Python3
Detailed Python IO programming
Python GUI interface programming
Python black magic metaclass
Talking about Python functional programming
Python programming Pycharm fast learning
Google Python Programming Style Guide
Python3 script programming commonly used.md
Analysis of Python object-oriented programming
XTU programming Python training three
How to understand python object-oriented programming
Python classic programming questions: string replacement