From 82377932605ea2c99b6c66a2ab0077e647a21e73 Mon Sep 17 00:00:00 2001 From: g1n Date: Thu, 8 Jul 2021 14:47:39 +0000 Subject: [PATCH] Add input --- laconia | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/laconia b/laconia index b32934b..eb29c00 100755 --- a/laconia +++ b/laconia @@ -13,14 +13,14 @@ usage() { } request(){ - page=$(printf "$host /$path $( $post | wc -c )\r\n$post" | nc $host $port) + page=$(printf "$host /$path $post_len\r\n$post\r\n" | nc $host $port) status=$(echo $page | awk 'NR == 1 {print $1}') meta=$(echo $page | awk 'NR == 1 {$1=="";print}') if [[ $status == 2 ]]; then - printf "$host /$path $( $post | wc -c )\r\n$post" | nc $host $port | awk 'NR > 1 {print}' + printf "$host /$path $post_len\r\n$post\r\n" | nc $host $port | awk 'NR > 1 {print}' elif [[ $status == 3 ]]; then #path=$meta - printf "%s %s 0\r\n" "$host" "/$path/"| nc $host 300 + printf "%s %s %s\r\n%s\r\n" "$host" "/$path/" "$post_len" "$post" | nc $host $port | awk 'NR > 1 {print}' elif [[ $status == 4 ]]; then printf "Client error: %s\n" "$meta" elif [[ $status == 5 ]]; then @@ -37,6 +37,7 @@ while getopts ":h:p:i:u:" arg; do ;; i | --input) export post=$OPTARG + export post_len=$( echo $post | wc -c ) ;; u | --url) url_unparsed=$OPTARG @@ -47,6 +48,8 @@ while getopts ":h:p:i:u:" arg; do host=$(echo "$url" | sed -e 's|^[^/]*//||' -e 's|/.*$||') path="$(echo $url | grep / | cut -d/ -f2-)" port=${port:-300} + post=${post:-""} + post_len=${post_len:-0} request else echo $url_unparsed is not a Spartan URL