Skip to content

Commit

Permalink
Added http banner grabs
Browse files Browse the repository at this point in the history
  • Loading branch information
GobiasSomeCoffeeCo committed Aug 14, 2023
1 parent f7ef07b commit aefbff6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ Feel free to mix and match flags as per your requirements!

**Utility Flags:**

-b Enable a service banner grabber. A simple banner grabber which connects to an open TCP port and prints out anything sent by the listening service within two seconds.
-v Enable verbose mode for real-time display of newly opened ports.
-v Enable verbose mode. Provides real-time display of detected open ports.
-b Enable a service banner grabber. A simple banner grabber which connects to an open TCP port and prints out anything sent by the listening service within two seconds. Also will attempt to grab the HTTP banner of common listening ports for that service.

Example:

Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ func main() {
for _, v := range res {
if opts.Banner {
silentscan.BannerGrab(v)
if v.Port == "80" || v.Port == "443" || v.Port == "8000" || v.Port == "8008" || v.Port == "8080" || v.Port == "8443" || v.Port == "8888" {
_, err := silentscan.GetHTTPBanner(v)
if err != nil {
fmt.Println(err)
}
}
}
if len(v.Banner) == 9 || v.Banner == "" {
fmt.Printf("%v\n", v.Status)
Expand Down
24 changes: 23 additions & 1 deletion pkg/syn/bannergrab.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package silentscan

import (
"crypto/tls"
"fmt"
"log"
"net"
"net/http"
"time"

//"github.com/google/gopacket"
"github.com/google/gopacket/pcap"
)

Expand All @@ -31,3 +32,24 @@ func BannerGrab(s *ScanResults) {
}()

}

func GetHTTPBanner(s *ScanResults) (string, error) {
s.TargetIP = "http://" + s.TargetIP
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}

client := &http.Client{Transport: tr}
resp, err := client.Head(s.TargetIP)
if err != nil {
return "", err
}
defer resp.Body.Close()

serverHeader := resp.Header.Get("Server")
if serverHeader == "" {
return "No Server header found", nil
}
s.Banner = fmt.Sprintf("Banner: %s\n", serverHeader)
return serverHeader, nil
}
2 changes: 1 addition & 1 deletion pkg/syn/syn_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

func handleFlags(opts *ScanOptions, tcp *layers.TCP) {
// SYN defaults to true. If users specify flags,
// SYN defaults to true. If users specify flags,
// we'll assume they prefer it off. We'll verify at the end if they want it enabled.
if opts.UseACK {
tcp.ACK = true
Expand Down
2 changes: 1 addition & 1 deletion pkg/syn/syn_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (s *scanner) scan(opts *ScanOptions, resultsChannel chan<- *ScanResults) er
if err == pcap.NextErrorTimeoutExpired {
continue
} else if err != nil {
log.Printf("%s error reading packet: %v", display.BAD, err)
//log.Printf("%s error reading packet: %v", display.BAD, err)
continue
}

Expand Down

0 comments on commit aefbff6

Please sign in to comment.