and commited on
Commit
a15a7d4
·
1 Parent(s): 89fad63
Files changed (3) hide show
  1. .gitignore +5 -0
  2. Dockerfile +10 -0
  3. curl_proxy.go +40 -0
.gitignore ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ .DS_Store
2
+ *.swp
3
+ *.out
4
+ .vscode
5
+ node_modules/
Dockerfile ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM golang:1.15.6
2
+ WORKDIR /
3
+ COPY curl_proxy.go /
4
+
5
+ # https://stackoverflow.com/questions/51508150/standard-init-linux-go190-exec-user-process-caused-no-such-file-or-directory
6
+ RUN CGO_ENABLED=0 go build curl_proxy.go
7
+
8
+ FROM lwthiker/curl-impersonate:0.6-chrome
9
+ COPY --from=0 /curl_proxy /usr/app/
10
+ CMD ["./curl_proxy"]
curl_proxy.go ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package main
2
+
3
+
4
+ // curl -H 'Authorization: Bearer xxx' -d 'https://ifconfig.me' 'https://gowah44030-curl.hf.space/curl'
5
+
6
+ import (
7
+ "fmt"
8
+ "net/http"
9
+ "io/ioutil"
10
+ "strings"
11
+ "os/exec"
12
+ )
13
+
14
+ func main() {
15
+
16
+ fmt.Println("start")
17
+ http.HandleFunc("/curl", func ( w http.ResponseWriter, r *http.Request) {
18
+
19
+ // reqToken := r.Header.Get("Authorization")
20
+ // splitToken := strings.Split(reqToken, "Bearer")
21
+ // token := strings.TrimSpace(splitToken[1])
22
+ // if token != "" {
23
+ // fmt.Fprint(w, "invalid key");
24
+ // return
25
+ // }
26
+
27
+
28
+ body, err := ioutil.ReadAll(r.Body)
29
+ if err != nil {
30
+ fmt.Fprint(w, err);
31
+ return
32
+ }
33
+
34
+ cmd := "curl_chrome116 "+ string(body) + ""
35
+ fmt.Println(cmd)
36
+ out, _ := exec.Command("sh","-c", cmd).Output()
37
+ fmt.Fprint(w, string(out));
38
+ })
39
+ http.ListenAndServe("0.0.0.0:7860", nil)
40
+ }