Giter VIP home page Giter VIP logo

freebind's Introduction

Freebind

Make use of any IP address from a prefix that is routed to your machine.

With the introduction of IPv6, single machines often get prefixes with more than one IP address assigned. However, without AnyIP and socket freebinding, many applications lack support to dynamically bind to arbitrary unconfigured addresses within these prefixes. Freebind enables the IP_FREEBIND socket option by hooking into socket library calls using LD_PRELOAD.

IPv6 services employing rate limiting often ban per /128 or per /64 in order to minimize collateral damage. If you have a statically routed prefix that is smaller than the prefix being banned, you can make use of freebind, which will bind sockets to random IP addresses from specified prefixes.

Usage

Installing

Clone and cd into the git repository, then run make install. In order for packetrand to be built successfully, libnetfilter-queue-dev is required.

Setup

Assume your ISP has assigned the subnet 2a00:1450:4001:81b::/64 to your server. In order to make use of freebinding, you first need to configure the Linux AnyIP kernel feature in order to be able to bind a socket to an arbitrary IP address from this subnet as follows:

ip -6 route add local 2a00:1450:4001:81b::/64 dev lo

Example

Having set up AnyIP, the following command will bind wget's internal socket to a random address from the specified subnet:

freebind -r 2a00:1450:4001:81b::/64 -- wget -qO- ipv6.wtfismyip.com/text

In practice, running this command multiple times will yield a new IP address every time.

Crawling with curl

You can use new versions of curl (tested with 7.87.0) with freebind to bypass web server rate limits as follows:

freebind -r 2a00:1450:4001:81b::/64 -- curl --http1.1 -6 -H "Connection: close" --parallel --parallel-immediate --parallel-max 100 --config config.txt

In the above example, config.txt contains the URLs you wish to crawl in the curl config format, e.g. url = "https://ipv6.wtfismyip.com/text". Consult the curl man page for more information on the format. Since curl cannot be explicitly configured to use a new socket for each request, we leverage the Connection: close header, which is only supported by HTTP/1.1. Alternatively, HTTP/1.0 could be used.

Note that freebind does not work with statically linked binaries in general, including those that can be downloaded from the curl website.

UDP per packet randomization

The freebind program is only suitable for assigning one IP address per socket. It will not assign a random IP address per packet. Therefore, packetrand making use of the netfilter API is included for use in scenarios that require a fresh IP address per outgoing packet.

Setup

Imagine you want to randomize source addresses for DNS resolving. The following command has iptables pass outgoing DNS packets to the packetrand userspace program:

ip6tables -I OUTPUT -j NFQUEUE -p udp --dport 53 --queue-num 0 --queue-bypass
ip6tables -I INPUT -j NFQUEUE -p udp --sport 53 --queue-num 0 --queue-bypass

Afterwards, the packetrand daemon could be invoked as follows, where 0 is the netfilter queue number:

packetrand 0 2a00:1450:4001:81b:: 2a00:1450:4001:81b::/64

This will cause packetrand to rewrite the source address of outgoing packets to a random address from the specified prefix and translate back the destination address of incoming packets to 2a00:1450:4001:81b:: which is supposed to be the address which the socket is bound to.

Source port randomization

You can use the -r switch in order to randomize source ports per packet.

packetrand 0 -r 53

In this case, all outgoing UDP packets that are handled by the queue have their source port randomized and 53 is the port number for incoming packets to be rewritten to.

Limitations

  • IPv6 extension headers are not yet supported

Notes

The application will only work if your internet service provider provides you with a routed prefix.

References

freebind's People

Contributors

blechschmidt avatar justanotherarchivist avatar ocean-moist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

freebind's Issues

can't compile on Ubuntu 20.04 with gcc 9.3.0

I'm not very experienced with the C language & toolchain, so I failed to solve this on my own.

uname -a
# Linux testing-2 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
gcc --version
# gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
apt install -y gcc make git
git clone https://github.com/blechschmidt/freebind.git
cd freebind
make
mkdir -p bin
gcc -Wall -shared -fPIC src/freebind.c -o bin/freebind.so -ldl
gcc -Wall src/preloader.c -o bin/freebind
src/preloader.c: In function ‘main’:
src/preloader.c:46:6: error: a label can only be part of a statement and a declaration is not a statement
   46 |      size_t buflen = strlen(buf);
      |      ^~~~~~
make: *** [Makefile:6: default] Error 1

Will not compile on musl

title

packetrand.c: In function 'cb':
packetrand.c:236:5: error: unknown type name 'u_int32_t'; did you mean 'uint32_t'?
  236 |     u_int32_t id = handle_pkt(nfa, &size);
      |     ^~~~~~~~~
      |     uint32_t

Citation

I am doing research in a related field of IPv6 source address randomization. I would like to cite Freebind as prior work. Is there anything you would like added to this Bibtex citation?

@software{freebind,
  author = {Blechschmidt, B},
  title = {{Freebind}},
  url = {https://github.com/blechschmidt/freebind},
  year = {2023}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.