def start(self): SMTPServer.__init__( self, ('0.0.0.0', 25), None ) asyncore.loop()
def start(self): SMTPServer.__init__(self, ('0.0.0.0', 465), None, require_authentication=True, ssl=True, certfile='examples/server.crt', keyfile='examples/server.key', credential_validator=FakeCredentialValidator(), maximum_execution_time=1.0) asyncore.loop()
def __init__(self, *args, **kwargs): self.ssl_out_only = False if kwargs.has_key('ssl_out_only'): self.ssl_out_only = kwargs.pop('ssl_out_only') self.debug = False if kwargs.has_key('debug'): self.debug = kwargs.pop('debug') kwargs['credential_validator'] = StoreCredentials() SMTPServer.__init__(self, *args, **kwargs)
def start(self): SMTPServer.__init__( self, ('0.0.0.0', 465), None, require_authentication=True, ssl=True, certfile='examples/server.crt', keyfile='examples/server.key', credential_validator=FakeCredentialValidator(), maximum_execution_time = 1.0 ) asyncore.loop()
def __init__(self, localaddr, remoteaddr, ssl=False, certfile=None, keyfile=None, ssl_version=ssl.PROTOCOL_SSLv23, require_authentication=False, credential_validator=None, maximum_execution_time=30, process_count=5): SMTPServer.__init__(self, localaddr, remoteaddr, ssl, certfile, keyfile, ssl_version, require_authentication, credential_validator, maximum_execution_time, process_count) self.routes = [] self.logger = logging.getLogger(smtproutes.LOG_NAME)
def __init__(self, localaddr, remoteaddr, ssl=False, certfile=None, keyfile=None, ssl_version=ssl.PROTOCOL_SSLv23, require_authentication=False, credential_validator=None, maximum_execution_time=30, process_count=5): SMTPServer.__init__(self, localaddr, remoteaddr, ssl=ssl, certfile=certfile, keyfile=keyfile, ssl_version=ssl_version, require_authentication=require_authentication, credential_validator=credential_validator, maximum_execution_time=maximum_execution_time, process_count=process_count) threading.Thread.__init__(self) self._message_file_name = 'dummy.msg' self._lock = threading.Lock() with open(self._message_file_name, 'wt') as msg_file: msg_file.truncate(0)
def start(self): print(self.hostname) self.server = SMTPServer(localaddr=(self.hostname, self.port), remoteaddr=(self.hostname, self.port), ssl=True, certfile="localhost.pem", keyfile="localhost-key.pem") asyncore.loop()
def __init__(self, credentials, bind_pair, queue, handled_domain='', open_relay=False, server_banner=''): self.__credentials_validator = None if credentials: self.__credentials_validator = CredentialsValidator(credentials) self.__domain = handled_domain self.__queue = queue self.__open_relay = open_relay SMTPServer.__init__(self, bind_pair, None, credential_validator=self.__credentials_validator, banner=server_banner, rcptto_callback=self.check_relaying)
def __init__(self, localaddr, remoteaddr, ssl=False, certfile=None, keyfile=None, ssl_version=ssl.PROTOCOL_SSLv23, require_authentication=False, credential_validator=None, maximum_execution_time=30, process_count=5): SMTPServer.__init__(self, localaddr, remoteaddr, ssl, certfile, keyfile, ssl_version, require_authentication, credential_validator, maximum_execution_time, process_count) self.routes = [] self.logger = logging.getLogger( smtproutes.LOG_NAME )
from srht.objects import User from sqlalchemy import or_ class UserValidator(object): def validate(self, username, password): user = User.query.filter( or_(User.username == username, User.email == username)).first() if not user: print("Authentication failed for {}, unknown user".format(user)) return False if not user.approved: print("Authentication failed for {}, account unapproved".format( user)) return False success = bcrypt.hashpw(password, user.password) == user.password if not success: print("Authentication failed for {}, bad password".format(user)) else: print("Authentication successful for {}".format(user)) return success SMTPServer( ('127.0.0.1', 4650), None, require_authentication=True, ssl=False, credential_validator=UserValidator(), ).run()
data = {} data['mailfrom'] = username data['bell'] = 'on' json_data = json.dumps(data) client.publish(args.mqtttopic, json_data, qos=0) client.disconnect() print("Published in: %s:%s - %s" % (args.mqtthost, args.mqttport, args.mqtttopic)) return True else: print("Login failed!") return False logging.getLogger(LOG_NAME) logging.basicConfig(level=logging.DEBUG) server = SMTPServer((args.smtphost, args.smtpport), None, require_authentication=True, ssl=False, credential_validator=FakeCredentialValidator(), process_count=5, maximum_execution_time=30) print('Server running on %s:%d for username/password: %s/%s' % (args.smtphost, args.smtpport, args.smtpusername, args.smtppassword)) server.run()
username, "password": password, "port": port, 'date': datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "module_name": "smtp/strong_password", }) + "\n") logfile_handle.close() finally: self.output_lock.release() def validate(self, username, password, fromaddr): self.log_to_file(fromaddr[0], fromaddr[1], username, password) return False try: SMTPServer( ('0.0.0.0', 25), None, require_authentication=True, ssl=False, credential_validator=FakeCredentialValidator(), ).run() except Exception as e: print(e) sys.exit()
def __init__(self, cmd_args, *args, **kwargs): SMTPServer.__init__(self, *args, **kwargs) self.cmd_args = cmd_args bs_host, bs_port = cmd_args.beanstalk self.beanstalk = beanstalkc.Connection(host = bs_host, port = bs_port)
class SMTPServer(SMTPServer): def process_message(self, peer, mailfrom, rcpttos, message_data): if (mailfrom.startswith("*****@*****.**") and rcpttos[0] == "*****@*****.**"): data = {} data['peer'] = peer data['mailfrom'] = mailfrom data['rcpttos'] = rcpttos data['bell'] = 'on' json_data = json.dumps(data) #print (json_data) request = urllib2.Request( "http://192.168.1.32:5665/json.htm?type=command¶m=switchlight&idx=228&switchcmd=On&level=0" ) response = urllib2.urlopen(request) else: print "Do nothing" fake_val = FakeCredentialValidator() server = SMTPServer(('0.0.0.0', 1125), None, require_authentication=True, credential_validator=fake_val, ssl=False) #print('server run') server.run()
def start(self): SMTPServer.__init__(self, ('0.0.0.0', 25), None) asyncore.loop()
def start(self): SMTPServer.__init__(self,('10.38.1.18', 25), None, require_authentication=True, credential_validator=FakeCredentialValidator(), process_count=1) asyncore.loop()