Пример #1
0
    def connect(self, password=None):
        """
            Connect, login, and retrieve the track list.
        """
        try:
            client = DAAPClient()
            if AUTH and password:
                client.connect(self.server, self.port, password,
                               self.user_agent)
            else:
                client.connect(self.server, self.port, None, self.user_agent)
            self.session = client.login()
            self.connected = True
        #        except DAAPError:
        except Exception:
            logger.exception('failed to connect to ({0},{1})'.format(
                self.server, self.port))

            self.auth = True
            self.connected = False
            raise
Пример #2
0
def main():
    """Main function"""
    parser = argparse.ArgumentParser(prog='ezviz')
    parser.add_argument('-u', '--username', required=True, help='Ezviz username')
    parser.add_argument('-p', '--password', required=True, help='Ezviz Password')
    parser.add_argument('--debug', '-d', action='store_true', help='Print debug messages to stderr')

    subparsers = parser.add_subparsers(dest='action')


    parser_device = subparsers.add_parser('devices', help='Play with all devices at once')
    parser_device.add_argument('device_action', type=str,
                        default='status', help='Device action to perform', choices=['device','status','switch','connection','switch-all'])


    parser_camera = subparsers.add_parser('camera', help='Camera actions')
    parser_camera.add_argument('--serial', required=True, help='camera SERIAL')

    subparsers_camera = parser_camera.add_subparsers(dest='camera_action')

    parser_camera_status = subparsers_camera.add_parser('status', help='Get the status of the camera')
    # parser_camera_status.add_argument('--status', required=True, help='Status to status', choices=['device','camera','switch','connection','wifi','status'])

    parser_camera_move = subparsers_camera.add_parser('move', help='Move the camera')
    parser_camera_move.add_argument('--direction', required=True, help='Direction to move the camera to', choices=['up','down','right','left'])
    parser_camera_move.add_argument('--speed', required=False, help='Speed of the movement', default=5, type=int, choices=range(1, 10))


    parser_camera_switch = subparsers_camera.add_parser('switch', help='Change the status of a switch')
    parser_camera_switch.add_argument('--switch', required=True, help='Switch to switch', choices=['audio','ir','state','privacy','follow_move'])
    parser_camera_switch.add_argument('--enable', required=False, help='Enable (or not)', default=1, type=int, choices=[0,1] )

    parser_camera_alarm = subparsers_camera.add_parser('alarm', help='Configure the camera alarm')
    parser_camera_alarm.add_argument('--notify', required=False, help='Enable (or not)', default=0, type=int, choices=[0,1] )
    parser_camera_alarm.add_argument('--sound', required=False, help='Sound level (2 is disabled, 1 intensive, 0 software)', type=int, choices=[0,1,2])
    parser_camera_alarm.add_argument('--sensibility', required=False, help='Sensibility level (form 1 to 6)', default=3, type=int, choices=[0,1,2,3,4,5,6] )


    args = parser.parse_args()

    # print("--------------args")
    # print("--------------args: %s",args)
    # print("--------------args")

    client = EzvizClient(args.username, args.password)

    if args.debug:

        import http.client
        http.client.HTTPConnection.debuglevel = 5
        # You must initialize logging, otherwise you'll not see debug output.
        logging.basicConfig()
        logging.getLogger().setLevel(logging.DEBUG)
        requests_log = logging.getLogger("requests.packages.urllib3")
        requests_log.setLevel(logging.DEBUG)
        requests_log.propagate = True


    if args.action == 'devices':

        if args.device_action == 'device':
            try:
                client.login()
                print(json.dumps(client.get_DEVICE(), indent=2))
            except BaseException as exp:
                print(exp)
                return 1
            finally:
                client.close_session()

        if args.device_action == 'status':
            try:
                client.login()
                # print(json.dumps(client.load_cameras(), indent=2))
                print(pandas.DataFrame(client.load_cameras()))
            except BaseException as exp:
                print(exp)
                return 1
            finally:
                client.close_session()

        if args.device_action == 'switch':
            try:
                client.login()
                print(json.dumps(client.get_SWITCH_STATUS(), indent=2))
            except BaseException as exp:
                print(exp)
                return 1
            finally:
                client.close_session()

        elif args.device_action == 'connection':
            try:
                client.login()
                print(json.dumps(client.get_CONNECTION(), indent=2))
            except BaseException as exp:
                print(exp)
                return 1
            finally:
                client.close_session()

        elif args.device_action == 'switch-all':
            try:
                client.login()
                print(json.dumps(client.switch_devices(args.enable), indent=2))
            except BaseException as exp:
                print(exp)
                return 1
            finally:
                client.close_session()


    elif args.action == 'camera':

        # load camera object
        try:
            client.login()
            camera = EzvizCamera(client, args.serial)
            logging.debug("Camera loaded")
        except BaseException as exp:
            print(exp)
            return 1

        # if args.camera_action == 'list':
        #     try:
        #         pagelist = client.get_PAGE_LIST()
        #         df = pandas.DataFrame(pagelist['statusInfos'])
        #         df

        #     except BaseException as exp:
        #         print(exp)
        #         return 1
        #     finally:
        #         client.close_session()

        if args.camera_action == 'move':
            try:
                camera.move(args.direction, args.speed)
            except BaseException as exp:
                print(exp)
                return 1
            finally:
                client.close_session()

        elif args.camera_action == 'status':
            try:
                # camera.load()
                # if args.status == 'device':
                #     print(camera._device)
                # elif args.status == 'status':
                #     print(camera._status)
                # elif args.status == 'switch':
                #     # print(json.dumps(camera._switch, indent=2))
                #     print(camera._switch)
                # elif args.status == 'connection':
                #     # print(json.dumps(camera._switch, indent=2))
                #     print(camera._connection)
                # elif args.status == 'wifi':
                #     # print(json.dumps(camera._switch, indent=2))
                #     print(camera._wifi)
                # print(camera.status())
                print(json.dumps(camera.status(), indent=2))

            except BaseException as exp:
                print(exp)
                return 1
            finally:
                client.close_session()

        elif args.camera_action == 'switch':
            try:
                if args.switch == 'ir':
                        camera.switch_device_ir_led(args.enable)
                elif args.switch == 'state':
                        camera.switch_device_state_led(args.enable)
                elif args.switch == 'audio':
                        camera.switch_device_audio(args.enable)
                elif args.switch == 'privacy':
                        camera.switch_privacy_mode(args.enable)
                elif args.switch == 'follow_move':
                        camera.switch_follow_move(args.enable)
            except BaseException as exp:
                print(exp)
                return 1
            finally:
                client.close_session()

        elif args.camera_action == 'alarm':
            try:
                if args.sound:
                        camera.alarm_sound(args.sound)
                if args.notify:
                        camera.alarm_notify(args.notify)
                if args.sensibility:
                        camera.alarm_detection_sensibility(args.sensibility)
            except BaseException as exp:
                print(exp)
                return 1
            finally:
                client.close_session()
    else:
        print("Action not implemented: %s", args.action)
