Simulate PPTP connexion in Python
Jeudi 26 juin 2014I want to check PPTP connexion into a script, so I write this small code to simulate first packet PPTP connection:
[sourcecode]
import socket
import array
import struct
HOST = "pptp.example.com"
PORT = 1723
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST,PORT))
hex_string = "009c00011a2b3c4d0001000001000000000000010000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004d6963726f736f667400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
hex_data = hex_string.decode("hex")
msg = bytearray(hex_data)
s.send(msg)
data = s.recv(8)
( len, type, magic ) = struct.unpack(‘>HHI’, data )
data = s.recv( len – 8 )
s.close()
print ( "len=%d,type=%d,magic=0x%0x" ) % ( len, type, magic )
print data.encode(‘hex_codec’)
[/sourcecode]
Source : http://tools.ietf.org/html/rfc2637
http://www.wireshark.org/