iredmail - 通过 curl 来增加域名
需求:从一个含用域名列表的文本文件中逐行读取,通过 curl 提交给 iredadmin
尝试:
##
# Configurations.
##
rm tmpcs.txt
rm cookie
# Path to temporary file which will store your cookie data.
cookie_path=cookie
username=postmaster@anqun.org
password=ps88888888
login_url="https://mail.anqun.org/iredadmin/login"
create_url="https://mail.anqun.org/iredadmin/create/domain"
# action_url="$create_url/$domainname"
##
# Logic. Most likely you shouldn't change here anything.
##
curl -i -b $cookie_path -c $cookie_path -d "username=$username&password=$password" "$login_url"
curl -i -b $cookie_path -c $cookie_path -o tmpcs.txt --request GET "$create_url"
csrf_token=$(grep -oP '(?<=<input type="hidden" name="csrf_token" value=")[^"]*' tmpcs.txt)
while read -r line; do
# 使用该行内容作为变量值来执行 cURL 命令
data="csrf_token=$csrf_token&domainName=$line&cn=&submit_add_domain=Add"
curl -i --cookie cookie --data "${data}" "$create_url"
done < domain.txt