Jump to content

PHP Curl to pineapple API


Recommended Posts


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:



//display errors, remove when done
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);


//define POST & encode in JSON

    'message'=>'Hello from apache!',

$JSON = json_encode($a);
print $JSON;

//curl post request
$c = curl_init();
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_URL, "");
//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'];
    die('Error: "' . curl_error($c) . '" - Code: ' . curl_errno($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?

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...