Skip to content

Commit

Permalink
xscan 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
hlcrd committed Feb 23, 2025
0 parents commit 74c0e74
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
xscan
47 changes: 47 additions & 0 deletions legal.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
RESPONSIBLE USE POLICY

By downloading and using any code or software provided herein, you agree to the following terms and conditions:

License Agreement:
You acknowledge that the downloaded code is subject to the terms
of the applicable license agreement accompanying the code. Ensure
compliance with all terms and conditions outlined in the license
agreement.

Authorized Use:
You agree to use the downloaded code solely for lawful purposes and
in accordance with its intended use as described in the accompanying
documentation or license agreement.

Responsibility for Modifications:
Any modifications made to the downloaded code are done at your own
risk. You are responsible for ensuring that any modifications comply
with applicable laws and regulations and do not infringe upon the
rights of any third party.

No Warranty:
The downloaded code is provided "as is" without any warranty, express
or implied. The authors or contributors of the code shall not be liable
for any damages arising from the use or inability to use the code.

Attribution: When applicable, you agree to provide appropriate attribution
to the authors or contributors of the downloaded code as specified in the
accompanying documentation or license agreement.

Compliance with Laws:
You agree to comply with all applicable laws, regulations, and policies
governing the use of the downloaded code, including but not limited to
intellectual property laws and export control regulations.

Indemnification:
You agree to indemnify and hold harmless the authors or contributors of
the downloaded code from any claims, damages, liabilities, or expenses
arising from your use or misuse of the code.

Termination:
These terms and conditions are effective until terminated. The authors
or contributors of the code reserve the right to terminate this agreement
at any time if you fail to comply with its terms.

By downloading and using the code, you acknowledge that you have read, understood, and agree to be bound by these
terms and conditions. If you do not agree with these terms, you are not authorized to download or use the code.
44 changes: 44 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

## ## ##### #### #### #####
#### ## ## ## ## ## ##
## ##### ## ##### ## ##
#### ## ## ## ## ## ## ##
## ## ###### #### ##### ## ##

______________________________________________________________________
ABOUT
______________________________________________________________________
Description: TCP port scanner
Program: xscan
Current version: 1.5
Languages: go 1.23.5
Tested on: Kali linux 2024.4 on Kernel Linux 6.11.2
Author: scarlet-oni
Dependencies: -

______________________________________________________________________
DOCUMENTATION
______________________________________________________________________
Xscan is a tcp port scanner written in golang.
Allows you to scan specific ports or all.

compilation:
go build ...
make (necessary makefile)

Run a scan on a specific port:
./xscan <ip/address> <port>

Start scanning with all ports:
./xscan <ip/address>

______________________________________________________________________
LEGAL STATEMENT
______________________________________________________________________
By downloading, modifying, redistributing, and/or executing xscan, the
user agrees to the contained legal.txt statement found in this repository.

I, scarlet-oni, the creator, take no legal responsibility for unlawful actions
caused/stemming from this program.

Use responsibly and ethically!
17 changes: 17 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.DEFAULT_GOAL := build

fmt:
go fmt xscan.go
.PHONY:fmt

lint: fmt
golint xscan.go
.PHONY:lint

vet: fmt
go vet xscan.go
.PHONY:vet

build: vet
go build xscan.go
.PHONY:build
3 changes: 3 additions & 0 deletions src/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module xscan

go 1.23.5
91 changes: 91 additions & 0 deletions src/xscan.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package main

import (
"fmt"
"log"
"net"
"os"
"sort"
"strconv"
"sync"
"time"
)

func scanner(address string, ports, results chan int, wg *sync.WaitGroup) {
defer wg.Done()
for p := range ports {
address := fmt.Sprintf("%s:%d", address, p)
conn, err := net.Dial("tcp", address)
if err != nil {
results <- -1
continue
}
conn.Close()
results <- p
}
}

func master(address, port string) {
if port != "" {
int_port, err := strconv.Atoi(port)
if err != nil {
log.Fatal("[E] ", err)
}
address = fmt.Sprintf("%s:%d", address, int_port)
conn, err := net.Dial("tcp", address)
if err == nil {
fmt.Printf("port %d is open\n", int_port)
} else {
fmt.Printf("Port %d is closed\n", int_port)
log.Fatal("[E] ", err)
}
conn.Close()
} else {
ports := make(chan int, 100)
results := make(chan int)
var openports []int
var wg sync.WaitGroup

for i := 0; i < cap(ports); i++ {
wg.Add(1)
go scanner(address, ports, results, &wg)
}

go func() {
for i := 1; i <= 1024; i++ {
ports <- i
}
close(ports)
}()

go func() {
wg.Wait()
close(results)
}()

for port := range results {
if port != -1 {
openports = append(openports, port)
}
}

sort.Ints(openports)

for _, port := range openports {
fmt.Printf("[%d] open\n", port)
}

time.Sleep(1 * time.Second)
}
}

func main() {
if len(os.Args) == 2 {
addr := os.Args[1]
master(addr, "")
} else if len(os.Args) == 3 {
addr := os.Args[1]
port_addr := os.Args[2]
master(addr, port_addr)
}
}

0 comments on commit 74c0e74

Please sign in to comment.