A basic project to learn Go which I will be updating through time. The tool is designed to perform port scanning on hosts by leveraging Go's quick run times as well as its portabilities.
To install gmap, ensure you have Go installed on your machine, then follow these steps:
git clone https://github.com/majir96/gmap.git
cd gmap
To compile gmap you can use the Go build tool. Here are the steps to do so, including options to reduce the size of the executable:
go build -ldflags="-s -w" -o gmap .
You can cross-compile the executable for different operating systems.
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o gmap.exe main.go
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o gmap main.go
If you have upx installed you can use it to reduce the binary size to make it lighter.
- Install upx
sudo apt install upx
2.Reduce binary size
upx gmap
To build and run gmap using Docker:
- Build the Docker Image
docker build -t gmap .
- Run the Docker Container
docker run --rm -it gmap -t 127.0.0.1 -p 80,443 -o output.txt -f txt
- Scan specific ports or ranges of ports
- Scan all ports (0-65535)
- Perform TCP and UDP scans
- Export scan results to text, CSV, or JSON files
- Filter results to show only open ports
- Set custom timeout for scan operations
go run main.go -t <IP> -p <PORTS> -s <scan> -o <OUTPUT FILE> -f <FORMAT>
- -t, --target <IP>: Target to scan (required)
- -p, --port <PORTS>: Port(s) to scan. Default set to common ports. Separate multiple ports with commas (e.g., -p 22,80,443) or specify a range (e.g., -p 0-100).
- -p-: Scan all ports (0-65535)
- -s, --scan <SCAN>: Type of scan to perform. Options:
- tcp: Perform a TCP scan (default)
- udp: Perform a UDP scan
- -h, --help: Display the help message
- -o, --output <FILE>: Export output to a file (default format: .txt)
- -f, --format <FORMAT>: Format to export the file to. Formats:
- txt: Export to text file (default)
- csv: Export to CSV file
- json: Export to JSON file
- --open: Filter by open ports on output
- --timeout <TIMEOUT>: Timeout for packets when scanning (e.g., 500ms, 2s, 1m)
go run main.go -t 127.0.0.1
go run main.go -t 192.168.1.1 -p 20-80
go run main.go -t 10.0.0.1 -p 53,123,161 -s udp -o scan_results -f json
- Use of Docker to deploy the tool
- Including nmap support
- Including new types of scan
- Including verbose mode
- Including proxy/IP spoofing
- Including vulnerability scanning
Contributions are welcome! Please fork the repository and create a pull request to add features, improve documentation, or fix bugs.
This project is licensed under the GPL License. See the LICENSE file for details.
Using gmap to scan networks without proper authorization is illegal and unethical. Always obtain explicit permission from the owner of the network before performing any scans. Unauthorized scanning can lead to severe legal consequences and negatively impact the security and stability of networks. The developers of gmap are not responsible for any misuse of this tool. Use it responsibly and ethically.