Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rangertaha committed Jan 17, 2025
2 parents 3ae7fb4 + be8068d commit f9f8e5e
Show file tree
Hide file tree
Showing 239 changed files with 591,476 additions and 5,329 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.9.0] - 2025-01-07
### SQLite database backend
- Load typosquatting and linguistic datasets from the database
- Store results in the database for better analysis
- Cleaned up the plugins and reduced repeating code
- Updated net library

## [0.8.2] - 2024-11-17
### Fixed summary output
- Fixed some issues with getting the total record count and setting the live flag
Expand All @@ -28,7 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.7.0] - 2024-07-11
### Cleanup & reorganize codebase
- Removed the server
- Removed the API server
- Removed the Dockerfile
- Improved plugins

Expand Down
52 changes: 52 additions & 0 deletions cmd/datasets/dev.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2024 Rangertaha. All Rights Reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package main

import (
"fmt"

"github.com/rangertaha/urlinsane/internal/config"
"github.com/rangertaha/urlinsane/internal/dataset"
"github.com/urfave/cli/v2"
)

var DevCmd = cli.Command{
Name: "dev",
Usage: "Dev",
UsageText: "",
UseShortOptionHandling: true,
Flags: importFlags,
Action: func(cCtx *cli.Context) error {
return Dev(cCtx)
},
}

func Dev(cli *cli.Context) error {
// var tlds dataset.Suffix
config.New(config.CliOptions(cli))

tlds := []dataset.Suffix{}
dataset.DB.Find(&tlds)

for _, tld := range tlds {
fmt.Println(tld.Name)
}

// result.RowsAffected // returns found records count, equals `len(users)`
// result.Error // returns error

return nil
}
12 changes: 1 addition & 11 deletions internal/domain/web.go → cmd/datasets/domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,5 @@
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package domain

type URL struct {
Address string `json:"ip,omitempty"`
}

// IPv4 []IP `json:"ipv4,omitempty"`
// IPv6 []IP `json:"ipv6,omitempty"`
// Banner Banner `json:"response,omitempty"`
// Screenshot string `json:"screenshot,omitempty"`
// Html string `json:"html,omitempty"`
// Ssdeep string `json:"ssdeep,omitempty"`
package main
102 changes: 102 additions & 0 deletions cmd/datasets/download.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright 2024 Rangertaha. All Rights Reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package main

import (
"bytes"
"fmt"
"io"
"net/http"
"os"
"path/filepath"
"strings"

"github.com/jedib0t/go-pretty/v6/text"
"github.com/rangertaha/urlinsane/internal/config"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)

var downloadFlags = []cli.Flag{}

var DownloadCmd = cli.Command{
Name: "download",
Aliases: []string{"d"},
Usage: "Download datasets",
UsageText: "download [opt..] [directory]",
UseShortOptionHandling: true,
Flags: downloadFlags,
Action: func(cCtx *cli.Context) error {
if cCtx.NArg() == 0 {
fmt.Println(text.FgRed.Sprint("\n a directory is needed!\n"))
cli.ShowSubcommandHelpAndExit(cCtx, 1)
}

_, err := config.New(config.CliOptions(cCtx))
if err != nil {
log.Error(err)
fmt.Println(text.FgRed.Sprint(err))
cli.ShowSubcommandHelpAndExit(cCtx, 1)
}
return Download(cCtx)
},
}

func Download(cli *cli.Context) error {
folder := cli.Args().First()
configDir := filepath.Join(folder, "domains")
if _, err := os.Stat(configDir); os.IsNotExist(err) {
if err = os.MkdirAll(configDir, 0750); err != nil {
log.Error(err)
}
}

DownloadSuffix(configDir)

return nil
}

func DownloadSuffix(dirname string) {
fmt.Println("Downloading public suffix...")
url := "https://publicsuffix.org/list/public_suffix_list.dat"
resp, err := http.Get(url)
if err != nil {
log.Error(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)

lines := strings.Split(string(body), "\n")
var buffer bytes.Buffer

for _, line := range lines {
line = strings.TrimSpace(line)
if strings.HasPrefix(line, "// ===BEGIN PRIVATE DOMAINS") {
break
}
if line != "" && !strings.HasPrefix(line, "//") {
line = strings.Replace(line, "*.", "", 1)
line = strings.Replace(line, "!", "", 1)
buffer.WriteString(line)
buffer.WriteString("\n")
}
}

if err := os.WriteFile(filepath.Join(dirname, "suffix.lst"), buffer.Bytes(), 0666); err != nil {
log.Fatal(err)
}

}
Loading

0 comments on commit f9f8e5e

Please sign in to comment.