Last active
June 5, 2020 02:18
-
-
Save bizkut/7c72d72a0fefb1058531709dd2f2d59d to your computer and use it in GitHub Desktop.
Use your mobile phone's data on your pc without tethering. Doesn't need jailbreak or root.
This file contains hidden or 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
#!/usr/bin/env python | |
import socket | |
import select | |
import threading | |
HOST = '' | |
PORT = 50007 | |
# use https or socks5 and use the same protocol on pc | |
PROXYHOST = 'your proxy server' | |
PROXYPORT = 8080 | |
def main(): | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind((HOST, PORT)) | |
s.listen(0) | |
while True: | |
conn, addr = s.accept() | |
print 'Connected by', addr, '#active', threading.active_count() | |
p = threading.Thread(target=tunnel, args=(conn,)) | |
p.start() | |
s.close() | |
def tunnel(conn): | |
provy = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
provy.connect((PROXYHOST, PROXYPORT)) | |
sent = threading.Thread(target=forwarder, args=(conn, provy)) | |
recv = threading.Thread(target=forwarder, args=(provy, conn)) | |
sent.start() | |
recv.start() | |
recv.join() | |
sent.join(10) | |
provy.close() | |
conn.close() | |
def forwarder(r_s, w_s): | |
try: | |
while True: | |
select.select([r_s], [], []) | |
data = r_s.recv(1024) | |
if not data: break | |
select.select([], [w_s], []) | |
w_s.sendall(data) | |
except Exception, e: | |
pass | |
r_s.close() | |
w_s.close() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need a public accessible proxy server.
make sure the phone's screen is stay active while using this. You can set the screen sleep to off.