Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys
- import re
- import urllib2
- import base64
- import logging # Help with debugging
- # Basic setup
- logging.basicConfig(filename='log.log', level=logging.DEBUG)
- url = 'http://192.168.2.4:8080'
- url = 'http://localhost:5005'
- username = 'admin'
- password = 'password' # Awkward. Should really just generate the cookie and use that
- encodedAuth = base64.encodestring(username + ':' + password).replace('\n', '')
- hash = sys.argv[1]
- logging.debug(hash)
- hash = 'AD196E2C1E4E12EC35CC7A45F3908D66D1F604B6'
- # Get token
- tokenURL = url + '/gui/token.html'
- tokenRequest = urllib2.Request(tokenURL)
- tokenRequest.add_header('Authorization', 'Basic %s' % encodedAuth)
- print tokenRequest.get_header('Authorization')
- logging.debug(tokenRequest)
- tokenResponse = urllib2.urlopen(tokenRequest).read()
- # print tokenResponse
- toSearch = "<html><div id='token' style='display:none;'>(.*)</div></html>"
- tokenString = re.search(toSearch, tokenResponse).group(1)
- tokenString = 'IxnsQ3j2E65f4cjzjpf1GvEMVs5aOS2DD1s4XJgtyLuz8uHk5Jcq6cYXqlYAAAAA'
- print tokenString
- # http://$server:$port/gui/?action=$removeAction\&token=$token\&hash=${lineTokens[0]}
- # http://localhost:8080/gui/?token=rDEQ_K-ocFLGGXMVAkME9Kwg9a1aOS2DD1s4XJgtyLuz8uHk5Jcq6bEpqlYAAAAA&action=remove&hash=214E78C2E058448F7265061DDB1596774916D947
- # http://localhost:5005/gui/?token=IxnsQ3j2E65f4cjzjpf1GvEMVs5aOS2DD1s4XJgtyLuz8uHk5Jcq6cYXqlYAAAAA&action=remove&hash=AD196E2C1E4E12EC35CC7A45F3908D66D1F604B6
- # Make action request
- actionURL = url + '/gui/?token=' + tokenString + '&action=remove&hash=' + hash
- print actionURL
- actionRequest = urllib2.Request(actionURL)
- actionRequest.add_header('Authorization', 'Basic %s' % encodedAuth)
- actionResponse = urllib2.urlopen(actionRequest)
- logging.debug(actionURL)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement