[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Mon Jun 6 10:37:26 2005 -->
- <!--x-from-r13: wnzrf.fhzaref ng tznvy.pbz (Xnzrf Ehzaref) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: [email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] Binary Matching -->
- <li><em>date</em>: Mon Jun 6 10:37:26 2005</li>
- <li><em>from</em>: james.sumners at gmail.com (James Sumners)</li>
- <li><em>in-reply-to</em>: <<a href="msg00231.html">[email protected]</a>></li>
- <li><em>references</em>: <<a href="msg00231.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] Binary Matching</li>
<?php
$initial_offset = 10; // 10 bytes
$bytes_to_read = 500; // 500 bytes
$first_file = '/some/file.bin';
$files_to_read = array('/file/one.bin', '/file/two.bin', '/file/three.bin');
$f = fopen($first_file, 'r');
fseek($f, $initial_offset);
$data = fread($f, $bytes_to_read);
fclose($f);
foreach ($files_to_read as $x) {
$f = fopen($x, 'r');
$cmp_data = fread($f, $bytes_to_read);
if ( $data == $cmp_data ) {
printf("{$first_file} matches some data in {$x}.\n");
}
fclose($f);
}
?>
On 6/6/05, Mister Anonymous <atlantalinuxenthusiast at gmail.com> wrote:
> I need to do some binary matching across many files and was wanting to
> get some recommendations on how to do it. I would like to be able to
> grab a section of binary data from one file (approximately 500
> continuous bytes) and check and see if that is included in other
> binary files. Any recommendations on an easy way to extract the
> initial 500 bytes (assume I would like to do it from some particular
> offset in the file) and then search for that data in the other file?
>
> I am afraid that perl might be the best way to do this, but I am not
> that much of a perl hacker. If there is an easy way to do it using
> python or a shell script, that would be preferable.
>
> Thanks.
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> <a rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale">http://www.ale.org/mailman/listinfo/ale</a>
>
--
James Sumners
<a rel="nofollow" href="http://james.roomfullofmirrors.com/">http://james.roomfullofmirrors.com/</a>
"All governments suffer a recurring problem: Power attracts
pathological personalities. It is not that power corrupts but that it
is magnetic to the corruptible. Such people have a tendency to become
drunk on violence, a condition to which they are quickly addicted."
Missionaria Protectiva, Text QIV (decto)
CH:D 59
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00235" href="msg00235.html">[ale] Binary Matching</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00231" href="msg00231.html">[ale] Binary Matching</a></strong>
<ul><li><em>From:</em> atlantalinuxenthusiast at gmail.com (Mister Anonymous)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00231.html">[ale] Binary Matching</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00233.html">[ale] Binary Matching</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00231.html">[ale] Binary Matching</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00235.html">[ale] Binary Matching</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00232"><strong>Date</strong></a></li>
<li><a href="threads.html#00232"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>