Add input
This commit is contained in:
parent
42dc38258d
commit
8237793260
9
laconia
9
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
|
||||
|
|
Loading…
Reference in New Issue