Ejemplo n.º 1
0
 def __init__(self, name, origin):
     self.name = name
     if not isinstance(origin, Base.Vector):
         raise RuntimeError("origin is not a Vector!")
     self.origin = origin
     self.stage1 = Stage1(name + "_Stage1", origin)
     self.stage2 = Stage2(name + "_Stage2",
                          origin.add(Base.Vector(0, 0, 95)))
     self.payload = Payload(name+"_Payload",\
                             origin.add(Base.Vector(0,0,95+400)), \
                             transparency=50)
Ejemplo n.º 2
0
    def parse(self, data):
        returnVal = {}

        log.debug('parsing coap header')

        header = self.parseBasicHeader(data)

        log.debug('parsing option list')

        option_pointer = self.parseOptionList(data, header)

        returnVal['header'] = header

        log.debug('reading payload')

        payload = Payload.Payload()
        payload.setPayload(data[option_pointer:])

        log.debug("Coap msg parsed")

        returnVal['payload'] = payload

        #here we can use a factory to get an appropiate parser.or instead use the ParserPayload

        return returnVal
Ejemplo n.º 3
0
#     'obj2' : ['love', 'ache', 'sonic', 'movie', 'chicken'],
#     'obj3' : ['drink', 'now', 'this', 'cofeetime'],
#     'obj4' : ['coffeetime', 'morning', 'brown', 'coffee']
#     }

# script_dic = 'coffee'

clips = {
    'obj1': [],
    'obj2': [],
    'obj3': [],
    'obj4': [],
    'obj6': [],
    'obj7': [],
}
clips['obj1'] = Payload.MetaData1()
clips['obj2'] = Payload.MetaData2()
clips['obj3'] = Payload.MetaData3()
clips['obj4'] = Payload.MetaData1()
clips['obj5'] = Payload.MetaData2()
clips['obj6'] = Payload.MetaData3()
clips['obj7'] = Payload.MetaData1()

#Load the Screenplay as a list
script_data = []


def LoadScript(script_path):
    pat = re.compile(r'[^a-zA-Z ]+')
    str = open(script_path, 'r')
    lst = str.read()
Ejemplo n.º 4
0
def main():
	global Client_RSApk

	# parse arguments (that's important)
	args = parse_args()

	# open the input file
	__input_filename__ = args.file
	f_in = open(__input_filename__, 'r')

	# read the raw data
	raw_data = f_in.read()

	#create a hash from the data
	dataHash = SHA256.new(raw_data).hexdigest()
	print "Sha-256: %s" % str(dataHash)

	# create a new AESCipher object
	# creating an object creates a new key as well
	aes = AESCipher()
	print "Block size: %d-bit" % (aes.BLOCK_SIZE*8)
	print "Key size: %d-bit" % (aes.KEY_SIZE*8)

	# b64 encode the key (good for sending)
	b64KEY = base64.b64encode(aes.key)  
	print "b64 Key: " + b64KEY + "\n"
	# use AESCipher object to encrypt raw_data
	encryptedData = aes.encrypt(raw_data)
	encryptedSize = sys.getsizeof(encryptedData)
	print "Encrypted data size: %.2f MB" % (encryptedSize / 1000000.0)
	
	# Payload object contains encrypted movie and 
	# the necessary information for symmetric encryption.
	pay = Payload(b64KEY, dataHash, encryptedData)

	# now, create the server socker and listen.
	serverPort = 12000
	serverSocket = socket(AF_INET,SOCK_STREAM)
	serverSocket.bind(('',serverPort))
	serverSocket.listen(1)

	# listening for connections
	while 1:
		#accept inbound tcp connections
		print "The server is ready to receive connections"
		connectionSocket, addr = serverSocket.accept()

		#Receive the projectors public key obj
		print '[*] Receiving projector public RSA key'
		cRSA = connectionSocket.recv(1024)
		Client_RSApk = cPickle.loads(cRSA) 
		#print our obj for verification
		print '[*] Projector RSA Public Key => ', Client_RSApk
		
		pay.key = Client_RSApk.encrypt(pay.key, '')[0]
		pay.fhash = Client_RSApk.encrypt(pay.fhash, '')[0]
		to_send = cPickle.dumps(pay)
		#get size of encrypted and pickled payload obj
		toSize = sys.getsizeof(to_send)
		print "Size of Payload = %d Bytes" %toSize

		# client needs to know size of the data.
		connectionSocket.send(str(toSize))
		connectionSocket.recv(1)

		# client is now ready to accept the data.
		connectionSocket.send(to_send)
		
		secure_wipe()
		sys.exit(1)
Ejemplo n.º 5
0
import time
import Payload
import Binary
import Jump
import Fibonacci
import Interpolation
import Exponential
import Linear
import loopy


### REF: https://stackabuse.com/search-algorithms-in-python/#fibonaccisearch

dic = Payload.RandomString()
search = 'KEQw6KGtxx685L09W4lo'



##################################
### Binary Search

start = time.time()
# # Algorithem starts here
x = Binary.Search(dic , search)
print("Binary Search Result:  " + str(x))
# # Algoritem stops here
end = time.time()
print("Binary Search Time:  " + str(end-start))
print()

##################################
Ejemplo n.º 6
0
 def createPayload(self, json):
     list = []
     for payload in json:
         list.append(Payload(payload))
     return list