Question

I have been stuck by the problems. I want to send a post message with cookies using the python requests packets, and I have searched a similar post here in stack, but still it didn't pass.

This problem origins from the seed project xss working set. I was ordered to generate a http post request with the cookies, and send it to the server.

I dumped the packets using wireshark, but I am sorry I cannot add images here for my 0-reputation,huhu……

The packet analyzed by wireshark get a Line-based text data: application/x-www-form-urlencoded while but my codes don't produce this, and the data is appended to the next packets.(I mean two packets were generated by my codes, on containing the headers and the other containing the http data, both the two packets have wrong calsums)

Here are my codes:

import requests
url="http://www.xsslabphpbb.com/posting.php"
data= {
    'subject': 'Alice-subject',
    'addbbcode18': '%23444444',
    'addbbcode20': '0',
    'helpbox': 'Close all open bbCode tags',
    'message': 'alice-body',
    'poll_title': '',
    'add_poll_option_text': '',
    'poll_length': '',
    'mode': 'newtopic',
    'sid': '5b2e663a3d724cc873053e7ca0f59bd0',
    'f': '1',
    'post': 'Submit',
    }
cookies = {'phpbb2mysql_data': 'a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A0%3A%22%22%3Bs%3A6%3A%22userid%22%3Bs%3A1%3A%223%22%3B%7D',
           'phpbb2mysql_t': 'a%3A9%3A%7Bi%3A3%3Bi%3A1330156986%3Bi%3A1%3Bi%3A1330160737%3Bi%3A5%3Bi%3A1330161702%3Bi%3A6%3Bi%3A1330179284%3Bi%3A2%3Bi%3A1330160743%3Bi%3A7%3Bi%3A1330163187%3Bi%3A8%3Bi%3A1330164442%3Bi%3A9%3Bi%3A1330164739%3Bi%3A10%3Bi%3A1330176335%3B%7D',
           'phpbb2mysql_sid': '5b2e663a3d724cc873053e7ca0f59bd0',
           }
print requests.post(url, data=data, cookies=cookies).text

Well, in fact, I was new to Python, and I don't know how to figure this bothering problem out. Can anybody give me any advice or suggestions? Thanks in advance! (Sorry for the picture, I hope you can understand me.)

Was it helpful?

Solution

The requests library lets you create Session objects that can track the cookies for you, so you should consider extending your knowledge in that direction.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top