Reputation: 340
POST DATA
POSTDATA =-----------------------------204994970613471446171879029128
Content-Disposition: form-data; name="f"; filename="shell.php"
Content-Type: application/x-php
<?php
echo("oi");
?>
-----------------------------204994970613471446171879029128
Content-Disposition: form-data; name="v"
up
-----------------------------204994970613471446171879029128--
FORM
<form method=post enctype=multipart/form-data><input type=file name=f><input name=v type=submit id=v value=up>
PYTHON
import requests
try:
files = {"f": open("page.php", "rb"),"v":"up"}
r = requests.post("http://soportetecnico.nixiweb.com/up.php", files=files, headers={"Content-type": "application/x-php"})
print r.text
except Exception as e:
print e
What i need to send a PHP file to upload with python? I dont't know what i'm doing wrong. Thank in advance for help =]
Upvotes: 0
Views: 534
Reputation: 62626
You should separate the files
and the data
in your request:
import requests
try:
files = {"f": open("page.php", "rb")}
values = {"v":"up"}
r = requests.post("http://soportetecnico.nixiweb.com/up.php", files=files, data=values, headers={"Content-type": "application/x-php"})
print r.text
except Exception as e:
print e
Upvotes: 2