{"action":"created","comment":{"url":"https://api.github.com/repos/binjitsu/binjitsu/pulls/comments/33191906","id":33191906,"diff_hunk":"@@ -66,28 +265,40 @@ def _leaker(self, addr):\n         return leak\n \n     def execute_writes(self):\n-        addrs = []\n-        bytes = []\n-\n-        #convert every write into single-byte writes\n-        for addr, data in self.writes:\n-            data = flat(data)\n-            for off, b in enumerate(data):\n-                addrs.append(addr+off)\n-                bytes.append(u8(b))\n-\n-        fmtstr = randoms(self.padlen) + flat(addrs)\n-        n = self.numbwritten + len(fmtstr)\n-\n-        for i, b in enumerate(bytes):\n-            b -= (n % 256)\n-            if b <= 0:\n-                b += 256\n-            fmtstr += \"%%%dc%%%d$hhn\" % (b, self.offset + i)\n-            n += b\n+        \"\"\"execute_writes() -> None\n+\n+        Makes payload and send it to the vulnerable process\n+\n+        Returns:\n+            None\n \n+        \"\"\"\n+        fmtstr = randoms(self.padlen)\n+        fmtstr += fmtstr_payload(self.offset, self.writes, numbwritten=self.padlen, write_size='byte')\n         self.execute_fmt(fmtstr)\n-        self.writes = []\n+        self.writes = {}\n \n     def write(self, addr, data):\n-        self.writes.append((addr, data))\n+        r\"\"\"write(addr, data) -> None\n+\n+        In order to tell : I want to write ``data`` at ``addr``.\n+\n+        Arguments:\n+            addr(int): the address where you want to write\n+            data(int): the data that you want to write ``addr``\n+\n+        Returns:\n+            None\n+\n+        Examples:\n+\n+            >>> def send_fmt_payload(payload):\n+            ...     print repr(payload)\n+            ...\n+            >>> f = FmtStr(send_fmt_payload, offset=5)\n+            >>> f.write(0x08040506, 0x1337babe)\n+            >>> f.execute_writes()\n+            '\\x06\\x05\\x04\\x08\\x07\\x05\\x04\\x08\\x08\\x05\\x04\\x08\\t\\x05\\x04\\x08%174c%5$hhn%252c%6$hhn%125c%7$hhn%220c%8$hhn'","path":"pwnlib/fmtstr.py","position":284,"original_position":284,"commit_id":"375000571e26ec582961c53685cb053d1097f14d","original_commit_id":"375000571e26ec582961c53685cb053d1097f14d","user":{"login":"zachriggle","id":111640,"avatar_url":"https://avatars.githubusercontent.com/u/111640?v=3","gravatar_id":"","url":"https://api.github.com/users/zachriggle","html_url":"https://github.com/zachriggle","followers_url":"https://api.github.com/users/zachriggle/followers","following_url":"https://api.github.com/users/zachriggle/following{/other_user}","gists_url":"https://api.github.com/users/zachriggle/gists{/gist_id}","starred_url":"https://api.github.com/users/zachriggle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zachriggle/subscriptions","organizations_url":"https://api.github.com/users/zachriggle/orgs","repos_url":"https://api.github.com/users/zachriggle/repos","events_url":"https://api.github.com/users/zachriggle/events{/privacy}","received_events_url":"https://api.github.com/users/zachriggle/received_events","type":"User","site_admin":false},"body":"Putting the addresses first may prevents using addresses with NULLs as their most siginificant bytes, which is possible to use if loaded into a zeroed buffer.\r\n\r\nIt's generally a better idea to put the format string first, followed by pointer-width padding, then the addresses to be loaded.","created_at":"2015-06-24T20:27:34Z","updated_at":"2015-06-24T20:27:34Z","html_url":"https://github.com/binjitsu/binjitsu/pull/41#discussion_r33191906","pull_request_url":"https://api.github.com/repos/binjitsu/binjitsu/pulls/41","_links":{"self":{"href":"https://api.github.com/repos/binjitsu/binjitsu/pulls/comments/33191906"},"html":{"href":"https://github.com/binjitsu/binjitsu/pull/41#discussion_r33191906"},"pull_request":{"href":"https://api.github.com/repos/binjitsu/binjitsu/pulls/41"}}},"pull_request":{"url":"https://api.github.com/repos/binjitsu/binjitsu/pulls/41","id":38188335,"html_url":"https://github.com/binjitsu/binjitsu/pull/41","diff_url":"https://github.com/binjitsu/binjitsu/pull/41.diff","patch_url":"https://github.com/binjitsu/binjitsu/pull/41.patch","issue_url":"https://api.github.com/repos/binjitsu/binjitsu/issues/41","number":41,"state":"open","locked":false,"title":"Format string documentation & generic function","user":{"login":"thetlk","id":2060873,"avatar_url":"https://avatars.githubusercontent.com/u/2060873?v=3","gravatar_id":"","url":"https://api.github.com/users/thetlk","html_url":"https://github.com/thetlk","followers_url":"https://api.github.com/users/thetlk/followers","following_url":"https://api.github.com/users/thetlk/following{/other_user}","gists_url":"https://api.github.com/users/thetlk/gists{/gist_id}","starred_url":"https://api.github.com/users/thetlk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thetlk/subscriptions","organizations_url":"https://api.github.com/users/thetlk/orgs","repos_url":"https://api.github.com/users/thetlk/repos","events_url":"https://api.github.com/users/thetlk/events{/privacy}","received_events_url":"https://api.github.com/users/thetlk/received_events","type":"User","site_admin":false},"body":"I added a generic function which generate format string bug payload. It takes some parameters : \r\n* ```offset``` : the first formatter's offfset you control\r\n* ```ok``` : list of tuple, each tuple must be composed as ```(where, what)```\r\n* ```numbwritten``` : number of byte already written by the printf function\r\n* ```write_size``` : must be 'byte', 'short', 'int'. Tells if you want to write byte by byte, short by short or int by int (hhn, hn or n)\r\nThe function takes ```context.bits``` value in reference for generating the payload. It supports 32 bits or 64 bits architectures.\r\n\r\nI also added some documentation. \r\n\r\nI have some issues with travis on archlinux, so there is no tests for this functions for the moment.\r\n","created_at":"2015-06-21T18:23:48Z","updated_at":"2015-06-24T20:27:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d4b9671c3911eabb02ee5df5e08e64689bc0cea","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/binjitsu/binjitsu/pulls/41/commits","review_comments_url":"https://api.github.com/repos/binjitsu/binjitsu/pulls/41/comments","review_comment_url":"https://api.github.com/repos/binjitsu/binjitsu/pulls/comments{/number}","comments_url":"https://api.github.com/repos/binjitsu/binjitsu/issues/41/comments","statuses_url":"https://api.github.com/repos/binjitsu/binjitsu/statuses/375000571e26ec582961c53685cb053d1097f14d","head":{"label":"thetlk:master","ref":"master","sha":"375000571e26ec582961c53685cb053d1097f14d","user":{"login":"thetlk","id":2060873,"avatar_url":"https://avatars.githubusercontent.com/u/2060873?v=3","gravatar_id":"","url":"https://api.github.com/users/thetlk","html_url":"https://github.com/thetlk","followers_url":"https://api.github.com/users/thetlk/followers","following_url":"https://api.github.com/users/thetlk/following{/other_user}","gists_url":"https://api.github.com/users/thetlk/gists{/gist_id}","starred_url":"https://api.github.com/users/thetlk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thetlk/subscriptions","organizations_url":"https://api.github.com/users/thetlk/orgs","repos_url":"https://api.github.com/users/thetlk/repos","events_url":"https://api.github.com/users/thetlk/events{/privacy}","received_events_url":"https://api.github.com/users/thetlk/received_events","type":"User","site_admin":false},"repo":{"id":37596506,"name":"binjitsu","full_name":"thetlk/binjitsu","owner":{"login":"thetlk","id":2060873,"avatar_url":"https://avatars.githubusercontent.com/u/2060873?v=3","gravatar_id":"","url":"https://api.github.com/users/thetlk","html_url":"https://github.com/thetlk","followers_url":"https://api.github.com/users/thetlk/followers","following_url":"https://api.github.com/users/thetlk/following{/other_user}","gists_url":"https://api.github.com/users/thetlk/gists{/gist_id}","starred_url":"https://api.github.com/users/thetlk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thetlk/subscriptions","organizations_url":"https://api.github.com/users/thetlk/orgs","repos_url":"https://api.github.com/users/thetlk/repos","events_url":"https://api.github.com/users/thetlk/events{/privacy}","received_events_url":"https://api.github.com/users/thetlk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/thetlk/binjitsu","description":"CTF framework and exploit development library","fork":true,"url":"https://api.github.com/repos/thetlk/binjitsu","forks_url":"https://api.github.com/repos/thetlk/binjitsu/forks","keys_url":"https://api.github.com/repos/thetlk/binjitsu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thetlk/binjitsu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thetlk/binjitsu/teams","hooks_url":"https://api.github.com/repos/thetlk/binjitsu/hooks","issue_events_url":"https://api.github.com/repos/thetlk/binjitsu/issues/events{/number}","events_url":"https://api.github.com/repos/thetlk/binjitsu/events","assignees_url":"https://api.github.com/repos/thetlk/binjitsu/assignees{/user}","branches_url":"https://api.github.com/repos/thetlk/binjitsu/branches{/branch}","tags_url":"https://api.github.com/repos/thetlk/binjitsu/tags","blobs_url":"https://api.github.com/repos/thetlk/binjitsu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thetlk/binjitsu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thetlk/binjitsu/git/refs{/sha}","trees_url":"https://api.github.com/repos/thetlk/binjitsu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thetlk/binjitsu/statuses/{sha}","languages_url":"https://api.github.com/repos/thetlk/binjitsu/languages","stargazers_url":"https://api.github.com/repos/thetlk/binjitsu/stargazers","contributors_url":"https://api.github.com/repos/thetlk/binjitsu/contributors","subscribers_url":"https://api.github.com/repos/thetlk/binjitsu/subscribers","subscription_url":"https://api.github.com/repos/thetlk/binjitsu/subscription","commits_url":"https://api.github.com/repos/thetlk/binjitsu/commits{/sha}","git_commits_url":"https://api.github.com/repos/thetlk/binjitsu/git/commits{/sha}","comments_url":"https://api.github.com/repos/thetlk/binjitsu/comments{/number}","issue_comment_url":"https://api.github.com/repos/thetlk/binjitsu/issues/comments{/number}","contents_url":"https://api.github.com/repos/thetlk/binjitsu/contents/{+path}","compare_url":"https://api.github.com/repos/thetlk/binjitsu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thetlk/binjitsu/merges","archive_url":"https://api.github.com/repos/thetlk/binjitsu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thetlk/binjitsu/downloads","issues_url":"https://api.github.com/repos/thetlk/binjitsu/issues{/number}","pulls_url":"https://api.github.com/repos/thetlk/binjitsu/pulls{/number}","milestones_url":"https://api.github.com/repos/thetlk/binjitsu/milestones{/number}","notifications_url":"https://api.github.com/repos/thetlk/binjitsu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thetlk/binjitsu/labels{/name}","releases_url":"https://api.github.com/repos/thetlk/binjitsu/releases{/id}","created_at":"2015-06-17T13:27:48Z","updated_at":"2015-06-17T13:27:49Z","pushed_at":"2015-06-24T08:58:09Z","git_url":"git://github.com/thetlk/binjitsu.git","ssh_url":"git@github.com:thetlk/binjitsu.git","clone_url":"https://github.com/thetlk/binjitsu.git","svn_url":"https://github.com/thetlk/binjitsu","homepage":"https://binjit.su","size":19463,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"binjitsu:master","ref":"master","sha":"4f5be7144bcb687e4f9031b584b8e7cc82628551","user":{"login":"binjitsu","id":6656233,"avatar_url":"https://avatars.githubusercontent.com/u/6656233?v=3","gravatar_id":"","url":"https://api.github.com/users/binjitsu","html_url":"https://github.com/binjitsu","followers_url":"https://api.github.com/users/binjitsu/followers","following_url":"https://api.github.com/users/binjitsu/following{/other_user}","gists_url":"https://api.github.com/users/binjitsu/gists{/gist_id}","starred_url":"https://api.github.com/users/binjitsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/binjitsu/subscriptions","organizations_url":"https://api.github.com/users/binjitsu/orgs","repos_url":"https://api.github.com/users/binjitsu/repos","events_url":"https://api.github.com/users/binjitsu/events{/privacy}","received_events_url":"https://api.github.com/users/binjitsu/received_events","type":"Organization","site_admin":false},"repo":{"id":29157870,"name":"binjitsu","full_name":"binjitsu/binjitsu","owner":{"login":"binjitsu","id":6656233,"avatar_url":"https://avatars.githubusercontent.com/u/6656233?v=3","gravatar_id":"","url":"https://api.github.com/users/binjitsu","html_url":"https://github.com/binjitsu","followers_url":"https://api.github.com/users/binjitsu/followers","following_url":"https://api.github.com/users/binjitsu/following{/other_user}","gists_url":"https://api.github.com/users/binjitsu/gists{/gist_id}","starred_url":"https://api.github.com/users/binjitsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/binjitsu/subscriptions","organizations_url":"https://api.github.com/users/binjitsu/orgs","repos_url":"https://api.github.com/users/binjitsu/repos","events_url":"https://api.github.com/users/binjitsu/events{/privacy}","received_events_url":"https://api.github.com/users/binjitsu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/binjitsu/binjitsu","description":"CTF framework and exploit development library","fork":true,"url":"https://api.github.com/repos/binjitsu/binjitsu","forks_url":"https://api.github.com/repos/binjitsu/binjitsu/forks","keys_url":"https://api.github.com/repos/binjitsu/binjitsu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/binjitsu/binjitsu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/binjitsu/binjitsu/teams","hooks_url":"https://api.github.com/repos/binjitsu/binjitsu/hooks","issue_events_url":"https://api.github.com/repos/binjitsu/binjitsu/issues/events{/number}","events_url":"https://api.github.com/repos/binjitsu/binjitsu/events","assignees_url":"https://api.github.com/repos/binjitsu/binjitsu/assignees{/user}","branches_url":"https://api.github.com/repos/binjitsu/binjitsu/branches{/branch}","tags_url":"https://api.github.com/repos/binjitsu/binjitsu/tags","blobs_url":"https://api.github.com/repos/binjitsu/binjitsu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/binjitsu/binjitsu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/binjitsu/binjitsu/git/refs{/sha}","trees_url":"https://api.github.com/repos/binjitsu/binjitsu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/binjitsu/binjitsu/statuses/{sha}","languages_url":"https://api.github.com/repos/binjitsu/binjitsu/languages","stargazers_url":"https://api.github.com/repos/binjitsu/binjitsu/stargazers","contributors_url":"https://api.github.com/repos/binjitsu/binjitsu/contributors","subscribers_url":"https://api.github.com/repos/binjitsu/binjitsu/subscribers","subscription_url":"https://api.github.com/repos/binjitsu/binjitsu/subscription","commits_url":"https://api.github.com/repos/binjitsu/binjitsu/commits{/sha}","git_commits_url":"https://api.github.com/repos/binjitsu/binjitsu/git/commits{/sha}","comments_url":"https://api.github.com/repos/binjitsu/binjitsu/comments{/number}","issue_comment_url":"https://api.github.com/repos/binjitsu/binjitsu/issues/comments{/number}","contents_url":"https://api.github.com/repos/binjitsu/binjitsu/contents/{+path}","compare_url":"https://api.github.com/repos/binjitsu/binjitsu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/binjitsu/binjitsu/merges","archive_url":"https://api.github.com/repos/binjitsu/binjitsu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/binjitsu/binjitsu/downloads","issues_url":"https://api.github.com/repos/binjitsu/binjitsu/issues{/number}","pulls_url":"https://api.github.com/repos/binjitsu/binjitsu/pulls{/number}","milestones_url":"https://api.github.com/repos/binjitsu/binjitsu/milestones{/number}","notifications_url":"https://api.github.com/repos/binjitsu/binjitsu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/binjitsu/binjitsu/labels{/name}","releases_url":"https://api.github.com/repos/binjitsu/binjitsu/releases{/id}","created_at":"2015-01-12T21:28:40Z","updated_at":"2015-06-23T12:29:39Z","pushed_at":"2015-06-24T20:24:08Z","git_url":"git://github.com/binjitsu/binjitsu.git","ssh_url":"git@github.com:binjitsu/binjitsu.git","clone_url":"https://github.com/binjitsu/binjitsu.git","svn_url":"https://github.com/binjitsu/binjitsu","homepage":"https://binjit.su","size":22857,"stargazers_count":80,"watchers_count":80,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":12,"mirror_url":null,"open_issues_count":15,"forks":12,"open_issues":15,"watchers":80,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/binjitsu/binjitsu/pulls/41"},"html":{"href":"https://github.com/binjitsu/binjitsu/pull/41"},"issue":{"href":"https://api.github.com/repos/binjitsu/binjitsu/issues/41"},"comments":{"href":"https://api.github.com/repos/binjitsu/binjitsu/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/binjitsu/binjitsu/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/binjitsu/binjitsu/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/binjitsu/binjitsu/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/binjitsu/binjitsu/statuses/375000571e26ec582961c53685cb053d1097f14d"}}}}