Skip to content
This repository was archived by the owner on Mar 6, 2022. It is now read-only.

Commit bef9f34

Browse files
author
Yury Komarov
committed
Merge branch 'master' of https://github.com/dan-v/awslambdaproxy
2 parents 4fe2c29 + e8cc220 commit bef9f34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+831
-419
lines changed

.circleci/config.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ jobs:
77
steps:
88
- checkout
99
- run: go get -u github.com/go-bindata/go-bindata/...
10-
- run: make all-zip
10+
- run: make
1111
- store_artifacts:
12-
path: build/zip/awslambdaproxy-linux-x86-64.zip
13-
destination: awslambdaproxy-linux-x86-64.zip
14-
- store_artifacts:
15-
path: build/zip/lambda.zip
16-
destination: lambda.zip
12+
path: artifacts

.dockerignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
build
2-
data
3-
images
1+
assets
2+
artifacts
43
bindata.go

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
5+
---
6+
7+
### Prerequisites
8+
9+
* [ ] I am running the [latest version](https://github.com/dan-v/awslambdaproxy/releases) of awslambdaproxy
10+
* [ ] I am have read the [README](https://github.com/dan-v/awslambdaproxy#usage) instructions and the [FAQ](https://github.com/dan-v/awslambdaproxy#faq)
11+
12+
### Description
13+
14+
[Description of the issue]
15+
16+
### Steps to Reproduce
17+
18+
1. [First Step]
19+
2. [Second Step]
20+
3. [and so on...]
21+
22+
**Expected behavior:** [What you expected to happen]
23+
24+
**Actual behavior:** [What actually happened]
25+
26+
### Environment
27+
* If you are using CLI, get the version and specify the full command you are using.
28+
```
29+
./awslambdaproxy version
30+
awslambdaproxy version 0.0.12
31+
./awslambdaproxy -r us-west-2,us-west-1 -f 60
32+
```
33+
* If you are using Docker, get the version and specify the full command you are using.
34+
```
35+
docker run -it --rm --entrypoint /app/awslambdaproxy vdan/awslambdaproxy -v
36+
awslambdaproxy version 0.0.12
37+
docker run -d vdan/awslambdaproxy -r us-west-2,us-west-1 -f 60
38+
```
39+
40+
### Error Output
41+
```
42+
...
43+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
5+
---
6+
7+
**Is your feature request related to a problem? Please describe.**
8+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9+
10+
**Describe the solution you'd like**
11+
A clear and concise description of what you want to happen.
12+
13+
**Describe alternatives you've considered**
14+
A clear and concise description of any alternative solutions or features you've considered.
15+
16+
**Additional context**
17+
Add any other context or screenshots about the feature request here.

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ fabric.properties
8383
# .idea/misc.xml
8484
# *.ipr
8585

86-
/awslambdaproxy
87-
data/lambda.zip
88-
data/lambda/main
8986
bindata.go
90-
build/
9187
.DS_Store
9288
vendor/
89+
artifacts
90+
coverage.html

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ RUN apt-get update -y
33
RUN apt-get install -y zip
44
RUN go get -u github.com/go-bindata/go-bindata/...
55
ADD . /src
6-
RUN cd /src && make linux
6+
RUN cd /src && make build
77

88
FROM alpine:latest
9-
COPY --from=build-env /src/build/linux/x86-64/awslambdaproxy /app/
9+
COPY --from=build-env /src/artifacts/server/linux/awslambdaproxy /app/
1010

1111
ENV AWS_ACCESS_KEY_ID=
1212
ENV AWS_SECRET_ACCESS_KEY=
@@ -32,7 +32,7 @@ RUN mkdir ${HOME}/.ssh
3232
EXPOSE 2222
3333
EXPOSE 8080
3434

35-
COPY docker/sshd_config /etc/ssh/sshd_config
36-
COPY docker/entrypoint.sh /entrypoint.sh
35+
COPY build/docker/sshd_config /etc/ssh/sshd_config
36+
COPY build/docker/entrypoint.sh /entrypoint.sh
3737

3838
ENTRYPOINT ["/entrypoint.sh"]

Makefile

Lines changed: 89 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,100 @@
1-
all: linux
1+
SHELL := /bin/bash
2+
TARGET := awslambdaproxy
3+
VERSION := $(shell cat VERSION)
4+
OS := linux
5+
ARCH := amd64
6+
PACKAGE := github.com/dan-v/$(TARGET)
27

3-
lambda:
4-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o data/lambda/main ./lambda
5-
zip -jr data/lambda data/lambda
8+
.PHONY: \
9+
clean \
10+
tools \
11+
test \
12+
coverage \
13+
vet \
14+
lint \
15+
fmt \
16+
build \
17+
lambda-build \
18+
server-build-linux \
19+
server-build-osx \
20+
doc \
21+
release \
22+
docker-build \
23+
docker-release \
624

7-
bindata: lambda
8-
go-bindata -nocompress -pkg awslambdaproxy -o bindata.go data/lambda.zip
25+
all: tools fmt build lint vet test release
926

10-
linux: bindata
11-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./build/linux/x86-64/awslambdaproxy ./cmd/awslambdaproxy
12-
13-
osx:
14-
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ./build/osx/x86-64/awslambdaproxy ./cmd/awslambdaproxy
27+
print-%:
28+
@echo $* = $($*)
1529

1630
clean:
17-
rm -rf data/lambda/awslambdaproxy-lambda
18-
rm -rf data/lambda.zip
19-
rm -rf build
20-
rm -rf bindata.go
31+
rm -Rf artifacts
32+
rm -vf $(CURDIR)/coverage.*
33+
34+
tools:
35+
go get golang.org/x/lint/golint
36+
go get github.com/axw/gocov/gocov
37+
go get github.com/matm/gocov-html
38+
39+
test:
40+
go test -v ./...
41+
42+
coverage:
43+
gocov test ./... > $(CURDIR)/coverage.out 2>/dev/null
44+
gocov report $(CURDIR)/coverage.out
45+
if test -z "$$CI"; then \
46+
gocov-html $(CURDIR)/coverage.out > $(CURDIR)/coverage.html; \
47+
if which open &>/dev/null; then \
48+
open $(CURDIR)/coverage.html; \
49+
fi; \
50+
fi
51+
52+
vet:
53+
go vet -v ./...
54+
55+
lint:
56+
golint $(go list ./... | grep -v /vendor/)
57+
58+
fmt:
59+
go fmt ./...
60+
61+
lambda-build:
62+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o artifacts/lambda/main ./pkg/lambda
63+
zip -jr artifacts/lambda artifacts/lambda
64+
go-bindata -nocompress -pkg server -o pkg/server/bindata.go artifacts/lambda.zip
65+
mv artifacts/lambda.zip artifacts/lambda-$(VERSION).zip
66+
67+
server-build-linux:
68+
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags \
69+
"-X $(PACKAGE)/cmd/awslambdaproxy.version=$(VERSION)" \
70+
-v -o $(CURDIR)/artifacts/server/$(OS)/$(TARGET) ./cmd/main.go
71+
72+
server-build-osx:
73+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags \
74+
"-X $(PACKAGE)/cmd/awslambdaproxy.version=$(VERSION)" \
75+
-v -o $(CURDIR)/artifacts/server/darwin/$(TARGET) ./cmd/main.go
76+
77+
build: lambda-build server-build-linux
78+
79+
build-osx: lambda-build server-build-osx
80+
81+
doc:
82+
godoc -http=:8080 -index
83+
84+
release:
85+
mkdir -p ./artifacts
86+
zip -jr ./artifacts/$(TARGET)-$(OS)-$(VERSION).zip ./artifacts/server/$(OS)/$(TARGET)
2187

88+
<<<<<<< HEAD
2289
all-zip: all
2390
mkdir ./build/zip
2491
zip -jr ./build/zip/awslambdaproxy-linux-x86-64 ./build/linux/x86-64/awslambdaproxy
2592
cp data/lambda.zip ./build/zip/
93+
=======
94+
docker:
95+
docker build . -t vdan/awslambdaproxy:$(VERSION) -t vdan/awslambdaproxy:latest
96+
>>>>>>> e8cc220d5edad0cbbac20ecd5143c1000ec2cda1
2697

27-
.PHONY: lambda bindata
98+
docker-release:
99+
docker push vdan/awslambdaproxy:$(VERSION)
100+
docker push vdan/awslambdaproxy:latest

README.md

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
<b>awslambdaproxy</b> is an [AWS Lambda](https://aws.amazon.com/lambda/) powered HTTP/SOCKS web proxy. It provides a constantly rotating IP address for your network traffic from all regions where AWS Lambda is available. The goal is to obfuscate your traffic and make it harder to track you as a user.
22

3-
![](/images/overview.gif?raw=true)
3+
![](/assets/images/overview.gif?raw=true)
44

55
## Features
66
* HTTP/HTTPS/SOCKS5 proxy protocols support (including authentication).
7-
* No special software required. Just configure your system to use a proxy.
8-
* Each AWS Lambda region provides 1 outgoing IP address that gets rotated roughly every 4 hours. That means if you use 10 AWS regions, you'll get 60 unique IPs per day.
7+
* No special client side software required. Just configure your system to use a proxy.
8+
* Each configured AWS Lambda region provides a large pool of constantly rotating IP address.
99
* Configurable IP rotation frequency between multiple regions.
10-
* Personal proxy server not shared with anyone else.
1110
* Mostly [AWS free tier](https://aws.amazon.com/free/) compatible (see FAQ below).
1211

1312
## Project status
1413
Current code status: <b>proof of concept</b>. This is the first Go application that I've ever written. It has no tests. It may not work. It may blow up. Use at your own risk.
1514

1615
## How it works
17-
At a high level, awslambdaproxy proxies TCP/UDP traffic through AWS Lambda regional endpoints. To do this, awslambdaproxy is setup on a publicly accessible host (e.g. EC2 instance) and it handles creating Lambda resources that run a proxy server ([ginuerzh/gost](https://github.com/ginuerzh/gost)). Since Lambda does not allow you to connect to bound ports in executing functions, a reverse SSH tunnel is established from the Lambda function to the host running awslambdaproxy. Once a tunnel connection is established, all user traffic is forwarded through this reverse tunnel to the proxy server. Lambda functions have a max execution time of 15 minutes, so there is a goroutine that continuously executes Lambda functions to ensure there is always a live tunnel in place. If multiple regions are specified, user traffic will be routed in a round robin fashion across these regions.
16+
At a high level, awslambdaproxy proxies TCP/UDP traffic through AWS Lambda regional endpoints. To do this, awslambdaproxy is setup on a publicly accessible host (e.g. EC2 instance) and it handles creating Lambda resources that run a proxy server ([gost](https://github.com/ginuerzh/gost)). Since Lambda does not allow you to connect to bound ports in executing functions, a reverse SSH tunnel is established from the Lambda function to the host running awslambdaproxy. Once a tunnel connection is established, all user traffic is forwarded through this reverse tunnel to the proxy server. Lambda functions have a max execution time of 15 minutes, so there is a goroutine that continuously executes Lambda functions to ensure there is always a live tunnel in place. If multiple regions are specified, user traffic will be routed in a round robin fashion across these regions.
1817

19-
![](/images/how-it-works.png?raw=true)
18+
![](/assets/images/how-it-works.png?raw=true)
2019

2120
## Installation
2221

@@ -27,13 +26,13 @@ The easiest way is to download a pre-built binary from the [GitHub Releases](htt
2726

2827
## Manual
2928

30-
1. Copy `awslambdaproxy` binary to a publicly accessible linux host (e.g. EC2 instance, VPS instance, etc). You will need to open the following ports on this host:
31-
* Port 22 - functions executing in AWS Lambda will open SSH connections back to the host running `awslambdaproxy`, so this port needs to be open to the world. The SSH key used here is dynamically generated at startup and added to the running users authorized_keys file.
32-
* Port 8080 - the default configuration will start a HTTP/SOCKS proxy listener on this port with default user/password authentication. If you don't want to publicly expose the proxy server, one option is to setup your own VPN server (e.g. [dosxvpn](https://github.com/dan-v/dosxvpn) or [algo](https://github.com/trailofbits/algo)), connect to it, and just run awslambdaproxy with the proxy listener only on localhost (-l localhost:8080).
29+
1. Copy `awslambdaproxy` binary to a <b>publicly accessible</b> linux host (e.g. EC2 instance, VPS instance, etc). You will need to <b>open the following ports</b> on this host:
30+
* <b>Port 22</b> - functions executing in AWS Lambda will open SSH connections back to the host running `awslambdaproxy`, so this port needs to be open to the world. The SSH key used here is dynamically generated at startup and added to the running users authorized_keys file.
31+
* <b>Port 8080</b> - the default configuration will start a HTTP/SOCKS proxy listener on this port with default user/password authentication. If you don't want to publicly expose the proxy server, one option is to setup your own VPN server (e.g. [dosxvpn](https://github.com/dan-v/dosxvpn) or [algo](https://github.com/trailofbits/algo)), connect to it, and just run awslambdaproxy with the proxy listener only on localhost (-l localhost:8080).
3332

3433
2. Optional, but I'd highly recommend taking a look at the Minimal IAM Policies section below. This will allow you to setup minimal permissions required to setup and run the project. Otherwise, if you don't care about security you can always use an access key with full administrator privileges.
3534

36-
3. `awslambdaproxy` will need access to credentials for AWS in some form. This can be either through exporting environment variables (as shown below), shared crendential file, or an IAM role if assigned to the instance you are running it on. See [this](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-credentials) for more details.
35+
3. `awslambdaproxy` will need access to credentials for AWS in some form. This can be either through exporting environment variables (as shown below), shared credential file, or an IAM role if assigned to the instance you are running it on. See [this](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-credentials) for more details.
3736

3837
```shell script
3938
export AWS_ACCESS_KEY_ID=XXXXXXXXXX
@@ -51,14 +50,32 @@ The easiest way is to download a pre-built binary from the [GitHub Releases](htt
5150
./awslambdaproxy run -r us-west-2,us-west-1,us-east-1,us-east-2
5251
```
5352

54-
6. Configure your web browser (or OS) to use the SOCKS5 proxy on the publicly accessible host running `awslambdaproxy` on port 8080.
53+
6. Configure your web browser (or OS) to use the HTTP/SOCKS5 proxy on the publicly accessible host running `awslambdaproxy` on port 8080.
54+
55+
## Examples
56+
```
57+
# execute proxy in four different regions with rotation happening every 60 seconds
58+
./awslambdaproxy run -r us-west-2,us-west-1,us-east-1,us-east-2 -f 60s
59+
60+
# choose a different port and username/password for proxy and add another listener on localhost with no auth
61+
./awslambdaproxy run -l "admin:admin@:8888,localhost:9090"
62+
63+
# bypass certain domains from using lambda proxy
64+
./awslambdaproxy run -b "*.websocket.org,*.youtube.com"
65+
66+
# specify a dns server for the proxy server to use for dns lookups
67+
./awslambdaproxy run -l "admin:awslambdaproxy@:8080?dns=1.1.1.1"
68+
69+
# increase function memory size for better network performance
70+
./awslambdaproxy run -m 512
71+
```
5572
5673
## Minimal IAM Policies
5774
* This assumes you have the AWS CLI setup with an admin user
5875
* Create a user with proper permissions needed to run the setup command. This user can be removed after running the setup command.
5976
```shell script
6077
aws iam create-user --user-name awslambdaproxy-setup
61-
aws iam put-user-policy --user-name awslambdaproxy-setup --policy-name awslambdaproxy-setup --policy-document file://iam/setup.json
78+
aws iam put-user-policy --user-name awslambdaproxy-setup --policy-name awslambdaproxy-setup --policy-document file://deployment/iam/setup.json
6279
aws iam create-access-key --user-name awslambdaproxy-setup
6380
{
6481
"AccessKey": {
@@ -73,7 +90,7 @@ aws iam create-access-key --user-name awslambdaproxy-setup
7390
* Create a user with proper permission needed to run the proxy.
7491
```shell script
7592
aws iam create-user --user-name awslambdaproxy-run
76-
aws iam put-user-policy --user-name awslambdaproxy-run --policy-name awslambdaproxy-run --policy-document file://iam/run.json
93+
aws iam put-user-policy --user-name awslambdaproxy-run --policy-name awslambdaproxy-run --policy-document file://deployment/iam/run.json
7794
aws iam create-access-key --user-name awslambdaproxy-run
7895
{
7996
"AccessKey": {
@@ -109,25 +126,25 @@ It will create all dependent resources and run awslambdaproxy inside Docker cont
109126
2. <b>Why did you use AWS Lambda for this?</b> The primary reason for using AWS Lambda in this project is the vast pool of IP addresses available that automatically rotate.
110127
3. <b>How big is the pool of available IP addresses?</b> This I don't know, but I do know I did not have a duplicate IP while running the proxy for a week.
111128
4. <b>Will this make me completely anonymous?</b> No, absolutely not. The goal of this project is just to obfuscate your web traffic by rotating your IP address. All of your traffic is going through AWS which could be traced back to your account. You can also be tracked still with [browser fingerprinting](https://panopticlick.eff.org/), etc. Your [IP address may still leak](https://ipleak.net/) due to WebRTC, Flash, etc.
112-
5. <b>How often will my external IP address change?</b> For each region specified, the IP address will change roughly every 4 hours. This of course is subject to change at any moment as this is not something that is documented by AWS Lambda.
129+
5. <b>How often will my external IP address change?</b> I'm not positive as that's specific to the internals of AWS Lambda, and that can change at any time. However, I'll give an example, with 4 regions specified rotating every 5 minutes it resulted in around 15 unique IPs per hour.
113130
6. <b>How much does this cost?</b> awslambdaproxy should be able to run mostly on the [AWS free tier](https://aws.amazon.com/free/) minus bandwidth costs. It can run on a t2.micro instance and the default 128MB Lambda function that is constantly running should also fall in the free tier usage. The bandwidth is what will cost you money; you will pay for bandwidth usage for both EC2 and Lambda.
114-
7. <b>Why does my connection drop periodically?</b> AWS Lambda functions can currently only execute for a maximum of 15 minutes. In order to maintain an ongoing proxy a new function is executed and all new traffic is cut over to it. Any ongoing connections to the previous Lambda function will hard stop after a timeout period. You generally won't see any issues for normal web browsing as connections are very short lived, but for any long lived connections you may see issues.
131+
7. <b>Why does my connection drop periodically?</b> AWS Lambda functions can currently only execute for a maximum of 15 minutes. In order to maintain an ongoing proxy a new function is executed and all new traffic is cut over to it. Any ongoing connections to the previous Lambda function will hard stop after a timeout period. You generally won't see any issues for normal web browsing as connections are very short lived, but for any long lived connections you will see issues. Consider using the `--bypass` flag to specify known domains that you know use persistent connections to avoid having your connection constantly dropping for these.
115132

116133
# Powered by
117134
* [gost](https://github.com/ginuerzh/gost) - A simple security tunnel written in Golang.
118135
* [yamux](https://github.com/hashicorp/yamux) - Golang connection multiplexing library.
119136
* [goad](https://github.com/goadapp/goad) - Code was borrowed from this project to handle AWS Lambda zip creation and function upload.
120137

121138
## Build From Source
122-
1. Install [Go](https://golang.org/dl/) and [go-bindata](https://github.com/kevinburke/go-bindata)
139+
1. Install [Go](https://golang.org/dl/) and [go-bindata](https://github.com/go-bindata/go-bindata)
123140

124141
2. Fetch the project with `git clone`:
125142

126143
```shell script
127144
git clone git@github.com:dan-v/awslambdaproxy.git && cd awslambdaproxy
128145
```
129146

130-
3. Run make to build awslambdaproxy. You'll find your `awslambdaproxy` binary in the `build` folder.
147+
3. Run make to build awslambdaproxy. You'll find your `awslambdaproxy` binary in the `artifacts` folder.
131148

132149
```shell script
133150
make

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.13
File renamed without changes.

0 commit comments

Comments
 (0)