Advertisement
FlyFar

drone_pwn.js

Mar 14th, 2023
1,594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.58 KB | Cybersecurity | 0 0
  1. var arDrone = require('ar-drone');
  2. var http    = require('http');
  3.  
  4. //var pngStream = arDrone.createClient().getPngStream();
  5. var client = arDrone.createClient();
  6. client.disableEmergency();
  7.  
  8. console.log('Connecting png stream ...');
  9. var pngStream = client.getPngStream();
  10.  
  11. var lastPng;
  12. pngStream
  13.   .on('error', console.log)
  14.   .on('data', function(pngBuffer) {
  15.     lastPng = pngBuffer;
  16.   });
  17.  
  18. var server = http.createServer(function(req, res) {
  19.   if (!lastPng) {
  20.     res.writeHead(503);
  21.     res.end('Did not receive any png data yet.');
  22.     return;
  23.   }
  24.  
  25.   res.writeHead(200, {'Content-Type': 'image/png'});
  26.   res.end(lastPng);
  27. });
  28.  
  29. server.listen(8080, function() {
  30.   console.log('Serving latest png on port 8080 ...');
  31.   client.takeoff();
  32.  
  33.   client
  34.     .after(5000, function() {
  35.       this.clockwise(0.5);
  36.     })
  37.     .after(5000, function() {
  38.       this.stop();
  39.     })
  40.     .after(5000, function() {
  41.       this.clockwise(0.5);
  42.     })
  43.     .after(5000, function() {
  44.       this.stop();
  45.     })
  46.     .after(5000, function() {
  47.       this.clockwise(0.5);
  48.     })
  49.     .after(5000, function() {
  50.       this.stop();
  51.     })
  52.     .after(5000, function() {
  53.       this.clockwise(-0.5);
  54.     })
  55.     .after(5000, function() {
  56.       this.stop();
  57.     })
  58.     .after(5000, function() {
  59.       this.clockwise(-0.5);
  60.     })
  61.     .after(5000, function() {
  62.       this.stop();
  63.     })
  64.     .after(5000, function() {
  65.       this.clockwise(-0.5);
  66.     })
  67.     .after(5000, function() {
  68.       this.stop();
  69.     })
  70.     .after(1000, function() {
  71.       this.stop();
  72.       this.land();
  73.     });
  74.  
  75. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement