Skip to content

Commit

Permalink
Merge pull request #1 from 3ndG4me/dev/gortscanner_5.0_threaded_port_…
Browse files Browse the repository at this point in the history
…scans

Added subroutine for threaded scan per port per target
  • Loading branch information
3ndG4me authored Oct 10, 2020
2 parents 47bb0a0 + 63502a0 commit a0128b2
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 5 deletions.
58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# !!!MAKE SURE YOUR GOPATH ENVIRONMENT VARIABLE IS SET FIRST!!!

# Variables
DIR=builds/
GORT=gortscanner
WINGORTLDFLAGS=-ldflags "-H=windowsgui"
W=Windows-x64
L=Linux-x64
A=Linux-arm
M=Linux-mips
D=Darwin-x64

# Make Directory to store executables
$(shell mkdir -p ${DIR})

# Change default to just make for the host OS and add MAKE ALL to do this
default: gort-windows gort-linux gort-darwin

all: default

# Compile Windows binaries
windows: gort-windows

# Compile Linux binaries
linux: gort-linux

# Compile Arm binaries
arm: gort-arm

# Compile mips binaries
mips: gort-mips

# Compile Darwin binaries
darwin: gort-darwin

# Compile gort - Windows x64
gort-windows:
export GOOS=windows GOARCH=amd64;go build ${WINGORTLDFLAGS} -o ${DIR}/${GORT}-${W}.exe main.go

# Compile gort - Linux mips
gort-mips:
export GOOS=linux;export GOARCH=mips;go build -o ${DIR}/${GORT}-${M} main.go

# Compile gort - Linux arm
gort-arm:
export GOOS=linux;export GOARCH=arm;export GOARM=7;go build -o ${DIR}/${GORT}-${A} main.go

# Compile gort - Linux x64
gort-linux:
export GOOS=linux;export GOARCH=amd64;go build -o ${DIR}/${GORT}-${L} main.go

# Compile gort - Darwin x64
gort-darwin:
export GOOS=darwin;export GOARCH=amd64;go build -o ${DIR}/${GORT}-${D} main.go

clean:
rm -rf ${DIR}*

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Instead of "po" in "port" you get "go" for "gort", because that's how that works
- Can parse port ranges and scan multiple ports Example: `gortscanner 192.168.0.1 1-1024`
- Any combiniation of the above 3
- Cross platform, makes it easy to drop a binary and not deal with python dependencies
- Significantly faster than the python version. Idk by how much, but it's pretty obvious side by side even tweaking delays.
- Significantly faster than the python version. Idk by how much, but it's pretty obvious side by side even tweaking delays, especially thanks to multithreaded goroutines as of version 5.0.
- Better output than version 1.0. Now displays `Host: <host> Ports: <Port/TCP>` for easier parsing.
- Try `./gortscanner <host(s)> <port(s)> | grep “Host:” | tee scan.out` for a nice easy to cut up report.

Expand Down
Binary file added builds/gortscanner-Darwin-x64
Binary file not shown.
Binary file added builds/gortscanner-Linux-x64
Binary file not shown.
Binary file added builds/gortscanner-Windows-x64.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions injection-status.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"name": "Gortscanner",
"version": "5.0",
"platform": "all-desktop",
"progress": "50%",
"progress": "100%",
"state": "in-progress",
"released": true,
"release_version": "4.0",
"release_version": "5.0",
"download_url": "https://github.com/3ndG4me/Gortscanner/releases",
"featured": false,
"featured_image": ""
Expand Down
30 changes: 28 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,22 @@ func doScan(target string, portList []int, wg *sync.WaitGroup) {

var portOutPut []int

var pwg sync.WaitGroup

for _, port := range portList {
// Convert string ports Ints back to strings to handles connection and printing status
conn, err := net.DialTimeout("tcp", target+":"+strconv.Itoa(port), time.Duration(1)*time.Second)

connStatus := make(chan net.Conn)
connErr := make(chan error)

pwg.Add(1)

// Spawn another goroutine per port for super fast scanning! (More ports == eats more memory of course)
go doTCPConnection(target, port, &pwg, connStatus, connErr)

conn,err := <-connStatus, <-connErr
close(connStatus)
close(connErr)

if err != nil {
fmt.Println(err)
}
Expand All @@ -95,6 +108,7 @@ func doScan(target string, portList []int, wg *sync.WaitGroup) {
portOutPut = append(portOutPut, port)
}
}
pwg.Wait()
stringPortOutput, _ := convertPortListToString(portOutPut)
if portOutPut != nil {
fmt.Println("Host: " + target + " Ports: " + strings.Join(stringPortOutput, "/TCP, ") + "/TCP")
Expand All @@ -103,6 +117,18 @@ func doScan(target string, portList []int, wg *sync.WaitGroup) {

}


func doTCPConnection(target string, port int, pwg *sync.WaitGroup, connStatus chan net.Conn, connErr chan error) {

defer pwg.Done()

// Convert string ports Ints back to strings to handles connection and printing status
conn, err := net.DialTimeout("tcp", target+":"+strconv.Itoa(port), time.Duration(1)*time.Second)

connStatus <- conn
connErr <- err
}

func main() {
// Get IP/CIDR range from args
if len(os.Args) < 3 {
Expand Down

0 comments on commit a0128b2

Please sign in to comment.