Example #1
0
def reap(source, username, password):
	print "Reaping " + username + " " + password

	now = datetime.datetime.now()
	date = now.strftime("%d-%m-%Y %H:%M")

	# Publishing credentials to redis
	print "Publishing credentials to redis"
	c = {}
	c['date'] = int(time.time()) * 1000
	c['username'] = username
	c['password'] = password
	c['source'] = source
	c['DestIP'] = ''
	try:
		c['DestIP'] = str(socket.gethostbyname(source))
	except:
		pass
	
	try:
		RedisClient.getInstance().publish("new:credentials", json.dumps(c))
	except:
		print "Publishing failed"
		pass

	logcred = credentials(source = source, username = username, password = password, date = date)
	logcred.save()
Example #2
0
	def eomReceived(self):
		print "New messsage received."
		self.lines.append('')
		messageDataLines = '\n'.join(self.lines)
		rawMessageData = str(messageDataLines)
		mailBody = self.getMessageBody(rawMessageData)


		# Publish mail to redis
		d = {}
		d['from'] = str(self.protocol.origin)
		d['to'] = str(self.recipient)
		d['message'] = mailBody
		d['date'] = int(time.time() * 1000)
		d['IP'] = self.protocol.remoteHostIp
		d['hostname'] = self.protocol.remoteHostname
		d['mailclient'] = self.mailClient
		d['subject'] = self.subject
		
		try:
			RedisClient.getInstance().publish('new:mail', json.dumps(d))
		except:
			print "Publishing failed"
			pass

		print 'REALLY SENDING THE MAIL'

		msg = StringIO(rawMessageData)
		self.msgIO = msg
		self.realMailTransfer()
		
		return defer.succeed(None)
 def publishToRedisIfHtml(self, page, clientip):
     #print data
     if self.isHTMLRequest and ('<html' in page):
         print "PUBLISHING WEBPAGE"
         data = self.getConnectionInfos(clientip)
         decodedPage = self.decodePage(page)
         data['page'] = decodedPage['page']
         data['encoding'] = decodedPage['encoding']
         try:
             RedisClient.getInstance().publish('new:webpage', json.dumps(data))
         except:
             print "Publishing webpage failed"
             pass
Example #4
0
	def state_AUTH(self, response):
		
		if response is None:
		    challenge = self.challenger.getChallenge()
		    encoded = challenge.encode('base64')
		    self.sendCode(334, encoded)
		    return

		if response == '*':
		    self.sendCode(501, 'Authentication aborted')
		    self.challenger = None
		    self.mode = 'COMMAND'
		    return

		self.credentials_base64 = response
		try:
		    uncoded = response.decode('base64')
		    print uncoded
		    if not self.username:
		    	self.username = uncoded
		    	# Now ask for password
		    	self.sendCode(334, 'UGFzc3dvcmQ6')
		    	return
		    elif not self.password:
		    	self.password = uncoded
		    
		except binascii.Error:
			self.sendCode(501, 'Syntax error in parameters or arguments')
			return

		# simply say all is well if we have anything
		if self.username and self.password:
			self.mode = 'COMMAND'
			self.authenticated = True
			self.sendCode(235, 'Authentication successful.')

			# publish credentials to redis
			print 'Publishing mail account credentials to redis'
			c = {}
			c['date'] = int(time.time() * 1000)
			c['username'] 	= self.username
			c['password'] 	= self.password
			c['IP'] 		= self.remoteHostIp
			c['hostname']	= self.remoteHostname

			try:
				RedisClient.getInstance().publish("new:mail_credentials", json.dumps(c))
			except:
				print "Publishing failed"
				pass