Example #1
0
def main():
    try:
        args, constants = init_variables()
        sock = utils.connect_to_server(args.host, args.port, args.name,
                                       constants)
        if args.smart:
            ply = players.SmartPlayer(args.name, sock)
        elif args.random:
            ply = players.RandomPlayer(args.name, sock)
        else:
            ply = players.SmartPlayer(args.name, sock)
        ply.play()
    except KeyboardInterrupt:
        if constants.connected:
            sock.shutdown(socket.SHUT_RDWR)
            sock.close()
Example #2
0
import utils
import logging
import time

logging.basicConfig(filename='prog.log',
                    filemode='w',
                    format='%(name)s - %(levelname)s - %(message)s',
                    level=logging.INFO)

ip, port = utils.get_args()

client = utils.connect_to_server(ip, port)

login_gen = utils.login_dictionary_gen(
    "C:/Users/Jessica/PycharmProjects/Password Hacker/Password Hacker/task/hacking/logins.txt"
)

pw_gen = utils.pass_gen2()

login = next(login_gen)

pw_accumulator = ''
letter = ''
password = '******'

while True:
    data = utils.json_data(login, password)
    utils.send_data(client, data)
    dict_msg = utils.json_response(utils.receive_data(client))
    msg = dict_msg['result']
Example #3
0
 def _connect(self):
     sftp = utils.connect_to_server()
     return sftp
Example #4
0
def main():
    multicast_sock = init_multicast_socket()

    last_server = load_last_server_info()

    while True:

        print("Gathering server responses...")
        send_discovery(multicast_sock)
        host_list = get_host_list(multicast_sock)
        print(f"Number of available servers: {len(host_list)}")

        if len(host_list) == 0:
            continue

        default_choice = get_default_server(host_list, last_server)

        print("Choose server:")
        print_all_servers(host_list, default_choice)
        choice = input()
        choice = default_choice if choice == "" else choice
        try:
            choice = int(choice)
        except ValueError:
            print("Incorrect choice.")
            continue
        if not 0 <= choice < len(host_list):
            print("Incorrect choice.")
            continue

        print("Enter time request interval (10-1000)[ms]:")
        try:
            repeat_time_interval = int(input())
        except ValueError:
            print("Incorrect request time interval.")
            continue
        if not 10 <= repeat_time_interval <= 1000:
            print("Incorrect request time interval.")
            continue

        try:
            sock = connect_to_server(host=host_list[choice][0], port=host_list[choice][1])
        except ConnectionRefusedError:
            print("Error: Connection refused.")
            continue

        break

    multicast_sock.close()

    with open("last_server.txt", "w") as file:
        file.write(str(host_list[choice]))

    try:
        repeat = True
        while True:
            server_time, delta = download_time(sock)
            print(f"Server time: {server_time}")
            print(f"Client/Server time difference [ms]: {delta}")

            if not repeat:
                sock.send(b"STOP")
                break

            time.sleep(repeat_time_interval / 1000)
            sock.send(b"REPEAT")

    except socket.error:
        print("Communication with server failed.")

    sock.close()
Example #5
0
import sys
import socket
import utils
from PyQt4 import QtGui
from connection import ConnectionWindow

try:
    utils.connect_to_server()
except Exception as e:
    QMessageBox.about(self, 'Erreur', 'Impossible de se connecter au serveur !')

