Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
riza committed Jan 30, 2020
0 parents commit e5a3040
Show file tree
Hide file tree
Showing 7 changed files with 845 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tldscan
test.json
out.txt
output.txt
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# tldscan
> TLD scanner by CNAME lookup
[![Go Report Card](https://goreportcard.com/badge/github.com/riza/tldscan)](https://goreportcard.com/report/github.com/riza/tldscan)
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/riza/tldscan)

## Usage

```bash
Usage of ./tldscan:
-d string
Domain (ex: starbucks)
-l string
TLD list file must type of json (ex: cctld.json,tld.json)
-o string
Output file (ex: output.txt)
```

## Meta
<table>
<tr>
<td align="center">
<a href="https://github.com/riza">
<img src="https://avatars1.githubusercontent.com/u/2565849?s=460&v=4" width="100px;" alt="Sinan Ülker"/>
<br />
<sub>
<b>Rıza Sabuncu</b>
</sub>
</a>
</td>
</tr>
</table>

Distributed under the GPL license. See ``LICENCE`` for more information.
1 change: 1 addition & 0 deletions brandlevel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["aaa","aarp","abarth","abb","abbott","abbvie","abc","accenture","aco","aeg","aetna","afl","agakhan","aig","aigo","airbus","airtel","akdn","alfaromeo","alibaba","alipay","allfinanz","allstate","ally","alstom","americanexpress","amex","amica","android","anz","aol","apple","aquarelle","aramco","audi","auspost","axa","azure","baidu","bananarepublic","barclaycard","barclays","basketball","bauhaus","bbc","bbt","bbva","bcg","bentley","bharti","bing","blanco","bloomberg","bms","bmw","bnl","bnpparibas","boehringer","bond","booking","bosch","bostik","bradesco","bridgestone","brother","bugatti","cal","calvinklein","canon","capitalone","caravan","cartier","cba","cbn","cbre","cbs","cern","cfa","chanel","chase","chintai","chrome","chrysler","cisco","citadel","citi","citic","clubmed","comcast","commbank","creditunion","crown","crs","Co-Operative Retailing System)","csc","cuisinella","dabur","datsun","dealer","dell","deloitte","delta","dhl","discover","dish","dnp","dodge","dunlop","dupont","dvag","edeka","emerck","epson","ericsson","erni","esurance","etisalat","eurovision","everbank","extraspace","fage","fairwinds","farmers","fedex","ferrari","ferrero","fiat","fidelity","firestone","firmdale","flickr","flir","flsmidth","ford","fox","fresenius","forex","frogans","frontier","fujitsu","fujixerox","gallo","gallup","gap","gbiz","gea","genting","giving","gle","globo","gmail","gmo","gmx","godaddy","goldpoint","goodyear","goog","google","grainger","guardian","gucci","hbo","hdfc","hdfcbank","hermes","hisamitsu","hitachi","hkt","honda","honeywell","hotmail","hsbc","hughes","hyatt","hyundai","ibm","ieee","ifm","ikano","imdb","infiniti","intel","intuit","ipiranga","iselect","itau","itv","iveco","jaguar","java","jcb","jcp","jeep","jpmorgan","juniper","kddi","kerryhotels","kerrylogistics","kerryproperties","kfh","kia","kinder","kindle","komatsu","kpmg","kred","kuokgroup","lacaixa","ladbrokes","lamborghini","lancaster","lancia","lancome","landrover","lanxess","lasalle","latrobe","lds","leclerc","lego","liaison","lexus","lidl","lifestyle","lilly","lincoln","linde","lipsy","lixil","locus","lotte","lpl","lplfinancial","lundbeck","lupin","macys","maif","man","mango","marriott","maserati","mattel","mckinsey","metlife","microsoft","mini","mit","mitsubishi","mlb","mma","monash","mormon","moto","movistar","msd","mtn","mtr","mutual","nadex","nationwide","natura","nba","nec","netflix","neustar","newholland","nexus","nfl","nhk","nico","nike","nikon","nissan","nissay","nokia","northwesternmutual","norton","nra","ntt","obi","office","omega","oracle","orange","otsuka","ovh","panasonic","pccw","pfizer","philips","piaget","pictet","ping","pioneer","play","playstation","pohl","founder Reinfried Pohl)","politie","praxi","prod","progressive","pru","prudential","pwc","quest","qvc","redstone","reliance","rexroth","ricoh","rmit","rocher","rogers","rwe","safety","sakura","samsung","sandvik","sandvikcoromant","sanofi","sap","saxo","sbi","sbs","sca","scb","schaeffler","schmidt","schwarz","scjohnson","scor","seat","sener","ses","sew","seven","sfr","seek","shangrila","sharp","shaw","shell","shriram","sina","sky","skype","smart","sncf","softbank","sohu","sony","spiegel","stada","staples","star","starhub","statebank","statefarm","statoil","stc","stcgroup","suzuki","swatch","swiftcover","symantec","taobao","target","tatamotors","tdk","telecity","telefonica","temasek","teva","tiffany","tjx","toray","toshiba","total","toyota","travelchannel","travelers","tui","tvs","ubs","unicom","uol","ups","vanguard","verisign","vig","viking","virgin","visa","vista","vistaprint","vivo","volkswagen","volvo","walmart","walter","weatherchannel","weber","weir","williamhill","windows","wme","wolterskluwer","woodside","wtc","xbox","xerox","xfinity","yahoo","yamaxun","yandex","yodobashi","youtube","zappos","zara","zip","zippo"]
1 change: 1 addition & 0 deletions cctld.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["ac","ad","ae","af","ag","ai","al","am","ao","aq","ar","as","at","au","aw","ax","az","ba","bb","bd","be","bf","bg","bh","bi","bj","bm","bn","bo","br","bs","bt","bv","bw","by","bz","ca","cc","cd","cf","cg","ch","ci","ck","cl","cm","cn","co","cr","cu","cv","cw","cx","cy","cz","de","dj","dk","dm","do","dz","ec","ee","eg","er","es","et","eu","fi","fj","fk","fm","fo","fr","ga","gb","gd","ge","gf","gg","gh","gi","gl","gm","gn","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm","hn","hr","ht","hu","id","ie","il","im","in","io","iq","ir","is","it","je","jm","jo","jp","ke","kg","kh","ki","km","kn","kp","kr","kw","ky","kz","la","lb","lc","li","lk","lr","ls","lt","lu","lv","ly","ma","mc","md","me","mg","mh","mk","ml","mm","mn","mo","mp","mq","mr","ms","mt","mu","mv","mw","mx","my","mz","na","nc","ne","nf","ng","ni","nl","no","np","nr","nu","nz","om","pa","pe","pf","pg","ph","pk","pl","pm","pn","pr","ps","pt","pw","py","qa","re","ro","rs","ru","rw","sa","sb","sc","sd","se","sg","sh","si","sj","sk","sl","sm","sn","so","sr","st","su","sv","sx","sy","sz","tc","td","tf","tg","th","tj","tk","tl","tm","tn","to","tr","tt","tv","tw","tz","ua","ug","uk","us","uy","uz","va","vc","ve","vg","vi","vn","vu","wf","ws","ye","yt","za","zm","zw"]
130 changes: 130 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package main

import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"net"
"os"
"strconv"
"strings"
"sync"
"time"
)

