示例#1
0
 def remote_connection(self):
     try:
         conn = Client(self.ip,
                       'administrator',
                       'interOP@123sys',
                       encrypt='False')
         conn.connect()
         return conn
     except Exception as e:
         print('Below exception occured .....\n')
         print(e)
         print()
示例#2
0
    def ConsultaUsuarioAD(self, servidor, usuario, senha, user):
        c = Client("%s" % servidor,
                   username="******" % usuario,
                   password="******" % senha)
        c.connect()

        try:
            c.create_service()
            stdout, stderr, rc = c.run_executable("cmd.exe",
                                                  arguments="/c net user %s" %
                                                  user)
            arquivo = open("user.txt", "wb")
            arquivo.write(stdout)
            arquivo.close()
            os.system("cat user.txt")

        finally:
            c.remove_service()
            c.disconnect()
示例#3
0
def msg(bot, update, args):
    """send message to terminal users"""
    if not args:
        update.message.reply_text(
            'Empty message string\nUsage: /msg <message>')
    else:
        separator = ' '
        arguments = '* %s' % (separator.join(args))
        for server in SERVERS:
            c = Client(server,
                       username=MSGUSERNAME,
                       password=MSGPASSWORD,
                       encrypt=True)
            c.connect()
            try:
                c.create_service()
                result = c.run_executable(EXECUTABLE, arguments=arguments)
            finally:
                c.remove_service()
                c.disconnect()

        #print("STDOUT:\n%s" % result[0].decode('utf-8') if result[0] else "")
        #print("STDERR:\n%s" % result[1].decode('utf-8') if result[1] else "")
        print("RC: %d" % result[2])
示例#4
0
import pandas as pd
import paramiko
from pypsexec.client import Client

# Read data from csv
data = pd.read_csv("demo.csv", sep="\t")

for index, row in data.iterrows():
    host = row["Hostname"]
    username = row["Username"]
    password = row["password"]
    try:
        #Windows Login
        c = Client(host,
                   username=username,
                   password=password,
                   encrypt=False,
                   port=3389)
        c.connect()
        try:
            stdout = c.run_executable("cmd.exe", arguments="systeminfo")
        finally:
            c.disconnect()
        output = []
        output = stdout[0].decode("utf-8")
        print(output.split("\r\n")[1:3])
    except:

        #Linux Login
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
from pypsexec.client import Client
import os
import time
import sys
funcao = sys.argv[1]
usuario = sys.argv[2]

if funcao == "ativar":
    c = Client("192.168.0.1", username="******", password="******", encrypt=False, port=445)
    c.connect()

    try:
            c.create_service()
            stdout = c.run_executable("cmd.exe", arguments="/c net user "+str(usuario)+" /ACTIVE:YES /domain")
            #saida = stdout[0].decode("utf-8")
            #print(str(saida))
            for item in stdout:
                    print(item)
            sys.exit()
    except KeyboardInterrupt:
            c.cleanup()
            c.remove_service()
            c.disconnect()
elif funcao == "desativar":

    c = Client("192.168.0.1", username="******", password="******", encrypt=False, port=445)
    c.connect()

    try:
            c.create_service()
            stdout = c.run_executable("cmd.exe", arguments="/c net user "+str(usuario)+" /ACTIVE:NO /domain")