Last active
June 27, 2019 18:02
-
-
Save Galiold/88dbeb9c08deb2c9cefec463b1fd71a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import ssl | |
def receive_print(ss): | |
response = b'' | |
while True: | |
recv = ss.recv(1024) | |
if not recv: | |
break | |
response += recv | |
print(response.decode()) | |
ss = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
ss = ssl.wrap_socket(ss, keyfile=None, certfile=None, server_side=False, cert_reqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_SSLv23) | |
ss.connect(('hotspot.um.ac.ir', 443)) | |
# ss = ssl.wrap_socket(s, ssl_version=ssl.PROTOCOL_TLSv1) | |
# addr = socket.gethostbyname('https://hotspot.um.ac.ir') | |
request = (''' | |
POST /login HTTP/1.1\r\n | |
Host: hotspot.um.ac.ir\r\n | |
Host: hotspot.um.ac.ir\r\n | |
Connection: keep-alive\r\n | |
Content-Length: 77\r\n | |
Cache-Control: max-age=0\r\n | |
Origin: https://hotspot.um.ac.ir\r\n | |
Upgrade-Insecure-Requests: 1\r\n | |
Content-Type: application/x-www-form-urlencoded\r\n | |
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36\r\n | |
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3\r\r | |
Referer: https://hotspot.um.ac.ir/login?\r\n | |
Accept-Encoding: gzip, deflate, br\r\n | |
Accept-Language: en-US,en;q=0.9,fa;q=0.8\r\n | |
Postman-Token: 1e20c964-4126-4c71-b240-3af429e2a1a8,bf26cbb9-dcf9-474b-8af7-9ee721118027\r\n | |
cache-control: no-cache\r\n | |
\r\n\r\n | |
username=&{username}&password=${Password}&dst=&popup=true\r\n | |
\r\n\r\n | |
''') | |
ss.send(request.encode('ascii')) | |
receive_print(ss) | |
ss.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment