Beispiel #1
0
def sayPerson():
    c.send(getpass.getUser()+' could be? REGULAR HUMAN - says the KGB',outPipe)    
Beispiel #2
0
def sayWitch():
    c.send(getpass.getUser()+' seems like maybe a wolf/human combo - says the KGB',outPipe)    
Beispiel #3
0
def sayWolf():
    c.send(getpass.getUser()+' MAYBE IS MAYBE MUCH WOLF - says the KGB',outPipe)    
Beispiel #4
0
import logging
import http.server
import socketserver
import getpass


class MyHTTPHandler(http.server.SimpleHTTPRequestHandler):
    def log_message(self, format, *args):
        logging.info(
            "%s - - [%s] %s\n" % (self.client_adress[0],
                                  self.log_date_time_string(), format % args))


logging.basicConfig(filename='/log/http-server.log',
                    format='%s(asctime)s - %(levelname)s - %(message)s',
                    level=logging.INFO)
logging.getLogger().addHandler(logging.StreamHandler())
logging.info('inicializando...')
PORT = 8000

httpd = socketserver.TCPServer(("", PORT), MyHTTPHandler)
logging.info('Escutando a porta: %s', PORT)
logging.info('Usuário: %s', getpass.getUser())
httpd.server_forever()
Beispiel #5
0
import logging
import http.server
import socketserver
import getpass

class MyHttpHandler(http.server.SimpleHTTPRequestHandler):
    def log_message(self, format, *args):
        logging.info("%s - - [%s] %s\n"% (
            self.client_address[0],
            self.log_date_time_string(),
            format%args
        ))

logging.basicConfig(
    filename='/log/http-server.log',
    format='%(asctime)s - %(levelname)s - %(message)s', 
    level=logging.INFO
)

logging.getLogger().addHandler(logging.StreamHandler())
logging.info('inicializando...')
PORT=8000

httpd = socketserver.TCPServer(("", PORT), MyHttpHandler)
logging.info('escutando a porta: %s', PORT)
logging.info('user: %s', getpass.getUser())
httpd.serve_forever()
Beispiel #6
0
    def server_thread_func():
        while True:
            client = None
            raw_client = None
            try:
                client, addr = server.accept()
                if certfile:
                    client = ssl.wrap_socket(client,
                                             server_side=True,
                                             ssl_version=ssl.PROTOCOL_TLSv1,
                                             certfile=certfile,
                                             keyfile=keyfile)
                write_bytes(client, PTVSDBG)
                write_int(client, PTVSDBG_VER)

                response = read_bytes(client, 7)
                if response != PTVSDBG:
                    continue
                dbg_ver = read_int(client)
                if dbg_ver != PTVSDBG_VER:
                    continue

                client_secret = read_string(client)
                if secret is None or secret == client_secret:
                    write_bytes(client, ACPT)
                else:
                    write_bytes(client, RJCT)
                    continue

                response = read_bytes(client, 4)

                if response == INFO:
                    try:
                        pid = os.getpid()
                    except AttributeError:
                        pid = 0
                    write_int(client, pid)

                    exe = sys.executable or ''
                    write_string(client, exe)

                    try:
                        username = getpass.getUser()
                    except AttributeError:
                        username = ''
                    write_string(client, username)

                    try:
                        impl = platform.python_implementation()
                    except AttributeError:
                        try:
                            impl = sys.implementation.name
                        except AttributeError:
                            impl = 'Python'

                    major, minor, micro, release_level, serial = sys.version_info

                    os_and_arch = platform.system()
                    if os_and_arch == "":
                        os_and_arch = sys.platform
                    try:
                        if sys.maxsize > 2**32:
                            os_and_arch += ' 64-bit'
                        else:
                            os_and_arch += ' 32-bit'
                    except AttributeError:
                        pass

                    version = '%s %s.%s.%s (%s)' % (impl, major, minor, micro,
                                                    os_and_arch)
                    write_string(client, version)

                    # Don't just drop the connection - let the debugger close it after it finishes reading.
                    client.recv(1)

                elif response == ATCH:
                    debug_options = vspd.parse_debug_options(
                        read_string(client))
                    if redirect_output:
                        debug_options.add('RedirectOutput')

                    if vspd.DETACHED:
                        write_bytes(client, ACPT)
                        try:
                            pid = os.getpid()
                        except AttributeError:
                            pid = 0
                        write_int(client, pid)

                        major, minor, micro, release_level, serial = sys.version_info
                        write_int(client, major)
                        write_int(client, minor)
                        write_int(client, micro)

                        vspd.attach_process_from_socket(client,
                                                        debug_options,
                                                        report=True)
                        vspd.mark_all_threads_for_break(
                            vspd.STEPPING_ATTACH_BREAK)
                        _attached.set()
                        client = None
                    else:
                        write_bytes(client, RJCT)

                elif response == REPL:
                    if not vspd.DETACHED:
                        write_bytes(client, ACPT)
                        vspd.connect_repl_using_socket(client)
                        client = None
                    else:
                        write_bytes(client, RJCT)

            except (socket.error, OSError):
                pass
            finally:
                if client is not None:
                    client.close()