This commit is contained in:
Neale Pickett 2018-07-24 23:53:06 +00:00
parent a860c7f069
commit d06ca08456
5 changed files with 84 additions and 84 deletions

View File

@ -14,8 +14,8 @@ package gapstring
import (
"bytes"
"fmt"
"encoding/binary"
"fmt"
"strings"
"unicode/utf16"
)
@ -298,7 +298,7 @@ func (g GapString) Hexdump() string {
glen := g.Length()
pos := 0
prev := []byte{}
for ; pos < glen; {
for pos < glen {
// Check for repeats
end := pos + 16
if end > glen {
@ -361,4 +361,3 @@ func (g GapString) Utf16LE(gap string) string {
func (g GapString) Utf16BE(gap string) string {
return g.Utf16(binary.BigEndian, gap)
}

View File

@ -10,11 +10,11 @@ package netshovel
import (
"flag"
"log"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
"github.com/google/gopacket/tcpassembly"
"log"
)
// Mainloop to handle dispatching of PCAP files from command line

View File

@ -4,9 +4,9 @@ import (
"encoding/binary"
"encoding/hex"
"fmt"
"github.com/dirtbags/netshovel/gapstring"
"strings"
"time"
"github.com/dirtbags/netshovel/gapstring"
)
// Error returned by convenience methods that are unable to get enough data
@ -14,6 +14,7 @@ type ShortError struct {
Wanted int // How many bytes you needed
Available int // How many bytes were available
}
func (e *ShortError) Error() string {
return fmt.Sprintf("Short read: wanted %d of %d available", e.wanted, e.available)
}
@ -21,6 +22,7 @@ func (e *ShortError) Error() string {
// Error returned by convenience methods that are unable to operate on gaps in data
type MissingError struct {
}
func (e *MissingError) Error() string {
return "Operation on missing bytes"
}
@ -81,7 +83,7 @@ func (pkt *Packet) Describe() string {
pkt.Description,
)
for _, f := range(pkt.Fields) {
for _, f := range pkt.Fields {
fmt.Fprintf(out, " %s: %s\n", f.key, f.value)
}
fmt.Fprint(out, pkt.Payload.Hexdump())
@ -248,4 +250,3 @@ func (pkt *Packet) Uint8(name string) (uint8, error) {
}
return value.(uint8), err
}

View File

@ -2,14 +2,14 @@ package netshovel
import (
"fmt"
"io"
"os"
"net/url"
"strings"
"time"
"github.com/dirtbags/netshovel/gapstring"
"github.com/google/gopacket"
"github.com/google/gopacket/tcpassembly"
"io"
"net/url"
"os"
"strings"
"time"
)
// A File and the path where it lives