const (
version = "v1.0"
)

var (
domainFlag, fileNameListFlag, outputFileFlag string
currentTLDs []string
outputFile *os.File
err error
)

func init() {
flag.StringVar(&domainFlag, "d", "", "Domain")
flag.StringVar(&fileNameListFlag, "l", "", "TLD list json file (ex: cctld.json,tld.json)")
flag.StringVar(&outputFileFlag, "o", "out.txt", "Output file name")
}

func banner(totalTLD string) {

var str = `
| | | | | |
| |_| | __| |___ ___ __ _ _ __
| __| |/ _ / __|/ __/ _ | '_ \
| |_| | (_| \__ \ (_| (_| | | | |
\__|_|\__,_|___/\___\__,_|_| |_| ` + version

str += "\n\n Total TLDs to scan: " + totalTLD
str += "\n-------------------------------------"

fmt.Println(str)
}

func main() {
flag.Parse()

if len(domainFlag) <= 1 {
log.Fatal("Domain must be not empty")
}

fileNames := strings.Split(fileNameListFlag, ",")

for _, fileName := range fileNames {
list, err := openList(fileName)

if err != nil {
log.Fatal(err)
}

currentTLDs = append(currentTLDs, list...)
}

outputFile, err = os.OpenFile(outputFileFlag, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)

if err != nil {
log.Fatalf("output file opening error: %s", err)
}

totalTLDs := strconv.FormatInt(int64(len(currentTLDs)), 10)

banner(totalTLDs)

start := time.Now()
foundCount := 0

var wg sync.WaitGroup
wg.Add(len(currentTLDs))

for _, tld := range currentTLDs {
domain := domainFlag + "." + tld
go func() {
defer wg.Done()
_, err := net.LookupCNAME(domain)
if err == nil {
foundCount++
logFound(domain)
}
}()
}

wg.Wait()

elapsed := time.Since(start)
pwd, _ := os.Getwd()
outputFilePath := pwd + "/" + outputFileFlag

result := "Scan finished, scanner took %s, founded %d domain, output saved to %s\n"

fmt.Printf(result, elapsed, foundCount, outputFilePath)

}

func logFound(domain string) {
fmt.Printf("\033[1;32m[FOUND]\033[0m %s\n", domain)
_, err := outputFile.WriteString(domain + "\n")
if err != nil {
log.Fatalf("failed writing to file: %s", err)
}
}

func openList(fileName string) (list []string, err error) {
data, err := ioutil.ReadFile(fileName)

if err != nil {
return
}

err = json.Unmarshal(data, &list)

if err != nil {
return
}

return
}
Loading

0 comments on commit e5a3040

Please sign in to comment.