mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 08:34:40 +01:00
commit
2e4b91ceea
3 changed files with 26 additions and 12 deletions
|
@ -43,19 +43,29 @@ class Connection:
|
|||
self.proto = 'udp'
|
||||
self.src_port = self.pkt.udp.sport
|
||||
self.dst_port = self.pkt.udp.dport
|
||||
elif self.pkt.p == ip.IP_PROTO_ICMP:
|
||||
self.proto = 'icmp'
|
||||
self.src_port = None
|
||||
self.dst_port = None
|
||||
|
||||
if None not in ( self.proto, self.src_addr, self.src_port, self.dst_addr, self.dst_port ):
|
||||
if self.proto == 'icmp':
|
||||
self.pid = None
|
||||
self.app = None
|
||||
self.app_path = None
|
||||
self.service = None
|
||||
|
||||
elif None not in (self.proto, self.src_addr, self.dst_addr):
|
||||
try:
|
||||
self.service = getservbyport( int(self.dst_port), self.proto )
|
||||
self.service = getservbyport(int(self.dst_port), self.proto)
|
||||
except:
|
||||
self.service = None
|
||||
|
||||
self.pid, self.app_path = get_pid_by_connection( procmon,
|
||||
self.src_addr,
|
||||
self.src_port,
|
||||
self.dst_addr,
|
||||
self.dst_port,
|
||||
self.proto )
|
||||
self.pid, self.app_path = get_pid_by_connection(procmon,
|
||||
self.src_addr,
|
||||
self.src_port,
|
||||
self.dst_addr,
|
||||
self.dst_port,
|
||||
self.proto)
|
||||
self.app = Application(procmon, desktop_parser,
|
||||
self.pid, self.app_path)
|
||||
self.app_path = self.app.path
|
||||
|
@ -71,6 +81,9 @@ class Connection:
|
|||
return "'%s' ( %s )" % ( self.app.name, self.app_path )
|
||||
|
||||
def get_app_name_and_cmdline(self):
|
||||
if self.proto == 'icmp':
|
||||
return 'Unknown'
|
||||
|
||||
if self.app.cmdline is not None:
|
||||
# TODO: Figure out why we get mixed types here
|
||||
cmdline = self.app.cmdline if isinstance(self.app.cmdline, str) else self.app.cmdline.decode()
|
||||
|
|
|
@ -138,7 +138,7 @@ class Snitch:
|
|||
logging.debug("Could not detect protocol for packet.")
|
||||
return
|
||||
|
||||
elif conn.pid is None:
|
||||
elif conn.pid is None and conn.proto != 'icmp':
|
||||
logging.debug("Could not detect process for connection.")
|
||||
return
|
||||
|
||||
|
|
|
@ -102,11 +102,12 @@ class Dialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
return self.add_connection_signal.emit()
|
||||
|
||||
def setup_labels(self):
|
||||
self.app_name_label.setText(self.connection.app.name)
|
||||
self.app_name_label.setText(
|
||||
getattr(self.connection.app, 'name', 'Unknown'))
|
||||
|
||||
message = self.MESSAGE_TEMPLATE % (
|
||||
self.connection.get_app_name_and_cmdline(),
|
||||
self.connection.app.pid,
|
||||
getattr(self.connection.app, 'pid', 'Unknown'),
|
||||
self.connection.hostname,
|
||||
self.connection.proto.upper(),
|
||||
self.connection.dst_port,
|
||||
|
@ -139,7 +140,7 @@ class Dialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
self._action_changed)
|
||||
|
||||
def setup_icon(self):
|
||||
if self.connection.app.icon is not None:
|
||||
if getattr(self.connection.app, 'icon', None) is not None:
|
||||
icon = QtGui.QIcon().fromTheme(self.connection.app.icon)
|
||||
pixmap = icon.pixmap(icon.actualSize(QtCore.QSize(48, 48)))
|
||||
self.icon_label.setPixmap(pixmap)
|
||||
|
|
Loading…
Add table
Reference in a new issue