H
H
Headballz2019-07-09 22:51:55
Python
Headballz, 2019-07-09 22:51:55

How to authorize on a site with a dropdown list (domain) using request?

There is a servicedesk website
5d24ec76132a8958103852.png

There is a working script for local authorization

s = requests.Session()
url = 'https://~.ru/j_security_check'
s.get(url)
data = dict(j_username='test', j_password='test')
s.post(url, data=data)


I want to log in under a domain u/z, j_security_check swears.

I looked at Network in IE (F12) in POST, there is something like this:

For local (successful login)

j_username=test&j_password=test&domain=Local+Authentication&LDAPEnable=false&hidden=Select+a+Domain&hidden=For+Domain&AdEnable=true&DomainCount=0&LocalAuth=No&LocalAuthWithDomain=No&dynamicUserAddition_status=true&localAuthEnable=true&logonDomainName=Local+Authentication&loginButton=


For domain (successful login)

AUTHRULE_NAME=SDRelationalLoginModule&j_username=user&j_password=userpass&domain=3&DOMAIN_NAME=DOMEN&LDAPEnable=false&hidden=Select+a+Domain&hidden=For+Domain&AdEnable=true&DomainCount=0&LocalAuth=No&LocalAuthWithDomain=DOMEN&dynamicUserAddition_status=true&localAuthEnable=true&logonDomainName=DOMEN&loginButton=


Tried code:
s = requests.Session()
url = 'https://~.ru/j_security_check'
s.get(url)
data = dict(j_username='user', j_password='userpass', domain='3', DOMAIN_NAME='DOMEN',
            LocalAuthWithDomain='DOMEN', logonDomainName='DOMEN')
s.post(url, data=data)


Did not help.
The domain selection block itself:
<span id="domainListSelect" style="display:block;">
            <select name="domain" class="form-control" onchange='checkLocalAuth(this)'>
              <option>-- Choose Domain --</option>

              <option value="1"> DOMEN1 </option> <!-- NO OUTPUTENCODING -->

              <option value="2"> DOMEN2 </option> <!-- NO OUTPUTENCODING -->

              <option value="3"> DOMEN</option> <!-- NO OUTPUTENCODING -->

              <option value='Local Authentication'>Local Authentication</option>

            </select>
          </span>


How to implement domain selection in POST?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Ternick, 2019-07-09
@Headballz

Well, in general, you can use selenium, but it is detected in many places, so it may not help :)

D
Dmitry Shitskov, 2019-07-09
@Zarom

Pass the desired value from option - "1", "2", "3" or 'Local Authentication'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question