shスクリプトのカールはおそらく空白のためです。

shスクリプトのカールはおそらく空白のためです。

shログ出力を受け取るスクリプトがあります。特定の条件でIPアドレスを見つけた場合は、そのcurlIPアドレスに要求を送信する必要があります(重要な場合は、受信者はPolycom VoIP電話です)。

受信機から以下を取得します。

PushParserC::parseDoc: Expecting <PolycomIPPhone>: $'<PolycomIPPhone><Data

正しい行は次のような結果を生成します。

wappPushHandlerC::Handle: <PolycomIPPhone><Data priority="Critical">Key:Setup

-vダンプでは、私はcurl次のようになります。

curl: (6) Could not resolve host: priority="Critical">Key.... <はIPアドレスでなければなりません。

どちらの場合も、スクリプトの空白が切り捨てられたようです。ほとんどのソリューションはスペースを削除しますが、これは意図したXHTMLを破損します。

私のスクリプトは次のとおりです

#!/bin/sh

tail -0f /var/log/somelogfile.log | while read line
do
  if echo $line | grep "\[WARNING\]" | grep -q "SIP auth failure" ; then

    # Log detected sip authentication error to file
    STR="$(echo $line | awk '{print "Date:",$1,"Time:",$2,"Login:",$14,"IP:",$17}')" >> logger.txt

    # Get the found private IP address out of the errored line
    IP="$(echo $STR | rev | cut -d" " -f1 | rev)"

    # Provide output to the user of the IP to brute
    echo "Target IP: " $IP

    # Content Type header
    CT="Content-Type: application/x-com-polycom-spipx"

    # The XHTML to send to the phone in question for forced factory reset
    XHTML="curl -v --digest -u Push:Push -d $'<PolycomIPPhone><Data priority=\"Critical\">Key:Setup\nKey:Dialpad2\nKey:Dialpad9\nKey:Dialpad9\nKey:Dialpad9\nKey:Softkey4\nKey:Dialpad1\nKey:Dialpad5\nKey:Dialpad5</Data></PolycomIPPhone>' --header \"$CT\" $IP/push"

    # print out URL for test
    echo $XHTML
    RESPONSE=`$XHTML`
    echo
    echo $RESPONSE
  fi
done


# This is an example of the fuctional code that works straight in the terminal.
# curl --digest -u Push:Push -d $'<PolycomIPPhone><Data priority="Critical">Key:Setup\nKey:Dialpad2\nKey:Dialpad9\nKey:Dialpad9\nKey:Dialpad9\nKey:Softkey4\nKey:Dialpad1\nKey:Dialpad5\nKey:Dialpad5</Data></PolycomIPPhone>' --header "Content-Type: application/x-com-polycom-spipx" xx.xx.xx.xx/push && echo

他のソリューションはスペースを削除するか、この文脈では不可能なエンコードを実行します。しかし、このアプリではこれらのどれも動作しません!

ありがとうございます!

ベストアンサー1

選択のために-d頑張ります

echo '$<PolycomIPPhone><Data priority=\"Critical\">....' | curl -d@- (other options)

~によるとman curl

文字@でデータを開始する場合、残りはデータを読み取るファイル名でなければなりません。または - カールを使用してstdinからデータを読み取る場合は、次のようにします。

おすすめ記事