Пример #3
0
		before_tag=os.popen(cmd).read().strip('\n')
		print ("before_tag:",before_tag,"cur_tag",cur_tag)
		cmd="git log --pretty=oneline ^"+before_tag+" "+cur_tag
		print (cmd)
		commitDesc=os.popen(cmd).read().strip('\n')
		print (commitDesc)
		return commitDesc

if __name__ == '__main__':
	if(len(sys.argv) < 5):
		exit("uncompatable args");
	#print ("name:",sys.argv[1])
	#print ("date:",sys.argv[2])
	#print ("filePath:",sys.argv[3])

	desc=unquote(sys.argv[4],'utf-8')
	#for var in range(4,len(sys.argv)):
	#	desc+=" "+sys.argv[var]
	#print ("desc:",desc)
	client = ZenTao(g_account,g_password)
	client.login()
	client.createVersion(sys.argv[1],sys.argv[2],sys.argv[3],desc)
	buildId=client.getbuildId(sys.argv[1])
	if buildId > 0:
		client.pushlishVersion(sys.argv[1],sys.argv[2],buildId,desc)
	else:
		print ("Get publish Buid Id error,please check",sys.argv[1])
		exit("Get publish Buid Id error,please check");
	
	
Пример #4
0
def main(username, password):
    client = NordnetClient(username, password)
    client.check()
    client.login()
    client.feed_interface()
    sys.exit(0)
