def yenile(self): p = sub.Popen(('iptables', '-L', '-v', '-n'), stdout=sub.PIPE) terminal_output, errors = p.communicate() terminal_output = str(terminal_output, 'UTF-8') terminal_output.split("/n") restore(tables) self.textBox_1.setPlainText(terminal_output)
def kuralSil(self): sub.call('iptables -F', shell=True) forward.clear() input.clear() output.clear() restore(tables) msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("Tüm Koruma Kuralları Silindi.") msg.setInformativeText("Güvende kalmak için korumayı açmayı unutmayın.") msg.setWindowTitle("Kurallar Silindi!") msg.exec() self.yenile()
def port_ac(self): deger = self.port.text() try: forward.remove(Reject(proto='tcp', dport=deger)) input.remove(Reject(proto='tcp', dport=deger)) output.remove(Reject(proto='tcp', dport=deger)) restore(tables) self.yenile() except: msg = QMessageBox() msg.setText("Port Açıldı") msg.exec() self.yenile()
def kuralEkle(self): # genel kurallar forward.clear() input.clear() output.clear() forward.append(Accept(proto='tcp', dport='53')) forward.append(Accept(proto='tcp', dport='80')) forward.append(Accept(proto='tcp', dport='443')) drop_ddos = Rule(proto='tcp', dport='80', m='limit', limit='25/minute', limit_burst='100', j='ACCEPT', comment='Save you from DDos :)') input.append(drop_ddos) restore(tables) self.yenile() forward.clear() input.clear() output.clear()
def paintEvent(self, event): # just setting some size aspects self.setMaximumHeight(30) self.setMaximumWidth(100) self.setMinimumWidth(100) self.setMaximumHeight(30) self.resize(self.parent().width(), self.parent().height()) painter = QtGui.QPainter() painter.begin(self) # for the black background brush = QtGui.QBrush(QtGui.QColor(20, 20, 20), style=QtCore.Qt.SolidPattern) painter.fillRect(self.rect(), brush) # smooth curves painter.setRenderHint(QtGui.QPainter.Antialiasing) # for the on off font font = QtGui.QFont() font.setFamily("Courier New") font.setPixelSize(12) painter.setFont(font) # change the look for on/off if self.isChecked(): # blue fill brush = QtGui.QBrush(QtGui.QColor(50, 50, 255), style=QtCore.Qt.SolidPattern) painter.setBrush(brush) # rounded rectangle as a whole painter.drawRoundedRect(0, 0, self.width() - 2, self.height() - 2, self.height() / 2, self.height() / 2) # white circle/button instead of the tick mark brush = QtGui.QBrush(QtGui.QColor(255, 255, 255), style=QtCore.Qt.SolidPattern) painter.setBrush(brush) painter.drawEllipse(self.width() - self.height(), 0, self.height(), self.height()) # on text painter.drawText(self.width() / 4, self.height() / 1.5, "Açık") forward.clear() input.clear() output.clear() # genel kurallar forward.append(Accept(proto='tcp', dport='53')) forward.append(Accept(proto='tcp', dport='80')) forward.append(Accept(proto='tcp', dport='443')) drop_ddos = Rule(proto='tcp', dport='80', m='limit', limit='25/minute', limit_burst='100', j='ACCEPT', comment='Save you from DDos :)') input.append(drop_ddos) restore(tables) else: # gray fill brush = QtGui.QBrush(QtGui.QColor(50, 50, 50), style=QtCore.Qt.SolidPattern) painter.setBrush(brush) # rounded rectangle as a whole painter.drawRoundedRect(0, 0, self.width() - 2, self.height() - 2, self.height() / 2, self.height() / 2) # white circle/button instead of the tick but in different location brush = QtGui.QBrush(QtGui.QColor(255, 255, 255), style=QtCore.Qt.SolidPattern) painter.setBrush(brush) painter.drawEllipse(0, 0, self.height(), self.height()) # off text painter.drawText(self.width() / 2, self.height() / 1.5, "Kapalı") sub.call('iptables -F > /dev/null', shell=True)
def port_kapa(self): deger = self.port.text() input.append(Reject(proto='tcp', dport=deger)) output.append(Reject(proto='tcp', dport=deger)) restore(tables) self.yenile()
input.append(Accept(match='conntrack', ctstate='ESTABLISHED')) output.append(Accept(match='conntrack', ctstate='ESTABLISHED')) # kurallara uymayan paketleri drop et forward.policy = Rule.DROP # default koruma forward.append(Accept(proto='tcp', dport='53')) forward.append(Accept(proto='tcp', dport='80')) forward.append(Accept(proto='tcp', dport='443')) drop_ddos = Rule(proto='tcp', dport='80', m='limit', limit='25/minute', limit_burst='100', j='ACCEPT', comment='Save you from DDos :)') input.append(drop_ddos) restore(tables) # iptables durumunu görüntüleme p = sub.Popen(('iptables', '-L', '-v', '-n'), stdout=sub.PIPE) terminal_output, errors = p.communicate() terminal_output = str(terminal_output, 'UTF-8') terminal_output.split("/n") # |------------------------ Özel CheckBox Sınıfımız -------------------------| class MyCheckBox(QCheckBox): def __init__(self, *args, **kwargs): QCheckBox.__init__(self, *args, **kwargs) self.setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255);") # set default check as True