<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-13656592</id><updated>2017-05-20T20:58:52.968+08:00</updated><category term="Linux kernel"/><category term="C++"/><category term="security"/><category term="CTF"/><category term="windbg"/><category term="Python"/><category term="Linux"/><category term="gdb"/><category term="binutils"/><category term="elf"/><category term="gcc"/><category term="coff"/><category term="cryptography"/><category term="cvs diff"/><category term="device driver"/><category term="ext2 filesystem"/><category term="graphics"/><category term="grub"/><category term="mathematics"/><category term="network"/><category term="profiling"/><category term="rpm"/><category term="vim"/><title type='text'>Notes from a humble computer user...</title><subtitle type='html'>Information from this blog is for my personal use only, mainly as a self reminder.  I will not be liable for any error in the content or any action taken in reliance thereon, including if it is cited or referenced. All copyrights and trademarks belong to their respective owner.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default?alt=atom&amp;redirect=false'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default?alt=atom&amp;start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Wei Chong Tan</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>163</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-13656592.post-2419906467364521099</id><published>2017-05-20T20:45:00.001+08:00</published><updated>2017-05-20T20:58:52.976+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="security"/><title type='text'>Application Whitelisting Bypass using Firefox?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Recently, thanks to a friend who bring my attention to the Javascript capability of the Firefox chrome code (this is the code in Firefox, not Chrome or Chromium browser), I have learnt new ways to launch cmd.exe, this time from Firefox.&lt;br /&gt;&lt;br /&gt;Unlike MS Edge or IE, when one enters something like &quot;file:///C/Windows/System32/cmd.exe&quot; or &quot;file:///C/Windows/System32/notepad.exe&quot; in Firefox&#39;s address bar, it does not usually execute cmd.exe. Instead it is what it looks like this:&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-V6qdyVZdzpY/WSA3NOuyXZI/AAAAAAAADu0/6qHhcu2kQg0FAnAUkoqFdZz0mgR19JacQCLcB/s1600/firefox-cmd-1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;131&quot; src=&quot;https://4.bp.blogspot.com/-V6qdyVZdzpY/WSA3NOuyXZI/AAAAAAAADu0/6qHhcu2kQg0FAnAUkoqFdZz0mgR19JacQCLcB/s320/firefox-cmd-1.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Opening notepad.exe from Firefox address bar&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;However, if we perform the following steps:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Open Firefox, enter &quot;about.config&quot; in address bar.&lt;/li&gt;&lt;li&gt;Set &quot;devtools.chrome.enabled&quot; to &quot;true&quot;.&lt;/li&gt;&lt;li&gt;Ctrl-Shift-J to launch the web console, go to JS tab and enter the below:&lt;/li&gt;&lt;li&gt;var file=Components.classes[&quot;@mozilla.org/file/local;1&quot;].createInstance(Components.interfaces.nsIFile);file.initWithPath(&quot;C:\\windows\\system32\\cmd.exe&quot;);file.launch();&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;The result looks like the following screenshot, where cmd.exe is successfully launched.&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-15MQDsRYjyE/WSA4Ig1VeNI/AAAAAAAADvA/ryAowCRr-TcYDaJMymBo_oOvbEafeTaNQCLcB/s1600/firefox-cmd-2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;140&quot; src=&quot;https://4.bp.blogspot.com/-15MQDsRYjyE/WSA4Ig1VeNI/AAAAAAAADvA/ryAowCRr-TcYDaJMymBo_oOvbEafeTaNQCLcB/s320/firefox-cmd-2.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Launching cmd.exe from Firefox&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;While I find this interesting, it would be even more fun if:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;There is a more direct way of executing cmd.exe, say from the address bar.&amp;nbsp;&lt;/li&gt;&lt;li&gt;We can perform more things with the Javascript chrome code.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;Admittedly I am not so familiar with the internals of Firefox, if you know any of the above, do educate me.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Anyway, since Firefox is such a common application on many Windows workstation, could this be useful as a application white listing bypass technique? :-)&lt;/div&gt;&lt;br /&gt;Note: The method described here is not new, and I am not the first one to discover them. It is (along with a few other methods) already documented &lt;a href=&quot;https://gist.github.com/wirepair/6896466#file-ff-os-cmd-exec&quot;&gt;here&lt;/a&gt;. I merely carry out the experiment and note down the steps.&lt;br /&gt;&lt;br /&gt;Update: As soon as I posted this, I realised there is simpler way to launch cmd.exe from Firefox, assuming Windows Explorer is not locked down, which is to click on cmd.exe, download it and use the &quot;Open Containing Folder&quot; icon (as shown in the following screenshot) to launch Windows Explorer from there. The rest is history... :-)&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-2TIJqMy5wSY/WSA9SyWpslI/AAAAAAAADvQ/a3Cwf-LLyRo5gGlrw7C74IeCWMztHoD8gCLcB/s1600/firefox-cmd-3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;83&quot; src=&quot;https://2.bp.blogspot.com/-2TIJqMy5wSY/WSA9SyWpslI/AAAAAAAADvQ/a3Cwf-LLyRo5gGlrw7C74IeCWMztHoD8gCLcB/s320/firefox-cmd-3.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Open Containing Folder&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/2419906467364521099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=2419906467364521099' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/2419906467364521099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/2419906467364521099'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2017/05/application-whitelisting-bypass-using_20.html' title='Application Whitelisting Bypass using Firefox?'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://4.bp.blogspot.com/-V6qdyVZdzpY/WSA3NOuyXZI/AAAAAAAADu0/6qHhcu2kQg0FAnAUkoqFdZz0mgR19JacQCLcB/s72-c/firefox-cmd-1.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-1302407065600372393</id><published>2017-05-10T20:21:00.000+08:00</published><updated>2017-05-10T20:21:28.692+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="security"/><category scheme="http://www.blogger.com/atom/ns#" term="windbg"/><title type='text'>Simulating Privileges Patching using Windows Kernel Debugger</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;The following is an experiment to simulate a Windows privilege escalation using privileges patching in access token. The experiment uses two windbg instances, one running within the target machine as user mode debugger and another running on the host machine as kernel debugger.&lt;br /&gt;&lt;br /&gt;Firstly, we launch the user mode windbg in the target machine as ordinary non admin user. Using this windbg, we attempt to attach to a the spoolsv.exe process, which is the Spooler service running as SYSTEM privilege. We can see that windbg fail to attach to the spoolsv.exe process.&lt;br /&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-bCn7kHgqhS8/WRMDjxacvEI/AAAAAAAADtE/5u55FBBVYvwaIHW8dg-4YO0NaRe025SHACLcB/s1600/windbg-spoolsv-priv-fail-1%2B-%2BCopy.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;256&quot; src=&quot;https://3.bp.blogspot.com/-bCn7kHgqhS8/WRMDjxacvEI/AAAAAAAADtE/5u55FBBVYvwaIHW8dg-4YO0NaRe025SHACLcB/s320/windbg-spoolsv-priv-fail-1%2B-%2BCopy.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;User mode windbg fail to attach to spoolsv.exe&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Next, we use the kernel mode windbg from the host machine to break into the target machine. We then locate the user mode windbg process and its corresponding access token address.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-cy8UKOIF5I4/WRMDuaVLnfI/AAAAAAAADtI/Im9cnc6Gx1kjpV44pMp3g9tV6jRh9PrPgCLcB/s1600/windbg-spoolsv-kd-1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;132&quot; src=&quot;https://1.bp.blogspot.com/-cy8UKOIF5I4/WRMDuaVLnfI/AAAAAAAADtI/Im9cnc6Gx1kjpV44pMp3g9tV6jRh9PrPgCLcB/s320/windbg-spoolsv-kd-1.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Locate access token within process structure&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-nH1agbd2iEM/WRMD2YGVVjI/AAAAAAAADtM/ExViIOYgqp8AvukTF2gsxELDZBfDVmbaACLcB/s1600/windbg-spoolsv-kd-2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;262&quot; src=&quot;https://4.bp.blogspot.com/-nH1agbd2iEM/WRMD2YGVVjI/AAAAAAAADtM/ExViIOYgqp8AvukTF2gsxELDZBfDVmbaACLcB/s320/windbg-spoolsv-kd-2.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Locate privileges structure within access token&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;From there we can locate the address of the _SEP_TOKEN_PRIVILEGES structure, where we first examine its original value.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-VqLKMVpghtI/WRMEb4lb2II/AAAAAAAADtU/AtG1bLf5_mAb6tkn9eg6qaSMyTiGgv-_wCLcB/s1600/windbg-spoolsv-kd-3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;25&quot; src=&quot;https://4.bp.blogspot.com/-VqLKMVpghtI/WRMEb4lb2II/AAAAAAAADtU/AtG1bLf5_mAb6tkn9eg6qaSMyTiGgv-_wCLcB/s320/windbg-spoolsv-kd-3.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;_SEP_TOKEN_PRIVILEGES original value&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;We then update the value to contain 0xffffffffffffffff for all the three members in the structure.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-OG0TqPKQvxA/WRMEl3KiTvI/AAAAAAAADtY/e5YoyeijMY0raU_ktNT3dJApFSTRIagzgCLcB/s1600/windbg-spoolsv-kd-4.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;41&quot; src=&quot;https://4.bp.blogspot.com/-OG0TqPKQvxA/WRMEl3KiTvI/AAAAAAAADtY/e5YoyeijMY0raU_ktNT3dJApFSTRIagzgCLcB/s320/windbg-spoolsv-kd-4.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Update _SEP_TOKEN_PRIVILEGES members&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Finally, we resume the target machine and use our user mode windbg to attach to the spoolsv.exe process again. This time, windbg is able to break into the spoolsv.exe process.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-_feSpJiQhdk/WRMFfgcmWDI/AAAAAAAADtk/RpeaXWj9ccMbvgGbMlp9OjxV6tLvKnk3ACLcB/s1600/windbg-spoolsv-priv-success-1%2B-%2BCopy.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;276&quot; src=&quot;https://1.bp.blogspot.com/-_feSpJiQhdk/WRMFfgcmWDI/AAAAAAAADtk/RpeaXWj9ccMbvgGbMlp9OjxV6tLvKnk3ACLcB/s320/windbg-spoolsv-priv-success-1%2B-%2BCopy.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/1302407065600372393/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=1302407065600372393' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/1302407065600372393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/1302407065600372393'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2017/05/simulating-privileges-patching-using.html' title='Simulating Privileges Patching using Windows Kernel Debugger'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://3.bp.blogspot.com/-bCn7kHgqhS8/WRMDjxacvEI/AAAAAAAADtE/5u55FBBVYvwaIHW8dg-4YO0NaRe025SHACLcB/s72-c/windbg-spoolsv-priv-fail-1%2B-%2BCopy.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-6497799996817832313</id><published>2017-05-07T18:45:00.001+08:00</published><updated>2017-05-07T19:17:50.553+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="security"/><category scheme="http://www.blogger.com/atom/ns#" term="windbg"/><title type='text'>Application Whitelisting Bypass using Windbg</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Casey Smith has thought us many cool application white listing bypass techniques. They can be found&amp;nbsp;&lt;a href=&quot;https://github.com/shmgr/ApplicationWhitelistBypassTechniques/blob/master/TheList.txt&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;div&gt;While learning those techniques, it occurs to me that anything officially signed by Microsoft that has the capability to load dll could be potentially useful. So maybe I can also add windbg to the list?&lt;/div&gt;&lt;div&gt;The steps are very simple. It uses windbg and cmd.dll (or any dll of your choice).&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Launch windbg.&lt;/li&gt;&lt;li&gt;Click File -&amp;gt; Attach to a Process..&lt;/li&gt;&lt;li&gt;Select any target process. In my case, I select the cmd.exe that was blocked. :-)&lt;/li&gt;&lt;li&gt;After windbg break into the process, type .load \\path\to\cmd.dll&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;The result can be seen in the following screenshot. The yellow box highlights the original cmd.exe which was blocked by the policy, the red box highlights the windbg command and the green box highlights the new cmd.dll built from ReactOS source.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-Go9PoXa35EI/WQ76GhwAf4I/AAAAAAAADrY/SWh25YwciVUlscvRIXGEAZFej0it1t0-wCLcB/s1600/cmd_dll_via_windbg.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://1.bp.blogspot.com/-Go9PoXa35EI/WQ76GhwAf4I/AAAAAAAADrY/SWh25YwciVUlscvRIXGEAZFej0it1t0-wCLcB/s320/cmd_dll_via_windbg.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/6497799996817832313/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=6497799996817832313' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/6497799996817832313'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/6497799996817832313'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2017/05/application-whitelisting-bypass-using.html' title='Application Whitelisting Bypass using Windbg'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://1.bp.blogspot.com/-Go9PoXa35EI/WQ76GhwAf4I/AAAAAAAADrY/SWh25YwciVUlscvRIXGEAZFej0it1t0-wCLcB/s72-c/cmd_dll_via_windbg.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-1490369942731440656</id><published>2017-04-17T20:38:00.002+08:00</published><updated>2017-04-17T20:39:24.458+08:00</updated><title type='text'>CreateProcess from C++ to C# to Powershell</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;I was trying to get myself familiar with how to invoke native calls such as Windows API from Powershell, which leads me to look into P/Invoke etc.&lt;br /&gt;To get started, I just try to call CreateProcess (without worrying too much about clean up or good coding etc) starting with C++, then C# and finally Powershell.&lt;br /&gt;&lt;br /&gt;First, C++&lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;#include &lt;windows .h=&quot;&quot;&gt; int main() {  STARTUPINFO si = { 0 };  si.cb = sizeof(si);  PROCESS_INFORMATION pi = { 0 };  TCHAR szCommandLine[] = TEXT(&quot;C:\\Windows\\System32\\notepad.exe&quot;);  BOOL bResult = CreateProcess(   NULL, //_In_opt_    LPCTSTR               lpApplicationName,   szCommandLine, //_Inout_opt_ LPTSTR                lpCommandLine,   NULL, //_In_opt_    LPSECURITY_ATTRIBUTES lpProcessAttributes,   NULL, //_In_opt_    LPSECURITY_ATTRIBUTES lpThreadAttributes,   FALSE, //_In_        BOOL                  bInheritHandles,   0, //_In_        DWORD                 dwCreationFlags,   NULL, //_In_opt_    LPVOID                lpEnvironment,   NULL, //_In_opt_    LPCTSTR               lpCurrentDirectory,   &amp;amp;si, //_In_        LPSTARTUPINFO         lpStartupInfo,   &amp;amp;pi //_Out_       LPPROCESS_INFORMATION lpProcessInformation  );      return 0; } &lt;/windows&gt;&lt;/div&gt;&lt;br /&gt;Next, C#&lt;br /&gt;The details are taken from &lt;a href=&quot;http://www.pinvoke.net/&quot;&gt;http://www.pinvoke.net/&lt;/a&gt;. There is possible a simpler/shorter way to write this, but I just want to get it to work for now.&lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;using System; using System.Runtime.InteropServices;  [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] struct STARTUPINFO {     public Int32 cb;     public string lpReserved;     public string lpDesktop;     public string lpTitle;     public Int32 dwX;     public Int32 dwY;     public Int32 dwXSize;     public Int32 dwYSize;     public Int32 dwXCountChars;     public Int32 dwYCountChars;     public Int32 dwFillAttribute;     public Int32 dwFlags;     public Int16 wShowWindow;     public Int16 cbReserved2;     public IntPtr lpReserved2;     public IntPtr hStdInput;     public IntPtr hStdOutput;     public IntPtr hStdError; }  [StructLayout(LayoutKind.Sequential)] struct PROCESS_INFORMATION {     public IntPtr hProcess;     public IntPtr hThread;     public int dwProcessId;     public int dwThreadId; }  [StructLayout(LayoutKind.Sequential)] struct SECURITY_ATTRIBUTES {     public int nLength;     public IntPtr lpSecurityDescriptor;     public int bInheritHandle; }  public class Kernel32 {     [DllImport(&quot;kernel32.dll&quot;, SetLastError = true, CharSet = CharSet.Auto)]     static extern bool CreateProcess(        string lpApplicationName,        string lpCommandLine,        ref SECURITY_ATTRIBUTES lpProcessAttributes,        ref SECURITY_ATTRIBUTES lpThreadAttributes,        bool bInheritHandles,        uint dwCreationFlags,        IntPtr lpEnvironment,        string lpCurrentDirectory,        [In] ref STARTUPINFO lpStartupInfo,        out PROCESS_INFORMATION lpProcessInformation);      public static void Main(string[] args)     {         STARTUPINFO si = new STARTUPINFO();         PROCESS_INFORMATION pi = new PROCESS_INFORMATION();         SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES();          CreateProcess(             null, //string lpApplicationName,             &quot;C:\\Windows\\System32\\notepad.exe&quot;, //string lpCommandLine,             ref sa, //ref SECURITY_ATTRIBUTES lpProcessAttributes,             ref sa, //ref SECURITY_ATTRIBUTES lpThreadAttributes,             false, //bool bInheritHandles,             0, //uint dwCreationFlags,             IntPtr.Zero, //IntPtr lpEnvironment,             null, //string lpCurrentDirectory,             ref si, //[In] ref STARTUPINFO lpStartupInfo,             out pi //out PROCESS_INFORMATION lpProcessInformation)             );          Console.ReadLine();     } } &lt;/div&gt;&lt;br /&gt;Finally, Powershell&lt;br /&gt;Note that when using Powershell, the lpApplicationName cannot be $null and lpCurrentDirectory needs to be populated. &lt;/div&gt;&lt;div class=&quot;mycode&quot;&gt;$csharp = @&#39; using System; using System.Runtime.InteropServices;  [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct STARTUPINFO {     public Int32 cb;     public string lpReserved;     public string lpDesktop;     public string lpTitle;     public Int32 dwX;     public Int32 dwY;     public Int32 dwXSize;     public Int32 dwYSize;     public Int32 dwXCountChars;     public Int32 dwYCountChars;     public Int32 dwFillAttribute;     public Int32 dwFlags;     public Int16 wShowWindow;     public Int16 cbReserved2;     public IntPtr lpReserved2;     public IntPtr hStdInput;     public IntPtr hStdOutput;     public IntPtr hStdError; };  [StructLayout(LayoutKind.Sequential)] public struct PROCESS_INFORMATION {     public IntPtr hProcess;     public IntPtr hThread;     public int dwProcessId;     public int dwThreadId; };  [StructLayout(LayoutKind.Sequential)] public struct SECURITY_ATTRIBUTES {     public int nLength;     public IntPtr lpSecurityDescriptor;     public int bInheritHandle; };  public class Kernel32 {     [DllImport(&quot;kernel32.dll&quot;, SetLastError = true, CharSet = CharSet.Auto)]     public static extern bool CreateProcess(        string lpApplicationName,        string lpCommandLine,        ref SECURITY_ATTRIBUTES lpProcessAttributes,        ref SECURITY_ATTRIBUTES lpThreadAttributes,        bool bInheritHandles,        uint dwCreationFlags,        IntPtr lpEnvironment,        string lpCurrentDirectory,        [In] ref STARTUPINFO lpStartupInfo,        out PROCESS_INFORMATION lpProcessInformation); } &#39;@  Add-Type -TypeDefinition $csharp  $si = New-Object STARTUPINFO $si.cb = [System.Runtime.InteropServices.Marshal]::SizeOf($si) # $si.dwFlags = 0x1 # $si.wShowWindow = 0x1 $pi = New-Object PROCESS_INFORMATION $sa = New-Object SECURITY_ATTRIBUTES $sa.nLength = [System.Runtime.InteropServices.Marshal]::SizeOf($sa) $dir = (Get-Location).Path # [Kernel32]::CreateProcess($null, &quot;C:\\Windows\\System32\\cmd.exe&quot;, [ref]$sa, [ref]$sa, $false, $0, [IntPtr]::Zero, $null, [ref]$si, [ref]$pi) # Using Powershell, lpApplicationName cannot be $null and lpCurrentDirectory needs to be populated [Kernel32]::CreateProcess(&quot;C:\Windows\System32\notepad.exe&quot;, $null, [ref] $sa, [ref] $sa, $false, 0x0, [IntPtr]::Zero, $dir, [ref] $si, [ref] $pi) # [System.Runtime.InteropServices.Marshal]::GetLastWin32Error() &lt;/div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/1490369942731440656/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=1490369942731440656' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/1490369942731440656'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/1490369942731440656'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2017/04/i-was-trying-to-get-myself-familiar.html' title='CreateProcess from C++ to C# to Powershell'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-7133603153708791851</id><published>2017-04-15T17:29:00.002+08:00</published><updated>2017-05-20T20:46:52.675+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="security"/><title type='text'>Building cmd.dll with CMake</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;After reading Didier Stevens&#39;s great post on&amp;nbsp;&lt;a href=&quot;https://blog.didierstevens.com/2010/02/04/cmd-dll/&quot;&gt;cmd.dll&lt;/a&gt;, I was excited to give it a try, by building cmd.dll from ReactOS source as described.&lt;br /&gt;However, I soon found out that the updated ReactOS source now uses CMake instead of RBuild, as stated in &lt;a href=&quot;https://www.reactos.org/wiki/RBuild&quot;&gt;ReactOS wiki&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The following are the modification to Didier&#39;s steps I needed, in order to build cmd.dll in the CMake environment.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;diff --git a/reactos/base/shell/cmd/CMakeLists.txt b/reactos/base/shell/cmd/CMakeLists.txt index 37d2c09ab7..29dabe5ec9 100644 --- a/reactos/base/shell/cmd/CMakeLists.txt +++ b/reactos/base/shell/cmd/CMakeLists.txt @@ -68,9 +68,9 @@ list(APPEND SOURCE      precomp.h)   add_rc_deps(cmd.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/terminal.ico) -add_executable(cmd ${SOURCE} cmd.rc) +add_library(cmd SHARED ${SOURCE} cmd.rc)  target_link_libraries(cmd wine) -set_module_type(cmd win32cui UNICODE) +set_module_type(cmd win32dll UNICODE)  add_importlibs(cmd advapi32 user32 msvcrt kernel32 ntdll)  add_pch(cmd precomp.h SOURCE)  add_cd_file(TARGET cmd DESTINATION reactos/system32 FOR all) diff --git a/reactos/base/shell/cmd/cmd.c b/reactos/base/shell/cmd/cmd.c index ed162bf9f6..8f680ef6bc 100644 --- a/reactos/base/shell/cmd/cmd.c +++ b/reactos/base/shell/cmd/cmd.c @@ -1816,7 +1816,7 @@ static VOID Cleanup()  /*   * main function   */ -int _tmain(int argc, const TCHAR *argv[]) +int original_tmain(int argc, const TCHAR *argv[])  {      HANDLE hConsole;      TCHAR startPath[MAX_PATH]; @@ -1832,6 +1832,8 @@ int _tmain(int argc, const TCHAR *argv[])      InputCodePage = 0;      OutputCodePage = 0;  +    AllocConsole(); +      hConsole = CreateFile(_T(&quot;CONOUT$&quot;), GENERIC_READ|GENERIC_WRITE,                            FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,                            OPEN_EXISTING, 0, NULL); @@ -1866,4 +1868,25 @@ int _tmain(int argc, const TCHAR *argv[])      return(nErrorLevel);  }  +INT WINAPI +DllMain( +    IN PVOID hInstanceDll, +    IN ULONG dwReason, +    IN PVOID reserved) +{ +    switch (dwReason) +    { +    case DLL_PROCESS_ATTACH: +        original_tmain(0, NULL); +        break; +    case DLL_THREAD_ATTACH: +        break; +    case DLL_THREAD_DETACH: +        break; +    case DLL_PROCESS_DETACH: +        break; +    } +    return TRUE; +} &lt;/div&gt;Besides the above mentioned modification, the build steps are the same.&lt;br /&gt;&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Download and install ReactOS Build Environment (consult&amp;nbsp;&lt;a href=&quot;https://www.reactos.org/wiki/Build_Environment&quot;&gt;ReactOS wiki&lt;/a&gt;) and source.&lt;/li&gt;&lt;li&gt;Run the ReactOS Build Environment.&lt;/li&gt;&lt;li&gt;cd reactos/reactos and run configure.cmd&lt;/li&gt;&lt;li&gt;cd output-MingW-i386&lt;/li&gt;&lt;li&gt;make cmd&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Hope it helps others who are struggling to build cmd.dll.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/7133603153708791851/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=7133603153708791851' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/7133603153708791851'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/7133603153708791851'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2017/04/building-cmddll-with-cmake.html' title='Building cmd.dll with CMake'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-4667980017250787805</id><published>2016-07-17T08:32:00.001+08:00</published><updated>2016-07-17T08:32:44.833+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CTF"/><category scheme="http://www.blogger.com/atom/ns#" term="security"/><title type='text'>Vulnhub FristiLeak 1 Walkthrough</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;I have decided not to continue on Necromancer, and try out an older VM, FristiLeak instead.&lt;br /&gt;Granted, there are already heaps of walkthrough since it is an old VM. &amp;nbsp;But that doesn&#39;t matter to me, if I haven&#39;t pwn it, it is still good to practice.&lt;br /&gt;As usual, the enumeration started with nmap, which only returns the default HTTP port.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-7DeZbcbbLDI/V4rHxSGdNEI/AAAAAAAAC-o/7ZK-h_nE1XgMPa3QPTp3RfGqLB8FZYaNACLcB/s1600/0-nmap-port-80-only.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;39&quot; src=&quot;https://2.bp.blogspot.com/-7DeZbcbbLDI/V4rHxSGdNEI/AAAAAAAAC-o/7ZK-h_nE1XgMPa3QPTp3RfGqLB8FZYaNACLcB/s320/0-nmap-port-80-only.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;In the browser, a page stating &quot;KEEP CALM and DRINK FRISTI&quot; was returned.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-Qd-R_ktbxaU/V4rH0fphH3I/AAAAAAAAC-s/zW-s3LRxXZgJW-gX8Z00Bd_wBkrRWhVZQCLcB/s1600/1-main-page.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://4.bp.blogspot.com/-Qd-R_ktbxaU/V4rH0fphH3I/AAAAAAAAC-s/zW-s3LRxXZgJW-gX8Z00Bd_wBkrRWhVZQCLcB/s320/1-main-page.PNG&quot; width=&quot;246&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Enumerating for robots.txt returned 3 entries.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-poRISDRkAPE/V4rH6ZsBelI/AAAAAAAAC-w/gYdBrEMoyic7u43YS4Zs3Zi4Fk2HkB5jQCLcB/s1600/2-robots-txt.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://4.bp.blogspot.com/-poRISDRkAPE/V4rH6ZsBelI/AAAAAAAAC-w/gYdBrEMoyic7u43YS4Zs3Zi4Fk2HkB5jQCLcB/s1600/2-robots-txt.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;However, attempting to browse those 3 entries all resulted in nothing more than a meme hinting that they were dead ends.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-yOwdWkaVgJU/V4rIdvCdEfI/AAAAAAAAC-4/zlXqY2sx-vkfRM7JTDSH8DucfDsyYVRFwCLcB/s1600/3-cola-not-the-url.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://2.bp.blogspot.com/-yOwdWkaVgJU/V4rIdvCdEfI/AAAAAAAAC-4/zlXqY2sx-vkfRM7JTDSH8DucfDsyYVRFwCLcB/s320/3-cola-not-the-url.PNG&quot; width=&quot;276&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Taking the hint that those dead ends all suggested various drinks names and the fact that the main page said drink Fristi, I tried to browse /fristi instead, which successfully landed on a admin portal login page.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-qiotVEZ_pPM/V4rIiC88w0I/AAAAAAAAC-8/gOcXIrffYAwJynNzGWi1C_fVVKMbetixwCLcB/s1600/4-fristi-login-page.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://1.bp.blogspot.com/-qiotVEZ_pPM/V4rIiC88w0I/AAAAAAAAC-8/gOcXIrffYAwJynNzGWi1C_fVVKMbetixwCLcB/s320/4-fristi-login-page.PNG&quot; width=&quot;300&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Several guesses of login credentials such as &quot;admin:admin&quot; and &quot;admin: fristi&quot; didn&#39;t helped.&lt;br /&gt;So, I checked out the HTML source. &amp;nbsp;There was a comment written by someone named eezeepz.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-to-WGQOGC5A/V4rI5SVTVFI/AAAAAAAAC_A/hXdrqC-NKIcso5tESrng5cwkyQJT3aEogCLcB/s1600/5-fristi-login-page-source-base64-image.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;156&quot; src=&quot;https://2.bp.blogspot.com/-to-WGQOGC5A/V4rI5SVTVFI/AAAAAAAAC_A/hXdrqC-NKIcso5tESrng5cwkyQJT3aEogCLcB/s320/5-fristi-login-page-source-base64-image.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Interestingly, the page encoded the &quot;Ha Ha&quot; image using base64. &amp;nbsp;So, I gave it a more detail inspection. &amp;nbsp;That paid off, I noticed there were a few separate base64 encoded image, like this one at the bottom of the source.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-FfRhtj1dDuM/V4rJ2nmNqkI/AAAAAAAAC_M/Yev1-hJ3cLsU5sWW8SKjzJckw3HFn1dxwCLcB/s1600/6-bottom-of-page-source-hidden-base64.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;144&quot; src=&quot;https://2.bp.blogspot.com/-FfRhtj1dDuM/V4rJ2nmNqkI/AAAAAAAAC_M/Yev1-hJ3cLsU5sWW8SKjzJckw3HFn1dxwCLcB/s320/6-bottom-of-page-source-hidden-base64.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;I decoded each of them. &amp;nbsp;The first 2 images were identical to the one shown on the login page, but the last one decodes to a different image, presumably something useful, &amp;nbsp;maybe a password?&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-IPbbmJL7-X4/V4rJ-sj8hzI/AAAAAAAAC_U/luOpB1T2074n2biRUbpA9ePJ_xc77FwJACLcB/s1600/7-hidden-base64-decoded-kekkek-password.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://2.bp.blogspot.com/-IPbbmJL7-X4/V4rJ-sj8hzI/AAAAAAAAC_U/luOpB1T2074n2biRUbpA9ePJ_xc77FwJACLcB/s1600/7-hidden-base64-decoded-kekkek-password.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;So, I tried to login the admin portal using &quot;eezeepz&quot; found in the HTML comment together with this newly found &quot;keKkeKKeKKeKkEkkEk&quot; string as password.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-S8QHIJvOmns/V4rKirEWPSI/AAAAAAAAC_c/oPTI_n2K5lMJ28dfOvWBxPSrXpyJt4aigCLcB/s1600/8-eezeepz-kekkek-login.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://3.bp.blogspot.com/-S8QHIJvOmns/V4rKirEWPSI/AAAAAAAAC_c/oPTI_n2K5lMJ28dfOvWBxPSrXpyJt4aigCLcB/s1600/8-eezeepz-kekkek-login.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;That worked! It landed me on a page with a link to upload file. ;-)&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-hRHJnA4ddRw/V4rK805xPBI/AAAAAAAAC_k/SHlPrCN0BZkQMDY4VLiC2Ccabfp9Q8uJQCLcB/s1600/9-login-successful.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;145&quot; src=&quot;https://2.bp.blogspot.com/-hRHJnA4ddRw/V4rK805xPBI/AAAAAAAAC_k/SHlPrCN0BZkQMDY4VLiC2Ccabfp9Q8uJQCLcB/s320/9-login-successful.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;I tried to upload a PHP webshell with .php extension but that failed, but it gave a rather useful error message.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-NQA2uolXaVo/V4rLGclAtaI/AAAAAAAAC_o/HMQEENchKpIlTuzyL1ZClpaJpP4X_gHHwCLcB/s1600/10-upload-webshell-php-failed.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;93&quot; src=&quot;https://1.bp.blogspot.com/-NQA2uolXaVo/V4rLGclAtaI/AAAAAAAAC_o/HMQEENchKpIlTuzyL1ZClpaJpP4X_gHHwCLcB/s320/10-upload-webshell-php-failed.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Renaming the webshell extension from .php to .php.png worked.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-yc8fAwag1No/V4rLfHgB4NI/AAAAAAAAC_0/wNklsjekw50_FYSxcb88Sy80sLW5hF1TgCLcB/s1600/11-renamed-php-png-upload-ok.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;35&quot; src=&quot;https://2.bp.blogspot.com/-yc8fAwag1No/V4rLfHgB4NI/AAAAAAAAC_0/wNklsjekw50_FYSxcb88Sy80sLW5hF1TgCLcB/s320/11-renamed-php-png-upload-ok.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;After some enumeration, I found a file named notes.txt under /home/eezeepz.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-iRtYTiDxJck/V4rL8ylQtoI/AAAAAAAAC_8/ZXsBfYXDjnctgnY3e10WKGGZfogR69PngCLcB/s1600/16-notes-jerry.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;134&quot; src=&quot;https://4.bp.blogspot.com/-iRtYTiDxJck/V4rL8ylQtoI/AAAAAAAAC_8/ZXsBfYXDjnctgnY3e10WKGGZfogR69PngCLcB/s320/16-notes-jerry.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;So, I tried out the helpful suggestion by writing &quot;id&quot; into /tmp/runthis file to see if it resulted in /tmp/cronresult as claimed.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-NWOwMI6a8Qk/V4rMbAg-qtI/AAAAAAAADAI/Yr79F-YeWqonYzq-L0J7siSs3bJ6GDxqQCLcB/s1600/17-tmp-runthis-id.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;56&quot; src=&quot;https://4.bp.blogspot.com/-NWOwMI6a8Qk/V4rMbAg-qtI/AAAAAAAADAI/Yr79F-YeWqonYzq-L0J7siSs3bJ6GDxqQCLcB/s320/17-tmp-runthis-id.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;It did, a /tmp/cronresult file was created.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-APcZ10GA3cI/V4rMiLsEbvI/AAAAAAAADAM/KzaqMAY2VL06EUVZPLlC2wwSHoK0_FD3wCLcB/s1600/18-tmp-cronresult-created.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;103&quot; src=&quot;https://1.bp.blogspot.com/-APcZ10GA3cI/V4rMiLsEbvI/AAAAAAAADAM/KzaqMAY2VL06EUVZPLlC2wwSHoK0_FD3wCLcB/s320/18-tmp-cronresult-created.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;However, the content was not what I had hoped for. &amp;nbsp;But once again, the error message was helpful.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-iIGUiNCFDc0/V4rM48SPhbI/AAAAAAAADAU/OVGMhSdIZzgqBN2C1vXpc3gLw7nTE1E6QCLcB/s1600/19-cronresult-id-failed.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;55&quot; src=&quot;https://3.bp.blogspot.com/-iIGUiNCFDc0/V4rM48SPhbI/AAAAAAAADAU/OVGMhSdIZzgqBN2C1vXpc3gLw7nTE1E6QCLcB/s320/19-cronresult-id-failed.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;As suggested, I used the chmod command in /home/admin directory, this time to modify the permission of the /home/admin itself.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-koranYb4Xdw/V4rNb57lB8I/AAAAAAAADAg/EDutibYqgmAz8xm33FKz2zLB8hSarG42gCLcB/s1600/20-chmod-home-admin.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;60&quot; src=&quot;https://1.bp.blogspot.com/-koranYb4Xdw/V4rNb57lB8I/AAAAAAAADAg/EDutibYqgmAz8xm33FKz2zLB8hSarG42gCLcB/s320/20-chmod-home-admin.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;That worked. Now, I can access the entire /home/admin simply as the apache process. &amp;nbsp;I noticed that there was a file owned by fristigod, so maybe it has something to do with the user fristigod.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-lOGF5sBSXN8/V4rN39gmTNI/AAAAAAAADAo/e30UXmZNWTA0HPLTa4r4Y8VTH1FGJ8eYwCLcB/s1600/21-home-admin-permission-changed.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;132&quot; src=&quot;https://2.bp.blogspot.com/-lOGF5sBSXN8/V4rN39gmTNI/AAAAAAAADAo/e30UXmZNWTA0HPLTa4r4Y8VTH1FGJ8eYwCLcB/s320/21-home-admin-permission-changed.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Without wasting anytime, I checked out all the files deemed interesting in that directory, staring with cryptedpass.txt.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-8b9HTdgc2nU/V4rOjtctsQI/AAAAAAAADA0/fA9b3DlN3qQ3GEvc8hL20ZdlrHkZtJbzACLcB/s1600/22-home-admin-cryptedpass-txt.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;49&quot; src=&quot;https://3.bp.blogspot.com/-8b9HTdgc2nU/V4rOjtctsQI/AAAAAAAADA0/fA9b3DlN3qQ3GEvc8hL20ZdlrHkZtJbzACLcB/s320/22-home-admin-cryptedpass-txt.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Next came the file cryptpass.py&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-puX_FmJygOo/V4rOzBZbS9I/AAAAAAAADA4/pV3uoMMY7VwnL45eswla9uqI2z97rO_JwCLcB/s1600/23-home-admin-cryptpass-py.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;97&quot; src=&quot;https://2.bp.blogspot.com/-puX_FmJygOo/V4rOzBZbS9I/AAAAAAAADA4/pV3uoMMY7VwnL45eswla9uqI2z97rO_JwCLcB/s320/23-home-admin-cryptpass-py.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This is followed by the file cronjob.py&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-R3mGHErRezM/V4rPEHHQHUI/AAAAAAAADBA/zQWAa-Nk3u85q6UNJ2pHAormkM1DQG5zwCLcB/s1600/24-home-admin-cronjob-py.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;173&quot; src=&quot;https://1.bp.blogspot.com/-R3mGHErRezM/V4rPEHHQHUI/AAAAAAAADBA/zQWAa-Nk3u85q6UNJ2pHAormkM1DQG5zwCLcB/s320/24-home-admin-cronjob-py.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;And finally, the all interesting whoisyourgodnow.txt&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-kbZTaD5LB-w/V4rPKRP3j-I/AAAAAAAADBE/ccy4wC9bI9w5cPM0qaDB97a6hduDPK2BQCLcB/s1600/25-home-admin-fristigod-whoisyourgodnow-txt.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;49&quot; src=&quot;https://3.bp.blogspot.com/-kbZTaD5LB-w/V4rPKRP3j-I/AAAAAAAADBE/ccy4wC9bI9w5cPM0qaDB97a6hduDPK2BQCLcB/s320/25-home-admin-fristigod-whoisyourgodnow-txt.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;After inspecting the source of cryptpass.py, I modified it to reverse the process of encoding to decode the downloaded text.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-WsZ1XfwkK30/V4rPgY-mV-I/AAAAAAAADBM/nB7ioloKt6UZWkHISwluJvsqd-ILaQ18gCLcB/s1600/26-decode-home-admin-txt-files.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;185&quot; src=&quot;https://3.bp.blogspot.com/-WsZ1XfwkK30/V4rPgY-mV-I/AAAAAAAADBM/nB7ioloKt6UZWkHISwluJvsqd-ILaQ18gCLcB/s320/26-decode-home-admin-txt-files.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The content of the file whoisyourgodnow.txt decodes to &quot;LetThereBeFristi!&quot;, which looks curiously like the password for the user fristigod, maybe?&lt;br /&gt;It is time to try out SU, which needed a TTY session. &amp;nbsp;However, I was a little upset to find that netcat was not installed on the target VM. &amp;nbsp;So, I searched the web for one and uploaded it there.&lt;br /&gt;After establishing a netcat reverse shell, I switch to the user fristigod with the password &quot;LetThereBeFristi!&quot;.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-0Ix55Dn-Mwg/V4rQsPNsuSI/AAAAAAAADBc/TFAkajhOdU82Gle_GEqIQuzz7JN8dbvIgCLcB/s1600/28-netcat-su-fristigod.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;158&quot; src=&quot;https://3.bp.blogspot.com/-0Ix55Dn-Mwg/V4rQsPNsuSI/AAAAAAAADBc/TFAkajhOdU82Gle_GEqIQuzz7JN8dbvIgCLcB/s320/28-netcat-su-fristigod.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Checking out sudo, I noticed there was a hidden suid binary called doCom.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-tq7Uddud0TU/V4rRNFWXOsI/AAAAAAAADBg/QkM_-0UALEA4gpAMC5-ZgMzY2U8uI1JqACLcB/s1600/29-found-doCom-suid.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;149&quot; src=&quot;https://2.bp.blogspot.com/-tq7Uddud0TU/V4rRNFWXOsI/AAAAAAAADBg/QkM_-0UALEA4gpAMC5-ZgMzY2U8uI1JqACLcB/s320/29-found-doCom-suid.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Executing doCom via sudo gave me root permission! The rest is just about sitting back and enjoy a bottle of Fristi? :-)&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-KuSFk7jNp0k/V4rRVVek5dI/AAAAAAAADBk/4K18elHs1rwzyaYkC5INy7NYx_i1gCcEgCLcB/s1600/30-pwned.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;157&quot; src=&quot;https://4.bp.blogspot.com/-KuSFk7jNp0k/V4rRVVek5dI/AAAAAAAADBk/4K18elHs1rwzyaYkC5INy7NYx_i1gCcEgCLcB/s320/30-pwned.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/4667980017250787805/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=4667980017250787805' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/4667980017250787805'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/4667980017250787805'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2016/07/vulnhub-fristileak-1-walkthrough.html' title='Vulnhub FristiLeak 1 Walkthrough'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://2.bp.blogspot.com/-7DeZbcbbLDI/V4rHxSGdNEI/AAAAAAAAC-o/7ZK-h_nE1XgMPa3QPTp3RfGqLB8FZYaNACLcB/s72-c/0-nmap-port-80-only.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-4059503801420090153</id><published>2016-07-12T19:13:00.000+08:00</published><updated>2016-07-12T19:13:21.912+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CTF"/><category scheme="http://www.blogger.com/atom/ns#" term="security"/><title type='text'>Vulnhub The Necromancer 1 Walkthrough (flag2)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Pondering on the hint from flag1, &quot;Chant the string of flag1 - u666&quot;, I thought maybe it was UDP port 666.&lt;br /&gt;But before that, I tried to decode flag1. Turns out that it was an MD5 hash.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-CsgN0lYvs14/V4TMc1CxqII/AAAAAAAAC9k/wgqdSMa5-PslfAkfQ1TbGiq1i-Tkc2oRACLcB/s1600/4-md5-hash-opensesame.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;53&quot; src=&quot;https://1.bp.blogspot.com/-CsgN0lYvs14/V4TMc1CxqII/AAAAAAAAC9k/wgqdSMa5-PslfAkfQ1TbGiq1i-Tkc2oRACLcB/s320/4-md5-hash-opensesame.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;MD5 of opensesame was flag1&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;So, I tried sending &quot;opensesame&quot; to UDP port 666 using hping3.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-nY753iqPwK4/V4TO-v3bTTI/AAAAAAAAC90/Ovb27AvRR6sUb6RrxJxZ1JIDeyY5-_KSwCLcB/s1600/5-hping3-udp-666.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;11&quot; src=&quot;https://3.bp.blogspot.com/-nY753iqPwK4/V4TO-v3bTTI/AAAAAAAAC90/Ovb27AvRR6sUb6RrxJxZ1JIDeyY5-_KSwCLcB/s400/5-hping3-udp-666.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Sending flag1 using hping3&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Maybe I did some mistake in my initial attempt, the response I received was &quot;You gasp for air! Time is running out!&quot;.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-9X6f_etKSYk/V4TO4z0TdxI/AAAAAAAAC9w/6YeVQHYQ3PswouhuF_sC5zywf8Y32ctGACLcB/s1600/5-udp-666-hint.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;117&quot; src=&quot;https://3.bp.blogspot.com/-9X6f_etKSYk/V4TO4z0TdxI/AAAAAAAAC9w/6YeVQHYQ3PswouhuF_sC5zywf8Y32ctGACLcB/s320/5-udp-666-hint.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Initial attempt failed&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;So, I tried sending in the original MD5 hash instead. &amp;nbsp;However, that gave me a different error message. &amp;nbsp;This time it was &quot;Chant is too long! You gasp for air!&quot;.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-QoYKn3KmE7o/V4TPiac-CLI/AAAAAAAAC98/hdsnLnE97kk5XwShJTGy-34tg_j-QAMbACLcB/s1600/6-udp-666-chant-too-long.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;94&quot; src=&quot;https://1.bp.blogspot.com/-QoYKn3KmE7o/V4TPiac-CLI/AAAAAAAAC98/hdsnLnE97kk5XwShJTGy-34tg_j-QAMbACLcB/s320/6-udp-666-chant-too-long.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Chant too long&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;That made me retry with &quot;opensesame&quot; again.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-DMqsjtYnWts/V4TPyUyblVI/AAAAAAAAC-E/kkFCa5iWRlg0Z7UbvU8RM5CAwLTLvEwCwCLcB/s1600/8-udp-666-opensesame-again.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;96&quot; src=&quot;https://1.bp.blogspot.com/-DMqsjtYnWts/V4TPyUyblVI/AAAAAAAAC-E/kkFCa5iWRlg0Z7UbvU8RM5CAwLTLvEwCwCLcB/s320/8-udp-666-opensesame-again.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Resending &quot;opensesame&quot;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;This time, it worked!&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-Gv02NJj7uG0/V4TP8BnMIKI/AAAAAAAAC-I/Sf1MVqmFrRIZa3M9jughmwq8tAX-JfjIQCLcB/s1600/9-udp-666-working.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;270&quot; src=&quot;https://3.bp.blogspot.com/-Gv02NJj7uG0/V4TP8BnMIKI/AAAAAAAAC-I/Sf1MVqmFrRIZa3M9jughmwq8tAX-JfjIQCLcB/s320/9-udp-666-working.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;flag2 in wireshark&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Copied from wireshark to a text editor, the returned message looked like this&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-hZnjoXKmAok/V4TQKyNuhQI/AAAAAAAAC-M/rca6gjr55vUEa8c2m0hO7hwg5F2q7s7PACLcB/s1600/10-udp-666-data-content-leafpad.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;107&quot; src=&quot;https://1.bp.blogspot.com/-hZnjoXKmAok/V4TQKyNuhQI/AAAAAAAAC-M/rca6gjr55vUEa8c2m0hO7hwg5F2q7s7PACLcB/s320/10-udp-666-data-content-leafpad.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;flag2 in text editor&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/4059503801420090153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=4059503801420090153' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/4059503801420090153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/4059503801420090153'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2016/07/vulnhub-necromancer-1-walkthrough-flag2.html' title='Vulnhub The Necromancer 1 Walkthrough (flag2)'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://1.bp.blogspot.com/-CsgN0lYvs14/V4TMc1CxqII/AAAAAAAAC9k/wgqdSMa5-PslfAkfQ1TbGiq1i-Tkc2oRACLcB/s72-c/4-md5-hash-opensesame.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-5428806432735945114</id><published>2016-07-11T18:33:00.000+08:00</published><updated>2016-07-11T18:33:58.586+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CTF"/><category scheme="http://www.blogger.com/atom/ns#" term="security"/><title type='text'>Vulnhub The Necromancer 1 Walkthrough (flag1)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Trying out The Necromancer 1 VM. &amp;nbsp;Here is the walkthrough for the 1st flag.&lt;br /&gt;&lt;br /&gt;I started with the usual nmap full TCP scan, but to my surprise, none of 65535 TCP ports were open. &amp;nbsp;So, I tried to capture the traffic with Wireshark and see if I could find anything.&lt;br /&gt;&lt;br /&gt;Then, I noticed this:&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-35mFcCYKdn0/V4N0fzXpaeI/AAAAAAAAC9E/v9AH7f63M_4QBMCdqKz3oDpBHXeEmK-EACLcB/s1600/1-wireshark-incoming-4444.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;42&quot; src=&quot;https://4.bp.blogspot.com/-35mFcCYKdn0/V4N0fzXpaeI/AAAAAAAAC9E/v9AH7f63M_4QBMCdqKz3oDpBHXeEmK-EACLcB/s320/1-wireshark-incoming-4444.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Incoming connection from The Necromancer VM to me&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;It seemed that the VM was trying to connect to me on port 4444!&lt;br /&gt;So, I tried to listen to TCP port 4444 with netcat and as expected an incoming TCP connection was established. &amp;nbsp;I received some random looking text.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-GnvkitfTYcs/V4N1adjMUtI/AAAAAAAAC9Q/OXi9k9qlNCwQJG4Zalkf50x2YXiOBA21QCLcB/s1600/2-nc-listening-4444.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;81&quot; src=&quot;https://1.bp.blogspot.com/-GnvkitfTYcs/V4N1adjMUtI/AAAAAAAAC9Q/OXi9k9qlNCwQJG4Zalkf50x2YXiOBA21QCLcB/s320/2-nc-listening-4444.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Incoming random looking text&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;After removing the &quot;...&quot; (3 dots) at the beginning and the end of the text, I was able to base64 decode the text into something comprehensible.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-RXaymzS1PPc/V4N1rBZJhCI/AAAAAAAAC9U/VDZVYVfH6V87SywtwygF8UX-NigPJzGgQCLcB/s1600/3-msg-4444-base64-decoded-after-removing-3dots.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;125&quot; src=&quot;https://2.bp.blogspot.com/-RXaymzS1PPc/V4N1rBZJhCI/AAAAAAAAC9U/VDZVYVfH6V87SywtwygF8UX-NigPJzGgQCLcB/s320/3-msg-4444-base64-decoded-after-removing-3dots.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Base64 decoded text with flag1&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;There was the 1st flag. :-)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/5428806432735945114/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=5428806432735945114' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/5428806432735945114'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/5428806432735945114'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2016/07/vulnhub-necromancer-1-walkthrough-flag1.html' title='Vulnhub The Necromancer 1 Walkthrough (flag1)'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://4.bp.blogspot.com/-35mFcCYKdn0/V4N0fzXpaeI/AAAAAAAAC9E/v9AH7f63M_4QBMCdqKz3oDpBHXeEmK-EACLcB/s72-c/1-wireshark-incoming-4444.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-5878003329727364647</id><published>2016-07-09T17:17:00.000+08:00</published><updated>2016-07-10T07:39:50.831+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CTF"/><category scheme="http://www.blogger.com/atom/ns#" term="security"/><title type='text'>Vulnhub Violator 1 Walkthrough (partial)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Just tried another VM in Vulnhub, this time it is Violator 1.&lt;br /&gt;As usual, the journey starts with nmap, which brings up 2 TCP ports, FTP (21) and HTTP (80).&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-1u7HLSBOl7o/V4CsEx0NvDI/AAAAAAAAC6o/iXlZ3SD7YGoSV1ZZUiuaJJEGISBwojPjwCLcB/s1600/1-nmap-log.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;86&quot; src=&quot;https://1.bp.blogspot.com/-1u7HLSBOl7o/V4CsEx0NvDI/AAAAAAAAC6o/iXlZ3SD7YGoSV1ZZUiuaJJEGISBwojPjwCLcB/s320/1-nmap-log.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;nmap shows port 21 and port 80&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;The default web page in HTTP port gives a hint that I should be trying out the FTP port instead.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-ojhvQotOt0Y/V4CtEFHBe7I/AAAAAAAAC60/V-Gh_LHVWhgcTAWrOZhRfsZu9cz_ZaHJACLcB/s1600/2-hint.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://4.bp.blogspot.com/-ojhvQotOt0Y/V4CtEFHBe7I/AAAAAAAAC60/V-Gh_LHVWhgcTAWrOZhRfsZu9cz_ZaHJACLcB/s320/2-hint.PNG&quot; width=&quot;296&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The hint says I&#39;m barking up the wrong tree.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Furthermore, I at the bottom of the page, it also provides another hint about a Wikipedia page that may be useful for me.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-n69iKMJ4--0/V4CtUIAuW7I/AAAAAAAAC64/kIiBUcAQaoY0Nljom5KULhv0ImATkeeRwCLcB/s1600/wikipedia.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;30&quot; src=&quot;https://3.bp.blogspot.com/-n69iKMJ4--0/V4CtUIAuW7I/AAAAAAAAC64/kIiBUcAQaoY0Nljom5KULhv0ImATkeeRwCLcB/s320/wikipedia.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Hint about Wikipedia page&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;So, I took the hint and checked out the FTP server. &amp;nbsp;It appeared to run ProFTPd 1.3.5. &amp;nbsp;So, I try to search ExploitDB to see if anything comes up. &amp;nbsp;I was lucky to find this:&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-GHhz4fif0ZA/V4CtucgzDlI/AAAAAAAAC7A/ALe55JHYtLkPrp_k2xIxa4YcwgrJX3jbACLcB/s1600/3-exploitdb-proftpd.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://1.bp.blogspot.com/-GHhz4fif0ZA/V4CtucgzDlI/AAAAAAAAC7A/ALe55JHYtLkPrp_k2xIxa4YcwgrJX3jbACLcB/s320/3-exploitdb-proftpd.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;ExploitDB entry for ProFTPd 1.3.5&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;So, &amp;nbsp;I tried the exploit suggested by the page to see if it works. It did.&lt;br /&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-xOHpCQNUWk4/V4CuNioUW5I/AAAAAAAAC7I/YGNXFpXkm2wLpl4p-lt13VpKrqfg8eT2wCLcB/s1600/4-ftp-copy-passwd.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;47&quot; src=&quot;https://1.bp.blogspot.com/-xOHpCQNUWk4/V4CuNioUW5I/AAAAAAAAC7I/YGNXFpXkm2wLpl4p-lt13VpKrqfg8eT2wCLcB/s320/4-ftp-copy-passwd.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Copy /etc/passwd by exploiting ProFTPd vulnerability&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;I was able to view the passwd file content.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-NAX-fv-s750/V4Cuj9ygddI/AAAAAAAAC7U/urtNHNWA5OsZhpLEDJaGyduTAeMjLJ9JACLcB/s1600/5-passwd.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;260&quot; src=&quot;https://2.bp.blogspot.com/-NAX-fv-s750/V4Cuj9ygddI/AAAAAAAAC7U/urtNHNWA5OsZhpLEDJaGyduTAeMjLJ9JACLcB/s320/5-passwd.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;/etc/passwd file content&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;However, when I tried to upload my PHP web shell as suggested, I met some challenges (which later I found out the reason but it is irrelevant by then).&lt;br /&gt;So, being lazy, I searched Metasploit for exploit that are readily available for ProFTPd 1.3.5. &amp;nbsp;Again, I was lucky&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-OgQzsFP6UQk/V4CvSo0AZ2I/AAAAAAAAC7c/KFXDwdBPlGQKEocV446GKeI7p04i5eg7ACLcB/s1600/metasploit-proftpd_modcopy_exec.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;226&quot; src=&quot;https://1.bp.blogspot.com/-OgQzsFP6UQk/V4CvSo0AZ2I/AAAAAAAAC7c/KFXDwdBPlGQKEocV446GKeI7p04i5eg7ACLcB/s320/metasploit-proftpd_modcopy_exec.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Metasploit exploit for ProFTPd 1.3.5&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;The exploit spawned a shell with the privilege of the web server (www-data). &amp;nbsp;I was delighted. &amp;nbsp;But after that I was stuck with the www-data shell for sometime.&lt;br /&gt;&lt;br /&gt;Furthermore, on another somewhat unrelated event, my VM environment was unstable and I had to reboot both my Kali and Violator VM. &amp;nbsp;Which is why, in all the screenshots below, you will notice that the IP address for Violator VM changed from the original 192.168.56.101 to 192.168.56.103.&lt;br /&gt;&lt;br /&gt;After enumerating the box for sometime, I still didn&#39;t get much improvement, but I did notice the 4 users from /etc/passwd file (and from their /home directory), namely af, aw, dg and mg.&lt;br /&gt;I tried to switch user to these account but I needed their passwords.&lt;br /&gt;&lt;br /&gt;Remembering the Wikipedia hint at the bottom of the Violator main web page, I paid Wikipedia a visit and manually copied (I tried CeWL but my VM ran out of memory) all the strings that I felt is relevant to create a wordlist.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-S8dkVj5hMMQ/V4CxrCpcFCI/AAAAAAAAC7s/Er2PNBiRQXwhFLi7y8g15BReqFSRod9ZwCLcB/s1600/wordlist.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://1.bp.blogspot.com/-S8dkVj5hMMQ/V4CxrCpcFCI/AAAAAAAAC7s/Er2PNBiRQXwhFLi7y8g15BReqFSRod9ZwCLcB/s320/wordlist.PNG&quot; width=&quot;109&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Wordlist scraped from Wikipedia page.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Next, I created a password list out of the wordlist using John the Ripper&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-wkBhdYQs6qA/V4CyhaPqk2I/AAAAAAAAC74/WLPiY1dqbqAGFFg9kCJhrI0U1zbYIpPlACLcB/s1600/john-the-ripper.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;13&quot; src=&quot;https://2.bp.blogspot.com/-wkBhdYQs6qA/V4CyhaPqk2I/AAAAAAAAC74/WLPiY1dqbqAGFFg9kCJhrI0U1zbYIpPlACLcB/s400/john-the-ripper.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Using John the Ripper to generate password list.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Using the generated password list, I used Hydra to brute force the FTP server again to discover the password of the users.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-iGDs4Bsdycg/V4CyqqHPRNI/AAAAAAAAC78/g4Elutao8nc7e91ZKo3bYeuN8atvDjUJgCLcB/s1600/9-hydra.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;57&quot; src=&quot;https://2.bp.blogspot.com/-iGDs4Bsdycg/V4CyqqHPRNI/AAAAAAAAC78/g4Elutao8nc7e91ZKo3bYeuN8atvDjUJgCLcB/s320/9-hydra.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Hydra brute force FTP for passwords.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;I was lucky again. Hydra presented me with the passwords for all 4 of the users.&lt;br /&gt;Trying out &quot;sudo -l&quot; on each one of them, I noticed that the user bd is allowed to execute the ProFTPd binary in the subdirectory of his home directory using sudo.&lt;br /&gt;I thought to myself, isn&#39;t that almost as good as a setuid? :-)&lt;br /&gt;So, I searched the etc subdirectory for the configuration file and downloaded it to my Kali VM for customization before uploading it back.&lt;br /&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-I06OLY3oYqw/V4C59ftCVwI/AAAAAAAAC8Q/bqlMvz8YbKER7EzAFHmEZLGeARhI9CjnwCLcB/s1600/10-dg-proftpd-conf.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;271&quot; src=&quot;https://2.bp.blogspot.com/-I06OLY3oYqw/V4C59ftCVwI/AAAAAAAAC8Q/bqlMvz8YbKER7EzAFHmEZLGeARhI9CjnwCLcB/s320/10-dg-proftpd-conf.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Difference between customized and the original proftpd.conf.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Looking back, maybe not all of the customization is necessary. &amp;nbsp;But well, it doesn&#39;t matter now.&lt;br /&gt;Next, I use sudo to execute the ProFTPd binary under bd user&#39;s home directory and checked that it binds to port 2100. &amp;nbsp;(The other instance that binded to port 2121 was due to an earlier mistake I made by not changing the DefaultAddress. &amp;nbsp;Let&#39;s ignore that for now).&lt;br /&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-TgtfGlkZslg/V4C6vmjd9HI/AAAAAAAAC8Y/sDE6FttZZqA2yZFWn85HrXj5G3lmrZx4wCLcB/s1600/11-dg-proftpd-2100.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;77&quot; src=&quot;https://4.bp.blogspot.com/-TgtfGlkZslg/V4C6vmjd9HI/AAAAAAAAC8Y/sDE6FttZZqA2yZFWn85HrXj5G3lmrZx4wCLcB/s320/11-dg-proftpd-2100.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;ProFTPd listening to port 2100&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;I then tried to connect the ProFTPd server listening to port 2100. &amp;nbsp;I was surprised to find that it was a different version of ProFTPd, namely version 1.3.3c.&lt;br /&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-OSWCQDXb5KY/V4C7f3Dj2sI/AAAAAAAAC8g/UUwPNzCI6HYVYpf2dXqdEh68vC5e2laGACLcB/s1600/12-proftpd-2100-133c.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;23&quot; src=&quot;https://3.bp.blogspot.com/-OSWCQDXb5KY/V4C7f3Dj2sI/AAAAAAAAC8g/UUwPNzCI6HYVYpf2dXqdEh68vC5e2laGACLcB/s400/12-proftpd-2100-133c.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;ProFTPd version 1.3.3c&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;So, I searched Metasploit for existing exploits and was glad to find one.&lt;br /&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-N3jGSD6lyo8/V4C8zDkWnyI/AAAAAAAAC8s/DYY1JrLlPBQxV_etsEhTi_lF5GBVLSGKACLcB/s1600/13-metasploit-proftpd_133c_backdoor-options.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://2.bp.blogspot.com/-N3jGSD6lyo8/V4C8zDkWnyI/AAAAAAAAC8s/DYY1JrLlPBQxV_etsEhTi_lF5GBVLSGKACLcB/s320/13-metasploit-proftpd_133c_backdoor-options.PNG&quot; width=&quot;278&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;ProFTPd 1.3.3c exploit in Metasploit&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Executing the exploit gave me a root shell.&lt;br /&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-CPUyZp9Zg0A/V4C88TQBOJI/AAAAAAAAC8w/X25AoOPSR88wgnlZCa0Uq1bTM7YxXWenACLcB/s1600/14-proftpd_133c_backdoor-rooted.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;266&quot; src=&quot;https://3.bp.blogspot.com/-CPUyZp9Zg0A/V4C88TQBOJI/AAAAAAAAC8w/X25AoOPSR88wgnlZCa0Uq1bTM7YxXWenACLcB/s320/14-proftpd_133c_backdoor-rooted.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Rooted!&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;That&#39;s it folks. &amp;nbsp;I stopped there after getting root access.&lt;br /&gt;Notice that the title of this post says partial? That&#39;s because in the description of this challenge in Vulnhub, it says &quot;The challenge isn&#39;t over with root. The flag is something special.&quot;&lt;br /&gt;It could have something to do with the Enigma machine emulator but I didn&#39;t take the time to figure that out.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/5878003329727364647/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=5878003329727364647' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/5878003329727364647'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/5878003329727364647'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2016/07/vulnhub-violator-walkthrough-partial.html' title='Vulnhub Violator 1 Walkthrough (partial)'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://1.bp.blogspot.com/-1u7HLSBOl7o/V4CsEx0NvDI/AAAAAAAAC6o/iXlZ3SD7YGoSV1ZZUiuaJJEGISBwojPjwCLcB/s72-c/1-nmap-log.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-4106957510035044338</id><published>2016-06-18T18:11:00.000+08:00</published><updated>2016-06-19T18:45:37.203+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CTF"/><category scheme="http://www.blogger.com/atom/ns#" term="security"/><title type='text'>Vulnhub Stapler 1 Walkthrough</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Today I tried out Stapler VM in Vulnhub and here is the walkthrough. (Note, I did not attend the BSide or anything, this is perform on the VM from Vulnhub, so this is likely something that others already have walkthrough).&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As usual, I start the scan using nmap, and found that port 22 and 139 was open.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-WGcz1aTIOhs/V2UYIiZKEwI/AAAAAAAAC4U/yea95kewUJghGT_eF1TDWgTF3p72UNDQgCLcB/s1600/nmap.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://2.bp.blogspot.com/-WGcz1aTIOhs/V2UYIiZKEwI/AAAAAAAAC4U/yea95kewUJghGT_eF1TDWgTF3p72UNDQgCLcB/s320/nmap.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So I ran enum4linux, which provided me with a list of enumerated user name.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-LEoxDFoTBt0/V2UZgY7zrfI/AAAAAAAAC4g/TMkXSw7Xq_wH0s6PL7F-Rwa7WNejXBxMQCLcB/s1600/enum4linux-user-names.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;245&quot; src=&quot;https://3.bp.blogspot.com/-LEoxDFoTBt0/V2UZgY7zrfI/AAAAAAAAC4g/TMkXSw7Xq_wH0s6PL7F-Rwa7WNejXBxMQCLcB/s320/enum4linux-user-names.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Using John the ripper, I created a password list out of the username list.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-DFCHKIiP_kU/V2UZmrEkl6I/AAAAAAAAC4o/APu0cNmvt04UUwDtg3TPK9prevUzMXUmwCKgB/s1600/john-wordlist-b.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;11&quot; src=&quot;https://2.bp.blogspot.com/-DFCHKIiP_kU/V2UZmrEkl6I/AAAAAAAAC4o/APu0cNmvt04UUwDtg3TPK9prevUzMXUmwCKgB/s320/john-wordlist-b.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I then attempted to brute force the ssh login using the generated password list and username list and discovered that the user SHayslett was using the same string for both username and password.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-dJVOCAYMHMw/V2UZvCC3YqI/AAAAAAAAC4w/PJzG3AXOwu0bD8Z8X2OrBFTRiHhpsnrzwCLcB/s1600/hydra-SHaylett.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;46&quot; src=&quot;https://2.bp.blogspot.com/-dJVOCAYMHMw/V2UZvCC3YqI/AAAAAAAAC4w/PJzG3AXOwu0bD8Z8X2OrBFTRiHhpsnrzwCLcB/s320/hydra-SHaylett.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After logging in as SHayslett via ssh, I try to enumerate the system.&lt;/div&gt;&lt;div&gt;While enumerating cron.d directory, I found that logrotate was using a custom script that was world writeable.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-xM56aKiWpH8/V2UZ3DOFj5I/AAAAAAAAC44/9IGfVkuWwBQxJY8Z1PJfa8IKZAEpl8I8gCLcB/s1600/cron-logrotate.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;56&quot; src=&quot;https://4.bp.blogspot.com/-xM56aKiWpH8/V2UZ3DOFj5I/AAAAAAAAC44/9IGfVkuWwBQxJY8Z1PJfa8IKZAEpl8I8gCLcB/s320/cron-logrotate.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;By uploading a netcat and appending custom command to the custom logrotate script, I was able to launch a reverse netcat shell with root privilege.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-1L7FZnNjhe0/V2Ud3bSQyyI/AAAAAAAAC5I/l1zi7Sl_x2scwCTtCRQtu6cTpnNZKHBEgCLcB/s1600/nc-listen-root-b.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;94&quot; src=&quot;https://3.bp.blogspot.com/-1L7FZnNjhe0/V2Ud3bSQyyI/AAAAAAAAC5I/l1zi7Sl_x2scwCTtCRQtu6cTpnNZKHBEgCLcB/s320/nc-listen-root-b.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Using the reverse netcat shell, the flag was obtained.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-X_P0upbtTxA/V2Ud-4ImRcI/AAAAAAAAC5Q/hIWR9UeRKdE-TK2T_Tjs209PVH12zeriQCLcB/s1600/nc-root-flag.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;274&quot; src=&quot;https://2.bp.blogspot.com/-X_P0upbtTxA/V2Ud-4ImRcI/AAAAAAAAC5Q/hIWR9UeRKdE-TK2T_Tjs209PVH12zeriQCLcB/s320/nc-root-flag.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;:-)&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/4106957510035044338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=4106957510035044338' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/4106957510035044338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/4106957510035044338'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2016/06/vulnhub-stapler-walkthrough.html' title='Vulnhub Stapler 1 Walkthrough'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://2.bp.blogspot.com/-WGcz1aTIOhs/V2UYIiZKEwI/AAAAAAAAC4U/yea95kewUJghGT_eF1TDWgTF3p72UNDQgCLcB/s72-c/nmap.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-5974234091928894330</id><published>2016-06-12T10:30:00.000+08:00</published><updated>2016-06-19T18:40:04.665+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="windbg"/><title type='text'>user mode process debugging from windbg kernel debugger via ntsd</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;When used together, ntsd and windbg can let us switch between kernel debugging and specific user mode process debugging.&lt;br /&gt;&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;First, ensure that the usual kernel mode debugging session is properly setup and working.&lt;/li&gt;&lt;li&gt;In the target machine, identify the user mode process id. This can be done using tasklist command. &amp;nbsp;Then launch ntsd against the selected process id.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-I43eawpYHEU/V1zHmPHbqlI/AAAAAAAAC3g/WYJV9hqwS9weMJp0C6flHTDJFjhk6Hp6ACKgB/s1600/tasklist-pid-ntsd.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;48&quot; src=&quot;https://1.bp.blogspot.com/-I43eawpYHEU/V1zHmPHbqlI/AAAAAAAAC3g/WYJV9hqwS9weMJp0C6flHTDJFjhk6Hp6ACKgB/s320/tasklist-pid-ntsd.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;attach ntsd against pid 2728 (calc.exe)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;&lt;li&gt;As a result, the windbg kernel debugger will break in and wait for input.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-7aYVveRUybY/V1zIdeXiMwI/AAAAAAAAC3s/4UWu9Lv8l0kA-CXR7ay7pDLUDROLBY8bQCLcB/s1600/windbg-kd.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;277&quot; src=&quot;https://1.bp.blogspot.com/-7aYVveRUybY/V1zIdeXiMwI/AAAAAAAAC3s/4UWu9Lv8l0kA-CXR7ay7pDLUDROLBY8bQCLcB/s320/windbg-kd.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;windbg kernel debugger breaks in&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;&lt;li&gt;From that point onwards, we can proceed to use the kernel debugger to inspect the user mode process in more detail.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-FySVUPPjxHc/V1zI01QqKAI/AAAAAAAAC30/C-648LtIR8AgNvf1EWoVzkGng4pBXxIQgCLcB/s1600/pid.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;121&quot; src=&quot;https://3.bp.blogspot.com/-FySVUPPjxHc/V1zI01QqKAI/AAAAAAAAC30/C-648LtIR8AgNvf1EWoVzkGng4pBXxIQgCLcB/s320/pid.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;pid is hex aa8 which is decimal 2728&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/5974234091928894330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=5974234091928894330' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/5974234091928894330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/5974234091928894330'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2016/06/user-mode-process-debugging-from-windbg.html' title='user mode process debugging from windbg kernel debugger via ntsd'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://1.bp.blogspot.com/-I43eawpYHEU/V1zHmPHbqlI/AAAAAAAAC3g/WYJV9hqwS9weMJp0C6flHTDJFjhk6Hp6ACKgB/s72-c/tasklist-pid-ntsd.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-1081154947604342391</id><published>2016-06-11T09:52:00.002+08:00</published><updated>2016-06-19T18:40:24.041+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gdb"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux kernel"/><title type='text'>KGDB Linux kernel debugging in Windows host using 2 Linux virtualbox guest</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;For those who needs to perform Linux kgdb debugging on Windows host like I do, below are the steps. &amp;nbsp;(As a side note, these steps have been described in detail in a virtualbox forum discussion before. &amp;nbsp;For details, refer to the comment I posted below. &amp;nbsp;For the rest of you who prefer a blog post with screenshots, read on :-)&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Create 2 Linux guest, one as the debugger running GDB and the other as the debugee kernel. &amp;nbsp;Both these VM should use the same Windows named pipe path for the serial ports settings. &amp;nbsp;But for the debugger VM, check the &quot;Connect to existing pipe/socket&quot; box, while for the debugee, keep it uncheck.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-lC5udC0eap8/V1trLihOTtI/AAAAAAAAC1w/JJ9O3pY5i44RMADy83EUaTvdKNZOUIoLACLcB/s1600/virtualbox-pipe.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;150&quot; src=&quot;https://2.bp.blogspot.com/-lC5udC0eap8/V1trLihOTtI/AAAAAAAAC1w/JJ9O3pY5i44RMADy83EUaTvdKNZOUIoLACLcB/s320/virtualbox-pipe.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Windows named pipe as virtual serial port&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;&lt;li&gt;I chose to build my own debugee kernel (using the default Fedora kernel config for make oldconfig) and &lt;b&gt;remove KDB&lt;/b&gt; from the compilation. I did this because if I include it in compilation (as how the default Fedora kernel config does), the GDB remote target handshake fails with some &quot;qStatus#49&quot; error.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-G2tUnS7NqDA/V1trrknEq2I/AAAAAAAAC14/e2duMltTvkQYoGF_dUB-D9I5dRZEK4FOgCLcB/s1600/kdb-not-set.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;121&quot; src=&quot;https://4.bp.blogspot.com/-G2tUnS7NqDA/V1trrknEq2I/AAAAAAAAC14/e2duMltTvkQYoGF_dUB-D9I5dRZEK4FOgCLcB/s320/kdb-not-set.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;CONFIG_KGDB_KDB is not set&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;&lt;li&gt;After finish building the new kernel and install it in the debugee system, copy its vmlinux (note, NOT vmlinuz) image to the debugger machine.&lt;/li&gt;&lt;li&gt;Start the debugee VM first, follow by the debugger VM. Optionally, we can use the &quot;pipelist&quot; utility from Sysinternals Suite to make sure that the shared named pipe is created.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-a1uQE4DzKjI/V1tsftj0MxI/AAAAAAAAC2E/2kZvonXyHvkVePrMbjgnNH9h40tvLCt4QCKgB/s1600/pipelist.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;28&quot; src=&quot;https://1.bp.blogspot.com/-a1uQE4DzKjI/V1tsftj0MxI/AAAAAAAAC2E/2kZvonXyHvkVePrMbjgnNH9h40tvLCt4QCKgB/s320/pipelist.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;pipelist shows that dbgpipe is created&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;&lt;li&gt;In the debugee VM, make sure to append &quot;kgdboc=ttyS0,115200n8 kgdbwait&quot; kernel boot parameter in the grub screen, if not already done so in grub.cfg earlier.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-PGsyOTkaKYI/V1ttMNRoNuI/AAAAAAAAC2U/k35NaIFvkxgfJVpLYoU6HXYwuOmc09tYQCLcB/s1600/kernel-parameter.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;28&quot; src=&quot;https://1.bp.blogspot.com/-PGsyOTkaKYI/V1ttMNRoNuI/AAAAAAAAC2U/k35NaIFvkxgfJVpLYoU6HXYwuOmc09tYQCLcB/s320/kernel-parameter.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;kgdboc and kgdbwait boot parameters&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;&lt;li&gt;Boot the debugee kernel, it should appear to hang at KGDB and wait for connection.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-W0yZqa915Jo/V1tti_BhPAI/AAAAAAAAC2c/ZJxfb-MUpYEeSe7TD0ZUmHBcO9O1zIFjwCLcB/s1600/kgdbwait.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;172&quot; src=&quot;https://1.bp.blogspot.com/-W0yZqa915Jo/V1tti_BhPAI/AAAAAAAAC2c/ZJxfb-MUpYEeSe7TD0ZUmHBcO9O1zIFjwCLcB/s320/kgdbwait.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;debugee kernel waiting for remote gdb connection&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;&lt;li&gt;Run &quot;gdb vmlinux&quot; in the debugger VM. &amp;nbsp;After GDB has started, optionally run &quot;set serial baud 115200&quot;, then run &quot;target remote /dev/ttyS0&quot;. &amp;nbsp;Wait for the connection to be established, and you are ready to go! (Here, I execute &quot;bt&quot; to see the backtrace).&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-G7PjnjMQTsE/V1tuaGwGiMI/AAAAAAAAC2s/qwDy2Cf9ilM913m8aj07iyNU2lM1oA54QCLcB/s1600/gdb-remote-target.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;165&quot; src=&quot;https://4.bp.blogspot.com/-G7PjnjMQTsE/V1tuaGwGiMI/AAAAAAAAC2s/qwDy2Cf9ilM913m8aj07iyNU2lM1oA54QCLcB/s320/gdb-remote-target.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;gdb remote target&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/li&gt;&lt;/ul&gt;In addition to the steps described above, we can optionally enable GDB script as described in&amp;nbsp;https://www.kernel.org/doc/Documentation/gdb-kernel-debugging.txt.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-z9Y_090k67o/V1wgrmEwHHI/AAAAAAAAC3M/MaNocEp0iX8Z-yrCNulUeJ59fv6UykEmACLcB/s1600/gdb-script-config-blue.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;176&quot; src=&quot;https://1.bp.blogspot.com/-z9Y_090k67o/V1wgrmEwHHI/AAAAAAAAC3M/MaNocEp0iX8Z-yrCNulUeJ59fv6UykEmACLcB/s320/gdb-script-config-blue.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;enable gdb script&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;We then copy the build tree over to the debugger machine (maybe we just need the scripts/gdb/ directory but I have not verify that, I just copy the entire build directory). &amp;nbsp;The scripts let us perform some convenient steps like &quot;ps&quot; as shown here.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-QETVLNSnpAY/V2ZwBZ1wllI/AAAAAAAAC5o/B-0p18xyPRA5_caqNiUQ6l8c4IJOaYVWwCKgB/s1600/lx-ps.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://3.bp.blogspot.com/-QETVLNSnpAY/V2ZwBZ1wllI/AAAAAAAAC5o/B-0p18xyPRA5_caqNiUQ6l8c4IJOaYVWwCKgB/s1600/lx-ps.PNG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;lx-ps&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Note that I need to make changes to the gdb scripts for the specific kernel version source that I build, which I did not describe the steps in this post.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/1081154947604342391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=1081154947604342391' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/1081154947604342391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/1081154947604342391'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2016/06/kgdb-linux-kernel-debugging-in-windows.html' title='KGDB Linux kernel debugging in Windows host using 2 Linux virtualbox guest'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://2.bp.blogspot.com/-lC5udC0eap8/V1trLihOTtI/AAAAAAAAC1w/JJ9O3pY5i44RMADy83EUaTvdKNZOUIoLACLcB/s72-c/virtualbox-pipe.PNG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-1450748337368252731</id><published>2016-06-05T21:04:00.000+08:00</published><updated>2016-06-19T18:40:53.014+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gdb"/><title type='text'>GDB TUI</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Recently watched this &quot;CppCon 2015: Greg Law &quot; Give me 15 minutes &amp;amp; I&#39;ll change your view of GDB&quot; video.&lt;br /&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=PorfLSr3DDI&quot;&gt;https://www.youtube.com/watch?v=PorfLSr3DDI&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It discusses about some simple but useful trick in GDB TUI mode.&lt;br /&gt;However, when I try them out, some of the Ctrl-X key combination does not always work on my machine.&lt;br /&gt;After some googling, I found this:&amp;nbsp;&lt;a href=&quot;https://sourceware.org/gdb/onlinedocs/gdb/TUI-Commands.html#TUI-Commands&quot;&gt;https://sourceware.org/gdb/onlinedocs/gdb/TUI-Commands.html#TUI-Commands&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;For those who are reluctant to read the document, use &quot;layout split&quot; to split your screen, &quot;layout reg&quot; to list the register.&lt;br /&gt;&lt;br /&gt;I hope these can be useful for other GDB users who wish to use TUI mode.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/1450748337368252731/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=1450748337368252731' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/1450748337368252731'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/1450748337368252731'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2016/06/gdb-tui.html' title='GDB TUI'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-9044417240632930551</id><published>2016-06-05T20:56:00.000+08:00</published><updated>2016-06-05T20:56:15.614+08:00</updated><title type='text'>msfelfscan to find jmp esp</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;It has been sooooooooooo long (again) that I have not post anything. Oh well, busy with things, as usual.&lt;br /&gt;But today I have just pick up a new trick in Metasploit (more specifically msfelfscan) that might worth reminding myself, so here goes.&lt;br /&gt;So, some of us find it quite convenient to use debugger like Immunity Debugger, OllyDbg and EDB to find &quot;JMP ESP&quot; instruction, for example.&lt;br /&gt;But what if we have no access to those?&lt;br /&gt;First, use the msfelfscan tool in Metasploit to scan for the binary.  This should give you a list of offsets.&lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;msfelfscan -j esp ./libc.so.6 &lt;/div&gt;Then, we can run the program that uses that library, for example can check the base address in /proc/&amp;ltpid&amp;gt/maps to search for the base address.&lt;br /&gt;When combined, should give us the &quot;JMP ESP&quot; address we are looking for. &lt;br /&gt;&lt;/pid&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/9044417240632930551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=9044417240632930551' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/9044417240632930551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/9044417240632930551'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2016/06/msfelfscan-to-find-jmp-esp.html' title='msfelfscan to find jmp esp'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-1752181703570864510</id><published>2014-08-30T21:56:00.003+08:00</published><updated>2014-08-30T21:56:55.509+08:00</updated><title type='text'>Ubuntu 14.04 and Android MTP</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;I&#39;m not sure is it just me, or are there some other Ubuntu users who are unable to access the files and directories in their Android smartphone.&lt;br /&gt;Anyway, I found that the below step/package works:&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;apt-get install jmtpfs &lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/1752181703570864510/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=1752181703570864510' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/1752181703570864510'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/1752181703570864510'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2014/08/ubuntu-1404-and-android-mtp.html' title='Ubuntu 14.04 and Android MTP'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-7111336937328963601</id><published>2014-06-01T16:20:00.001+08:00</published><updated>2014-06-01T21:14:02.010+08:00</updated><title type='text'>vim to ubuntu 14.04: youcompleteme :-)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;I just found out that &quot;youcompleteme&quot; was added as a package in Ubuntu 14.04 LTS.&lt;br /&gt;Now, vim fans like me can have the amazing IDE-like experience by simply doing the few easy steps below:&lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;apt-get install vim apt-get install vim-youcompleteme apt-get install vim-addon-manager vam install youcompleteme &lt;/div&gt;The screen shots (C++ and Python) below work out of the box!&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-dvwfJAJn8NY/U4sm4DMvTHI/AAAAAAAAB50/O_CkHdxbwGk/s1600/ycm_cpp.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-dvwfJAJn8NY/U4sm4DMvTHI/AAAAAAAAB50/O_CkHdxbwGk/s1600/ycm_cpp.png&quot; height=&quot;141&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-bkaNYSti0tc/U4sm7D2d2pI/AAAAAAAAB58/p1bgiTwx1wk/s1600/ycm_python.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-bkaNYSti0tc/U4sm7D2d2pI/AAAAAAAAB58/p1bgiTwx1wk/s1600/ycm_python.png&quot; height=&quot;150&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Enjoy! &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/7111336937328963601/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=7111336937328963601' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/7111336937328963601'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/7111336937328963601'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2014/06/vim-to-ubuntu-1404-youcompleteme.html' title='vim to ubuntu 14.04: youcompleteme :-)'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-dvwfJAJn8NY/U4sm4DMvTHI/AAAAAAAAB50/O_CkHdxbwGk/s72-c/ycm_cpp.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-3273112764350840231</id><published>2014-02-24T21:26:00.001+08:00</published><updated>2015-06-03T16:33:48.132+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><title type='text'>Value Semantics, Concepts Based Polymorphism and Composite Pattern</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Not long ago, I watched &lt;a href=&quot;http://isocpp.org/blog/2012/12/value-semantics-and-concepts-based-polymorphism-sean-parent&quot;&gt;Sean Parent&#39;s Value Semantics and Concepts Based Polymorphism&lt;/a&gt;.&lt;br /&gt;&lt;div&gt;In the presentation, Sean showed a sample code that manipulates &quot;document type&quot;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Yesterday, while flipping over an old book on my book shelf, &lt;a href=&quot;http://www.amazon.com/Pattern-Hatching-Design-Patterns-Applied/dp/0201432935&quot;&gt;Pattern Hatching: Design Patterns Applied, by John Vlissides&lt;/a&gt;, I came across his example of using the Composite Pattern to illustrate a simplified file system structure with class Node, class File and class Directory. &amp;nbsp;There it uses the classical way of inheritance.&lt;/div&gt;&lt;div&gt;I couldn&#39;t help but notice the similarity between the simplified file system recursive structure of the Composite Pattern with Sean&#39;s example of the document inside document.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, I just play around with concepts based polymorphism a bit.&lt;/div&gt;&lt;div&gt;Note that the code may not be optimize or anything, as it is a quick copy-and-modify.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Here is node.h: &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;#ifndef NODE_H #define NODE_H  #include &lt;iostream&gt;#include &lt;vector&gt;#include &lt;memory&gt;#include &lt;initializer_list&gt; class node_t {     struct concept_t {         virtual ~concept_t() = default;         virtual size_t total_size() const = 0;         virtual void print(std::ostream&amp;amp; out) = 0;         virtual concept_t* copy() = 0;     };     struct file_model_t : concept_t {         file_model_t(size_t x) : total_size_(x) {}         size_t total_size() const { return total_size_; }         void print(std::ostream&amp;amp; out) { out &amp;lt;&amp;lt; total_size_; }         concept_t* copy() { return new file_model_t(*this); }         size_t total_size_;     };     struct dir_model_t : concept_t {         dir_model_t(std::initializer_list&lt;node_t&gt; l) : children_(l) {}         size_t total_size() const {              size_t total_size = 0;             for (const auto&amp;amp; c : children_) total_size += c.total_size();             return total_size;          }         virtual void print(std::ostream&amp;amp; out) {             out &amp;lt;&amp;lt; &quot;(&quot;;             auto i = children_.begin();             out &amp;lt;&amp;lt; *i;             ++i;             while (i != children_.end()) {                 out &amp;lt;&amp;lt; &quot;,&quot;;                 out &amp;lt;&amp;lt; *i;                 ++i;             }             out &amp;lt;&amp;lt; &quot;)&quot;;         }         concept_t* copy() { return new dir_model_t(*this); }         std::vector&lt;node_t&gt; children_;     };     std::unique_ptr&lt;concept_t&gt; p_; public:     node_t(size_t value) : p_(new file_model_t(value)) { /*std::cout &amp;lt;&amp;lt; &quot;ctor file&quot; &amp;lt;&amp;lt; std::endl;*/ }     node_t(std::initializer_list&lt;node_t&gt; l) : p_(new dir_model_t(l)) { /*std::cout &amp;lt;&amp;lt; &quot;ctor dir&quot; &amp;lt;&amp;lt; std::endl;*/ }     node_t(const node_t&amp;amp; x) : p_(x.p_-&amp;gt;copy()) { /*std::cout &amp;lt;&amp;lt; &quot;copy&quot; &amp;lt;&amp;lt; std::endl;*/ }     node_t&amp;amp; operator=(node_t x) {         //std::cout &amp;lt;&amp;lt; &quot;assign&quot; &amp;lt;&amp;lt; std::endl;         p_ = std::move(x.p_);         return *this;     }     size_t total_size() const {         return p_-&amp;gt;total_size();     }     friend     std::ostream&amp;amp; operator&amp;lt;&amp;lt;(std::ostream&amp;amp; out, const node_t&amp;amp; n) {         n.p_-&amp;gt;print(out);         return out;     } };   using file_t = node_t; using directory_t = node_t;  #endif //NODE_H &lt;/node_t&gt;&lt;/concept_t&gt;&lt;/node_t&gt;&lt;/node_t&gt;&lt;/initializer_list&gt;&lt;/memory&gt;&lt;/vector&gt;&lt;/iostream&gt;&lt;/div&gt;And here is the client code: &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;#include &lt;iostream&gt;#include &lt;vector&gt;#include &quot;node.h&quot;  int main() {     file_t f1 ( 10 );     std::cout &amp;lt;&amp;lt; &quot;f1: &quot; &amp;lt;&amp;lt; f1.total_size() &amp;lt;&amp;lt; std::endl;     file_t f2 ( 20 );     std::cout &amp;lt;&amp;lt; &quot;f2: &quot; &amp;lt;&amp;lt; f2.total_size() &amp;lt;&amp;lt; std::endl;     directory_t d1 { f1, f2 };     std::cout &amp;lt;&amp;lt; &quot;d1: &quot; &amp;lt;&amp;lt; d1.total_size() &amp;lt;&amp;lt; std::endl;     file_t f3 ( 30 );     std::cout &amp;lt;&amp;lt; &quot;f3: &quot; &amp;lt;&amp;lt; f3.total_size() &amp;lt;&amp;lt; std::endl;     directory_t d2 { f3, d1 };     std::cout &amp;lt;&amp;lt; &quot;d2: &quot; &amp;lt;&amp;lt; d2.total_size() &amp;lt;&amp;lt; std::endl;     std::cout &amp;lt;&amp;lt; d2 &amp;lt;&amp;lt; std::endl; } &lt;/vector&gt;&lt;/iostream&gt;&lt;/div&gt;And this is the output: &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;f1: 10 f2: 20 d1: 30 f3: 30 d2: 60 (30,(10,20)) &lt;/div&gt;&lt;br /&gt;Note how the directory nests the subdirectory.&lt;br /&gt;More importantly, the value semantics of the client code, polymorphism without reference or pointer, cool!&lt;br /&gt;&lt;br /&gt;Admittedly, I&#39;m quite new to this concepts-based polymorphism technique, and may also not be paying too much attention to other aspect of the C++ code in general.  If you find any mistake, feedback and advice are appreciated. &lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/3273112764350840231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=3273112764350840231' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/3273112764350840231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/3273112764350840231'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2014/02/value-semantic-and-composite-pattern.html' title='Value Semantics, Concepts Based Polymorphism and Composite Pattern'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-5131333084880502979</id><published>2013-12-31T23:50:00.000+08:00</published><updated>2013-12-31T23:50:15.931+08:00</updated><title type='text'>Discrete Fourier Transform and Nested For Loops</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This will be my last post for this year, 2013. Hehe, what a way to spend my new year countdown.&lt;br /&gt;A while ago, Discrete Fourier Transform gave me a feeling of &quot;I understand the intuition but the equation...&quot;.&lt;br /&gt;So, I spent some time understanding the math behind.&lt;br /&gt;After some reading, I kinda think that it would be easier for programmer to understand it if we spell it out as nested for loops, instead of equation that Capital Sigma notation. So, here is a post that I try to code it out in Python (originally to convince myself, but hopefully it can help others too).&lt;br /&gt;First, we import NumPy and Matplotlib, so that we can plot the output to help with the understanding.&lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;import numpy import matplotlib.pyplot &lt;/div&gt;Next, we create a couple sine, cosine, with different (multiple) frequencies. &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;N = 44 time = numpy.arange(N) sine = numpy.sin(2 * numpy.pi * (1.0/N) * time) cosine = numpy.cos(2 * numpy.pi * (1.0/N) * time)  legend_sine_real, = matplotlib.pyplot.plot(sine.real, marker=&#39;o&#39;) legend_sine_imag, = matplotlib.pyplot.plot(sine.imag, marker=&#39;o&#39;) matplotlib.pyplot.legend([legend_sine_real, legend_sine_imag], [&quot;sine real&quot;, &quot;sine imag&quot;]) matplotlib.pyplot.title(&quot;time domain sine&quot;) matplotlib.pyplot.savefig(&quot;time_domain_sine.png&quot;) matplotlib.pyplot.clf() # matplotlib.pyplot.show()  # sine2a and sine2b should be equivalent sine2a = numpy.sin(2 * numpy.pi * (2.0/N) * time) sine2b = numpy.array([sine[n*2 % N] for n in time])  legend_sine2b_real, = matplotlib.pyplot.plot(sine2b.real, marker=&#39;o&#39;) legend_sine2b_imag, = matplotlib.pyplot.plot(sine2b.imag, marker=&#39;o&#39;) matplotlib.pyplot.legend([legend_sine2b_real, legend_sine2b_imag], [&quot;sine2b real&quot;, &quot;sine2b imag&quot;]) matplotlib.pyplot.title(&quot;time domain sine2b&quot;) matplotlib.pyplot.savefig(&quot;time_domain_sine2b.png&quot;) matplotlib.pyplot.clf() # matplotlib.pyplot.show()  sine4 = numpy.sin(2 * numpy.pi * (4.0/N) * time)  legend_sine4_real, = matplotlib.pyplot.plot(sine4.real, marker=&#39;o&#39;) legend_sine4_imag, = matplotlib.pyplot.plot(sine4.imag, marker=&#39;o&#39;) matplotlib.pyplot.legend([legend_sine4_real, legend_sine4_imag], [&quot;sine4 real&quot;, &quot;sine4 imag&quot;]) matplotlib.pyplot.title(&quot;time domain sine4&quot;) matplotlib.pyplot.savefig(&quot;time_domain_sine4.png&quot;) matplotlib.pyplot.clf() # matplotlib.pyplot.show() &lt;/div&gt;The wave forms we get are like: &lt;a href=&quot;http://3.bp.blogspot.com/-Ix0fuVaSin8/UsLleEA6S9I/AAAAAAAAB3c/_-UIaW_KwIE/s1600/time_domain_sine2b.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/-Ix0fuVaSin8/UsLleEA6S9I/AAAAAAAAB3c/_-UIaW_KwIE/s320/time_domain_sine2b.png&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-1J7kRmm_Cyk/UsLlfUATEOI/AAAAAAAAB3o/UKl9junH2iI/s1600/time_domain_sine4.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-1J7kRmm_Cyk/UsLlfUATEOI/AAAAAAAAB3o/UKl9junH2iI/s320/time_domain_sine4.png&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-tkGnjys1W_g/UsLld7VIk8I/AAAAAAAAB3Y/WOojGSTulWg/s1600/time_domain_sine.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-tkGnjys1W_g/UsLld7VIk8I/AAAAAAAAB3Y/WOojGSTulWg/s320/time_domain_sine.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Then, we add up the wave forms with different frequencies to create our time domain data &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;data = sine + sine2b + sine4  legend_data_real, = matplotlib.pyplot.plot(data.real, marker=&#39;o&#39;) legend_data_imag, = matplotlib.pyplot.plot(data.imag, marker=&#39;o&#39;) matplotlib.pyplot.legend([legend_data_real, legend_data_imag], [&quot;data real&quot;, &quot;data imag&quot;]) matplotlib.pyplot.title(&quot;time domain data&quot;) matplotlib.pyplot.savefig(&quot;time_domain_data.png&quot;) matplotlib.pyplot.clf() # matplotlib.pyplot.show() &lt;/div&gt;This should give us: &lt;a href=&quot;http://4.bp.blogspot.com/-p6KSlS36vck/UsLl14pkQoI/AAAAAAAAB3w/qw_c7bkaoJ4/s1600/time_domain_data.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-p6KSlS36vck/UsLl14pkQoI/AAAAAAAAB3w/qw_c7bkaoJ4/s320/time_domain_data.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;After that, we create the &quot;scary&quot; coefficient array (the one that usually appears as complex exponential of &#39;e&#39;) &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;coff = numpy.arange(N, dtype=numpy.complex) coff.real = cosine coff.imag = sine * -1.0 &lt;/div&gt;Finally, we perform the DFT using nested for loops. &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;# freq = numpy.fft.fft(data) # equivalently, we can implement DFT (which is not as efficient as FFT, since it is O(n^2)), but for learning purpose freq = numpy.arange(N, dtype=numpy.complex) for p in time:     freq[p] = numpy.complex(real=0.0, imag=0.0)     for q in time:         freq[p] += data[q] * coff[p*q % N]  legend_freq_real, = matplotlib.pyplot.plot(freq.real, marker=&#39;o&#39;) legend_freq_imag, = matplotlib.pyplot.plot(freq.imag, marker=&#39;o&#39;) matplotlib.pyplot.legend([legend_freq_real, legend_freq_imag], [&quot;freq real&quot;, &quot;freq imag&quot;]) matplotlib.pyplot.title(&quot;freq domain spectrum&quot;) matplotlib.pyplot.savefig(&quot;freq_domain_spectrum.png&quot;) matplotlib.pyplot.clf() # matplotlib.pyplot.show() &lt;/div&gt;And here is the plot for the DFT (you can enable the line that uses numpy.fft.fft to verify and see if the result is identical): &lt;a href=&quot;http://4.bp.blogspot.com/-Xc13lhk9MW4/UsLmBcrEO_I/AAAAAAAAB34/e1qn2ebN97o/s1600/freq_domain_spectrum.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-Xc13lhk9MW4/UsLmBcrEO_I/AAAAAAAAB34/e1qn2ebN97o/s320/freq_domain_spectrum.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Yeah, I know, it is probably too lame for those who already understand it.  But hopefully, for some who find it easier to read source code (and loops) compare to mathematical symbol, this can be helpful. By the way, if you find that I have coded/explained something inaccurately, feel free to let me know, I will appreciate it and update it accordingly. Happy New Year 2014! :) &lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/5131333084880502979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=5131333084880502979' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/5131333084880502979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/5131333084880502979'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2013/12/discrete-fourier-transform-and-nested.html' title='Discrete Fourier Transform and Nested For Loops'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-Ix0fuVaSin8/UsLleEA6S9I/AAAAAAAAB3c/_-UIaW_KwIE/s72-c/time_domain_sine2b.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-4663211442076479797</id><published>2013-11-25T17:34:00.001+08:00</published><updated>2015-06-03T16:34:46.312+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Python, COM and Windows UIAutomation</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Occasionally, we need to automate some of the GUI application. &amp;nbsp;For Windows desktop application, we can use UIAutomation API.&lt;br /&gt;There are quite a number of tutorial how that can be done, in say, C# (.NET) or even C++ (COM). &amp;nbsp;There are even PowerShell wrapper.&lt;br /&gt;When it comes to Python, there are of course existing library like PyWinAuto. &amp;nbsp;But what if we want to use UIAutomation API just like the rest of the languages. &amp;nbsp;Since COM should be able to get consumed by any languages, and Python, as usual, should be able to do wonderful things, why not give it a try. &amp;nbsp;However, I have yet to find a tutorial on that. &amp;nbsp;At least I haven&#39;t found one. &amp;nbsp;Hence, this tutorial (or rather, sample code):&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;import subprocess import time import comtypes from comtypes import * from comtypes.client import * import win32gui, win32api, win32con, ctypes comtypes.client.GetModule(&#39;UIAutomationCore.dll&#39;) from comtypes.gen.UIAutomationClient import *  if __name__ == &quot;__main__&quot;:     # launch calculator executable     subprocess.Popen(&#39;calc.exe&#39;)     time.sleep(1)     # initialize COM for UIAutomation     iuia = CoCreateInstance(CUIAutomation._reg_clsid_, interface=IUIAutomation, clsctx=CLSCTX_INPROC_SERVER)     # get desktop root element     root_elem = iuia.GetRootElement()     time.sleep(1)     # get calculator window     cond_calc = iuia.CreatePropertyCondition(UIA_NamePropertyId, &quot;Calculator&quot;)     calc = root_elem.FindFirst(scope=TreeScope_Descendants, condition=cond_calc)     time.sleep(1)     print(calc)     print(calc.CurrentName)     # button &#39;6&#39;     cond_6 = iuia.CreatePropertyCondition(UIA_NamePropertyId, str(6))     print(cond_6)     time.sleep(1)     cond_btn = iuia.CreatePropertyCondition(UIA_ControlTypePropertyId, UIA_ButtonControlTypeId)     print(cond_btn)     time.sleep(1)     cond_and = iuia.CreateAndCondition(cond_6, cond_btn)     print(cond_and)     time.sleep(1)     button_6 = calc.FindFirst(scope=TreeScope_Descendants, condition=cond_and)     time.sleep(1)     # click button &#39;6&#39;     print(button_6)     print(button_6.CurrentName)     patt_click = button_6.GetCurrentPattern(UIA_InvokePatternId)     iinvoke = patt_click.QueryInterface(IUIAutomationInvokePattern)     iinvoke.Invoke()   &lt;/div&gt;This should launch calc.exe and click button &#39;6&#39;. At the moment, I haven&#39;t master all the skill and internal details, and all the inelegant time.sleep etc are still there.  Do educate me if you more.  Otherwise, I might update this when I know more. &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/4663211442076479797/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=4663211442076479797' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/4663211442076479797'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/4663211442076479797'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2013/11/python-com-and-windows-uiautomation.html' title='Python, COM and Windows UIAutomation'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-6098492413825716224</id><published>2013-11-02T12:22:00.001+08:00</published><updated>2013-11-02T12:22:06.784+08:00</updated><title type='text'>Building LLVM/Clang, YouCompleteMe etc in Windows using VS2008.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;First of all, these steps are more or less described nicely in their respective websites:&lt;br /&gt;&lt;a href=&quot;http://llvm.org/releases/3.3/docs/CMake.html&quot;&gt;http://llvm.org/releases/3.3/docs/CMake.html&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://clang.llvm.org/get_started.html&quot;&gt;http://clang.llvm.org/get_started.html&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://github.com/Valloric/YouCompleteMe/wiki/Windows-Installation-Guide&quot;&gt;https://github.com/Valloric/YouCompleteMe/wiki/Windows-Installation-Guide&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Here I just add in the specific tried and true steps for myself.&lt;br /&gt;Why VS2008? Why not VS2013? Well, just trying, since I build the rest of my stuff, especially Python 2.6 extensions in VS2008. &amp;nbsp;I might retry in VS2013 later.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Install GnuPG from&amp;nbsp;&lt;a href=&quot;http://gpg4win.org/&quot;&gt;http://gpg4win.org/&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Download LLVM 3.3 source tarballs from&amp;nbsp;&lt;a href=&quot;http://www.llvm.org/releases/download.html#3.3&quot;&gt;http://www.llvm.org/releases/download.html#3.3&lt;/a&gt;, and verify their integrity using GnuPG after obtaining GPG key. &lt;/li&gt;&lt;div class=&quot;mycode&quot;&gt;gpg2 --keyserver pgp.mit.edu --recv-key E95C63DC  gpg2 --verify llvm-3.3.src.tar.gz.sig llvm-3.3.src.tar.gz  gpg2 --verify cfe-3.3.src.tar.gz.sig cfe-3.3.src.tar.gz &lt;/div&gt;&lt;li&gt;Unzip llvm-3.3.src.tar.gz to a directory, say, C:\llvm-3.3.src\. &amp;nbsp;&lt;/li&gt;&lt;li&gt;Unzip cfe-3.3.src\ portion of cfe-3.3.src.tar.gz (the file also include other directories, such as Driver\, Modules\, test\ etc) to a subdirectory of LLVM source, namely C:\llvm-3.3.src\tools\. &amp;nbsp;Then, rename the result subdirectory from C:\llvm-3.3.src\tools\cfe-3.3.src\ to C:\llvm-3.3.src\tools\clang\.&lt;/li&gt;&lt;li&gt;Install CMake from&amp;nbsp;&lt;a href=&quot;http://www.cmake.org/&quot;&gt;http://www.cmake.org/&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Install GnuWin32 so that tools like grep is available.&lt;/li&gt;&lt;li&gt;Open a Visual Studio 2008 Command Prompt. &lt;/li&gt;&lt;li&gt;Create a build directory, C:\llvm_build\ and change to that directory and run CMake to create a VS2008 (MSVC 9.0) solution file.&lt;/li&gt;&lt;div class=&quot;mycode&quot;&gt;C:\llvm_build&amp;gt;cmake -DLLVM_TARGETS_TO_BUILD=&quot;X86&quot; -DLLVM_LIT_TOOLS_DIR=C:\GnuWin32\bin -DCMAKE_INSTALL_PREFIX=C:\llvm-3.3.bin -DLLVM_INCLUDE_TESTS=OFF -G&quot;Visual Studio 9 2008&quot; . C:\llvm-3.3.src &lt;/div&gt;&lt;div class=&quot;mycode&quot;&gt;C:\llvm_build&amp;gt;msbuild LLVM.sln /t:ALL_BUILD /p:configuration=Release /fl /flp:logfile=MsBuildLLVM.log;verbosity=diagnostic &lt;/div&gt;&lt;li&gt;Install the binary to destination directory (C:\llvm-3.3.bin) upon completing compilation&lt;/li&gt;&lt;div class=&quot;mycode&quot;&gt;C:\llvm_build&amp;gt;msbuild INSTALL.vcproj /fl /flp:logfile=MsBuildLLVM.log;verbosity=diagnostic /p:configuration=Release &lt;/div&gt;&lt;li&gt;Build YouCompleteMe, similarly using CMake and MSBuild (on VS2008). First create and change to directory C:\ycm_clang_build&lt;/li&gt;&lt;div class=&quot;mycode&quot;&gt;C:\ycm_clang_build&amp;gt;cmake -G &quot;Visual Studio 9 2008&quot; -DPATH_TO_LLVM_ROOT=c:\llvm-3.3.bin . c:\Users\MyLoginName\vimfiles\bundle\YouCompleteMe\cpp &lt;/div&gt;&lt;div class=&quot;mycode&quot;&gt;C:\ycm_clang_build&amp;gt;msbuild YouCompleteMe.sln /t:ycm_core /p:configuration=Release /fl /flp:logfile=MsBuildYcmClang.log;verbosity=diagnostic C:\ycm_clang_build&amp;gt;msbuild YouCompleteMe.sln /t:ycm_client_support /p:configuration=Release /fl /flp:logfile=MsBuildYcmClang.log;verbosity=diagnostic &lt;/div&gt;&lt;li&gt;Upon completion, copy ycm_core.pyd and ycm_client_support.pyd from C:\ycm_build\ycm\Release, and libclang.dll from C:\llvm-3.3.bin\bin to C:Users\MyLoginName\vimfiles\bundle\YouCompleteMe\python\&lt;/li&gt;&lt;/ol&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-zrXExAWLN0o/UnR8Pu1Qu_I/AAAAAAAAB1g/ZGefcbS_eFs/s1600/hello_ycm.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;169&quot; src=&quot;http://1.bp.blogspot.com/-zrXExAWLN0o/UnR8Pu1Qu_I/AAAAAAAAB1g/ZGefcbS_eFs/s320/hello_ycm.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Voila! Done! And this is what I discover it is capable of. :-)&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/6098492413825716224/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=6098492413825716224' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/6098492413825716224'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/6098492413825716224'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2013/11/building-llvmclang-youcompleteme-etc-in.html' title='Building LLVM/Clang, YouCompleteMe etc in Windows using VS2008.'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-zrXExAWLN0o/UnR8Pu1Qu_I/AAAAAAAAB1g/ZGefcbS_eFs/s72-c/hello_ycm.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-8549048886575482539</id><published>2013-10-26T10:39:00.001+08:00</published><updated>2015-06-03T16:34:46.321+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Boost.Python to integrate Python and C++, without bjam.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;First of all, I would like to say, yes I heard, there are other solutions, such as Cython, Pyd or even using plain Python.h.&lt;br /&gt;But this is a post about my hello world trial on Boost.Python. &amp;nbsp;In future, I might try out other C++ compiler, Python version, on other OSes, and also Cython etc.&lt;br /&gt;But for the moment, I just pick the below combination:&lt;br /&gt;&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;OS: Windows 7 (64 bit)&lt;/li&gt;&lt;li&gt;Python: Python 2.6.6 (32 bit)&lt;/li&gt;&lt;li&gt;Visual Studio 2008 Express Edition (a.k.a MSVC 9.0): because it was used to compile Python 2.6 and 2.7, so must the Python extension, or so I heard.&lt;/li&gt;&lt;li&gt;Boost 1.54.0 prebuilt binary (boost_1_54_0-msvc-9.0-32).&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;So, let&#39;s get on with it.&lt;/div&gt;First, copy the code from here: &lt;br /&gt;&lt;a href=&quot;http://www.boost.org/doc/libs/1_54_0/libs/python/doc/tutorial/doc/html/index.html#python.quickstart&quot;&gt;http://www.boost.org/doc/libs/1_54_0/libs/python/doc/tutorial/doc/html/index.html#python.quickstart&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To prevent the below error: &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;C:\boost_1_54_0-msvc-9.0-32\boost/config/auto_link.hpp(355) : fatal error C1189:#error :  &quot;Mixing a dll boost library with a static runtime is a really bad idea...&quot; &lt;/div&gt;Prepend this to the file &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;#define BOOST_PYTHON_STATIC_LIB &lt;/div&gt;To save you some trouble, here is the code: &lt;div class=&quot;mycode&quot;&gt;#define BOOST_PYTHON_STATIC_LIB #include &amp;ltboost/python.hpp&amp;gt  char const* greet() {     return &quot;hello, world&quot;; }  BOOST_PYTHON_MODULE(hello_ext) {     using namespace boost::python;     def(&quot;greet&quot;, greet); } &lt;/div&gt;Save the file as hello_ext.cpp And compile it using this command line (from VS2008 command prompt, not plain cmd.exe): &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;cl /LD /EHsc /I &quot;C:\boost_1_54_0-msvc-9.0-32&quot; /I &quot;C:\Python26\include&quot; hello_ext.cpp /link /LIBPATH:&quot;C:\boost_1_54_0-msvc-9.0-32\lib32-msvc-9.0&quot; /LIBPATH:&quot;C:\Python26\libs&quot; /out:hello_ext.pyd &lt;/div&gt;Finally, run your Python interpreter and import the resulting library: &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;&amp;gt;&amp;gt;&amp;gt; import hello_ext &amp;gt;&amp;gt;&amp;gt; hello_ext.greet() &#39;hello, world&#39; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/8549048886575482539/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=8549048886575482539' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/8549048886575482539'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/8549048886575482539'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2013/10/boostpython-to-integrate-python-and-c.html' title='Boost.Python to integrate Python and C++, without bjam.'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-2913379228034713297</id><published>2013-07-26T08:58:00.000+08:00</published><updated>2016-06-19T18:38:42.317+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="windbg"/><title type='text'></title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;I was trying to inspect a URB in WinDBG. From the help file, it says: &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;!urb The !urb extension command is obsolete. Use the dt URB command instead. &lt;/div&gt;However, when I try dt URB or even dt _URB, this was the result: &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;kd&amp;gt; dt URB ************************************************************************* ***                                                                   *** ***                                                                   *** ***    Either you specified an unqualified symbol, or your debugger   *** ***    doesn&#39;t have full symbol information.  Unqualified symbol      *** ***    resolution is turned off by default. Please either specify a   *** ***    fully qualified symbol module!symbolname, or enable resolution *** ***    of unqualified symbols by typing &quot;.symopt- 100&quot;. Note that   *** ***    enabling unqualified symbol resolution with network symbol     *** ***    server shares in the symbol path may cause the debugger to     *** ***    appear to hang for long periods of time when an incorrect      *** ***    symbol name is typed or the network symbol server is down.     *** ***                                                                   *** ***    For some commands to work properly, your symbol path           *** ***    must point to .pdb files that have full type information.      *** ***                                                                   *** ***    Certain .pdb files (such as the public OS symbols) do not      *** ***    contain the required information.  Contact the group that      *** ***    provided you with these symbols if you need this command to    *** ***    work.                                                          *** ***                                                                   *** ***    Type referenced: URB                                           *** ***                                                                   *** ************************************************************************* Symbol URB not found. &lt;/div&gt;I checked and was quite sure the symbol was correctly loaded. After trying a to quality the symbol with a few modules names that appear to be more relevant to USB like usbehci etc, I gave up. Luckily the below trick saved the day: &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;kd&amp;gt; !for_each_module dt ${@#ModuleName}!_URB &lt;/div&gt;It automatically iterate through all the modules checking for _URB and finally found the below: &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;kd&amp;gt; dt _URB Wdf01000!_URB    +0x000 UrbHeader        : _URB_HEADER    +0x000 UrbSelectInterface : _URB_SELECT_INTERFACE    +0x000 UrbSelectConfiguration : _URB_SELECT_CONFIGURATION    +0x000 UrbPipeRequest   : _URB_PIPE_REQUEST    +0x000 UrbFrameLengthControl : _URB_FRAME_LENGTH_CONTROL    +0x000 UrbGetFrameLength : _URB_GET_FRAME_LENGTH    +0x000 UrbSetFrameLength : _URB_SET_FRAME_LENGTH    +0x000 UrbGetCurrentFrameNumber : _URB_GET_CURRENT_FRAME_NUMBER    +0x000 UrbControlTransfer : _URB_CONTROL_TRANSFER    +0x000 UrbControlTransferEx : _URB_CONTROL_TRANSFER_EX    +0x000 UrbBulkOrInterruptTransfer : _URB_BULK_OR_INTERRUPT_TRANSFER    +0x000 UrbIsochronousTransfer : _URB_ISOCH_TRANSFER    +0x000 UrbControlDescriptorRequest : _URB_CONTROL_DESCRIPTOR_REQUEST    +0x000 UrbControlGetStatusRequest : _URB_CONTROL_GET_STATUS_REQUEST    +0x000 UrbControlFeatureRequest : _URB_CONTROL_FEATURE_REQUEST    +0x000 UrbControlVendorClassRequest : _URB_CONTROL_VENDOR_OR_CLASS_REQUEST    +0x000 UrbControlGetInterfaceRequest : _URB_CONTROL_GET_INTERFACE_REQUEST    +0x000 UrbControlGetConfigurationRequest : _URB_CONTROL_GET_CONFIGURATION_REQUEST    +0x000 UrbOSFeatureDescriptorRequest : _URB_OS_FEATURE_DESCRIPTOR_REQUEST    +0x000 UrbOpenStaticStreams : _URB_OPEN_STATIC_STREAMS &lt;br /&gt;I know this could be a n00b trick, but hopefully, this trick will safe some of you some hard work the next time you need check something on all the modules.&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/2913379228034713297/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=2913379228034713297' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/2913379228034713297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/2913379228034713297'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2013/07/i-was-trying-to-inspect-urb-in-windbg.html' title=''/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-8758208814222540950</id><published>2013-07-25T16:13:00.000+08:00</published><updated>2016-06-19T18:39:07.033+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="windbg"/><title type='text'>Relating IRPs to Processes in WinDBG</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;I wouldn&#39;t have imagine myself posting on Windows OS internals or WinDBG.  But I have to admit that lately, playing around a bit on WinDBG and I kinda like it. Usually, the example in books uses !irp and !process.  But lately I came across this one that is quite useful when we need to relate one to another: &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;1: kd&amp;gt; !processirps 0x899b4600 0x3 **** PROCESS 899b4600 (Image: csrss.exe) ****  Checking threads for IRPs.    Thread 840b83c0:      IRP 840f0580 - Owned by \Driver\kbdclass for device KeyboardClass0 (899776c8)    Thread 840ba040:      IRP 97810e28 - Owned by \Driver\mouclass for device PointerClass1 (84109550)     IRP 8989bb40 - Owned by \Driver\mouclass for device PointerClass0 (89968d88)  Checking file objects for IRPs. &lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/8758208814222540950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=8758208814222540950' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/8758208814222540950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/8758208814222540950'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2013/07/relating-irps-to-processes-in-windbg.html' title='Relating IRPs to Processes in WinDBG'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-4184037171621907519</id><published>2013-07-21T12:26:00.000+08:00</published><updated>2016-06-19T18:39:48.370+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gdb"/><title type='text'>View process address space mapping and searching for string using GDB</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;Came across this useful trick to search for strings in memory using GDB, here in &lt;a href=&quot;http://stackoverflow.com/questions/5691193/gdb-listing-all-mapped-memory-regions-for-a-crashed-process&quot;&gt;StackOverflow&lt;/a&gt;&lt;br /&gt;Tried it out myself, it is useful for me. :) &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;(gdb) info proc mappings process 5340 Mapped address spaces:            Start Addr           End Addr       Size     Offset objfile             0x400000           0x401000     0x1000        0x0 /tmp/mainloop.x             0x600000           0x601000     0x1000        0x0 /tmp/mainloop.x             0x601000           0x602000     0x1000     0x1000 /tmp/mainloop.x       0x7ffff7a1b000     0x7ffff7bd0000   0x1b5000        0x0 /lib/x86_64-linux-gnu/libc-2.15.so       0x7ffff7bd0000     0x7ffff7dcf000   0x1ff000   0x1b5000 /lib/x86_64-linux-gnu/libc-2.15.so       0x7ffff7dcf000     0x7ffff7dd3000     0x4000   0x1b4000 /lib/x86_64-linux-gnu/libc-2.15.so       0x7ffff7dd3000     0x7ffff7dd5000     0x2000   0x1b8000 /lib/x86_64-linux-gnu/libc-2.15.so       0x7ffff7dd5000     0x7ffff7dda000     0x5000        0x0        0x7ffff7dda000     0x7ffff7dfc000    0x22000        0x0 /lib/x86_64-linux-gnu/ld-2.15.so       0x7ffff7fdd000     0x7ffff7fe0000     0x3000        0x0        0x7ffff7ff9000     0x7ffff7ffb000     0x2000        0x0        0x7ffff7ffb000     0x7ffff7ffc000     0x1000        0x0 [vdso]       0x7ffff7ffc000     0x7ffff7ffd000     0x1000    0x22000 /lib/x86_64-linux-gnu/ld-2.15.so       0x7ffff7ffd000     0x7ffff7fff000     0x2000    0x23000 /lib/x86_64-linux-gnu/ld-2.15.so       0x7ffffffde000     0x7ffffffff000    0x21000        0x0 [stack]   0xffffffffff600000 0xffffffffff601000     0x1000        0x0 [vsyscall] &lt;/div&gt;&lt;div class=&quot;mycode&quot;&gt;(gdb) maintenance info sections Exec file:     `/tmp/mainloop.x&#39;, file type elf64-x86-64.     0x00400238-&amp;gt;0x00400254 at 0x00000238: .interp ALLOC LOAD READONLY DATA HAS_CONTENTS     0x00400254-&amp;gt;0x00400274 at 0x00000254: .note.ABI-tag ALLOC LOAD READONLY DATA HAS_CONTENTS     0x00400274-&amp;gt;0x00400298 at 0x00000274: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS     0x00400298-&amp;gt;0x004002b4 at 0x00000298: .gnu.hash ALLOC LOAD READONLY DATA HAS_CONTENTS     0x004002b8-&amp;gt;0x00400300 at 0x000002b8: .dynsym ALLOC LOAD READONLY DATA HAS_CONTENTS     0x00400300-&amp;gt;0x00400338 at 0x00000300: .dynstr ALLOC LOAD READONLY DATA HAS_CONTENTS     0x00400338-&amp;gt;0x0040033e at 0x00000338: .gnu.version ALLOC LOAD READONLY DATA HAS_CONTENTS     0x00400340-&amp;gt;0x00400360 at 0x00000340: .gnu.version_r ALLOC LOAD READONLY DATA HAS_CONTENTS     0x00400360-&amp;gt;0x00400378 at 0x00000360: .rela.dyn ALLOC LOAD READONLY DATA HAS_CONTENTS     0x00400378-&amp;gt;0x00400390 at 0x00000378: .rela.plt ALLOC LOAD READONLY DATA HAS_CONTENTS     0x00400390-&amp;gt;0x0040039e at 0x00000390: .init ALLOC LOAD READONLY CODE HAS_CONTENTS     0x004003a0-&amp;gt;0x004003c0 at 0x000003a0: .plt ALLOC LOAD READONLY CODE HAS_CONTENTS     0x004003c0-&amp;gt;0x00400574 at 0x000003c0: .text ALLOC LOAD READONLY CODE HAS_CONTENTS     0x00400574-&amp;gt;0x0040057d at 0x00000574: .fini ALLOC LOAD READONLY CODE HAS_CONTENTS     0x00400580-&amp;gt;0x00400584 at 0x00000580: .rodata ALLOC LOAD READONLY DATA HAS_CONTENTS     0x00400584-&amp;gt;0x004005b0 at 0x00000584: .eh_frame_hdr ALLOC LOAD READONLY DATA HAS_CONTENTS     0x004005b0-&amp;gt;0x00400654 at 0x000005b0: .eh_frame ALLOC LOAD READONLY DATA HAS_CONTENTS     0x00600e10-&amp;gt;0x00600e18 at 0x00000e10: .init_array ALLOC LOAD DATA HAS_CONTENTS     0x00600e18-&amp;gt;0x00600e20 at 0x00000e18: .fini_array ALLOC LOAD DATA HAS_CONTENTS     0x00600e20-&amp;gt;0x00600e28 at 0x00000e20: .jcr ALLOC LOAD DATA HAS_CONTENTS     0x00600e28-&amp;gt;0x00600ff8 at 0x00000e28: .dynamic ALLOC LOAD DATA HAS_CONTENTS     0x00600ff8-&amp;gt;0x00601000 at 0x00000ff8: .got ALLOC LOAD DATA HAS_CONTENTS     0x00601000-&amp;gt;0x00601020 at 0x00001000: .got.plt ALLOC LOAD DATA HAS_CONTENTS     0x00601020-&amp;gt;0x00601030 at 0x00001020: .data ALLOC LOAD DATA HAS_CONTENTS     0x00601030-&amp;gt;0x00601038 at 0x00001030: .bss ALLOC     0x00000000-&amp;gt;0x0000006b at 0x00001030: .comment READONLY HAS_CONTENTS &lt;/div&gt;&lt;div class=&quot;mycode&quot;&gt;(gdb) find /b 0x601020, 0x60103c, &#39;H&#39;,&#39;E&#39;,&#39;L&#39;,&#39;L&#39;,&#39;O&#39; 0x601030 &lt;buf&gt;1 pattern found. (gdb) x /1sb 0x601030 0x601030 &lt;buf&gt;: &quot;HELLO_WORLD&quot; &lt;/buf&gt;&lt;/buf&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/4184037171621907519/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=4184037171621907519' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/4184037171621907519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/4184037171621907519'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2013/07/view-process-address-space-mapping-and.html' title='View process address space mapping and searching for string using GDB'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13656592.post-1054457349406737538</id><published>2013-06-30T22:57:00.001+08:00</published><updated>2015-06-03T16:34:46.308+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Do, Re, Mi, Fa, So...with Python and Numpy</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;It has been ages I have not post anything. Same lame excuse, busy with bla...bla...bla... :) Lately, I&#39;m playing a bit with Python to play with sound. And here is a simple code to generate a simple Do..Re...Mi...Fa...So... I&#39;m sure there are already tons of such example on the Net, which this will just be yet another example. Oh, well. :) &lt;br /&gt;&lt;div class=&quot;mycode&quot;&gt;import numpy import scipy.io.wavfile import matplotlib.pyplot  doremi = [523.0, 587.0, 659.0, 698.0, 784.0] # C,D,E,F,G or Do,Re,Mi,Fa,So  amplitude = 65536.0/4.0 sampling_rate = 44100.0 # sampling rate duration = 0.5 # 0.5 seconds sample = sampling_rate * duration t = numpy.arange(sample)  t = t/sample # scale each element for normalization song = numpy.array([]) for freq in doremi:  wav = numpy.sin(2*numpy.pi*freq*t)*amplitude  song = numpy.concatenate([song, wav]) scipy.io.wavfile.write(&#39;doremi.wav&#39;, sampling_rate, song.astype(numpy.int16)) matplotlib.pyplot.specgram(song) # generate spectogram matplotlib.pyplot.savefig(&#39;doremi.png&#39;) &lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weichong78.blogspot.com/feeds/1054457349406737538/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=13656592&amp;postID=1054457349406737538' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/1054457349406737538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13656592/posts/default/1054457349406737538'/><link rel='alternate' type='text/html' href='http://weichong78.blogspot.com/2013/06/do-re-mi-fa-sowith-python-and-numpy.html' title='Do, Re, Mi, Fa, So...with Python and Numpy'/><author><name>Wei Chong Tan</name><uri>https://plus.google.com/110067934885261232842</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-JwLzJ5A4Yk0/AAAAAAAAAAI/AAAAAAAACww/iOPQUgAN3Lo/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry></feed>