我需要登录到一个网站通过https协议使用卷曲和上传一个文件在一个特定的文件夹。我能够登录到网站通过CSRF启用网站通过HTTPS卷曲。但是无法上传该文件。我想这是因为HTTPS协议启用了CSRF令牌。,所以我需要弄清楚如何通过HTTPS协议处理CSRF令牌并使用CURL命令上传文件。。
登录格式:(工作)
curl -u username:password https://ftp.example.com上传格式:(不起作用)
curl -k -T "./testfile.txt" -u "username":"password" https://example.com/upload/注1:我目前正在运行这个命令RHEL 6。
注2:我需要处理CSRF令牌。
注3:可以通过ftp和sftp协议登录/上传。
我非常希望有一个解决办法。谢谢!
发布于 2017-08-29 10:20:51
工作解决方案!
最后,我设法找到了一个解决方案,
我们需要在第一个连接中下载CSRF令牌,然后在第二次连接尝试时使用下载的CSRF令牌。让我们看看下面的示例脚本。
#!/bin/sh
logs_path="/home/usr/logs" #Change your path here
my_username="testuser" #Change your username here
my_password="testuser" #Change your password here
host_name="localhost.com" #Change your sitename here
touch "$logs_path/testfile.test"
curl -k -c "$logs_path/cookies.txt" -u "$my_username":"$my_password" "https://$host_name:443" > /dev/null 2>&1
curl -k -b "$logs_path/cookies.txt" -T "$logs_path/testfile.test" -u "$my_username":"$my_password" "https://$host_name:443/puts/" > /dev/null 2>&1
status="$?"
if [[ $status == 0 ]]; then
echo -e "\nSuccess!"
else
echo -e "\nFailed!"
fihttps://stackoverflow.com/questions/43437961
复制相似问题