language stringlengths 0 24 | filename stringlengths 9 214 | code stringlengths 99 9.93M |
|---|---|---|
Go | bettercap/modules/wifi/wifi.go | package wifi
import (
"bytes"
"fmt"
"net"
"regexp"
"strconv"
"sync"
"time"
"github.com/bettercap/bettercap/modules/utils"
"github.com/bettercap/bettercap/network"
"github.com/bettercap/bettercap/packets"
"github.com/bettercap/bettercap/session"
"github.com/google/gopacket"
"github.com/google/gopacket/la... |
Go | bettercap/modules/wifi/wifi_ap.go | package wifi
import (
"errors"
"net"
"time"
"github.com/bettercap/bettercap/network"
"github.com/bettercap/bettercap/packets"
"github.com/bettercap/bettercap/session"
"github.com/evilsocket/islazy/tui"
)
var errNoRecon = errors.New("Module wifi.ap requires module wifi.recon to be activated.")
func (mod *WiF... |
Go | bettercap/modules/wifi/wifi_assoc.go | package wifi
import (
"bytes"
"fmt"
"net"
"sort"
"github.com/bettercap/bettercap/network"
"github.com/bettercap/bettercap/packets"
)
func (mod *WiFiModule) sendAssocPacket(ap *network.AccessPoint) {
if err, pkt := packets.NewDot11Auth(mod.iface.HW, ap.HW, 1); err != nil {
mod.Error("cloud not create auth pa... |
Go | bettercap/modules/wifi/wifi_csa.go | package wifi
import (
"bytes"
"fmt"
"github.com/bettercap/bettercap/network"
"github.com/bettercap/bettercap/packets"
"github.com/google/gopacket/layers"
"net"
)
func (mod *WiFiModule) isCSASilent() bool {
if err, is := mod.BoolParam("wifi.channel_switch_announce.silent"); err != nil {
mod.Warning("%v", err)... |
Go | bettercap/modules/wifi/wifi_deauth.go | package wifi
import (
"bytes"
"fmt"
"net"
"sort"
"time"
"github.com/bettercap/bettercap/network"
"github.com/bettercap/bettercap/packets"
)
func (mod *WiFiModule) injectPacket(data []byte) {
if err := mod.handle.WritePacketData(data); err != nil {
mod.Error("could not inject WiFi packet: %s", err)
mod.Se... |
Go | bettercap/modules/wifi/wifi_events.go | package wifi
import (
"github.com/bettercap/bettercap/network"
)
type ClientEvent struct {
AP *network.AccessPoint
Client *network.Station
}
type DeauthEvent struct {
RSSI int8 `json:"rssi"`
AP *network.AccessPoint `json:"ap"`
Address1 string `json:"address1"`
Addre... |
Go | bettercap/modules/wifi/wifi_fake_auth.go | package wifi
import (
"bytes"
"fmt"
"github.com/bettercap/bettercap/network"
"github.com/bettercap/bettercap/packets"
"net"
)
func (mod *WiFiModule) isFakeAuthSilent() bool {
if err, is := mod.BoolParam("wifi.fake_auth.silent"); err != nil {
mod.Warning("%v", err)
} else {
mod.csaSilent = is
}
return mo... |
Go | bettercap/modules/wifi/wifi_hopping.go | package wifi
import (
"net"
"time"
"github.com/bettercap/bettercap/network"
)
func (mod *WiFiModule) isInterfaceConnected() bool {
ifaces, err := net.Interfaces()
if err != nil {
mod.Error("error while enumerating interfaces: %s", err)
return false
}
for _, iface := range ifaces {
if mod.iface.HwAddres... |
Go | bettercap/modules/wifi/wifi_recon.go | package wifi
import (
"bytes"
"net"
"time"
"github.com/bettercap/bettercap/network"
"github.com/bettercap/bettercap/packets"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
func (mod *WiFiModule) stationPruner() {
mod.reads.Add(1)
defer mod.reads.Done()
maxApTTL := time.Duration(mod.ap... |
Go | bettercap/modules/wifi/wifi_recon_handshakes.go | package wifi
import (
"bytes"
"fmt"
"github.com/bettercap/bettercap/network"
"net"
"path"
"github.com/bettercap/bettercap/packets"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
func allZeros(s []byte) bool {
for _, v := range s {
if v != 0 {
return false
}
}
return true
}
fun... |
Go | bettercap/modules/wifi/wifi_show.go | package wifi
import (
"fmt"
"sort"
"strconv"
"strings"
"time"
"github.com/bettercap/bettercap/modules/net_recon"
"github.com/bettercap/bettercap/network"
"github.com/bettercap/bettercap/session"
"github.com/dustin/go-humanize"
"github.com/evilsocket/islazy/ops"
"github.com/evilsocket/islazy/tui"
)
func ... |
Go | bettercap/modules/wifi/wifi_show_sort.go | package wifi
import (
"github.com/bettercap/bettercap/network"
"github.com/bettercap/bettercap/session"
)
type ByRSSISorter []*network.Station
func (a ByRSSISorter) Len() int { return len(a) }
func (a ByRSSISorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByRSSISorter) Less(i, j int) bool {
if a[i]... |
Go | bettercap/modules/wol/wol.go | package wol
import (
"fmt"
"net"
"regexp"
"github.com/bettercap/bettercap/packets"
"github.com/bettercap/bettercap/session"
"github.com/google/gopacket/layers"
"github.com/evilsocket/islazy/str"
"github.com/evilsocket/islazy/tui"
)
var (
reMAC = regexp.MustCompile(`^([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})... |
Go | bettercap/network/arp.go | package network
import (
"fmt"
"strings"
"sync"
"github.com/bettercap/bettercap/core"
)
type ArpTable map[string]string
var (
arpWasParsed = false
arpLock = &sync.RWMutex{}
arpTable = make(ArpTable)
)
func ArpUpdate(iface string) (ArpTable, error) {
arpLock.Lock()
defer arpLock.Unlock()
// Sign... |
Go | bettercap/network/arp_parser_darwin.go | package network
import "regexp"
var ArpTableParser = regexp.MustCompile(`^[^\d\.]+([\d\.]+).+\s+([a-f0-9:]{11,17})\s+on\s+([^\s]+)\s+.+$`)
var ArpTableTokens = 4
var ArpTableTokenIndex = []int{1, 2, 3}
var ArpCmd = "arp"
var ArpCmdOpts = []string{"-a", "-n"} |
Go | bettercap/network/arp_parser_linux.go | package network
import "regexp"
var ArpTableParser = regexp.MustCompile(`^([a-f\d\.:]+)\s+dev\s+(\w+)\s+\w+\s+([a-f0-9:]{17})\s+.+$`)
var ArpTableTokens = 4
var ArpTableTokenIndex = []int{1, 3, 2}
var ArpCmd = "ip"
var ArpCmdOpts = []string{"neigh"} |
Go | bettercap/network/arp_parser_windows.go | package network
import "regexp"
var ArpTableParser = regexp.MustCompile(`^[^\d\.]+([\d\.]+).+\s+([a-f0-9\-]{11,17})\s+.+$`)
var ArpTableTokens = 3
var ArpTableTokenIndex = []int{1, 2, -1}
var ArpCmd = "arp"
var ArpCmdOpts = []string{"-a"} |
Go | bettercap/network/ble.go | // +build !windows
package network
import (
"encoding/json"
"sync"
"time"
"github.com/bettercap/gatt"
"github.com/evilsocket/islazy/data"
)
const BLEMacValidator = "([a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2})"
type BLEDevNewCallback func(dev *BLEDev... |
Go | bettercap/network/ble_device.go | // +build !windows
package network
import (
"encoding/json"
"time"
"github.com/bettercap/gatt"
)
type BLECharacteristic struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Handle uint16 `json:"handle"`
Properties []string `json:"properties"`
Data interface{} ... |
Go | bettercap/network/ble_unsupported.go | // +build windows
package network
import (
"encoding/json"
"time"
"github.com/evilsocket/islazy/data"
)
type BLEDevice struct {
LastSeen time.Time
Alias string
}
func NewBLEDevice() *BLEDevice {
return &BLEDevice{
LastSeen: time.Now(),
}
}
type BLEDevNewCallback func(dev *BLEDevice)
type BLEDevLostCal... |
Go | bettercap/network/debug.go | package network
type DebugFunc func(format string, args ...interface{})
var Debug = func(format string, args ...interface{}) {
} |
Go | bettercap/network/hid.go | package network
import (
"encoding/json"
"sync"
"time"
"github.com/evilsocket/islazy/data"
)
type HIDDevNewCallback func(dev *HIDDevice)
type HIDDevLostCallback func(dev *HIDDevice)
type HID struct {
sync.RWMutex
aliases *data.UnsortedKV
devices map[string]*HIDDevice
newCb HIDDevNewCallback
lostCb HIDDe... |
Go | bettercap/network/hid_device.go | package network
import (
"encoding/hex"
"encoding/json"
"fmt"
"sort"
"strings"
"sync"
"time"
"github.com/evilsocket/islazy/str"
)
type HIDType int
const (
HIDTypeUnknown HIDType = 0
HIDTypeLogitech HIDType = 1
HIDTypeAmazon HIDType = 2
HIDTypeMicrosoft HIDType = 3
HIDTypeDell HIDType = 4
)
... |
Go | bettercap/network/lan.go | package network
import (
"encoding/json"
"net"
"strings"
"sync"
"github.com/evilsocket/islazy/data"
)
const LANDefaultttl = 10
type EndpointNewCallback func(e *Endpoint)
type EndpointLostCallback func(e *Endpoint)
type LAN struct {
sync.Mutex
hosts map[string]*Endpoint
iface *Endpoint
gateway *Endpoin... |
Go | bettercap/network/lan_endpoint.go | package network
import (
"encoding/binary"
"fmt"
"net"
"strconv"
"strings"
"time"
"github.com/evilsocket/islazy/tui"
)
type OnHostResolvedCallback func(e *Endpoint)
type Endpoint struct {
Index int `json:"-"`
IP net.IP `json:"-"`
Net ... |
Go | bettercap/network/lan_test.go | package network
import (
"testing"
"github.com/evilsocket/islazy/data"
)
func buildExampleLAN() *LAN {
iface, _ := FindInterface("")
gateway, _ := FindGateway(iface)
exNewCallback := func(e *Endpoint) {}
exLostCallback := func(e *Endpoint) {}
aliases := &data.UnsortedKV{}
return NewLAN(iface, gateway, aliase... |
Python | bettercap/network/make_manuf.py | #!/usr/bin/python
import os
import six
import re
base = os.path.dirname(os.path.realpath(__file__))
# "https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf;hb=HEAD"
with open(os.path.join(base, 'manuf.go.template')) as fp:
template = fp.read()
with open(os.path.join(base, 'manuf')) as fp... |
bettercap/network/manuf | # This file was generated by running ./tools/make-manuf.py.
# Don't change it directly, change manuf.tmpl instead.
#
#
# /etc/manuf - Ethernet vendor codes, and well-known MAC addresses
#
# Laurent Deniel <laurent.deniel [AT] free.fr>
#
# Wireshark - Network traffic analyzer
# By Gerald Combs <gerald [AT] wireshark.org... | |
Go | bettercap/network/manuf.go | package network
import (
"fmt"
"strings"
"math/big"
)
var manuf = map[string]string {
"20.255861678145536": "Tibit Communications",
"24.24664": "Copper Mountain Communications, Inc.",
"24.7364181": "Realme Chongqing MobileTelecommunications Corp Ltd",
"24.2789": "ScottCare Corporation",
"... |
bettercap/network/manuf.go.template | package network
import (
"fmt"
"strings"
"math/big"
)
var manuf = #MAP#
func ManufLookup(mac string) string {
macHex := strings.Replace(mac, ":", "", -1)
macInt := new(big.Int)
if _, ok := macInt.SetString(macHex, 16); ok == false {
return ""
}
for mask := uint(0); mask < 48; m... | |
Go | bettercap/network/meta.go | package network
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"sync"
"github.com/bettercap/bettercap/core"
)
type Meta struct {
sync.Mutex
m map[string]interface{}
}
// we want to protect concurrent access to the Meta
// object so the m field needs to be unexported, this
// is to have it in JSON regard... |
Go | bettercap/network/meta_test.go | package network
import (
"strings"
"testing"
)
func buildExampleMeta() *Meta {
return NewMeta()
}
func TestNewMeta(t *testing.T) {
exp := len(Meta{}.m)
got := len(NewMeta().m)
if got != exp {
t.Fatalf("expected '%v', got '%v'", exp, got)
}
}
func TestMetaMarshalJSON(t *testing.T) {
_, err := buildExampleM... |
Go | bettercap/network/net.go | package network
import (
"errors"
"fmt"
"net"
"regexp"
"strings"
"github.com/bettercap/bettercap/core"
"github.com/evilsocket/islazy/data"
"github.com/evilsocket/islazy/str"
"github.com/evilsocket/islazy/tui"
"github.com/malfunkt/iprange"
)
var ErrNoIfaces = errors.New("No active interfaces found.")
var ... |
Go | bettercap/network/net_darwin.go | package network
import (
"fmt"
"net"
"regexp"
"strconv"
"github.com/bettercap/bettercap/core"
"github.com/evilsocket/islazy/str"
)
const airPortPath = "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport"
var WiFiChannelParser = regexp.MustCompile(`(?m)^.*Supported Chann... |
Go | bettercap/network/net_gateway.go | // +build !android
package network
import (
"github.com/bettercap/bettercap/routing"
)
func FindGateway(iface *Endpoint) (*Endpoint, error) {
gateway, err := routing.Gateway(routing.IPv4, iface.Name())
if err != nil {
return nil, err
}
if gateway == iface.IpAddress {
Debug("gateway is the interface")
ret... |
Go | bettercap/network/net_gateway_android.go | package network
import (
"github.com/bettercap/bettercap/core"
"github.com/evilsocket/islazy/str"
)
// Hi, i'm Android and my mum said I'm special.
func FindGateway(iface *Endpoint) (*Endpoint, error) {
output, err := core.Exec("getprop", []string{"net.dns1"})
if err != nil {
return nil, err
}
gw := str.Tri... |
Go | bettercap/network/net_linux.go | package network
import (
"bufio"
"fmt"
"net"
"regexp"
"strconv"
"strings"
"github.com/bettercap/bettercap/core"
)
// see Windows version to understand why ....
func getInterfaceName(iface net.Interface) string {
return iface.Name
}
func SetInterfaceChannel(iface string, channel int) error {
curr := GetInte... |
Go | bettercap/network/net_test.go | package network
import (
"net"
"testing"
"github.com/evilsocket/islazy/data"
)
func TestIsZeroMac(t *testing.T) {
exampleMAC, _ := net.ParseMAC("00:00:00:00:00:00")
exp := true
got := IsZeroMac(exampleMAC)
if got != exp {
t.Fatalf("expected '%t', got '%t'", exp, got)
}
}
func TestIsBroadcastMac(t *testin... |
Go | bettercap/network/net_wifi.go | package network
import (
"sync"
)
const NO_CHANNEL = -1
var (
currChannels = make(map[string]int)
currChannelLock = sync.Mutex{}
)
func GetInterfaceChannel(iface string) int {
currChannelLock.Lock()
defer currChannelLock.Unlock()
if curr, found := currChannels[iface]; found {
return curr
}
return NO_CH... |
Go | bettercap/network/net_windows.go | package network
import (
"fmt"
"net"
"strings"
"github.com/google/gopacket/pcap"
)
/*
* net.Interface does not have the correct name on Windows and pcap.Interface
* does not have the hardware address for some reason ... so this is what I
* had to do in Windows ... tnx Microsoft <3
*
* FIXME: Just to be clea... |
Go | bettercap/network/pcap.go | package network
import (
"fmt"
"time"
"github.com/evilsocket/islazy/tui"
"github.com/google/gopacket/pcap"
)
const (
PCAP_DEFAULT_SETRF = false
PCAP_DEFAULT_SNAPLEN = 65536
PCAP_DEFAULT_BUFSIZE = 2_097_152
PCAP_DEFAULT_PROMISC = true
PCAP_DEFAULT_TIMEOUT = pcap.BlockForever
)
var CAPTURE_DEFAULTS = Captu... |
Go | bettercap/network/services.go | package network
var portServices = map[string]map[int]string{
"tcp": {
6566: "sane-port",
1094: "rootd",
4557: "fax",
10000: "webmin",
106: "poppassd",
5674: "mrtd",
98: "linuxconf",
371: "clearcase",
873: "rsync",
5269: "xmpp-server",
15345: "xpilot",
143: "imap2",
345: "p... |
Go | bettercap/network/wifi.go | package network
import (
"encoding/json"
"os"
"path/filepath"
"strconv"
"sync"
"time"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcapgo"
"github.com/evilsocket/islazy/data"
"github.com/evilsocket/islazy/fs"
)
func Dot11Freq2Chan(freq int) int {
if freq <... |
Go | bettercap/network/wifi_ap.go | package network
import (
"encoding/json"
"sync"
"time"
"github.com/evilsocket/islazy/data"
)
type AccessPoint struct {
*Station
sync.RWMutex
aliases *data.UnsortedKV
clients map[string]*Station
withKeyMaterial bool
}
type apJSON struct {
*Station
Clients []*Station `json:"clients"`
Ha... |
Go | bettercap/network/wifi_handshake.go | package network
import (
"sync"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
type Handshake struct {
sync.RWMutex
Beacon gopacket.Packet
Challenges []gopacket.Packet
Responses []gopacket.Packet
Confirmations []gopacket.Packet
hasPMKID bool
unsaved []gopacket.... |
Go | bettercap/network/wifi_station.go | package network
import (
"fmt"
"regexp"
"strconv"
"strings"
)
var (
pathNameCleaner = regexp.MustCompile("[^a-zA-Z0-9]+")
)
type Station struct {
*Endpoint
Frequency int `json:"frequency"`
Channel int `json:"channel"`
RSSI int8 `json:"rssi"`
Se... |
Go | bettercap/network/wifi_test.go | package network
import (
"testing"
"github.com/evilsocket/islazy/data"
)
// Define test data for dot11 frequency <-> channel tests
type dot11pair struct {
frequency int
channel int
}
var dot11TestVector = []dot11pair{
{2472, 13},
{2484, 14},
{5825, 165},
{5885, 177},
}
func buildExampleWiFi() *WiFi {
al... |
Go | bettercap/packets/arp.go | package packets
import (
"net"
"github.com/google/gopacket/layers"
)
func NewARPTo(from net.IP, from_hw net.HardwareAddr, to net.IP, to_hw net.HardwareAddr, req uint16) (layers.Ethernet, layers.ARP) {
eth := layers.Ethernet{
SrcMAC: from_hw,
DstMAC: to_hw,
EthernetType: layers.EthernetTypeARP,
... |
Go | bettercap/packets/arp_test.go | package packets
import (
"net"
"reflect"
"testing"
)
func TestNewARPTo(t *testing.T) {
from := net.IP{0, 0, 0, 0}
from_hw, _ := net.ParseMAC("01:23:45:67:89:ab")
to := net.IP{0, 0, 0, 0}
to_hw, _ := net.ParseMAC("01:23:45:67:89:ab")
req := uint16(0)
eth, arp := NewARPTo(from, from_hw, to, to_hw, req)
if !... |
Go | bettercap/packets/dhcp6.go | package packets
import (
"errors"
// TODO: refactor to use gopacket when gopacket folks
// will fix this > https://github.com/google/gopacket/issues/334
"github.com/mdlayher/dhcp6"
)
const DHCP6OptDNSServers = 23
const DHCP6OptDNSDomains = 24
const DHCP6OptClientFQDN = 39
// link-local
const IPv6Prefix = "fe80::... |
Go | bettercap/packets/dhcp6_layer.go | package packets
import (
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
type DHCPv6Layer struct {
Raw []byte
}
func (l *DHCPv6Layer) LayerType() gopacket.LayerType { return layers.LayerTypeDHCPv6 }
func (l DHCPv6Layer) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) er... |
Go | bettercap/packets/dhcp6_layer_test.go | package packets
import (
"github.com/google/gopacket"
"testing"
)
func TestDHCPv6Layer(t *testing.T) {
layer := DHCPv6Layer{}
exp := 0
got := len(layer.Raw)
if exp != got {
t.Fatalf("expected '%v', got '%v'", exp, got)
}
}
func TestDHCP6SerializeTo(t *testing.T) {
layer := DHCPv6Layer{}
buffer := gopack... |
Go | bettercap/packets/dhcp6_test.go | package packets
import (
"github.com/mdlayher/dhcp6"
"testing"
)
func TestDHCP6OptDNSServers(t *testing.T) {
exp := 23
got := DHCP6OptDNSServers
if exp != got {
t.Fatalf("expected '%v', got '%v'", exp, got)
}
}
func TestDHCP6OptDNSDomains(t *testing.T) {
exp := 24
got := DHCP6OptDNSDomains
if exp != got {... |
Go | bettercap/packets/doc.go | // Package packets contains structure declarations for network packets and the main packets queue.
package packets |
Go | bettercap/packets/dot11.go | package packets
import (
"bytes"
"net"
"github.com/bettercap/bettercap/network"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
var (
openFlags = 1057
wpaFlags = 1041
specManFlag = 1<<8
durationID = uint16(0x013a)
capabilityInfo = uint16(0x0411)
listenInterval = uint1... |
Go | bettercap/packets/dot11_test.go | package packets
import (
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"net"
"reflect"
"testing"
)
func TestDot11Vars(t *testing.T) {
var units = []struct {
got interface{}
exp interface{}
}{
{openFlags, 1057},
{wpaFlags, 1041},
{fakeApRates, []byte{0x82, 0x84, 0x8b, 0x96, 0x24, 0x... |
Go | bettercap/packets/dot11_types.go | package packets
import (
"encoding/binary"
"fmt"
)
type Dot11CipherType uint8
const (
Dot11CipherWep Dot11CipherType = 1
Dot11CipherTkip Dot11CipherType = 2
Dot11CipherWrap Dot11CipherType = 3
Dot11CipherCcmp Dot11CipherType = 4
Dot11CipherWep104 Dot11CipherType = 5
)
func (a Dot11CipherType) String... |
Go | bettercap/packets/dot11_types_test.go | package packets
import (
"reflect"
"testing"
)
func TestDot11CipherTypes(t *testing.T) {
var units = []struct {
got interface{}
exp interface{}
}{
{uint8(Dot11CipherWep), uint8(1)},
{uint8(Dot11CipherTkip), uint8(2)},
{uint8(Dot11CipherWrap), uint8(3)},
{uint8(Dot11CipherCcmp), uint8(4)},
{uint8(Dot... |
Go | bettercap/packets/dot11_wps.go | package packets
import (
"bytes"
"encoding/binary"
"encoding/hex"
"fmt"
"net"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
var (
wpsSignatureBytes = []byte{0x00, 0x50, 0xf2, 0x04}
)
func wpsUint16At(data []byte, size int, offset *int) (bool, uint16) {
if *offset <= size-2 {
off := *... |
Go | bettercap/packets/dot11_wps_attrs.go | package packets
import (
"bytes"
"encoding/binary"
"encoding/hex"
"fmt"
"strings"
)
type wpsAttrType int
const (
wpsHex wpsAttrType = 0
wpsStr wpsAttrType = 1
)
type wpsAttr struct {
Name string
Type wpsAttrType
Func func([]byte, *map[string]string) string
Desc map[string]string
}
type wpsDevType struct... |
Go | bettercap/packets/icmp6.go | package packets
import (
"github.com/google/gopacket/layers"
"net"
)
func ICMP6NeighborAdvertisement(srcHW net.HardwareAddr, srcIP net.IP, dstHW net.HardwareAddr, dstIP net.IP, routerIP net.IP) (error, []byte) {
eth := layers.Ethernet{
SrcMAC: srcHW,
DstMAC: dstHW,
EthernetType: layers.EthernetTy... |
Go | bettercap/packets/krb5.go | package packets
import (
"errors"
"fmt"
"strconv"
"time"
"encoding/asn1"
"encoding/hex"
)
const (
Krb5AsRequestType = 10
Krb5Krb5PrincipalNameType = 1
Krb5CryptDesCbcMd4 = 2
Krb5CryptDescCbcMd5 = 3
Krb5CryptRc4Hmac = 23
)
var (
ErrNoCrypt = errors.New("No crypt alg found")... |
Go | bettercap/packets/krb5_test.go | package packets
import (
"encoding/asn1"
"errors"
"reflect"
"testing"
"time"
)
func TestKrb5Contants(t *testing.T) {
var units = []struct {
got interface{}
exp interface{}
}{
{Krb5AsRequestType, 10},
{Krb5Krb5PrincipalNameType, 1},
{Krb5CryptDesCbcMd4, 2},
{Krb5CryptDescCbcMd5, 3},
{Krb5CryptRc4H... |
Go | bettercap/packets/mdns.go | package packets
import (
"net"
"strings"
"github.com/evilsocket/islazy/str"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
const MDNSPort = 5353
var (
MDNSDestMac = net.HardwareAddr{0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb}
MDNSDestIP = net.ParseIP("224.0.0.251")
)
func MDNSGetMeta(pkt gopack... |
Go | bettercap/packets/mysql.go | package packets
var (
MySQLGreeting = []byte{
0x5b, 0x00, 0x00, 0x00, 0x0a, 0x35, 0x2e, 0x36,
0x2e, 0x32, 0x38, 0x2d, 0x30, 0x75, 0x62, 0x75,
0x6e, 0x74, 0x75, 0x30, 0x2e, 0x31, 0x34, 0x2e,
0x30, 0x34, 0x2e, 0x31, 0x00, 0x2d, 0x00, 0x00,
0x00, 0x40, 0x3f, 0x59, 0x26, 0x4b, 0x2b, 0x34,
0x60, 0x00, 0xff, 0x... |
Go | bettercap/packets/nbns.go | package packets
import (
"strconv"
"github.com/evilsocket/islazy/str"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
const (
NBNSPort = 137
NBNSMinRespSize = 73
)
var (
// NBNS hostname resolution request buffer.
NBNSRequest = []byte{
0x82, 0x28, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0... |
Go | bettercap/packets/ntlm.go | package packets
import (
"encoding/base64"
"encoding/binary"
"encoding/hex"
"errors"
"strings"
"sync"
"unsafe"
)
const (
NTLM_SIG_OFFSET = 0
NTLM_TYPE_OFFSET = 8
NTLM_TYPE1_FLAGS_OFFSET = 12
NTLM_TYPE1_DOMAIN_OFFSET = 16
NTLM_TYPE1_WORKSTN_OFFSET = 24
NTLM_TYPE1_DATA_OFFSET = 32
NTLM_TYPE1_MINSI... |
Go | bettercap/packets/ntlm_test.go | package packets
import (
"reflect"
"testing"
)
func TestNTLMConstants(t *testing.T) {
var units = []struct {
got interface{}
exp interface{}
}{
{NTLM_SIG_OFFSET, 0},
{NTLM_TYPE_OFFSET, 8},
{NTLM_TYPE1_FLAGS_OFFSET, 12},
{NTLM_TYPE1_DOMAIN_OFFSET, 16},
{NTLM_TYPE1_WORKSTN_OFFSET, 24},
{NTLM_TYPE1_D... |
Go | bettercap/packets/queue.go | package packets
import (
"encoding/json"
"fmt"
"net"
"sync"
"sync/atomic"
"github.com/bettercap/bettercap/network"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
)
type Activity struct {
IP net.IP
MAC net.HardwareAddr
Meta map[string]string
S... |
Go | bettercap/packets/queue_test.go | package packets
import (
"net"
"reflect"
"testing"
)
func TestQueueActivity(t *testing.T) {
i := net.IP{}
h := net.HardwareAddr{}
a := Activity{
IP: i,
MAC: h,
}
var units = []struct {
got interface{}
exp interface{}
}{
{a.IP, i},
{a.MAC, h},
{a.Source, false},
}
for _, u := range units {
... |
Go | bettercap/packets/serialize.go | package packets
import (
"github.com/google/gopacket"
)
var SerializationOptions = gopacket.SerializeOptions{
FixLengths: true,
ComputeChecksums: true,
}
func Serialize(layers ...gopacket.SerializableLayer) (error, []byte) {
buf := gopacket.NewSerializeBuffer()
if err := gopacket.SerializeLayers(buf, Seri... |
Go | bettercap/packets/tcp.go | package packets
import (
"github.com/google/gopacket/layers"
"net"
)
func NewTCPSyn(from net.IP, from_hw net.HardwareAddr, to net.IP, to_hw net.HardwareAddr, srcPort int, dstPort int) (error, []byte) {
from4 := from.To4()
to4 := to.To4()
if from4 != nil && to4 != nil {
eth := layers.Ethernet{
SrcMAC: ... |
Go | bettercap/packets/teamviewer.go | package packets
import (
"encoding/binary"
"fmt"
)
const TeamViewerPort = 5938
var teamViewerCommands = map[uint8]string{
10: "CMD_IDENTIFY",
11: "CMD_REQUESTCONNECT",
13: "CMD_DISCONNECT",
14: "CMD_VNCDISCONNECT",
15: "CMD_TVCONNECTIONFAILED",
16: "CMD_PING",
17: "CMD_PINGOK",
18: "CMD_MASTERCOMMA... |
Go | bettercap/packets/udp.go | package packets
import (
"github.com/google/gopacket/layers"
"net"
)
func NewUDPProbe(from net.IP, from_hw net.HardwareAddr, to net.IP, port int) (error, []byte) {
eth := layers.Ethernet{
SrcMAC: from_hw,
DstMAC: net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
EthernetType: layers.EthernetT... |
Go | bettercap/packets/upnp.go | package packets
import (
"bufio"
"bytes"
"fmt"
"net"
"net/http"
"strings"
"github.com/evilsocket/islazy/str"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
const (
UPNPPort = 1900
)
var (
UPNPDestMac = net.HardwareAddr{0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb}
UPNPDestIP ... |
Go | bettercap/packets/wsd.go | package packets
import (
"net"
)
const (
WSDPort = 3702
)
var (
WSDDestIP = net.ParseIP("239.255.255.250")
WSDDiscoveryPayload = []byte("<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
"<soap:Envelope" +
" xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\"" +
" xmlns:wsa=\"http://schemas.xmlso... |
Go | bettercap/routing/route.go | package routing
type RouteType string
const (
IPv4 RouteType = "IPv4"
IPv6 RouteType = "IPv6"
)
type Route struct {
Type RouteType
Default bool
Device string
Destination string
Gateway string
Flags string
} |
Go | bettercap/routing/tables.go | package routing
import "sync"
var (
lock = sync.RWMutex{}
table = make([]Route, 0)
)
func Table() []Route {
lock.RLock()
defer lock.RUnlock()
return table
}
func Update() ([]Route, error) {
lock.Lock()
defer lock.Unlock()
return update()
}
func Gateway(ip RouteType, device string) (string, error) {
Updat... |
Go | bettercap/routing/update_darwin.go | package routing
import (
"regexp"
"strings"
"github.com/bettercap/bettercap/core"
"github.com/evilsocket/islazy/str"
)
var parser = regexp.MustCompile(`^([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+).*$`)
func update() ([]Route, error) {
table = make([]Route, 0)
output, err := core.Exec("netstat", []string{"-n", ... |
Go | bettercap/routing/update_linux.go | package routing
import (
"regexp"
"strings"
"github.com/bettercap/bettercap/core"
"github.com/evilsocket/islazy/str"
)
var (
routeHeadings []string
whitespaceParser = regexp.MustCompile(`\s+`)
)
func update() ([]Route, error) {
table = make([]Route, 0)
output, err := core.Exec("netstat", []string{"-r", ... |
Go | bettercap/routing/update_windows.go | package routing
import (
"github.com/bettercap/bettercap/core"
"github.com/evilsocket/islazy/str"
"regexp"
"strings"
)
var parser = regexp.MustCompile(`^.+\d+\s+([^\s]+)\s+\d+\s+(.+)$`)
func update() ([]Route, error) {
table = make([]Route, 0)
for ip, inet := range map[RouteType]string{IPv4: "ipv4", IPv6: "ip... |
Go | bettercap/session/command_handler.go | package session
import (
"regexp"
"sync"
"github.com/bettercap/readline"
)
type CommandHandler struct {
*sync.Mutex
Name string
Description string
Completer *readline.PrefixCompleter
Parser *regexp.Regexp
exec func(args []string, s *Session) error
}
func NewCommandHandler(name string, ... |
Go | bettercap/session/command_handler_test.go | package session
import (
"testing"
)
func sameStrings(a []string, b []string) bool {
if len(a) != len(b) {
return false
}
for i, v := range a {
if v != b[i] {
return false
}
}
return true
}
func assertPanic(t *testing.T, msg string, f func()) {
defer func() {
if r := recover(); r == nil {
t.Fata... |
Go | bettercap/session/doc.go | // Package session contains code to manage the interactive session, modules, environment, etc.
package session |
Go | bettercap/session/environment.go | package session
import (
"encoding/json"
"fmt"
"io/ioutil"
"sort"
"strconv"
"sync"
"github.com/evilsocket/islazy/fs"
)
type EnvironmentChangedCallback func(newValue string)
type Environment struct {
sync.Mutex
Data map[string]string `json:"data"`
cbs map[string]EnvironmentChangedCallback
}
func NewEnvir... |
Go | bettercap/session/environment_test.go | package session
import (
"encoding/json"
"io/ioutil"
"os"
"reflect"
"testing"
)
var (
testEnvFile = "/tmp/test.env"
testEnvData = map[string]string{
"people": "shit",
"moo": "boo",
"foo": "bar",
}
testEnvSorted = []string{"foo", "moo", "people"}
)
func setup(t testing.TB, envFile bool, envFileDa... |
Go | bettercap/session/events.go | package session
import (
"fmt"
"os"
"sort"
"sync"
"time"
"github.com/evilsocket/islazy/log"
"github.com/evilsocket/islazy/tui"
)
type Event struct {
Tag string `json:"tag"`
Time time.Time `json:"time"`
Data interface{} `json:"data"`
}
type LogMessage struct {
Level log.Verbosity
Message string... |
Go | bettercap/session/events_ignore_list.go | package session
import (
"encoding/json"
"errors"
"fmt"
"strings"
"sync"
"github.com/evilsocket/islazy/str"
)
var (
ErrEmptyExpression = errors.New("expression can not be empty")
)
type filter string
func (f filter) Matches(s string) bool {
return string(f) == s || strings.HasPrefix(s, string(f))
}
type E... |
Go | bettercap/session/events_test.go | package session
import (
"sync"
"testing"
"time"
)
func TestNewEvent(t *testing.T) {
type args struct {
tag string
data interface{}
}
tests := []struct {
name string
args args
want Event
}{
{
name: "Create new event with nil data",
args: args{"tag", nil},
want: Event{Tag: "tag", Data: ni... |
Go | bettercap/session/module.go | package session
import (
"encoding/json"
"fmt"
"net"
"strings"
"sync"
"time"
"github.com/evilsocket/islazy/log"
"github.com/evilsocket/islazy/str"
"github.com/evilsocket/islazy/tui"
)
type Module interface {
Name() string
Description() string
Author() string
Handlers() []ModuleHandler
Parameters() map[... |
Go | bettercap/session/module_handler.go | package session
import (
"encoding/json"
"fmt"
"regexp"
"strconv"
"sync"
"github.com/evilsocket/islazy/str"
"github.com/evilsocket/islazy/tui"
"github.com/bettercap/readline"
)
const (
IPv4Validator = `^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$`
IPv6Validator = `^[:a-fA-F0-9]{6,}$`
IPValidator = `^[\.:a-fA-F0-9]{... |
Go | bettercap/session/module_handler_test.go | package session
import (
"reflect"
"regexp"
"testing"
)
func TestNewModuleHandler(t *testing.T) {
type args struct {
name string
expr string
desc string
exec func(args []string) error
}
tests := []struct {
name string
args args
want ModuleHandler
}{
{
name: "Test NewModuleHandler empty expr"... |
Go | bettercap/session/module_param.go | package session
import (
"crypto/rand"
"encoding/json"
"fmt"
"net"
"regexp"
"strconv"
"strings"
"github.com/evilsocket/islazy/tui"
)
type ParamType int
const (
STRING ParamType = iota
BOOL = iota
INT = iota
FLOAT = iota
)
type ModuleParam struct {
Name string... |
Go | bettercap/session/prompt.go | package session
import (
"fmt"
"strings"
"github.com/evilsocket/islazy/tui"
"github.com/dustin/go-humanize"
)
const (
PromptVariable = "$"
DefaultPrompt = "{by}{fw}{cidr} {fb}> {env.iface.ipv4} {reset} {bold}» {reset}"
DefaultPromptMonitor = "{by}{fb} {env.iface.name} {reset} {bold}» {reset}"
)
... |
Go | bettercap/session/script.go | package session
import (
"fmt"
"io/ioutil"
"path/filepath"
"regexp"
"strings"
"github.com/bettercap/bettercap/caplets"
_ "github.com/bettercap/bettercap/js"
"github.com/evilsocket/islazy/fs"
"github.com/evilsocket/islazy/plugin"
"github.com/evilsocket/islazy/str"
)
// require("telegram.js")
var requirePar... |
Go | bettercap/session/script_builtin.go | package session
import (
"github.com/bettercap/bettercap/js"
"github.com/robertkrimen/otto"
)
func jsEnvFunc(call otto.FunctionCall) otto.Value {
argv := call.ArgumentList
argc := len(argv)
if argc == 1 {
// get
varName := call.Argument(0).String()
if found, varValue := I.Env.Get(varName); found {
v, e... |
Go | bettercap/session/script_builtin_runtime.go | package session
import (
"encoding/json"
"io/ioutil"
"os"
"github.com/bettercap/bettercap/js"
"github.com/evilsocket/islazy/fs"
"github.com/evilsocket/islazy/log"
"github.com/robertkrimen/otto"
)
// see https://github.com/robertkrimen/otto/issues/213
var jsRuntime = otto.New()
func jsRunFunc(call otto.Functi... |
Go | bettercap/session/session.go | package session
import (
"errors"
"fmt"
"net"
"os"
"regexp"
"runtime"
"runtime/pprof"
"sort"
"strings"
"time"
"github.com/bettercap/readline"
"github.com/bettercap/bettercap/caplets"
"github.com/bettercap/bettercap/core"
"github.com/bettercap/bettercap/firewall"
"github.com/bettercap/bettercap/network... |
Go | bettercap/session/session_completers.go | package session
import (
"strings"
"github.com/bettercap/bettercap/network"
)
func prefixMatches(prefix, what string) bool {
return prefix == "" || strings.HasPrefix(what, prefix)
}
func addIfMatches(to *[]string, prefix string, what string) {
if prefixMatches(prefix, what) {
*to = append(*to, what)
}
}
fun... |
Go | bettercap/session/session_core_handlers.go | package session
import (
"bufio"
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"sort"
"strconv"
"strings"
"time"
"github.com/bettercap/bettercap/core"
"github.com/bettercap/bettercap/network"
"github.com/bettercap/readline"
"github.com/evilsocket/islazy/str"
"github.com/evilsocket/islazy/tui"
)
func... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.