使用curl命令登录网站并获取cookie,并将json数据上传

curl -k -X POST -c cookie.txt --header 'Content-Type: application/json' --header 'Accept: application/json' -d 
        {“username”="admin","password"="123"} https://www.XXX.com

-k的意思是指访问前缀是https的情况下不对服务器证书SSL进行检查访问,如果前缀是http 可以直接curl http://www.xxx.com。

-X POST同理有-X PUT,-X DELETE,-X GET等,-X POST是指使用post请求给服务器传递数据。我们将用户名和密码通过curl命令post到指定网站,然后通过 -c cookie.txt将获取的cookie写到cookie.txt的文件里。

 

curl -kv -X PUT --header 'Content-Type:application/json' --header 'Accept: application/json ' -d {#这里是所传的json值} -b cookie.txt https://www.xxx.com

通过-b cookie.txt获取cookie然后访问网站,传输json数据。

 

发布了6 篇原创文章 · 获赞 6 · 访问量 2万+
展开阅读全文

linux下curl -b 加载 cookie 的问题求救

05-25

要加载的cookie文件: ``` .e.test.cn TRUE / FALSE 1428635701 CRM_ADMIN %1B%A7h4z%A9_I%08%91%CAc%7D%18%1D%EB .test.cn TRUE / FALSE Q u%3D%25O5%25PR%25O4%25S0%25O5%25PR%25O4%25S0%25O7%25N2%25O7%25N2%25PO%25PQ%26n%3DCUC%25O1%25R0%25O3%25PP%26le%3D%26m%3DZGHlWGWOWGWOWGWOWGWOWGWOZmNl%26qid%3D1334231151%26im%3D1_t00df551a583a87f4e9%26src%3Dpcw_adsystem_dianjing%26t%3D1 .test.cn TRUE / FALSE T s%3Df4de676ab20437e44e247a6816950111%26t%3D1432539749%26lm%3D%26lf%3D2%26sk%3D2f468caba91c9d812dc2b40765190c2e%26mt%3D1432539749%26rc%3D%26v%3D2.0%26a%3D0 .test.cn TRUE / FALSE 1453361536 __guid 59546617.1361129544114280400.1427441536251.224 .test.cn TRUE / FALSE 1427881867 __hsid p%2BXBNwZTe0bgt7rDlrfj26WMqwj7tQUm3IO8DsZMQCC%2Fpz5sW9sKK0oSd80tCJOO .test.cn TRUE / FALSE 2373875461 __huid 10D56zvW3UZiHzJEGt7IL%2Fcy4MA%2F2o5N6VOP8zA3bLJ%2Bs%3D e.test.cn FALSE / FALSE 1432626118 monitor_count 2 .e.test.cn TRUE / FALSE 1432094965 open_auth_admin %95G%C2%88%21t%FDW%9D%11%07%DD%0F%AE%B3%9B1%10%B1%E9R2%E4%40%8A%ECKg%19%A6%28%E7B%3D%C6%ADF%E2%DC%C5%E8%E1%80%8C%05%0E%F42qt%1A%3D%9A%16i%8E%AAG%3Af%BF%B9%90%83%F6o%25-%CF%1D%F5%12%D2%C0o%D3%17%C5%CCi%2B%DA%26ds%05%85%BB%04W5%F3%0BYR%DA%26%C6eUj%E5%DB-%CC%F2%8B%AEv%B0%1Bir%DD%1DTv%BC%FE%CCQHi%9D%02j%C6%22%08%DA%09%E5%3C%5E%E2%EF%AC%B0vX%7F%CB%A2%F2%A1Gnp%97%0A%FBX%C1%A0nt%96%3E%BCR%88%E6E%D4%09%00%D6%AA%C0%8Bj%C8%0D%00%F1%BD%FD%A7%90%E6%3D%BEsP-%A4%CF%D5%01%5B%98%15%C5%88%3F%8E%5C%EF%9C%C9E%08%B9%FB%8ET%A0%15s2v%1D%97x%1F%03%A6m%7F%1A%17Q%B4%CE3.%93%DE2TAR0%16%14%98%D5_o%E7%BD%CB%A8%82z%19UK%0Dt%AC%07c%BE%8F%0BhK%8F%2A%AC%21%F2%F1%F4Y%BE%60%14%C9T%DC%CA%CE6%B9%2F%E7%8F%14%2F%40%1Ak%A9%01%EBQ%BA%AA%DEW%3F%1A%B5%EB%F5%22%AC%F6%00%A9%F9%25%7C%29%A9%1B%FA%92%F3%17%D4%CAD%9E%F7e%13%22%B5%D5TqoW%08%8A%9C%2A%B5%B8%5BI%BE%05%C1%09%3D%C1%D9%CFh%E2%D6%0E%F7eLU%E5%3B%C3%EE%C1%12%21%96%BD%06n%E3a6%C6%12%D7%C6%F2%BD%E2%D2x%B5o%C7 .test.cn TRUE / FALSE 1432093162 open_auth_admin %81%1A%D4%FE%22%1FHG%E5%0B%8A%277%2A%7D%0F%3AHK%24%AD%CF%7Fj%E7%A9%A2%1E%0A%C6%C3H6%06+c%F3%5C0%F9%29%EA%C8%A3%BDH%1F%E0%F6%0A%3A%B4%D6%08_%CEGwYC%F0z%CE%22k%F3O%BF%98%EB%23%3A%F5%D3%81c%3D%8E%7B%B0%9B%EA3%CChy%DC%BF%06F5%12%9A%25%5B%7E%AAp%F1%D6%E7%27%96D%F6p%B0%25%AC%B2%95%BC%1D%87f%FAS%A3%BE%E2%98%AB%7D%82%D6%F1%A9%3EGx%07T%0C%AA%C0%CD%BC%D0%8E%2ASm%F1%CD%F2%08%FE%FD%C1B%CF%DF%28%DBl%93%27%28u%90%85%1F%13%12%83f%BA%26I%9D%C5%C1%88.%9D%2A%B7%EB%DDN%D7%27q%D9%A3%10%BDS%EC%13%98%2Cx%8D%C8%F3%87+R%5E%ED%81%A6%07x%B1%DAB%1C%80%1D%C4%C1%8BN%15%5D%C1F%E4%23%B0%E3%B5%5E%85v%C5y%C9%13%3AB%0A%5BC%5D%D0%0Fb%DA%E8%AB%B7%D3%00%A8%DD_u%99%07%8A%09%98%991%BCI%B9%C4%E7%9BN%C0%3E%DA%F9%29N%F6%1E%8F%A8%13%D6%FAGM%D5K%E0%D2O%14%11%3D%25%9B%7C%E4%DF%E9%FD%0F%C2%D7%E1%1A%29%A0%2ACu%7B%05PMV%C1%CA%C2%92M%98%9D%0B%D8%3A%FA%D4%A2z%94%60%17l%C9%01B%00%E5P%7D%BE%F5%0CZm%2C%1A%96I%BDeM0%CD%85%90I%DAaP%AC%8AJ%ED%60%25%E8%60%BA%C3%D1wfZ%FA%E05%CC%E9%16%AE%CB .e.test.cn TRUE / FALSE 1428635701 s v%CE%01%E1%80%2B%B5%A5%1B%1D-%00O%D7%FF%83 e.test.cn FALSE / FALSE test_cookie_enable null ``` ``` curl -b cookies.txt -I http://qhq.cg.e.test.cn -vv ``` 运行后显示附带的cookie跟cookie源文件不符,Q和T都没正确附带,是什么原因呢? ``` * About to connect() to qhq.bool_cg.e.test.cn port 80 * Trying 127.0.0.1... connected * Connected to qhq.bool_cg.e.test.cn (127.0.0.1) port 80 > HEAD / HTTP/1.1 > User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 > Host: qhq.bool_cg.e.test.cn > Accept: */* > Cookie: __huid=10D56zvW3UZiHzJEGt7IL%2Fcy4MA%2F2o5N6VOP8zA3bLJ%2Bs%3D; __guid=59546617.1361129544114280400.1427441536251.224; s%3Df4de676ab20437e44e247a6816950111%26t%3D1432539749%26lm%3D%26lf%3D2%26sk%3D2f468caba91c9d812dc2b40765190c2e%26mt%3D1432539749%26rc%3D%26v%3D2.0%26a%3D0=; u%3D%25O5%25PR%25O4%25S0%25O5%25PR%25O4%25S0%25O7%25N2%25O7%25N2%25PO%25PQ%26n%3DCUC%25O1%25R0%25O3%25PP%26le%3D%26m%3DZGHlWGWOWGWOWGWOWGWOWGWOZmNl%26qid%3D1334231151%26im%3D1_t00df551a583a87f4e9%26src%3Dpcw_adsystem_dianjing%26t%3D1= > < HTTP/1.1 302 Moved Temporarily HTTP/1.1 302 Moved Temporarily < Server: nginx/1.6.2 Server: nginx/1.6.2 < Date: Mon, 25 May 2015 09:03:26 GMT Date: Mon, 25 May 2015 09:03:26 GMT < Content-Type: text/html; charset=utf-8 Content-Type: text/html; charset=utf-8 < Connection: keep-alive Connection: keep-alive < X-Powered-By: PHP/5.5.23 X-Powered-By: PHP/5.5.23 < logid: app_714325446064994598 logid: app_714325446064994598 < Location: http://zbx.mcc.e.test.cn Location: http://zbx.mcc.e.test.cn * Connection #0 to host qhq.bool_cg.e.test.cn left intact * Closing connection #0 ``` 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览