def test_encode(self): stream = util.BufferedByteStream() encoder = amf3.Encoder(stream) x = flex.ArrayCollection() x['spam'] = 'eggs' encoder.writeElement(x) self.assertEquals( stream.getvalue(), '\n\x07Cflex.messaging.io.ArrayCollection' '\t\x01\tspam\x06\teggs\x01') stream = util.BufferedByteStream() encoder = amf0.Encoder(stream) x = flex.ArrayCollection() x['spam'] = 'eggs' encoder.writeElement(x) self.assertEquals( stream.getvalue(), '\x11\n\x07Cflex.messaging.io.ArrayCollection\t\x01\tspam\x06\x09' 'eggs\x01')
def test_create(self): ac = flex.ArrayCollection([1, 2, 3]) self.assertEquals(ac, {0: 1, 1: 2, 2: 3}) ac = flex.ArrayCollection(('a', 'b', 'b')) self.assertEquals(ac, {0: 'a', 1: 'b', 2: 'b'}) ac = flex.ArrayCollection({'first': 'Matt', 'last': 'Matthews'}) self.assertEquals(ac, {'first': 'Matt', 'last': 'Matthews'})
def test_create(self): self.assertEquals(flex.ArrayCollection(), []) self.assertEquals(flex.ArrayCollection([1, 2, 3]), [1, 2, 3]) self.assertEquals(flex.ArrayCollection(('a', 'b', 'b')), ['a', 'b', 'b']) class X(object): def __iter__(self): return iter(['foo', 'bar', 'baz']) self.assertEquals(flex.ArrayCollection(X()), ['foo', 'bar', 'baz']) self.assertRaises(TypeError, flex.ArrayCollection, {'first': 'Matt', 'last': 'Matthews'})
def test_getItemIndex(self): a = flex.ArrayCollection(['a', 'b', 'c']) self.assertEqual(a.getItemIndex('a'), 0) self.assertEqual(a.getItemIndex('b'), 1) self.assertEqual(a.getItemIndex('c'), 2) self.assertEqual(a.getItemIndex('d'), -1)
def test_addItem(self): a = flex.ArrayCollection() self.assertEqual(a, []) self.assertEqual(a.length, 0) a.addItem('hi') self.assertEqual(a, ['hi']) self.assertEqual(a.length, 1)
def test_removeAll(self): a = flex.ArrayCollection(['a', 'b', 'c']) self.assertEqual(a.length, 3) a.removeAll() self.assertEqual(a, []) self.assertEqual(a.length, 0)
def test_getItemAt(self): a = flex.ArrayCollection(['a', 'b', 'c']) self.assertEqual(a.getItemAt(0), 'a') self.assertEqual(a.getItemAt(1), 'b') self.assertEqual(a.getItemAt(2), 'c') self.assertRaises(IndexError, a.getItemAt, -1) self.assertRaises(IndexError, a.getItemAt, 3)
def test_encode_amf0(self): self.encoder = pyamf.get_encoder(pyamf.AMF0) self.buf = self.encoder.stream x = flex.ArrayCollection() x.append('eggs') self.assertEncoded( x, '\x11\n\x07Cflex.messaging.io.ArrayCollection\t\x03\x01\x06\teggs')
def test_encode_amf0(self): x = flex.ArrayCollection() x.append('eggs') stream = util.BufferedByteStream() encoder = amf0.Encoder(stream) encoder.writeElement(x) self.assertEquals(stream.getvalue(), '\x11\n\x07Cflex.messaging.io.ArrayCollection\t\x03\x01\x06\teggs')
def test_addItemAt(self): a = flex.ArrayCollection() self.assertEqual(a, []) self.assertRaises(IndexError, a.addItemAt, 'foo', -1) self.assertRaises(IndexError, a.addItemAt, 'foo', 1) a.addItemAt('foo', 0) self.assertEqual(a, ['foo']) a.addItemAt('bar', 0) self.assertEqual(a, ['bar', 'foo']) self.assertEqual(a.length, 2)
def test_removeItemAt(self): a = flex.ArrayCollection(['a', 'b', 'c']) self.assertRaises(IndexError, a.removeItemAt, -1) self.assertRaises(IndexError, a.removeItemAt, 3) self.assertEqual(a.removeItemAt(1), 'b') self.assertEqual(a, ['a', 'c']) self.assertEqual(a.length, 2) self.assertEqual(a.removeItemAt(1), 'c') self.assertEqual(a, ['a']) self.assertEqual(a.length, 1) self.assertEqual(a.removeItemAt(0), 'a') self.assertEqual(a, []) self.assertEqual(a.length, 0)
def test_proxy(self): from pyamf import flex self.alias.amf3 = True self.alias.proxy_attrs = ('foo', 'bar') self.alias.compile() self.assertEquals(self.alias.proxy_attrs, ['bar', 'foo']) attrs = { 'foo': flex.ArrayCollection(['bar', 'baz']), 'bar': flex.ObjectProxy({'foo': 'gak'}) } ret = self.alias.getDecodableAttributes(self.obj, attrs) self.assertEquals(ret, {'foo': ['bar', 'baz'], 'bar': {'foo': 'gak'}})
def getProxiedAttribute(self, attr, obj): """ Returns the proxied equivalent for C{obj}. @param attr: The attribute of the proxy request. Useful for class introspection. @type attr: C{str} @param obj: The object to proxy. @return: The proxied object or the original object if it cannot be proxied. """ # the default is to just check basic types from pyamf import flex if type(obj) is list: return flex.ArrayCollection(obj) elif type(obj) is dict: return flex.ObjectProxy(obj) return obj
def test_encode_amf3(self): x = flex.ArrayCollection() x.append('eggs') self.assertEncoded( x, '\n\x07Cflex.messaging.io.ArrayCollection\t\x03\x01\x06\teggs')
def test_setItemAt(self): a = flex.ArrayCollection(['a', 'b', 'c']) self.assertEqual(a.setItemAt('d', 1), 'b') self.assertEqual(a, ['a', 'd', 'c']) self.assertEqual(a.length, 3)
file_path = r"C:\Thick Client\command_injection_1.txt" with open(file_path, "r") as fuzz_file: # for entries in fuzz_file: for entries in range(0,1): # msg = messaging.RemotingMessage(operation='getUploadFiles', # clientId='6525D474-C40B-310E-5166-1BBAD11DB51D', # destination='scheduleUploadDocCommand', # messageId=str(uuid.uuid4()).upper(), # body=['IRMEHT2'], # headers={'DSId': '62A318D7-A719-932E-AAB7-19ED3B5CFA23', # 'DSEndpoint': 'my-amf', 'DSRequestTimeout': '150'}, # timeToLive= 0, # timestamp=0) # updateReportDistributionStatus data_array = flex.ArrayCollection([{'docID': '37969668', 'targetID': '42413994', 'reportId': '64035', 'status': 'COMPLETED', 'filename': "FILE || Generic Report.pdf"}]) msg = messaging.RemotingMessage(operation='updateReportDistributionStatus', clientId='C747A8F6-9409-0C8F-2BCB-65AF73A43268', destination='scheduleUploadDocCommand', messageId=str(uuid.uuid4()).upper(), body=[data_array], headers={'DSId': 'C747A362-5B1C-7F78-1CB4-A6FE0D75F959', 'DSEndpoint': 'my-amf', 'DSRequestTimeout': '150'}, timeToLive=0, timestamp=0) req = remoting.Request(target= None, body=[msg])#, msg_2]) ev = remoting.Envelope(pyamf.AMF3) ev['/0'] = req # print("\n\n" + str(req)) # Encode request bin_msg = remoting.encode(ev)
def test_readonly_length_property(self): a = flex.ArrayCollection() self.assertRaises(AttributeError, setattr, a, 'length', 3)