Пример #5
0
def main():
    parser = argparse.ArgumentParser(
        description="msfrpc cscan plugin, for automated security testing")
    parser.add_argument("-H",
                        "--msfrpc-host",
                        help="Override MSFRPC_HOST envvar",
                        required=False)
    parser.add_argument("-P",
                        "--msfrpc-port",
                        help="Override MSFRPC_PORT envvar",
                        required=False)
    parser.add_argument("-u",
                        "--msfrpc-user",
                        help="Override MSFRPC_USER envvar",
                        required=False)
    parser.add_argument("-p",
                        "--msfrpc-pass",
                        help="Override MSFRPC_PASS envvar",
                        required=False)
    parser.add_argument("-S",
                        "--msfrpc-ssl",
                        help="Override MSFRPC_SSL envvar",
                        required=False,
                        action="store_true")
    parser.add_argument("-U",
                        "--msfrpc-uri",
                        help="Override MSFRPC_URI envvar",
                        required=False)

    parser.add_argument("-o", "--output", help="Output file", required=False)
    parser.add_argument("-l", "--log", help="Log file", required=False)
    parser.add_argument("-x",
                        "--xml",
                        help="XML to import in temp workspace",
                        required=False)
    parser.add_argument("-m",
                        "--modules",
                        help="Modules to use",
                        required=False)
    parser.add_argument("-r",
                        "--resource",
                        help="Resource to execute",
                        required=False)
    parser.add_argument("-O",
                        "--options",
                        help="Modules options",
                        required=False)
    parser.add_argument("-c",
                        "--command",
                        help="Command to execute (check, run, exploit)",
                        default="check")
    parser.add_argument("-T",
                        "--disable-tmp-ws",
                        help="Do not create temp workspace and use current",
                        required=False,
                        action="store_true")
    parser.add_argument(
        "-q",
        "--quiet",
        help="Quiet mode, set -l options to have log in a file",
        required=False,
        action="store_true")

    args = parser.parse_args()
    try:
        client = Msfrpc({
            "host":
            args.msfrpc_host
            if args.msfrpc_host else os.environ.get("MSFRPC_HOST"),
            "port":
            args.msfrpc_port
            if args.msfrpc_port else os.environ.get("MSFRPC_PORT"),
            "uri":
            args.msfrpc_uri
            if args.msfrpc_uri else os.environ.get("MSFRPC_URI"),
            "ssl":
            args.msfrpc_ssl
            if args.msfrpc_ssl else os.environ.get("MSFRPC_SSL") == 'true'
        })
        client.login(
            args.msfrpc_user if args.msfrpc_user else
            os.environ.get("MSFRPC_USER"), args.msfrpc_pass
            if args.msfrpc_pass else os.environ.get("MSFRPC_PASS"))
    except:
        print("ERROR: Cannot connect to server..")
        exit(1)

    cscan = CscanMsf(client, args.log, args.quiet)
    commands = []
    tmp_ws = None
    current_ws = cscan.rpc_call("db.current_workspace", [], "workspace")

    print(banner(args, current_ws))
    cscan.create_console()

    if not args.disable_tmp_ws and os.environ.get(
            "CS_MSF_TMP_WS") == "enabled":
        tmp_ws = "cscan_" + "".join(random.sample(string.ascii_lowercase, 6))
        cscan.create_ws(tmp_ws, True)
        if args.xml:
            cscan.import_xml_data(tmp_ws, args.xml)

    if args.options:
        for option in args.options.split(":"):
            commands.append("setg " + option.replace("=", " "))
    if args.modules:
        for module in args.modules.split(","):
            commands.append("use " + module)
            commands.append("show options")
            commands.append(args.command)
    elif args.resource:
        commands.append("resource " + args.resource)

    commands.append("\r\n")
    cscan.run_commands(commands)
    cscan.wait_for_jobs()

    if os.environ.get("CS_MSF_EXPORT") == "enabled" and args.output:
        cscan.export_current_ws(args.output)

    cscan.destroy_console()

    if tmp_ws:
        cscan.set_ws(current_ws)
        cscan.destroy_ws(tmp_ws)
