pwn.js

50 | Basic Usage
Pre-built version of the library is located at /dist/pwn.js. API documentation is available in /docs or here, and examples of complete exploits are in /examples.
51 | If you want to implement a new Chakra exploit, you can use this basic template:
52 | var Exploit = (function() {
53 | var ChakraExploit = pwnjs.ChakraExploit,
54 | Integer = pwnjs.Integer;
55 |
56 | function Exploit() {
57 | ChakraExploit.call(this);
58 | // TODO: implement your exploit
59 | // TODO: leak any Chakra.dll address (e.g. a vtable)
60 | this.initChakra(vtable);
61 | }
62 | Exploit.prototype = Object.create(ChakraExploit.prototype);
63 | Exploit.prototype.constructor = Exploit;
64 | Exploit.prototype.read = function (address, size) {
65 | switch (size) {
66 | case 8:
67 | case 16:
68 | case 32:
69 | case 64:
70 | // TODO: implement memory read of address
71 | }
72 | }
73 | Exploit.prototype.write = function (address, value, size) {
74 | switch (size) {
75 | case 8:
76 | case 16:
77 | case 32:
78 | case 64:
79 | // TODO: implement memory write of value to address
80 | }
81 | }
82 | return Exploit;
83 | })();
Using an exploit in a payload is easier if you use the deprecated with statement:
84 | with (new Exploit()) {
85 | var malloc = importFunction('msvcrt.dll', 'malloc', Uint8Ptr);
86 | // ...
87 | }
You can also define an Exploit object (non-deprecated, but more verbose):
88 | var e = new Exploit();
89 | var malloc = e.importFunction('msvcrt.dll', 'malloc', Uint8Ptr);
90 | // ...
Build Instructions
You can rebuild the library using webpack:
91 | $ npm install
92 | $ npm run build
You can rebuild the documentation using jsdoc:
93 | $ npm run jsdoc
Also, you can run a small HTTP server to host the documentation and examples:
94 | $ npm start
95 |