De Wiki inetshell
Saltar a: navegación, buscar

Unix Socket[editar]

https://github.com/byronwolfman/dd-openvpn/blob/master/openvpn.py

import socket
import sys
import os

server_address = '/var/run/openvpn.mgmt'
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(server_address)
data = sock.makefile('rb')
line = data.readline()
if not line.startswith('>INFO:OpenVPN'):
    print('Error')
    sock.close()
    sys.exit(1)
sock.send('load-stats\r\n')
line = data.readline().rstrip().lstrip('SUCCESS: ')
print(line)
sock.close()