2014-12-17 3 views
0

curl을 사용하여 로그인 및 가능한 쿠키가있는 웹 사이트에 연결하는 데 문제가 있습니다. =login with curl이 작동하지 않습니다. bash

(이 예를 들어 내 이메일 = [email protected] 및 비밀번호 mypass!을 :이 같은 것 통과 올바른 데이터를 생각

<div id="authorize"> 

<form action="/" method="post" id="user-login" accept-charset="UTF-8"><div><div class="my-form-wrapper"> 
<div class="form-item form-type-textfield form-item-name"> 
<input type="text" id="edit-name" name="name" value="" size="60" maxlength="60" class="form-text required" /> <label class="option" for="edit-name">E-mail Address <span class="form-required" title="This field is required.">*</span></label> 

<div class="description">Please enter your E-mail Address.</div> 
</div> 
<div class="form-item form-type-password form-item-pass"> 
<input type="password" id="edit-pass" name="pass" size="60" maxlength="128" class="form-text required" /> <label class="option" for="edit-pass">Password <span class="form-required" title="This field is required.">*</span></label> 

<div class="description">Enter your Password.</div> 
</div> 
<input type="hidden" name="form_build_id" value="form-Jrv1EcWkN7AHVeYQoKEGjmtx5OSIcfcS7BbLp4vPB7k" /> 
<input type="hidden" name="form_id" value="user_login" /> 
<div class="login-forgot"><a href="/user/password">Forgot?</a></div><input type="hidden" name="dest_page" value="/home" /> 
<div class="form-actions form-wrapper" id="edit-actions"><input type="submit" id="edit-submit" name="op" value="Log in" class="form-submit" /></div></div></div></form>     
     <div class="register"><a href="/user/register">Register</a></div> 


</div> 

: 여기

사이트의 인증의 HTML입니다)

curl -d "name=myname%40email.com&pass=mypass%21&form_build_id=form-Jrv1EcWkN7AHVeYQoKEGjmtx5OSIcfcS7BbLp4vPB7k&form_id=user_login&dest_page=%2Fhome&op=Log+in" https://mywebsite.com 

두 가지 문제가 있습니다.

1) 내가 사이트를 curl 때마다, 생산하는 새로운 form_build_id

2) 내 로그인이 작동하고 있는지 내가 말할 수없고, I가 %21%40!@을 변환 할 수 있겠 내 사용자 이름과 비밀번호? 단일 호출 구문 분석/요청 빌딩/재발급을 할 수있는 도구를 원하는 경우

+0

"사이트가 말릴 때마다 새로운 form_build_id가 생성됩니다." 그것은 당신이하려는 일을하지 못하게하는 것입니다. :) –

+0

'form_build_id' 가능성이 높습니다'CSRF'/etc. 보호 기능을 제공하므로 서버로 다시 가져와 반영해야 할 가능성이 큽니다. 나머지에 관해서는 나는 모른다. 브라우저에서 사용해보고 전송 내용을 찾으십시오. –

+0

@AlexHowansky 나는 그곳에 방법이 있기를 정말로 바랬다 .../ –

답변

0

토큰 가서 쿠키를 구성, 반환 된 토큰을 저장합니다.

token=$(curl -b $cookie_path -c $cookie_path --request GET "$site_url/services/session/token" -s) 

인증. "X-CSRF-Token : $ token"헤더에 토큰이있는 $ login_url에 대한 POST.

curl -H "X-CSRF-Token: $token" -b $cookie_path -c $cookie_path -d "username=$username&password=$password" "$login_url" -s 

인증 후 새 토큰 가져 오기

token=$(curl -b $cookie_path -c $cookie_path --request GET "$site_url/services/session/token" -s) 
0

, 당신이 사용할 수있는 내 Xidel :

xidel https://mywebsite.com -f 'form((//form)[1], {"name": "myname", "pass": "mypass"})' --download - 
관련 문제