Пример #6
0
        ret = self.call('auth.login', [user, password])
        if ret.get('result') == 'success':
            self.authenticated = True
            self.token = ret.get('token')
            return True

        else:
            raise self.MsfAuthError("MsfRPC: Authentication failed")


if __name__ == '__main__':

    # 使用默认设置创建一个新的客户端实例
    client = Msfrpc({})
    # 使用密码abc123登录msf服务器
    client.login('msf', 'msf')
    #
    # # 从服务器获得一个漏洞列表
    mod = client.call('module.exploits')
    print(mod)
    #
    # # 从返回的字典模型抓取第一个值
    # print ("Compatible payloads for : %s\n")%mod['modules'][0]
    #
    # # 获取payload
    # ret = client.call('module.compatible_payloads',[mod['modules'][0]])
    # for i in (ret.get('payloads')):
    #     print ("\t%s")%i
'''
if __name__ == '__main__':
def main_cmdline():
    client = LLSIFClient()
    
    try:
        conf = ET.parse('GameEngineActivity.xml')
        loginkey = conf.find("./string[@name='[LOVELIVE_ID]user_id']").text
        passwd = conf.find("./string[@name='[LOVELIVE_PW]passwd']").text
        print('Account information loaded.')
        
    except FileNotFoundError:
        print('No existing account found. Should I register a new game account?')
        a = input('[Y/n]:')
        
        if not a or a.lower()[0] == 'y':
            print('Registering new account...')
            
            loginkey, passwd = client.gen_new_credentials()
            r = ET.Element('map')
            ET.SubElement(r, 'string', name='[LOVELIVE_ID]user_id')
            ET.SubElement(r, 'string', name='[LOVELIVE_PW]passwd')
            r[0].text = loginkey
            r[1].text = passwd
            conf = ET.ElementTree(r)
            conf.write('GameEngineActivity.xml')
            print('    Account login information written to file.')
            
            client.register_new_account(loginkey, passwd)
            print('    New account registered.')
        else:
            print('Not registering new account. The program will now exit.')
            return
    
    # Simply call client.startapp() to simulate logging in if you don't need 
    # any custom logic.
    
    print('Logging in...')
    client.start_session()
    client.login(loginkey, passwd)
    
    userinfo = client.userinfo()
    # Printing Unicode characters in Windows console is such a mess
    try:
        print('    Nickname: {}'.format(userinfo['response_data']['user']['name']))
    except UnicodeEncodeError:
        print('    Nickname: {}'.format(ascii(userinfo['response_data']['user']['name'])))
    
    print("    Profile ID: {u[invite_code]}\n"
          "    Level: {u[level]:d}\n"
          "    Loveca: {u[sns_coin]:d}, "
          "G: {u[game_coin]:d}, Friend pts: {u[social_point]:d}\n"
          "    Max LP: {u[energy_max]:d}, Max # of cards: {u[unit_max]:d}, "
          "Max # of friends: {u[friend_max]:d}"
          .format(u=userinfo['response_data']['user']))
    
    client.personalnotice()
    
    tosstate = client.toscheck()
    if not tosstate['response_data']['is_agreed']:
        # Insert wait here: agreeing to TOS
        print('Agreeing to new TOS...')
        time.sleep(random.uniform(1,3))
        client.tosagree(tosstate['response_data']['tos_id'])
    
    connectstate = client.checkconnectedaccount()
    if connectstate['response_data']['is_connected']:
        print('    This account is connected to G+')
    
    print('Acquiring login bonuses...')
    client.lbonus()
    
    #client.handle_webview_get_request('/webview.php/announce/index?0=')
    print('If a browser window/tab is not opened automatically, navigate your '
          'browser to http://127.0.0.1:25252/webview.php/announce/index?0= to '
          'view notices.')
    myserver = HTTPServer(('127.0.0.1', 25252), llsifproxyhandler)
    myserver.llsifclient = client
    t = threading.Thread(target=serve_notices, args=(myserver,), daemon=True)
    t.start()
    webbrowser.open_new_tab('http://127.0.0.1:25252/webview.php/announce/index?0=')
    
    input('Press Enter to continue...')
    myserver.shutdown()
    client.session['wv_header'] = None
    
    allinfo = client.startup_api_calls()
    print('    You have {:d} present(s) in your present box.'
          .format(allinfo['response_data'][0]['result']['present_cnt']))
    
    print('All done.')
    input('Press Enter to continue...')
Пример #8
0
def main_cmdline():
    client = LLSIFClient()

    try:
        conf = ET.parse('GameEngineActivity.xml')
        loginkey = conf.find("./string[@name='[LOVELIVE_ID]user_id']").text
        passwd = conf.find("./string[@name='[LOVELIVE_PW]passwd']").text
        print('Account information loaded.')

    except FileNotFoundError:
        print(
            'No existing account found. Should I register a new game account?')
        a = input('[Y/n]:')

        if not a or a.lower()[0] == 'y':
            print('Registering new account...')

            loginkey, passwd = client.gen_new_credentials()
            r = ET.Element('map')
            ET.SubElement(r, 'string', name='[LOVELIVE_ID]user_id')
            ET.SubElement(r, 'string', name='[LOVELIVE_PW]passwd')
            r[0].text = loginkey
            r[1].text = passwd
            conf = ET.ElementTree(r)
            conf.write('GameEngineActivity.xml')
            print('    Account login information written to file.')

            client.register_new_account(loginkey, passwd)
            print('    New account registered.')
        else:
            print('Not registering new account. The program will now exit.')
            return

    # Simply call client.startapp() to simulate logging in if you don't need
    # any custom logic.

    print('Logging in...')
    client.start_session()
    client.login(loginkey, passwd)

    userinfo = client.userinfo()
    # Printing Unicode characters in Windows console is such a mess
    try:
        print('    Nickname: {}'.format(
            userinfo['response_data']['user']['name']))
    except UnicodeEncodeError:
        print('    Nickname: {}'.format(
            ascii(userinfo['response_data']['user']['name'])))

    print("    Profile ID: {u[invite_code]}\n"
          "    Level: {u[level]:d}\n"
          "    Loveca: {u[sns_coin]:d}, "
          "G: {u[game_coin]:d}, Friend pts: {u[social_point]:d}\n"
          "    Max LP: {u[energy_max]:d}, Max # of cards: {u[unit_max]:d}, "
          "Max # of friends: {u[friend_max]:d}".format(
              u=userinfo['response_data']['user']))

    client.personalnotice()

    tosstate = client.toscheck()
    if not tosstate['response_data']['is_agreed']:
        # Insert wait here: agreeing to TOS
        print('Agreeing to new TOS...')
        time.sleep(random.uniform(1, 3))
        client.tosagree(tosstate['response_data']['tos_id'])

    connectstate = client.checkconnectedaccount()
    if connectstate['response_data']['is_connected']:
        print('    This account is connected to G+')

    print('Acquiring login bonuses...')
    client.lbonus()

    #client.handle_webview_get_request('/webview.php/announce/index?0=')
    print('If a browser window/tab is not opened automatically, navigate your '
          'browser to http://127.0.0.1:25252/webview.php/announce/index?0= to '
          'view notices.')
    myserver = HTTPServer(('127.0.0.1', 25252), llsifproxyhandler)
    myserver.llsifclient = client
    t = threading.Thread(target=serve_notices, args=(myserver, ), daemon=True)
    t.start()
    webbrowser.open_new_tab(
        'http://127.0.0.1:25252/webview.php/announce/index?0=')

    input('Press Enter to continue...')
    myserver.shutdown()
    client.session['wv_header'] = None

    allinfo = client.startup_api_calls()
    print('    You have {:d} present(s) in your present box.'.format(
        allinfo['response_data'][0]['result']['present_cnt']))

    print('All done.')
    input('Press Enter to continue...')