PROC TCP: mudanças entre as edições
Ir para navegação
Ir para pesquisar
(Criou página com '=URLs= *[https://www.kernel.org/doc/Documentation/networking/proc_net_tcp.txt Kernel.org proc_net_tcp.txt ] =scripts= ==Convert HEX IP to DEC IP== BASH <syntaxhighlight lang=b...') |
Sem resumo de edição |
||
Linha 1: | Linha 1: | ||
= | =/proc/net/tcp= | ||
*[https://www.kernel.org/doc/Documentation/networking/proc_net_tcp.txt Kernel.org proc_net_tcp.txt ] | *[https://www.kernel.org/doc/Documentation/networking/proc_net_tcp.txt Kernel.org proc_net_tcp.txt ] | ||
=scripts= | =scripts= |
Edição atual tal como às 12h24min de 23 de setembro de 2019
/proc/net/tcp
scripts
Convert HEX IP to DEC IP
BASH
echo 0100007F |sed -r "s/../&\n/g" | while read valor; do echo "ibase=16;$valor" | bc;done | tac |tr '\n' '.'
PYTHON
def listen_sockets():
listens = []
lines = open("/proc/net/tcp").readlines()
for l in lines:
ls = l.split()
if ls[3] == '0A':
lp = ls[1].split(':')
ip = str(lp[0])
pair = "%s.%s.%s.%s:%s" %( int(ip[6:8], 16), int(ip[4:6], 16), int(ip[2:4], 16), int(ip[0:2], 16), int(lp[1], 16))
listens.append(str(pair))
return listenslistens = listen_sockets()
print listens
listens = listen_sockets()
print listens
ST Codes
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode 0: 0100007F:08A0 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 7321 1 ffff81002f449980 3000 0 0 2 -1 1: 00000000:006F 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 6656 1 ffff81003a30c080 3000 0 0 2 -1 2: 00000000:0272 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 6733 1 ffff81003a30c6c0 3000 0 0 2 -1 3: 0100007F:0277 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 7411 1 ffff81002f448d00 3000 0 0 2 -1 4: 0100007F:0019 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 7520 1 ffff81002f4486c0 3000 0 0 2 -1 5: 0100007F:089F 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 7339 1 ffff81002f449340 3000 0 0 2 -1 6: 0100007F:E753 0100007F:0016 01 00000000:00000000 02:000AFA92 00000000 500 0 18198 2 ffff81002f448080 204 40 20 2 -1 7: 0100007F:E752 0100007F:0016 06 00000000:00000000 03:000005EC 00000000 0 0 0 2 ffff81000805dc00 On line sl 0: a listening port on tcp/2208. st = 0A = LISTEN On line sl 6: An established session on tcp/22. st = 01 = ESTABLISHED On line sl 7: An socket in TIME_WAIT state after ssh logout. No inode. st = 06 = TIME_WAIT