Skip to content

Commit

Permalink
adding http banner
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberRoute committed Mar 6, 2024
1 parent e72973a commit 39ee97d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ nmap -vvv -sT -p 1-65535 {target_IP}
- **SYN Scan:** Perform SYN scans to identify open ports on a target host (supports IPv4 and IPv6).
- **Connect Scan:** Perform a full TCP handshake on a target host (supports IPv4 and IPv6).
- **ICMP Echo Request:** Send ICMP Echo Requests to discover live hosts on the network.
- **Banners Grabbing:** An experimental feature so far on FTP, SSH, IRC, MYSQL, POP.
- **Banners Grabbing:** An experimental feature so far on FTP, SSH, IRC, MYSQL, HTTP, POP.

```
2024/03/06 16:42:16 Port 22(ssh) open Version: SSH-2.0-OpenSSH_7.4
Expand Down
31 changes: 31 additions & 0 deletions scanme/grabbers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@ import (
"time"
)

func GetHeader(ipAddress string, port int) (string, error) {
req, err := net.DialTimeout("tcp", ipAddress+":"+strconv.Itoa(port), 1*time.Second)
if err != nil {
return "", err
}
defer req.Close()

_, err = req.Write([]byte("HEAD / HTTP/1.0\r\n\r\n"))
if err != nil {
return "", err
}

reader := bufio.NewReader(req)
for {
line, err := reader.ReadString('\n')
if err != nil {
return "", err
}

if strings.HasPrefix(line, "Server:") {
return strings.TrimSpace(strings.TrimPrefix(line, "Server:")), nil
}
}
}

func GrabMysqlBanner(ipAddress string, port int) (string, error) {
req, err := net.DialTimeout("tcp", ipAddress+":"+strconv.Itoa(port), 1*time.Second)
if err != nil {
Expand Down Expand Up @@ -45,6 +70,12 @@ func GrabBanner(ipAddress string, port int) string {
return ""
}
return mysqlBanner
case 80: // HTTP
serverHeader, err := GetHeader(ipAddress, port)
if err != nil {
return ""
}
return serverHeader
case 6667: // IRC
default:
return ""
Expand Down

0 comments on commit 39ee97d

Please sign in to comment.