Skip to content
/ c_wait Public

ConnectionWait (universal shell-script for health-check & PT)

Notifications You must be signed in to change notification settings

alaahag/c_wait

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

'c_wait' - ConnectionWait v1.4

Intro:

'c_wait' is a PenetrationTesting and DevOps tool [an advanced health-check tool].
The script checks for open-connections (using user-input [args]).
And when the task is complete: The script will exit successfully (or with failure).

Examples, Where can I use this script?

  • DevOps and automations: Health-check for databases before initializing the servers.
  • PenetrationTesting: Display current installed health-check methods inside X machine.

Changelog v1.4:

  • Added more health-check methods (Crystal, Picolisp, G++, Clang++, GNAT(Ada), Haskell, Swift, Kotlin, Prolog(SWI), Neko, FreePascal).
  • Added an option to save output to a log file.
  • Fixed small bugs and optimized health-check methods.
  • Typo.

Changelog v1.3:

  • Added more health-check methods (CQL-shell, Racket, Guile, Julia).
  • Fixed bugs.
  • Optimized methods.
  • Optimized code.
  • Typo.
  • More validations.

Changelog v1.2:

  • Added a new option to display all supported and installed methods: [ ./c_wait.sh --installed ].
  • Full support for the latest BusyBox version of Telnet and Wget.
  • Added more health-check methods (SSH, MongoDB-Client, Groovy, Zsh, Ocaml).
  • Fixed bugs.
  • Optimized methods and performance.
  • Optimzed code.

Features:

  1. Optimized for Kubernetes and Docker images (including full support for the most popular OS-images: Alpine, Ubuntu, CentOS, Fedora, Debian, AmazonLinux, OracleLinux, ROS, CirrOS, Mageia, ClearLinux, SourceMage and openSUSE).
  2. In addition, Full support for: BusyBox, Termux, macOS, RedHat, SUSELinux, ArchLinux, Mageia, GentooLinux, Endless, OpenBSD, FreeBSD, Solus, Guix, Slackware and other Linux distributions.
  3. Supporting over 53 health-check methods, to check for open-connections.
  4. Allow adding unlimited number of hosts.
  5. Allow connection-modes:
    @ 'all' hosts must be connected to complete the task.
    @ 'any' of the hosts must be connected to complete the task.
  6. Allow limited/forever connection-retries.
  7. Option to display the installed and supported methods inside X machine.
  8. Customize methods and messages (easily editable from global values).
  9. Simple, user-friendly and easy to use.

Methods; health-check order:

  1. Netcat
  2. Bash
  3. SSH
  4. cURL
  5. Wget
  6. Telnet
  7. Gawk
  8. Zsh
  9. Ncat
  10. Nmap
  11. Socat
  12. Python
  13. Python3
  14. NodeJS
  15. Ruby
  16. Perl
  17. PHP
  18. Tcl
  19. OpenSSL
  20. Scala
  21. Crystal
  22. CQL-shell
  23. Mongo-shell
  24. Groovy
  25. R
  26. Elixir
  27. Erlang
  28. Clojure
  29. Racket
  30. Guile
  31. PicoLisp
  32. PowerShell
  33. Julia
  34. GCC
  35. G++
  36. Clang
  37. Clang++
  38. GNAT(Ada)
  39. Java-JDK
  40. Haskell
  41. Rust
  42. Go
  43. SBCL
  44. Dart
  45. D
  46. Nim
  47. OCaml
  48. Swift
  49. Kotlin
  50. .NET
  51. Prolog(SWI)
  52. Neko
  53. FreePascal

Default global values:

With args:

HOSTS="8.8.8.8:53 db:3306"  
SLEEP_TIME="3"  
RETRIES_COUNT="0"  
CONNECT_MODE="all"  
IS_QUIET_MODE="no"  
LOG_FILE="-"  

Without args:

METHODS="nc bash ssh curl wget telnet gawk zsh ncat nmap socat python python3 node ruby perl php tclsh openssl scala crystal cqlsh mongo groovy Rscript elixir erl clojure racket guile pil pwsh julia gcc g++ clang clang++ gnatmake javac ghc rustc go sbcl dart dmd nim ocamlc swiftc kotlinc dotnet swipl nekoc fpc"

TIMEOUT="2"

readonly INIT_MESSAGE="'c_wait' - Initializing ..."
readonly CONNECT_MESSAGE="'c_wait' - Connection Succeed!"
readonly FAIL_MESSAGE="'c_wait' - Connection Failed!"
readonly DONE_MESSAGE="'c_wait' - Task Completed :)"
readonly QUIT_MESSAGE="'c_wait' - Terminated!"
You can modify the default values (read the source-code comments).
./c_wait --help
[ 'c_wait' - ConnectionWait v1.4 ]

Usage:
  ./c_wait.sh --connect {all|any}
     --sleep <secs> --retry <num|'forever'>
     --log <file|'-'> <hosts:ports ...>

Short usage:
  ./c_wait.sh -c {all|any} -r <num|'0'>
     -s <secs> -l <file|'-'> <hosts ...>

Examples:
  ./c_wait.sh -l out.txt
  ./c_wait.sh --sleep 1 google.com 8.8.8.8:53
  ./c_wait.sh -s 4 ftp:21 192.168.1.1:22
  ./c_wait.sh --quiet -s 10 -r 3 myserver:8000
  ./c_wait.sh -c any --log - localhost myftp:21
  ./c_wait.sh --connect all -q --retry 4 tln:25

Options and default values:
  <hosts:ports ...>
     ('8.8.8.8:53 db:3306')

  -c | --connect {all|any}
     ('all' of the selected hosts)

  -s | --sleep <seconds>
     ('3' seconds)

  -r | --retry <number|'forever'>
     (connection-retries: 'forever')

  -l | --log <file|'-'>
     (log file: '')

  -q | --quiet
     (minimal output? 'no')

Display info:
  -i | --installed
     (display installed methods)

  -h | --help | /?
     (display this usage)

Known 'Issues':

Methods:
  • Mongo-shell: Will not be able to connect to '0.0.0.0' (connection will fail).
Others:
  • No support for Solaris OS (incompatible version of 'grep').

Example using Docker:

cat docker-compose.yml:
services:  
  db:  
    image: postgres  
    container_name: db  
    ..........  
    ..........  
    expose:  
      - '5432'
    networks:  
      - shared  
    ..........  
    ..........  

  django_app:  
    build: .  
    ..........  
    ..........  
    entrypoint: /var/www/my_app/entrypoint_django_run.sh  
    networks:  
      - shared  
    ..........  
    ..........  

networks:  
  shared:    
cat entrypoint_django_run.sh
./c_wait.sh db:5432  
python3 manage.py runserver 0.0.0.0:8000  

[email protected] , +972527337763

[PT & DevOPS developer, Looking for my next challenge].