app = QtGui.QApplication(sys.argv)
connWindow = ConnectionWindow(None)
connWindow.show()
app.exec_()
Example #6
0
    def run(self):
        """
        Commence with the registration already.
        """

        # not really required, but probably best that ordinary users don't try
        # to run this not knowing what it does.
        if os.getuid() != 0:
            raise InfoException("root access is required to register")

        print "- preparing to koan home"
        self.conn = utils.connect_to_server(self.server, self.port)
        reg_info = {}
        print "- gathering network info"
        netinfo = utils.get_network_info()
        reg_info["interfaces"] = netinfo
        print "- checking hostname"
        sysname = ""
        if self.hostname != "" and self.hostname != "*AUTO*":
            hostname = self.hostname
            sysname = self.hostname
        else:
            hostname = socket.getfqdn()
            if hostname == "localhost.localdomain":
                if self.hostname == '*AUTO*':
                    hostname = ""
                    sysname = str(time.time())
                else:
                    raise InfoException(
                        "must specify --fqdn, could not discover")
            if sysname == "":
                sysname = hostname

        if self.profile == "":
            raise InfoException("must specify --profile")

        # we'll do a profile check here just to avoid some log noise on the remote end.
        # network duplication checks and profile checks also happen on the remote end.

        avail_profiles = self.conn.get_profiles()
        matched_profile = False
        for x in avail_profiles:
            if x.get("name", "") == self.profile:
                matched_profile = True
                break

        reg_info['name'] = sysname
        reg_info['profile'] = self.profile
        reg_info['hostname'] = hostname

        if not matched_profile:
            raise InfoException(
                "no such remote profile, see 'koan --list-profiles'")

        if not self.batch:
            self.conn.register_new_system(reg_info)
            print "- registration successful, new system name: %s" % sysname
        else:
            try:
                self.conn.register_new_system(reg_info)
                print "- registration successful, new system name: %s" % sysname
            except:
                traceback.print_exc()
                print "- registration failed, ignoring because of --batch"

        return
# Activate the POA
poaManager = poa._get_the_POAManager()
poaManager.activate()

t1 = threading.Thread(target=run_orb)
t1.daemon = True
t1.start()

without_path = True
while without_path:
    try:
        dir_file = raw_input("\nDigite o caminho do diretorio completo:")
        if os.path.exists(os.path.dirname(dir_file)):
            eo.set_path_file(dir_file)
            server = connect_to_server('Server')
            server.connect(name_server, eo.get_file_list())
            without_path = False
        else:
            print("Diretorio nao encontrado!")
    except:
        print("Diretorio nao encontrado!")

running = True
while running:
    os.system('cls' if os.name == 'nt' else 'clear')
    print("\n#########################################################")
    print("#############   GERENCIAMENTO DE ARQUIVOS   #############")
    print("#########################################################")
    print("\n# DIGITE O NUMERO REFERENTE AO QUE DESEJA NO MENU")
    print("1 - Buscar arquivo")
Example #8
0
    def run(self):
        """
        Commence with the registration already.
        """
      
        # not really required, but probably best that ordinary users don't try
        # to run this not knowing what it does.
        if os.getuid() != 0:
           raise InfoException("root access is required to register")
 
        print "- preparing to koan home"
        self.conn = utils.connect_to_server(self.server, self.port)
        reg_info = {}
        print "- gathering network info"
        netinfo = utils.get_network_info()
        reg_info["interfaces"] = netinfo
        print "- checking hostname"
        sysname = ""
        if self.hostname != "" and self.hostname != "*AUTO*":
            hostname = self.hostname
            sysname  = self.hostname
        else:
            hostname = socket.getfqdn()
            if hostname == "localhost.localdomain": 
                if self.hostname == '*AUTO*':
                    hostname = ""
                    sysname = str(time.time())
                else:
                    raise InfoException("must specify --fqdn, could not discover")
            if sysname == "":
                sysname = hostname

        if self.profile == "":
            raise InfoException("must specify --profile")

        # we'll do a profile check here just to avoid some log noise on the remote end.
        # network duplication checks and profile checks also happen on the remote end.

        avail_profiles = self.conn.get_profiles()
        matched_profile = False
        for x in avail_profiles:
            if x.get("name","") == self.profile:
               matched_profile=True
               break
        
        reg_info['name'] = sysname
        reg_info['profile'] = self.profile
        reg_info['hostname'] = hostname
        
        if not matched_profile:
            raise InfoException("no such remote profile, see 'koan --list-profiles'") 

        if not self.batch:
            self.conn.register_new_system(reg_info)
            print "- registration successful, new system name: %s" % sysname
        else:
            try:
                self.conn.register_new_system(reg_info)
                print "- registration successful, new system name: %s" % sysname
            except:
                traceback.print_exc()
                print "- registration failed, ignoring because of --batch"

        return