-2
from socket import *

def main ():
    print('''========================================================================== ''')
    print('''  [-]   S T A R T I N G      T H E        D E C O Y        S E R V E R  [-] ''')
    print('''========================================================================== ''')
    ip_add = "192.168.43.195"
    port = 80
    try :
        socket_connection=socket(AF_INET,SOCK_STREAM)
        socket_connection.bind(port,ip_add)
        socket_connection.listen(10)
        while 1 :
            attacker_connection,attacker_addr = socket_connection.accept()
            print("Decoy Server Is Created on The Attacker".format(attacker_addr[0]))
            attacker_connection.send(b"<h1> Unable to connect from The server Please Check Your Network Connection </h1>")
            data = attacker_connection.recv(3072)
            print(data)
    except error as identifier:
        print("An Error Was Encounterd While Deploying A Decoy Server".format(identifier))
    except KeyboardInterrupt as ky :
        print("Decoy Server Stopped By The User")
        print(" [+]..../ Exiting \....[+] ")
    finally:
        socket_connection.close()
if __name__ == '__main__':
      main()

This Is my code whenever I run the program it shows bind() takes exactly one argument how to bind ipadd(),port in two arguments

Art
  • 2,836
  • 4
  • 17
  • 34

1 Answers1

4

You need to call

socket_connection.bind((ip_add,port))

That means passing a tuple to the function (it gets one argument that specify the endpoint which is a pair/a tuple).

Please see the guidelines on posts here.

eyal0931
  • 59
  • 6