Meterpreter reverse_tcp kills its parent process
I have been playing around with backtrack and its tools for already 2 years. I am now working for an antivirus/anti malware company and I wanted to show my bosses how easy it is to obfuscate a reverse_tcp payload.
I used msfpayload with "C" option to obtain meterpreter reverse_tcp in HEX. Then i wrote my own program in C that contains the binary code of the reverse_shell and executes it in memory using void pointers - " ((void(*)(void))buf2)(); " , where buf2 is an array of unsigned chars, containing the payload.
Whenever I execute the payload, if the connection fails, the new thread dedicated for the payload kills the whole process and the program dies.
I want to make sure that even if the payload fails, the program will continue running and re-try to execute it (sort of a persistence).
*Note - I have noticed that this only happens if the machine that runs the multi/handler is UP. If it is not up, then the reverse_tcp just times out and dies without killing the process. But if the machine running the multi/handler is up with NO handler bind to it - the reverse_tcp dies and kills my program.
Please give me some guidelines regarding my problem. I do not want BT community to do my job (that's why I am not posting any code), I just want to find out where the problem might be.