WithSecureLabs/drozer

Getting result in python using sendAndReceive or other methods

hitabi opened this issue · 1 comments

I am trying to give a run command and get the response programatically in a python script.

I see that Session class has sendAndReceive method session.py#L591 which takes in a Message object. There is also Reflector class's sendAndReceive method reflector.py#L100 which takes in either a Factory such as ReflectionRequestFactory or a Message object. There is no document on it so my guess is that we have to add commands as arguments. Before I dump all my code I want to know if this is the only way or there some one-liner code that I overlooked.

command = 'run app.package.list'
args = Message.Argument(type=Message.Argument.STRING, string=command)
fac = ReflectionRequestFactory(Message.ReflectionRequest.INVOKE).setArguments([args])
res = self.session.reflector.sendAndReceive(fac)
print(res)

Gives error AttributeError: _pb on reflection_request.py:118
request.argument.add().MergeFrom(argument._pb())

Hey! Full disclosure: it'll take us a while to get back to you on this.

Long story short - there isn't currently an easy/documented way of interacting with drozer programmatically. I agree there should be, and I'll add it to my list.

The methods you identified are used for sending drozer protocol commands between the console and agent - not really relevant to what you're trying to do.