mirror of
https://github.com/bettercap/bettercap
synced 2025-07-14 00:53:46 -07:00
misc: replaced glide with go dep
This commit is contained in:
parent
a2e90769fe
commit
6b6078d30d
533 changed files with 298 additions and 128052 deletions
12
vendor/github.com/chifflier/nfqueue-go/.travis.yml
generated
vendored
12
vendor/github.com/chifflier/nfqueue-go/.travis.yml
generated
vendored
|
@ -1,12 +0,0 @@
|
|||
language: go
|
||||
|
||||
go:
|
||||
- 1.6
|
||||
- tip
|
||||
install:
|
||||
- go get github.com/google/gopacket
|
||||
- go get github.com/google/gopacket/layers
|
||||
- go get github.com/chifflier/nfqueue-go/nfqueue
|
||||
before_install:
|
||||
- sudo apt-get -qq update
|
||||
- sudo apt-get install -y pkg-config libnfnetlink-dev libnetfilter-queue-dev
|
54
vendor/github.com/chifflier/nfqueue-go/README.md
generated
vendored
54
vendor/github.com/chifflier/nfqueue-go/README.md
generated
vendored
|
@ -1,54 +0,0 @@
|
|||
# nfqueue-go
|
||||
|
||||
|
||||
[](https://travis-ci.org/chifflier/nfqueue-go)
|
||||
[](https://godoc.org/github.com/chifflier/nfqueue-go/nfqueue)
|
||||
|
||||
nfqueue-go is a wrapper library for
|
||||
[libnetfilter-queue](http://www.netfilter.org/projects/libnetfilter_queue/). The goal is to provide a library to gain access to packets queued by the kernel packet filter.
|
||||
|
||||
It is important to note that these bindings will not follow blindly libnetfilter_queue API. For ex., some higher-level wrappers will be provided for the open/bind/create mechanism (using one function call instead of three).
|
||||
|
||||
**The API is not yet stable.**
|
||||
|
||||
To use the library, a program must
|
||||
- open a queue
|
||||
- bind to a network family (`AF_PACKET` for IPv4)
|
||||
- provide a callback function, which will be automatically called when a packet is received. The callback must return a verdict
|
||||
- create the queue, providing the queue number (which must match the `--queue-num` from the iptables rules, see below
|
||||
- run a loop, waiting for events. The program should also provide a clean way to exit the loop (for ex on `SIGINT`)
|
||||
|
||||
## Using library
|
||||
|
||||
```
|
||||
import "github.com/chifflier/nfqueue-go/nfqueue"
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
See [test_nfqueue](nfqueue/test_nfqueue/test_nfqueue.go) for a minimal example, and [test_nfqueue_gopacket](nfqueue/test_nfqueue_gopacket/test_nfqueue.go) for an example using the [gopacket](https://github.com/google/gopacket) library to decode the packets.
|
||||
|
||||
## IPtables
|
||||
|
||||
You must add rules in netfilter to send packets to the userspace queue.
|
||||
The number of the queue (--queue-num option in netfilter) must match the
|
||||
number provided to create_queue().
|
||||
|
||||
Example of iptables rules:
|
||||
|
||||
iptables -A OUTPUT --destination 1.2.3.4 -j NFQUEUE --queue-num 0
|
||||
|
||||
Of course, you should be more restrictive, depending on your needs.
|
||||
|
||||
## Privileges
|
||||
|
||||
nfqueue-go does not require root privileges, but needs to open a netlink socket and send/receive packets to the kernel.
|
||||
|
||||
You have several options:
|
||||
- Use the CAP_NET_ADMIN capability in order to allow your application to receive from and to send packets to kernel-space:
|
||||
```setcap 'cap_net_admin=+ep' /path/to/program```
|
||||
- Run your program as `root` and drop privileges
|
||||
|
||||
## License
|
||||
|
||||
This library is licensed under the GNU General Public License version 2, or (at your option) any later version.
|
54
vendor/github.com/chifflier/nfqueue-go/nfqueue/test_nfqueue/test_nfqueue.go
generated
vendored
54
vendor/github.com/chifflier/nfqueue-go/nfqueue/test_nfqueue/test_nfqueue.go
generated
vendored
|
@ -1,54 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"github.com/chifflier/nfqueue-go/nfqueue"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func real_callback(payload *nfqueue.Payload) int {
|
||||
fmt.Println("Real callback")
|
||||
fmt.Printf(" id: %d\n", payload.Id)
|
||||
fmt.Printf(" mark: %d\n", payload.GetNFMark())
|
||||
fmt.Printf(" in %d out %d\n", payload.GetInDev(), payload.GetOutDev())
|
||||
fmt.Printf(" Φin %d Φout %d\n", payload.GetPhysInDev(), payload.GetPhysOutDev())
|
||||
fmt.Println(hex.Dump(payload.Data))
|
||||
fmt.Println("-- ")
|
||||
payload.SetVerdict(nfqueue.NF_ACCEPT)
|
||||
return 0
|
||||
}
|
||||
|
||||
func main() {
|
||||
q := new(nfqueue.Queue)
|
||||
|
||||
q.SetCallback(real_callback)
|
||||
|
||||
q.Init()
|
||||
defer q.Close()
|
||||
|
||||
q.Unbind(syscall.AF_INET)
|
||||
q.Bind(syscall.AF_INET)
|
||||
|
||||
q.CreateQueue(0)
|
||||
q.SetMode(nfqueue.NFQNL_COPY_PACKET)
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
go func(){
|
||||
for sig := range c {
|
||||
// sig is a ^C, handle it
|
||||
_ = sig
|
||||
q.StopLoop()
|
||||
}
|
||||
}()
|
||||
|
||||
// XXX Drop privileges here
|
||||
|
||||
q.Loop()
|
||||
q.DestroyQueue()
|
||||
q.Close()
|
||||
os.Exit(0)
|
||||
}
|
66
vendor/github.com/chifflier/nfqueue-go/nfqueue/test_nfqueue_gopacket/test_nfqueue.go
generated
vendored
66
vendor/github.com/chifflier/nfqueue-go/nfqueue/test_nfqueue_gopacket/test_nfqueue.go
generated
vendored
|
@ -1,66 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"github.com/chifflier/nfqueue-go/nfqueue"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/google/gopacket"
|
||||
"github.com/google/gopacket/layers"
|
||||
)
|
||||
|
||||
func real_callback(payload *nfqueue.Payload) int {
|
||||
fmt.Println("Real callback")
|
||||
fmt.Printf(" id: %d\n", payload.Id)
|
||||
fmt.Println(hex.Dump(payload.Data))
|
||||
// Decode a packet
|
||||
packet := gopacket.NewPacket(payload.Data, layers.LayerTypeIPv4, gopacket.Default)
|
||||
// Get the TCP layer from this packet
|
||||
if tcpLayer := packet.Layer(layers.LayerTypeTCP); tcpLayer != nil {
|
||||
fmt.Println("This is a TCP packet!")
|
||||
// Get actual TCP data from this layer
|
||||
tcp, _ := tcpLayer.(*layers.TCP)
|
||||
fmt.Printf("From src port %d to dst port %d\n", tcp.SrcPort, tcp.DstPort)
|
||||
}
|
||||
// Iterate over all layers, printing out each layer type
|
||||
for _, layer := range packet.Layers() {
|
||||
fmt.Println("PACKET LAYER:", layer.LayerType())
|
||||
fmt.Println(gopacket.LayerDump(layer))
|
||||
}
|
||||
fmt.Println("-- ")
|
||||
payload.SetVerdict(nfqueue.NF_ACCEPT)
|
||||
return 0
|
||||
}
|
||||
|
||||
func main() {
|
||||
q := new(nfqueue.Queue)
|
||||
|
||||
q.SetCallback(real_callback)
|
||||
|
||||
q.Init()
|
||||
|
||||
q.Unbind(syscall.AF_INET)
|
||||
q.Bind(syscall.AF_INET)
|
||||
|
||||
q.CreateQueue(0)
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
go func(){
|
||||
for sig := range c {
|
||||
// sig is a ^C, handle it
|
||||
_ = sig
|
||||
q.StopLoop()
|
||||
}
|
||||
}()
|
||||
|
||||
// XXX Drop privileges here
|
||||
|
||||
q.Loop()
|
||||
q.DestroyQueue()
|
||||
q.Close()
|
||||
os.Exit(0)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue