Example #1
0
    def run_smb_server(self, smb_shares):
        # We cannot use MOSDEF sockets with this
        s = sock.socket(sock.AF_INET, sock.SOCK_STREAM)
        s.setsockopt(sock.SOL_SOCKET, sock.SO_REUSEADDR, 1)

        server = libsmb.SMBServer(s)
        for (share_path, local_path) in smb_shares.iteritems():
            logging.info("added share %s (maps to %s)" %
                         (share_path, local_path))
            server.add_share(share_path, local_path)

        try:
            server.listen()

            while self.state != self.HALT:
                # logging.info("checking for halt")
                try:
                    while (server.accept()
                           == True) and (self.state != self.HALT):
                        logging.info("Serving client request")
                except libsmb.SMBServerException as h:
                    if "timed out" in str(h):
                        pass
                    else:
                        raise
                except:
                    raise
        except Exception as e:
            print e
        logging.info("Shutting down SMB server")
        server.shutdown()
Example #2
0
    def run(self):
        self.exploit.log("Starting SMB server")
        SHARES = {
            u'D2': os.getcwd() + u'/3rdparty/D2SEC/exploits/d2sec_kingview/d2'
        }

        self.exploit.smblock.acquire()
        self.exploit.smbinit = 1
        self.exploit.smblock.release()

        try:
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            server = libsmb.SMBServer(s)
            for k, v in SHARES.items():
                server.add_share(k, v)

            server.listen()
            while server.accept() == True:
                pass

        except Exception, ex:
            import traceback
            traceback.print_exc()
            server.shutdown()
Example #3
0
import logging
import socket as sock

if "." not in sys.path:
    sys.path.append('.')

import libs.newsmb.libsmb as libsmb

SHARES = {u'LALA': u'/tmp/lala', 'IPC$': None}

if __name__ == '__main__':

    if len(sys.argv) > 1 and sys.argv[1] == '-v':
        logger = logging.getLogger()
        logger.setLevel(logging.DEBUG)

    try:
        s = sock.socket(sock.AF_INET, sock.SOCK_STREAM)
        s.setsockopt(sock.SOL_SOCKET, sock.SO_REUSEADDR, 1)
        server = libsmb.SMBServer(s)
        for k, v in SHARES.items():
            server.add_share(k, v)

        server.listen()
        while server.accept() == True:
            pass
    except Exception, ex:
        import traceback
        traceback.print_exc()
        server.shutdown()