diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index e69de29..0000000 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..45f15a2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/lbd diff --git a/Makefile b/Makefile deleted file mode 100644 index 3a80be4..0000000 --- a/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile for source rpm: lbd -# $Id$ -NAME := lbd -SPECFILE = $(firstword $(wildcard *.spec)) - -define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done -endef - -MAKEFILE_COMMON := $(shell $(find-makefile-common)) - -ifeq ($(MAKEFILE_COMMON),) -# attept a checkout -define checkout-makefile-common -test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 -endef - -MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) -endif - -include $(MAKEFILE_COMMON) diff --git a/lbd b/lbd new file mode 100644 index 0000000..dd18ce7 --- /dev/null +++ b/lbd @@ -0,0 +1,186 @@ +#!/bin/bash +# lbd (load balancing detector) detects if a given domain uses +# DNS and/or HTTP Load-Balancing (via Server: and Date: header and diffs between server answers) +# Copyright (C) 2010-2014 Stefan Behte +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# License: GNU General Public License, version 2 +# http://www.gnu.org/licenses/gpl-2.0.html +# +# Contact me, if you have any new ideas, bugs/bugfixes, recommondations or questions! +# Please also contact me, if you just like the tool. :) +# +# craig at haquarter dot de +# +# 0.1: - initial release +# 0.2: - fix license for fedora +# - fix indenting +# 0.3: - fix bug if dns server returns same IP multiple times +# (fix by bit bori, thanks!) +# - fix bug if there is no date header +# (fix by Paul Rib, thanks!) +# 0.4: - support HTTPs, support different ports +# (thanks Bharadwaj Machiraju) + +QUERIES=50 +DOMAIN=$1 +PORT=${2-80} # Use default port 80, if not given +if [ "$3" = "https" ] +then + HTTPS=true +else + HTTPS=false +fi +METHODS="" + +echo +echo "lbd - load balancing detector 0.4 - Checks if a given domain uses load-balancing." +echo " Written by Stefan Behte (http://ge.mine.nu)" +echo " Proof-of-concept! Might give false positives." + +if [ "$1" = "" ] +then + echo "usage: $0 domain [port] {https}" + echo + exit -1 +fi + +echo -e -n "\nChecking for DNS-Loadbalancing:" +NR=`host $DOMAIN | grep "has add" | uniq | wc -l` + +if [ $NR -gt 1 ] +then + METHODS="DNS" + echo " FOUND" + host $DOMAIN | grep "has add" | uniq + echo +else + echo " NOT FOUND" +fi + +echo -e "Checking for HTTP-Loadbalancing [Server]: " +for ((i=0 ; i< $QUERIES ; i++)) +do + if [ $HTTPS = true ] + then + printf "HEAD / HTTP/1.1\r\nhost: $DOMAIN\r\nConnection: close\r\n\r\n" | openssl s_client -host $DOMAIN -port $PORT -quiet > .nlog 2> /dev/null + else + printf "HEAD / HTTP/1.1\r\nhost: $DOMAIN\r\nConnection: close\r\n\r\n" | nc $DOMAIN $PORT > .nlog 2>/dev/null + fi + + S=`grep -i "Server:" .nlog | awk -F: '{print $2}'` + + if ! grep "`echo ${S}| cut -b2-`" .log &>/dev/null + then + echo "${S}" + fi + cat .nlog >> .log +done + +NR=`sort .log | uniq | grep -c "Server:"` + +if [ $NR -gt 1 ] +then + echo " FOUND" + METHODS="$METHODS HTTP[Server]" +else + echo " NOT FOUND" +fi +echo +rm .nlog .log + + +echo -e -n "Checking for HTTP-Loadbalancing [Date]: " +D4= + +for ((i=0 ; i<$QUERIES ; i++)) +do + if [ $HTTPS = true ] + then + D=`printf "HEAD / HTTP/1.1\r\nhost: $DOMAIN\r\nConnection: close\r\n\r\n" | openssl s_client -host $DOMAIN -port $PORT -quiet 2> /dev/null | grep "Date:" | awk '{print $6}'` + else + D=`printf "HEAD / HTTP/1.1\r\nhost: $DOMAIN\r\nConnection: close\r\n\r\n" | nc $DOMAIN $PORT 2>/dev/null | grep "Date:" | awk '{print $6}'` + fi + printf "$D, " + + if [ "$D" == "" ] + then + echo "No date header found, skipping." + break + fi + + Df=$(echo " $D" | sed -e 's/:0/:/g' -e 's/ 0/ /g') + D1=$(echo ${Df} | awk -F: '{print $1}') + D2=$(echo ${Df} | awk -F: '{print $2}') + D3=$(echo ${Df} | awk -F: '{print $3}') + + if [ "$D4" = "" ]; then D4=0; fi + + if [ $[ $D1 * 3600 + $D2 * 60 + $D3 ] -lt $D4 ] + then + echo "FOUND" + METHODS="$METHODS HTTP[Date]" + break; + fi + + D4="$[ $D1 * 3600 + $D2 * 60 + $D3 ]" + + if [ $i -eq $[$QUERIES - 1] ] + then + echo "NOT FOUND" + fi +done + +echo -e -n "\nChecking for HTTP-Loadbalancing [Diff]: " +for ((i=0 ; i<$QUERIES ; i++)) +do + if [ $HTTPS = true ] + then + printf "HEAD / HTTP/1.1\r\nhost: $DOMAIN\r\nConnection: close\r\n\r\n" | openssl s_client -host $DOMAIN -port $PORT -quiet 2> /dev/null | grep -v -e "Date:" -e "Set-Cookie" > .nlog + else + printf "HEAD / HTTP/1.1\r\nhost: $DOMAIN\r\nConnection: close\r\n\r\n" | nc $DOMAIN $PORT 2>/dev/null | grep -v -e "Date:" -e "Set-Cookie" > .nlog + fi + + if ! cmp .log .nlog &>/dev/null && [ -e .log ] + then + echo "FOUND" + diff .log .nlog | grep -e ">" -e "<" + METHODS="$METHODS HTTP[Diff]" + break; + fi + + cp .nlog .log + + if [ $i -eq $[$QUERIES - 1] ] + then + echo "NOT FOUND" + fi +done + +rm .nlog .log + + +if [ "$METHODS" != "" ] +then + echo + echo $DOMAIN does Load-balancing. Found via Methods: $METHODS + echo +else + echo + echo $DOMAIN does NOT use Load-balancing. + echo +fi + diff --git a/lbd.spec b/lbd.spec new file mode 100644 index 0000000..c035beb --- /dev/null +++ b/lbd.spec @@ -0,0 +1,134 @@ +Name: lbd +Version: 0.4 +Release: 21%{?dist} +Summary: A DNS/HTTP load balancing detector + +# Automatically converted from old format: GPLv2+ - review is highly recommended. +License: GPL-2.0-or-later +URL: https://github.com/craig/ge.mine.nu/tree/master/lbd +Source0: https://raw.githubusercontent.com/craig/ge.mine.nu/master/lbd/%{name}.sh#/%{name} +BuildArch: noarch + +Requires: bind-utils +Requires: nc + +%description +lbd (load balancing detector) detects if a given domain uses DNS and/or HTTP +Load-Balancing (via Server: and Date: header and diffs between server answers). + +%prep +# Nothing to prep + +%build +# Nothing to build + +%install +install -d %{buildroot}%{_bindir} +install -p -m 755 %{SOURCE0} %{buildroot}%{_bindir}/ + +%files +%{_bindir}/lbd + +%changelog +* Thu Jul 24 2025 Fedora Release Engineering - 0.4-21 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + +* Fri Jan 17 2025 Fedora Release Engineering - 0.4-20 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + +* Fri Jul 26 2024 Miroslav Suchý - 0.4-19 +- convert license to SPDX + +* Thu Jul 18 2024 Fedora Release Engineering - 0.4-18 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Thu Jan 25 2024 Fedora Release Engineering - 0.4-17 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Sun Jan 21 2024 Fedora Release Engineering - 0.4-16 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Thu Jul 20 2023 Fedora Release Engineering - 0.4-15 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Thu Jan 19 2023 Fedora Release Engineering - 0.4-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Thu Jul 21 2022 Fedora Release Engineering - 0.4-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Thu Jan 20 2022 Fedora Release Engineering - 0.4-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Thu Jul 22 2021 Fedora Release Engineering - 0.4-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Tue Jan 26 2021 Fedora Release Engineering - 0.4-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Tue Jul 28 2020 Fedora Release Engineering - 0.4-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Wed Jan 29 2020 Fedora Release Engineering - 0.4-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Jul 25 2019 Fedora Release Engineering - 0.4-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Fri Feb 01 2019 Fedora Release Engineering - 0.4-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Fri Jul 13 2018 Fedora Release Engineering - 0.4-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Wed Feb 07 2018 Fedora Release Engineering - 0.4-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 0.4-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Fri Feb 10 2017 Fedora Release Engineering - 0.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Wed May 11 2016 Fabian Affolter - 0.4-1 +- Update to latest upstream release 0.4 + +* Thu Feb 04 2016 Fedora Release Engineering - 0.2-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Wed Jun 17 2015 Fedora Release Engineering - 0.2-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Sat Jun 07 2014 Fedora Release Engineering - 0.2-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Sat Aug 03 2013 Fedora Release Engineering - 0.2-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Tue Mar 26 2013 Nikolay Ulyanitsky - 0.2-7 +- fix url + +* Thu Feb 14 2013 Fedora Release Engineering - 0.2-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Thu Jul 19 2012 Fedora Release Engineering - 0.2-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Fri Jan 13 2012 Fedora Release Engineering - 0.2-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Mon Feb 07 2011 Fedora Release Engineering - 0.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Sun Apr 18 2010 Nikolay Ulyanitsky - 0.2-2 +- Fix the license + +* Sat Apr 17 2010 Nikolay Ulyanitsky - 0.2-1 +- Update to 0.2 + +* Sat Mar 13 2010 Nikolay Ulyanitsky - 0.1-2 +- Replace generally useful macros by regular commands + +* Tue Feb 02 2010 Nikolay Ulyanitsky - 0.1-1 +- Initial package build + diff --git a/sources b/sources index e69de29..5c76edd 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +41e1f86a71b75f9cea7a98e38be3844a lbd