Ejemplo n.º 1
0
 def get_deny_ip():
     ports = execute("SELECT * FROM ufw_ip;")
     result = []
     for i in ports:
         result.append({
             "rule_id": i[0],
             "ip": i[1],
             "protocol": i[2],
             "description": i[3]
         })
     return result
Ejemplo n.º 2
0
 def get_allow_port():
     ports = execute("SELECT * FROM ufw_port;")
     result = []
     for i in ports:
         result.append({
             "rule_id": i[0],
             "port": i[1],
             "protocol": i[2],
             "description": i[3]
         })
     return result
Ejemplo n.º 3
0
 def delete_deny_ip(self):
     execute("DELETE FROM ufw_ip WHERE ip = ? AND protocol = ?;",
             (self.ip, self.protocol))
     os.system("sudo ufw delete deny from {} proto {}".format(
         self.ip, self.protocol))
Ejemplo n.º 4
0
 def add_deny_ip(self, description):
     execute(
         "INSERT INTO ufw_ip (ip, protocol, description) VALUES(?, ?, ?)",
         (self.ip, self.protocol, description))
     os.system("sudo ufw deny from {} proto {}".format(
         self.ip, self.protocol))
Ejemplo n.º 5
0
 def delete_allow_port(self):
     execute("DELETE FROM ufw_port WHERE port = ? AND protocol = ?;",
             (self.port, self.protocol))
     os.system("sudo ufw delete allow {}/{}".format(self.port,
                                                    self.protocol))
     pass
Ejemplo n.º 6
0
 def add_allow_port(self, description):
     execute(
         "INSERT INTO ufw_port (port, protocol, description) VALUES(?, ?, ?)",
         (self.port, self.protocol, description))
     os.system("sudo ufw allow {}/{}".format(self.port, self.protocol))