https://github.com/yeong-hwan/local-proxy
Local proxy program can bypass and image blocking
https://github.com/yeong-hwan/local-proxy
bypass image-block proxy socket-programming
Last synced: over 1 year ago
JSON representation
Local proxy program can bypass and image blocking
- Host: GitHub
- URL: https://github.com/yeong-hwan/local-proxy
- Owner: yeong-hwan
- Created: 2024-02-25T18:55:10.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-28T08:52:36.000Z (over 2 years ago)
- Last Synced: 2025-02-01T18:13:29.356Z (over 1 year ago)
- Topics: bypass, image-block, proxy, socket-programming
- Language: Python
- Homepage:
- Size: 38.2 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# local-proxy
## Flow chart by Psuedo code
## How to run
Check detail proxy setting [here](#mac-proxy-server-setup)
```zsh
cd src
python3 proxy.py 8080
```
## How it works
**Parsing for get “User-Agent” data**
```python
request_data_dict = {}
for line in request_data.decode().splitlines():
try:
title, content = line.split(": ")
request_data_dict[title] = content
except:
pass
response_user_agent = request_data_dict['User-Agent']
end_index = response_user_agent.find(")")
cleaned_user_agent = response_user_agent[:end_index+1].replace("User-Agent: ", "")
```
**Redirection to “mnet.Yonsei.ac.kr” when URL has “korea”**
```python
# Connect to the destination server
server_socket = None
response_data = None
try:
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if url_filter == "O":
destination_host = "mnet.yonsei.ac.kr"
server_socket.connect((destination_host, 80))
except Exception as e:
print("\nServer socket error: " + str(e))
server_socket.sendall(request_data)
```
**Image Filtering**
Log response through proxy
It logs also http status, content-type, content-length and send response_data to client
But It don’t send response_data when drop image
```python
# Print log for the received response
print(f"[CLI <== PRX --- SRV]")
if image_filter == "O":
if response_content.startswith("image"):
print(f" > 404 Not Found")
else:
print(f" > {cleaned_status}")
print(f" > {response_content} {response_bytes}bytes")
client_socket.sendall(response_data)
else:
print(f" > {cleaned_status}")
print(f" > {response_content} {response_bytes}bytes")
# Forward the modified response to the client
client_socket.sendall(response_data)
```
## Snapshots
### Mac proxy server setup
### Image filtering
**Image filtering at test page**
### Redirection
**Redirection from Korea univ page to Yonsei univ page**
**Image filtering with Redirection**
## Environment
OS: Mac Sonoma
Language: Python(3.8.5)