sebaz Posted March 19, 2018 Posted March 19, 2018 Hi! I am trying to build a new webinterface for the pineapple, because I want to use the device to teach people how vulnerable they are. I want to use the pineapple API for this, using PHP to call the functions on my pineapple via cURL. I have the following code: Quote <?php //display errors, remove when done ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); $key="apiToken"; //define POST & encode in JSON $a=[ 'system'=>'notifications', 'action'=>'addNotification', 'message'=>'Hello from apache!', 'apiToken'=>'7de64925dd8703fc5595a7d0b845ce0ed965fa799b67a19b310cb2538017aeaacb205e6dbc72d8758c3b995d25a1a273783c49bfb7519b2e71fbd49af074ab35' ]; $JSON = json_encode($a); print $JSON; //curl post request $c = curl_init(); curl_setopt($c, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($c, CURLOPT_FOLLOWLOCATION, true); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_URL, "http://172.16.42.1:1471/api"); //curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_POSTFIELDS, $JSON); curl_setopt($c, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Authorization: ' . $key )); //print curl output $result = curl_exec($c); print $result; $info = curl_getinfo($c); print '</br>'; print $info['http_code']; if(!curl_exec($c)){ die('Error: "' . curl_error($c) . '" - Code: ' . curl_errno($c)); } curl_close($c); When I execute this code, i'll get bag a '200' http code. All good right? However, the server output is 'not authenticated' and nothing happens on the pineapple, no notification appears. Does anybody have any idea what I'm doing wrong?
sebaz Posted May 3, 2018 Author Posted May 3, 2018 turns out, the url has to have a '/' at the end. It works when you use: curl_setopt($c, CURLOPT_URL, "http://172.16.42.1:1471/api/");
Recommended Posts
Archived
This topic is now archived and is closed to further replies.