mirror of
https://github.com/maride/pancap.git
synced 2026-04-24 06:35:46 +00:00
Reformat code
This commit is contained in:
@@ -2,24 +2,24 @@ package arp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/maride/pancap/common"
|
||||
"github.com/maride/pancap/output"
|
||||
"github.com/google/gopacket"
|
||||
"github.com/google/gopacket/layers"
|
||||
"github.com/maride/pancap/common"
|
||||
"github.com/maride/pancap/output"
|
||||
"log"
|
||||
"net"
|
||||
)
|
||||
|
||||
var (
|
||||
arpStatsList []arpStats
|
||||
devices []arpDevice
|
||||
arpStatsList []arpStats
|
||||
devices []arpDevice
|
||||
linkLocalBlock = net.IPNet{
|
||||
IP: net.IPv4(169, 254, 0, 0),
|
||||
Mask: net.IPv4Mask(255, 255, 0, 0),
|
||||
}
|
||||
)
|
||||
|
||||
type Protocol struct {}
|
||||
type Protocol struct{}
|
||||
|
||||
// Checks if the given packet is an ARP packet we can process
|
||||
func (p *Protocol) CanAnalyze(packet gopacket.Packet) bool {
|
||||
@@ -118,7 +118,7 @@ func (p *Protocol) getStatOrCreate(macaddr string) *arpStats {
|
||||
|
||||
// None found yet, we need to create a new one
|
||||
arpStatsList = append(arpStatsList, arpStats{
|
||||
macaddr: macaddr,
|
||||
macaddr: macaddr,
|
||||
})
|
||||
|
||||
// And return it
|
||||
|
||||
@@ -2,5 +2,5 @@ package arp
|
||||
|
||||
type arpDevice struct {
|
||||
macaddr string
|
||||
ipaddr string
|
||||
ipaddr string
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package arp
|
||||
|
||||
type arpStats struct {
|
||||
macaddr string
|
||||
asked int
|
||||
answered int
|
||||
askedList []string
|
||||
macaddr string
|
||||
asked int
|
||||
answered int
|
||||
askedList []string
|
||||
answeredList []string
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package dhcpv4
|
||||
|
||||
import (
|
||||
"github.com/maride/pancap/output"
|
||||
"github.com/google/gopacket"
|
||||
"github.com/google/gopacket/layers"
|
||||
"github.com/maride/pancap/output"
|
||||
)
|
||||
|
||||
type Protocol struct {
|
||||
hostnames []hostname
|
||||
hostnames []hostname
|
||||
networkSetup map[layers.DHCPOpt][]byte
|
||||
requestMAC []string
|
||||
responses []dhcpResponse
|
||||
requestMAC []string
|
||||
responses []dhcpResponse
|
||||
}
|
||||
|
||||
// Checks if the given packet is a DHCP packet we can process
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package dhcpv4
|
||||
|
||||
type dhcpResponse struct {
|
||||
destMACAddr string
|
||||
newIPAddr string
|
||||
destMACAddr string
|
||||
newIPAddr string
|
||||
serverMACAddr string
|
||||
askedFor bool
|
||||
askedFor bool
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dhcpv4
|
||||
|
||||
type hostname struct {
|
||||
hostname string
|
||||
hostname string
|
||||
requestedByMAC string
|
||||
granted bool
|
||||
granted bool
|
||||
deniedHostname string
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package dhcpv4
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/maride/pancap/common"
|
||||
"github.com/google/gopacket/layers"
|
||||
"github.com/maride/pancap/common"
|
||||
"log"
|
||||
)
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ import (
|
||||
|
||||
var (
|
||||
watchedOpts = []layers.DHCPOpt{
|
||||
layers.DHCPOptSubnetMask, // Option 1
|
||||
layers.DHCPOptRouter, // Option 3
|
||||
layers.DHCPOptDNS, // Option 6
|
||||
layers.DHCPOptSubnetMask, // Option 1
|
||||
layers.DHCPOptRouter, // Option 3
|
||||
layers.DHCPOptDNS, // Option 6
|
||||
layers.DHCPOptBroadcastAddr, // Option 28
|
||||
layers.DHCPOptNTPServers, // Option 42
|
||||
layers.DHCPOptLeaseTime, // Option 51
|
||||
layers.DHCPOptT1, // Option 58
|
||||
layers.DHCPOptNTPServers, // Option 42
|
||||
layers.DHCPOptLeaseTime, // Option 51
|
||||
layers.DHCPOptT1, // Option 58
|
||||
}
|
||||
)
|
||||
|
||||
@@ -126,7 +126,7 @@ func formatDate(rawDate []byte) (string, bool) {
|
||||
intDate := binary.LittleEndian.Uint32(rawDate)
|
||||
seconds := intDate % 60
|
||||
minutes := intDate / 60 % 60
|
||||
hours := intDate / 60 / 60 % 60
|
||||
hours := intDate / 60 / 60 % 60
|
||||
formattedDate := ""
|
||||
|
||||
// Check which words we need to pick
|
||||
|
||||
@@ -2,8 +2,8 @@ package dhcpv4
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/maride/pancap/common"
|
||||
"github.com/google/gopacket/layers"
|
||||
"github.com/maride/pancap/common"
|
||||
)
|
||||
|
||||
// Processes the DHCP request packet handed over
|
||||
|
||||
@@ -2,8 +2,8 @@ package dhcpv4
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/maride/pancap/common"
|
||||
"github.com/google/gopacket/layers"
|
||||
"github.com/maride/pancap/common"
|
||||
"log"
|
||||
)
|
||||
|
||||
|
||||
@@ -2,20 +2,20 @@ package dns
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/maride/pancap/common"
|
||||
"github.com/google/gopacket/layers"
|
||||
"github.com/maride/pancap/common"
|
||||
"golang.org/x/net/publicsuffix"
|
||||
"log"
|
||||
)
|
||||
|
||||
var (
|
||||
numAnswers int
|
||||
answerDomains []string
|
||||
answerBaseDomains []string
|
||||
numAnswers int
|
||||
answerDomains []string
|
||||
answerBaseDomains []string
|
||||
answerPrivateDomains []string
|
||||
answerType = make(map[layers.DNSType]int)
|
||||
answerPublicIPv4 []string
|
||||
answerPrivateIPv4 []string
|
||||
answerType = make(map[layers.DNSType]int)
|
||||
answerPublicIPv4 []string
|
||||
answerPrivateIPv4 []string
|
||||
)
|
||||
|
||||
// Called on every DNS packet to process response(s)
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
var (
|
||||
privateBlocks = []net.IPNet{
|
||||
{net.IPv4(10, 0, 0, 0), net.IPv4Mask(255, 0, 0, 0)}, // 10.0.0.0/8
|
||||
{net.IPv4(10, 0, 0, 0), net.IPv4Mask(255, 0, 0, 0)}, // 10.0.0.0/8
|
||||
{net.IPv4(172, 16, 0, 0), net.IPv4Mask(255, 240, 0, 0)}, // 172.16.0.0/12
|
||||
{net.IPv4(192, 168, 0, 0), net.IPv4Mask(255, 255, 0, 0)}, // 192.168.0.0/24
|
||||
{net.IPv4(100, 64, 0, 0), net.IPv4Mask(255, 192, 0, 0)}, // 100.64.0.0/10
|
||||
@@ -58,7 +58,7 @@ func (p *Protocol) generateDNSTypeSummary(typearr map[layers.DNSType]int) string
|
||||
if iter == 0 {
|
||||
// We don't need to append yet
|
||||
answerstr = elem
|
||||
} else if iter == len(answerarr) - 1 {
|
||||
} else if iter == len(answerarr)-1 {
|
||||
// Last element, use "and" instead of a comma
|
||||
answerstr = fmt.Sprintf("%s and %s", answerstr, elem)
|
||||
} else {
|
||||
@@ -68,4 +68,4 @@ func (p *Protocol) generateDNSTypeSummary(typearr map[layers.DNSType]int) string
|
||||
}
|
||||
|
||||
return answerstr
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package dns
|
||||
|
||||
import (
|
||||
"github.com/maride/pancap/output"
|
||||
"github.com/google/gopacket"
|
||||
"github.com/google/gopacket/layers"
|
||||
"github.com/maride/pancap/output"
|
||||
)
|
||||
|
||||
type Protocol struct {}
|
||||
type Protocol struct{}
|
||||
|
||||
func (p *Protocol) CanAnalyze(packet gopacket.Packet) bool {
|
||||
return packet.Layer(layers.LayerTypeDNS) != nil
|
||||
|
||||
@@ -2,18 +2,18 @@ package dns
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/maride/pancap/common"
|
||||
"github.com/google/gopacket/layers"
|
||||
"github.com/maride/pancap/common"
|
||||
"golang.org/x/net/publicsuffix"
|
||||
"log"
|
||||
)
|
||||
|
||||
var (
|
||||
numQuestions int
|
||||
questionDomains []string
|
||||
questionBaseDomains []string
|
||||
numQuestions int
|
||||
questionDomains []string
|
||||
questionBaseDomains []string
|
||||
questionPrivateDomains []string
|
||||
questionType = make(map[layers.DNSType]int)
|
||||
questionType = make(map[layers.DNSType]int)
|
||||
)
|
||||
|
||||
// Called on every DNS packet to process questions
|
||||
@@ -72,4 +72,4 @@ func (p *Protocol) generateDNSQuestionSummary() string {
|
||||
|
||||
// And return summary
|
||||
return summary
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"github.com/maride/pancap/common"
|
||||
"github.com/maride/pancap/output"
|
||||
"github.com/google/gopacket"
|
||||
"github.com/google/gopacket/layers"
|
||||
"github.com/google/gopacket/tcpassembly"
|
||||
"github.com/maride/pancap/common"
|
||||
"github.com/maride/pancap/output"
|
||||
)
|
||||
|
||||
type Protocol struct {
|
||||
initialized bool
|
||||
requestFactory *httpRequestFactory
|
||||
responseFactory *httpResponseFactory
|
||||
requestPool *tcpassembly.StreamPool
|
||||
responsePool *tcpassembly.StreamPool
|
||||
requestAssembler *tcpassembly.Assembler
|
||||
initialized bool
|
||||
requestFactory *httpRequestFactory
|
||||
responseFactory *httpResponseFactory
|
||||
requestPool *tcpassembly.StreamPool
|
||||
responsePool *tcpassembly.StreamPool
|
||||
requestAssembler *tcpassembly.Assembler
|
||||
responseAssembler *tcpassembly.Assembler
|
||||
}
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@ package http
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"github.com/maride/pancap/output"
|
||||
"github.com/google/gopacket"
|
||||
"github.com/google/gopacket/tcpassembly"
|
||||
"github.com/google/gopacket/tcpassembly/tcpreader"
|
||||
"github.com/maride/pancap/output"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var (
|
||||
responseSummaryLines []string
|
||||
responseSummaryLines []string
|
||||
)
|
||||
|
||||
type httpResponseFactory struct{}
|
||||
|
||||
Reference in New Issue
Block a user