[Python] Setting HTTP header field has no effect

Discussão em 'Python' iniciado por Stack, Dezembro 8, 2024.

  1. Stack

    Stack Membro Participativo

    I'm doing a MitM attack homework. It requires me to change the HTTP payload (adding script tags to the HTML content). I was able to inject the script but I found the content received on the user's side is always cut short. I then realized that the Content-Length field in the HTTP header wasn't increased to accommodate the longer HTTP data.

    I tried to set the Content-Length header this way. new_packet.show() prints fine, showing the updated Content-Length. But when I checked on the client side it still sees the original Content-Length as if nothing was changed.

    res: HTTPResponse = tcp[HTTPResponse]
    res.fields["Content_Length"] = content_len
    new_packet = IP(src=ip.src, dst=ip.dst) / tcp
    new_packet.show()
    send(new_packet)


    I checked other related answers here and on scapy's github issues page but the discussions seem to be very outdated. Has anyone successfully changed the header fields this way? Am I supposed to use another method to modify header fields?

    Continue reading...

Compartilhe esta Página