Skip to content

Commit

Permalink
feat: route http requests through a proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
bjarneo committed Mar 14, 2022
1 parent a3dd4f6 commit 9786350
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ Looking for new features? Create an issue.
- POST/PUT/PATCH HTTP requests
- HTTP JSON payload
- Custom HTTP headers
- Proxy HTTP requests

## Coming

- UDP payload attachment
- Form data payload
- JSON output of the result
- Proxy

## Usage

Expand Down Expand Up @@ -86,6 +86,8 @@ Usage of RIP
POST HTTP request (default false)
-put bool
PUT HTTP request (default false)
-proxy string
The proxy URL to route the traffic (default "")
-udp bool
Run requests UDP flood attack and not http requests (default false)
-udp-bytes int
Expand Down
12 changes: 12 additions & 0 deletions request/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"net"
"net/http"
"net/url"

"github.com/bjarneo/rip/statistics"
"github.com/bjarneo/rip/utils"
Expand Down Expand Up @@ -64,6 +65,17 @@ func httpRequests(hosts []string, args utils.Arguments, stats statistics.Statist
}

client := &http.Client{}

if args.Proxy() != "" {
proxyUrl, err := url.Parse(args.Proxy())

if err != nil {
panic(err)
}

client.Transport = &http.Transport{Proxy: http.ProxyURL(proxyUrl)}
}

resp, err := client.Do(req)

if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions utils/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Arguments struct {
patch *bool
json *string
headers *string
proxy *string
}

func Args() Arguments {
Expand All @@ -34,6 +35,7 @@ func Args() Arguments {
patch: flag.Bool("patch", false, "PATCH HTTP request"),
json: flag.String("json", "", "Path to the JSON payload file to be used for the HTTP requests"),
headers: flag.String("headers", "", "Path to the headers file"),
proxy: flag.String("proxy", "", "The proxy URL to route the traffic"),
}

flag.Parse()
Expand Down Expand Up @@ -120,3 +122,7 @@ func (flags *Arguments) Headers() []string {

return make([]string, 0)
}

func (flags *Arguments) Proxy() string {
return *flags.proxy
}

0 comments on commit 9786350

Please sign in to comment.