Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Wintrmvte committed Mar 16, 2021
0 parents commit db28027
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<h1 align="center"> UnChain </h1> <br>
<p align="center">
<a>
<img src="img.png" width="500" height="600">
</a>
</p>

<p align="center">
A tool to find redirection chains in multiple URLs
</p>



## Introduction

<p>
UnChain automates process of finding and following `30X` redirects by extracting "Location" header of HTTP responses.
</p>

## Usage

Specify a single address (or a file containing URLs) using `-u/--url` flag.


Binary file added img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added unchain
Binary file not shown.
85 changes: 85 additions & 0 deletions unchain.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package main

import(
"fmt"
"os"
"net/http"
"strings"
"github.com/akamensky/argparse"
"github.com/olekukonko/tablewriter"
"github.com/fatih/color"
"github.com/common-nighthawk/go-figure"
. "github.com/redcode-labs/Coldfire"
)

func find_redirects(url string){
if !strings.Contains(url, "https://") && !strings.Contains(url, "http:"){
url = "https://"+url
}
table_data := [][]string{}
next_url := url
for i := 0; i < 50; i++{
redir := &http.Client{CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse }}
res, err := redir.Get(next_url)
if err != nil{
PrintError(err.Error())
}
next_url = res.Header.Get("Location")
sc := IntToStr(res.StatusCode)
url_color := Red
u := next_url
if sc == "200"{
url_color = Green
u = url
}
id := IntToStr(i)
table_data = append(table_data, []string{id, url_color(u), sc})
if sc == "200"{
break
}
}
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"ID", "URL", "STATUS CODE"})
table.SetAutoWrapText(false)
table.SetCenterSeparator("*")
table.SetAlignment(tablewriter.ALIGN_CENTER)
table.SetRowSeparator("-")
for v := range table_data {
table.Append(table_data[v])
}
if len(table_data) != 0{
fmt.Println("")
PrintInfo("URL => "+url)
table.Render()
fmt.Println("")
}
}

func print_banner(){
banner := figure.NewFigure("UnChain", "", true)
color.Set(color.FgMagenta)
fmt.Println("")
banner.Print()
color.Unset()
fmt.Println("")
fmt.Println(F("\tCreated by: redcodelabs.io "+Red("<*>")))
fmt.Println("")
}

func main(){
print_banner()
parser := argparse.NewParser("unchain", "")
var URLS *string = parser.String("u", "url", &argparse.Options{Required: true, Help: "File containing urls or a single url"})
err := parser.Parse(os.Args)
ExitOnError(err)
urls := []string{}
if Exists(*URLS){
urls = FileToSlice(*URLS)
} else{
urls = []string{*URLS}
}
for _, u := range urls{
find_redirects(u)
}
}

0 comments on commit db28027

Please sign in to comment.