5 Replies Latest reply on Nov 28, 2011 7:36 PM by bola

    Question about msfrpcd APIs

      Hi everyone,

      I'm looking for some explanations about msfrpcd APIs, in particual about db remote APIs like db.connect.


      I don't understand what are the arguments to pass to the RPC call db.connect.


      For example if i write:


      i obtain:

      {'result': 'failed'}


      i understand that the args of the db.connect call are more than none, but i tried a lot of combination but it didn't work :\






      P.S. Possibly if someone has some good place where to find good API documentation, the pdf about APIs here on the site is incomplete (i suppose.)

        • Re: Question about msfrpcd APIs

          The official API doc is here on the community site: https://community.rapid7.com/docs/DOC-1516 -- As you noted, the db.* calls are currently unsupported.


          That said, you can certainly look at the v10 api in order to determine the appropriate arguments. The (rpc) db methods are located in lib/msf/core/rpc/v10/rpc_db.rb.


          It appears that you'll need to set a 'driver' option, as well as the regular arguments required to connect to the DB (located in lib/msf/core/db_manager.rb) -- those arguments should be at a minimum: host, port, username, password.


          These arguments are then passed directly to Active Record to establish the database connection. You can find more about that API here: http://api.rubyonrails.org/classes/ActiveRecord/Base.html#method-c-establish_con nection

          1 of 1 people found this helpful
            • Re: Question about msfrpcd APIs

              Keep in mind the db.* RPC APIs are not supported and likely to be deprecated. We suggest that you setup your DB connection in the code that loads the RPC service, not through the API itself.

              • Re: Question about msfrpcd APIs

                Thanks for the answers, however: how can i use api v10?

                It's like the old APIs, so i have to use rpc.call("API_TO_CALL") or i have to instruct the RPC server to use v10 APIs?




                  • Re: Question about msfrpcd APIs

                    The v10 api is implemented with msgpack (http://msgpack.org/). You can install the official client with a 'gem install msfrpc-client', and this includes an example of accessing the Pro methods of the API. More examples can be found here. Framework-only methods can be accessed similarly.


                    The Framework listener can be started by loading the plugin 'load msgrpc'  which will start a listener on the default port of :55552/tcp. The Pro listener is started automatically, and is located at :3790/tcp.

                      • Re: Question about msfrpcd APIs

                        At first, thanks for the help.


                        I installed the required gems and i'm looking at the examples on the repos, but i have another question: for example if i use:


                        Has this call the syntax the old APIs, or there is a new set of calls? If it's so i didn't understand hot to use the new calls in .../msf/lib/msf/core/rpc/v10/ and i would like to seek clarifications.


                        i follow this steps:


                        - execute msfrpcd in msg mode    OK   

                        - execute msfrpc_irb.rb example   OK

                        - execute in irb shell old calls       OK

                        - execute in irb shell new calls      Msf::RPC::ServerException: ArgumentError Unknown API Group:


                        I'm quite sure that i'm in mistake with syntax but looking at this



                        and obviusly changing the call to fit the framework, for example db.rpc_status (the old one was db.status, right?) i get that Exception.