Compare commits
10 Commits
v1.0.0
...
256a0598d9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
256a0598d9 | ||
|
|
00736d5415 | ||
|
|
f2e7d3a9ad | ||
|
|
5cd5775161 | ||
|
|
b9972468c8 | ||
|
|
75d8c776f2 | ||
|
|
e04dd39969 | ||
|
|
515e0f3add | ||
|
|
46ae2cafab | ||
|
|
ed153442dd |
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2021 ProjectDiscovery, Inc.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
22
README.md
22
README.md
@@ -1,4 +1,22 @@
|
|||||||
# unhttpx
|
# unhttpx
|
||||||
unhttpx is not a fast and multi-purpose HTTP toolkit that allows running multiple probes using the retryablehttp library. In fact, it does the exact opposite.
|
|
||||||
|
|
||||||
**TL;DR: turns a list of URLs into hostnames.**
|
[](https://pkg.go.dev/github.com/melvinsh/unhttpx)
|
||||||
|
|
||||||
|
Turns a list of URLs into hostnames.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
go install -v github.com/melvinsh/unhttpx@latest
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
$ echo "https://google.com/yo" | unhttpx
|
||||||
|
google.com
|
||||||
|
|
||||||
|
$ cat urls.txt | unhttpx
|
||||||
|
hackerone.com
|
||||||
|
zerocopter.com
|
||||||
|
```
|
||||||
|
|||||||
29
main.go
29
main.go
@@ -3,39 +3,24 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var urls []string
|
|
||||||
|
|
||||||
scanner := bufio.NewScanner(os.Stdin)
|
scanner := bufio.NewScanner(os.Stdin)
|
||||||
|
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
u := scanner.Text()
|
inputURL := scanner.Text()
|
||||||
|
parsedURL, err := url.Parse(inputURL)
|
||||||
if u != "" {
|
if err != nil {
|
||||||
urls = append(urls, u)
|
fmt.Fprintf(os.Stderr, "Error parsing URL: %v\n", err)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
fmt.Println(parsedURL.Host)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := scanner.Err(); err != nil {
|
if err := scanner.Err(); err != nil {
|
||||||
log.Println(err)
|
fmt.Fprintf(os.Stderr, "Error reading input: %v\n", err)
|
||||||
}
|
|
||||||
|
|
||||||
for _, url := range urls {
|
|
||||||
fmt.Println(host(url))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func host(u string) string {
|
|
||||||
parsed, err := url.Parse(u)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return u
|
|
||||||
}
|
|
||||||
|
|
||||||
return parsed.Host
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user