How
to access WCC server using Python ?
How
to login to web site using Python ?
Main
Tasks
1.
Getting login URL and parameters
2.
Creat phyton file
3.
Running phyton code
WCC
server ->ucm.company.com:16200
1.1
Access UCM URL in chrome
http://ucm.company.com:16200/cs/
click
on login
http://ucm.company.com:16200/cs/login/login.htm
1.2
Cltr+Shift+I ( Developer mode )
Click
on Network
1.3
Enter username and password , then enter
1.4
Select j_security_check (status 302)
1.5
Click on Header
IS
Authentication URL and , other parameters will be
displayed
if
you select other (302 status) URL ,
Which
means , login is already done .
1.6
:
This
means
LOGIN_URL
= "http://ucm.company.com:16200/cs/login/j_security_check”
j_username=weblogic
j_password=
welcome1
2.
Creat phyton file
2.1,
For testing we will access , content belongs
to
secure group
URL
to Access :
http://ucm.company.com:16200/cs/idcplg?IdcService=DOC_INFO&dID=414&dDocName=AWSECM000414&IsSoap=1
2.2
Script :
#!/bin/python
import
requests
import
re
from
lxml import html
USERNAME
= "weblogic"
PASSWORD
= "welcome1"
IdcService=DOC_INFO&dID=3223&dDocName=STJACOBPC1IDCO003622&IsSoap=1"
LOGIN_URL
=
"http://ucm.company.com:16200/cs/login/j_security_check"
URL
=
"http://ucm.company.com:16200/cs/idcplg?
IdcService=DOC_INFO&dID=414&dDocName=AWSECM000414&IsSoap=1
"
session_requests
= requests.session()
#
Get login csrf token
result
= session_requests.get(LOGIN_URL)
#
Create payload
payload
= {
"j_username":
USERNAME,
"j_password":
PASSWORD,
}
flag
= 0
#
Perform login
result
= session_requests.post(LOGIN_URL, data = payload, headers =
dict(referer = LOGIN_URL))
regex
= 'idcToken = ".{13,47}"'
pattern
= re.compile(regex)
for
line in result:
role
= re.findall(pattern,line)
if
role:
print
line
flag=1
if
(flag==1):
result
= session_requests.get(URL, headers = dict(referer = URL))
for
line in result:
print(line)
else:
print("In
Valid Login")
result
= session_requests.get(LOGIN_URL)
This
will perform ,login part
with
layload
regex
= 'idcToken = ".{13,47}"'
Will
check for correct login .
result
= session_requests.get(URL, headers = dict(referer = URL))
This
will use to access the content info page URL
3.
Running phyton code
./ucmlogin.py
Correct login : , after
getting idctoken, it will print content info
var
idcToken = "1471027281668:4F907EFE0CE5AFE561EDCA60CF8cB71E2";
//
user specific strings and flags: used only to d
<?xml
version='1.0' encoding='utf-8' ?>
SOAP-ENV:Envelope
xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-E
NV:Body>
<idc:service mlns:idc="http://www.stellent.com/IdcService/"
IdcService="DOC_INFO">
<idc:document
dDocName="AWSECM000
414"
dStatus="RELEASED" dDocTitle="Test RIDC
Checkin"
DocUrl="http://localhost:16200/cs/groups/secure/docum
ents/document/zwnt/md
aw/~edisp/awsecm000414.txt"
dUser="weblogic"
dDocFormats="text/plain"
dID="414">
In
correct Login , There wont be any idctoken
./ucmlogin.py
In
Valid Login
No comments:
Post a Comment