<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Java - iExploit</title>
      <link>http://iexploit.org/index.php?p=/categories/java/feed.rss</link>
      <pubDate>Mon, 20 May 13 15:29:03 -0400</pubDate>
         <description>Java - iExploit</description>
   <language>en-CA</language>
   <atom:link href="/index.php?p=/discussions/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Source Code Place For Beginner</title>
      <link>http://iexploit.org/index.php?p=/discussion/6207/source-code-place-for-beginner</link>
      <pubDate>Sun, 28 Oct 2012 10:44:06 -0400</pubDate>
      <dc:creator>blackhathunter</dc:creator>
      <guid isPermaLink="false">6207@/index.php?p=/discussions</guid>
      <description><![CDATA[<br><br><br><br>When you try to learn programming&nbsp; Reading ebooks is not enough...<br><br><br><br><br><br>It is recommended toyou to also Study many Programming source Code.<br><br><br><br><br><br>Here are Place where you can find such stuff:<br><br><br><br><div class="f kv"><a rel="nofollow" href="http://www.planet-source-code.com"><cite>www.<b>planet</b>-<b>source</b>-<b>code</b>.com</cite></a><br><br><a rel="nofollow" href="http://www.sourcecodesworld.com">www.sourcecodesworld.com</a><br><br><br><br><a rel="nofollow" href="http://www.programmersheaven.com"><cite>www.<b>programmersheaven</b>.com</cite></a><br><br><a rel="nofollow" href="http://javaboutique.internet.com"><cite><b>javaboutique</b>.internet.com</cite></a><br><br><br><br><br><br><br></div><br><br><br><br><div class="f kv"><cite><br><br></cite></div><br><br>]]></description>
   </item>
   <item>
      <title>Smashing Java WebStart For Fun With POC</title>
      <link>http://iexploit.org/index.php?p=/discussion/6213/smashing-java-webstart-for-fun-with-poc</link>
      <pubDate>Sat, 10 Nov 2012 12:39:52 -0500</pubDate>
      <dc:creator>blackhathunter</dc:creator>
      <guid isPermaLink="false">6213@/index.php?p=/discussions</guid>
      <description><![CDATA[Hello Java coder...<br><br><br>Have you ever wondered the good use of Java Webstart ?<br><br>Read this Free Ebook For More info:<br><br><span style="font-family: Garamond; color: #3366ff; font-size: large;"><b><a rel="nofollow" href="http://www.tusfiles.net/fz91vtctgg55">Smashing Java WebStart For Fun With POC</a> </b></span><br><br><br><br>Original source:<br><br><a rel="nofollow" href="http://www.zoolazoola.com/account/tutorial"><span style="font-family: Garamond; font-size: large;"><b>www.zoolazoola.com</b></span></a><br><br><br><br>PS: you must also install java runtime environment<br><br>]]></description>
   </item>
   <item>
      <title>Can you help me in my program?</title>
      <link>http://iexploit.org/index.php?p=/discussion/6179/can-you-help-me-in-my-program</link>
      <pubDate>Fri, 14 Sep 2012 21:22:51 -0400</pubDate>
      <dc:creator>ReverseEngineering</dc:creator>
      <guid isPermaLink="false">6179@/index.php?p=/discussions</guid>
      <description><![CDATA[<div>Imagine that you have 2 jugs, a small one and a large one, with integer capacities of sCap and lCap gallons, <br>respectively (sCap &lt; lCap).</div><div><br></div><div><ol><li><span style="font-size: 10pt;">Initially both jugs are empty.</span></li><li><span style="font-size: 10pt;">You are allowed to completely fill each jug from a tap, or empty them on the ground.</span></li><li><span style="font-size: 10pt;">You can also pour one jug into the other: pouring stops when either the receiving jug is full or no water is left in the pouring jug (i.e. no water is spilled).</span></li><li><span style="font-size: 10pt;">Note that each pouring action will cause a positive number of whole gallons to be transferred.</span></li><li><span style="font-size: 10pt;">Given the final state of the jugs, the problem is to find a valid sequence of actions such that after performing the actions, the small and large jugs show exactly the final state given.</span></li></ol></div><div>&nbsp;</div><div>Input: capacity of jug A, capacity of jug B, desired output</div><div>Output: current state of the jugs, steps in solving the problem</div><div>&nbsp;</div><div>Important: Your group must use RECURSION in solving the problem.</div><div>Bonus: Implement a three jug problem.</div><div>&nbsp;</div><div>Sample run:</div><div>&nbsp;</div><div>Enter capacity of jug A: &nbsp;10</div><div>Enter capacity of jug B: 3</div><div>Enter the goal: 4 0</div><div>&nbsp;</div><div>A &nbsp; &nbsp; &nbsp;B</div><div>---------</div><div>10 &nbsp; &nbsp;0 &nbsp; : &nbsp;Fill A</div><div>7 &nbsp; &nbsp; &nbsp;3 &nbsp; &nbsp;: Pour A to B</div><div>7 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;: Empty B</div><div>4 &nbsp; &nbsp; &nbsp;3 &nbsp; &nbsp;: Pour A to B</div><div>4 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;: Empty B</div><div>&nbsp;</div><div>Sample run:</div><div>&nbsp;</div><div>Enter capacity of jug A: 5</div><div>Enter capacity of jug B: 3</div><div>Enter the goal: 2 0</div><div>&nbsp;</div><div>A &nbsp; &nbsp; &nbsp;B</div><div>---------</div><div>5 &nbsp; &nbsp; &nbsp;0 &nbsp; : &nbsp;Fill A</div><div>2 &nbsp; &nbsp; &nbsp;3 &nbsp; &nbsp;: Pour A to B</div><div>2 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;: Empty B</div><div>&nbsp;</div><div>Sample run:</div><div>&nbsp;</div><div>Enter capacity of jug A: 5</div><div>Enter capacity of jug B: 3</div><div>Enter the goal: 1 0</div><div>&nbsp;</div><div>A &nbsp; &nbsp; &nbsp;B</div><div>---------</div><div>0 &nbsp; &nbsp; &nbsp;3 &nbsp; : &nbsp;Fill B</div><div>3 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;: Pour B to A</div><div>3 &nbsp; &nbsp; &nbsp;3 &nbsp; &nbsp;: Fill B</div><div>5 &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp;: Pour B to A</div><div>0 &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp;: Empty A</div><div>1 &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;: Pour B to A</div>]]></description>
   </item>
   <item>
      <title>GUI in Java?</title>
      <link>http://iexploit.org/index.php?p=/discussion/6157/gui-in-java</link>
      <pubDate>Wed, 05 Sep 2012 09:56:27 -0400</pubDate>
      <dc:creator>Phage</dc:creator>
      <guid isPermaLink="false">6157@/index.php?p=/discussions</guid>
      <description><![CDATA[Does anyone have some great material or tutorials on creating GUI in Java? My project should end up in a simple text editor like Notepad in windows.<br><br>I have checked:<br>thenewboston<br><a rel="nofollow" href="http://www.codeproject.com/Articles/33536/An-Introduction-to-Java-GUI-Programming">http://www.codeproject.com/Articles/33536/An-Introduction-to-Java-GUI-Programming</a><br>]]></description>
   </item>
   <item>
      <title>MozillaRecovery - crack master passwords</title>
      <link>http://iexploit.org/index.php?p=/discussion/5968/mozillarecovery-crack-master-passwords</link>
      <pubDate>Sat, 03 Mar 2012 16:29:45 -0500</pubDate>
      <dc:creator>Deque</dc:creator>
      <guid isPermaLink="false">5968@/index.php?p=/discussions</guid>
      <description><![CDATA[Hello iExploit,<br><br>I have to tell you, this was a lot of work, but I got obsessed with figuring out, how Mozilla saves passwords. Once I found out, I wrote this software for this. There is not much information about that topic in the internet. The programs I found which recover master passwords from Mozilla applications weren't open source. <br><br><span><b><span style="color: #98FB98;">About the program</span></b></span><br><br><span style="color: #87CEFA;">Requirements:</span> Java 7<br><br>http&#58;//s7&#46;directupload&#46;net/images/120113/g76oy4sq&#46;png<br><br><span style="color: #87CEFA;">Download .jar and source:</span> <a class="postlink" rel="nofollow" href="http://www.mediafire.com/?3d9iygbfyuiohtl">http://www.mediafire.com/?3d9iygbfyuiohtl</a><br><br>Once you start the program, it searches automatically for default locations of your key3.db in Firefox and, if not found, in the Thunderbird application directory. I prepared and tested this for Windows 7 and Linux. If it is not working for your OS, please tell me the default location for it. I just need the information to put that in. You can change the location by hand, of course.<br><br>key3.db is the file that is used to recover the master password. You can start a wordlist attack on that. The program ships with a default worldlist, but it is small (I didn't want to upload a wordlist file that adds several megabytes to the program). You can use your own list by changing the location.<br><br>Alternatively you can start a bruteforce attack by activating the "bruteforce" checkbox. Although I used threads, this is limited to a word length of five (a bruteforce attack with a wordlength of six would take several days, so I don't allow that) and the alphabet a-zA-Z by now. I got about 30000 password tests per second on my machine.<br><br>Once you got the master password, it is very easy to obtain saved login information from signons.sqlite, since both, Thunderbird and Firefox, will show usernames and passwords in plain text. (google if you don't know how)<br><br>Conclusion: Always set a master password if you save login information with Thunderbird or Firefox. Otherwise the login information can be obtained without any problems.<br><br><span><b><span style="color: #98FB98;">About the source</span></b></span><br><br>The only (non-standard) library I used is apache.log4j for logging purposes. You will see a properties file and a log folder. The standard logging level is WARN. If you change this level to INFO or DEBUG, the master passwords found with the program will be saved in there, so be careful with that option.<br><br><span style="color: #87CEFA;">Lines of code without comments and empty lines: </span>914<br><span style="color: #87CEFA;">Lines of code with everything else:</span> 1141<br><br><span style="color: #87CEFA;">License:</span><br>[spoiler]<br><br>Copyright 2012 Deque at <a class="postlink" rel="nofollow" href="http://www.iexploit.org">http://www.iexploit.org</a> All rights reserved.<br><br>Redistribution and use in source and binary forms, with or without modification, are<br>permitted provided that the following conditions are met:<br><br>1. Redistributions of source code must retain the above copyright notice, this list of<br>conditions and the following disclaimer.<br><br>2. Redistributions in binary form must reproduce the above copyright notice, this list<br>of conditions and the following disclaimer in the documentation and/or other materials<br>provided with the distribution.<br><br>THIS SOFTWARE IS PROVIDED BY Deque at <a class="postlink" rel="nofollow" href="http://www.iexploit.org">http://www.iexploit.org</a> ``AS IS'' AND ANY EXPRESS OR IMPLIED<br>WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND<br>FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Deque at <a class="postlink" rel="nofollow" href="http://www.iexploit.org">http://www.iexploit.org</a> OR<br>CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br>CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR<br>SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON<br>ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING<br>NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF<br>ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br><br>The views and conclusions contained in the software and documentation are those of the<br>authors and should not be interpreted as representing official policies, either expressed<br>or implied, of Deque at <a class="postlink" rel="nofollow" href="http://www.iexploit.org">http://www.iexploit.org</a><br><br>[/spoiler]<br><br>The code was tested for: Firefox 9.01 Thunderbird 9.01, Windows 7, Arch Linux.<br>If you have a different setting, you can help me by telling me that it worked or that it didn't.<br><br><span style="color: #87CEFA;">Problems?</span><br><br>Please make sure that you have Java 7.<br>If there are still problems, post the logging file that is in the logs folder.<br><br>Have fun.<br>Deque]]></description>
   </item>
   <item>
      <title>[Java] PEAnalyser - get info about .exe and .dll files</title>
      <link>http://iexploit.org/index.php?p=/discussion/5966/java-peanalyser-get-info-about-exe-and-dll-files</link>
      <pubDate>Thu, 01 Mar 2012 10:30:10 -0500</pubDate>
      <dc:creator>Deque</dc:creator>
      <guid isPermaLink="false">5966@/index.php?p=/discussions</guid>
      <description><![CDATA[Hello iExploit,<br><br>this release is an analyser for the portable executable format (PE) of Microsoft. This includes .exe and .dll files.<br>It is a command line program. Usage is very simple:<br><br><blockquote class="Quote"><div class="QuoteText">java -jar peanalyse &lt;filename&gt;</div></blockquote><br><br>And here is a sample result:<br><br>[spoiler]<br><blockquote class="Quote"><div class="QuoteText">************** PEAnalyser 0.1 by <a rel="nofollow" href="mailto:Deque@iExploit.org">Deque@iExploit.org</a> **************<br><br>analysing file: 7z.exe<br><br>PE signature offset: 232<br>PE signature correct: yes<br><br>----------------<br>COFF header info<br>----------------<br><br>characteristics:<br>    * Image only, Windows CE, and Windows NT and later.<br>    * Image only.<br>    * Application can handle &gt; 2 GB addresses.<br><br>machine type: x64<br>number of sections: 5<br>size of optional header: 240<br>time date stamp: Thu Nov 18 17:08:29 CET 2010<br><br>--------------------<br>Optional header info<br>--------------------<br><br>Standard fields<br>...............<br><br>address of entry point: 188096 (0x2dec0)<br>address of base of code: 4096 (0x1000)<br>magic number: 523 --&gt; PE32+ executable<br>major linker version: 8 (0x8)<br>minor linker version: 0 (0x0)<br>size of code: 186368 (0x2d800)<br>size of initialized data: 105984 (0x19e00)<br>size of unitialized data: 0 (0x0)<br><br>Windows specific fields<br>.......................<br><br>checksum: 0 (0x0)<br><br>dll characteristics:<br>    * Terminal Server aware.<br><br>file alignment in bytes: 512 (0x200)<br>image base: 4194304 (0x400000), default for Windows NT, 2000, XP, 95, 98 and Me<br>loader flags (reserved, must be zero): 0 (0x0)<br>major image version: 0 (0x0)<br>major operating system version: 4 (0x4)<br>major subsystem version: 5 (0x5)<br>minor image version: 0 (0x0)<br>minor operating system version: 0 (0x0)<br>minor subsystem version: 2 (0x2)<br>number of rva and sizes: 16 (0x10)<br>section alignment in bytes: 4096 (0x1000)<br>size of headers (MS DOS stub, PE header, and section headers): 1024 (0x400)<br>size of heap commit: 4096 (0x1000)<br>size of heap reserve: 1048576 (0x100000)<br>size of image in bytes: 307200 (0x4b000)<br>size of stack commit: 4096 (0x1000)<br>size of stack reserve: 1048576 (0x100000)<br>subsystem: The Windows character subsystem<br>win32 version value (reserved, must be zero): 0 (0x0)<br><br>Data directories<br>................<br><br>virtual_address/size<br><br>import table: 28(0x1c)/28<br>resource table: 16(0x10)/16<br>exception table: 8(0x8)/8<br>IAT: 192(0xc0)/192<br><br><br>-------------<br>Section Table<br>-------------<br><br>entry number 1:<br>...............<br><br>characteristics:<br>    * The section contains executable code.<br>    * The section can be executed as code.<br><br>name: .text<br>number of line numbers: 0 (0x0)<br>number of relocations: 0 (0x0)<br>pointer to line numbers: 0 (0x0)<br>pointer to raw data: 1024 (0x400)<br>pointer to relocations: 0 (0x0)<br>size of raw data: 186368 (0x2d800)<br>virtual address: 4096 (0x1000)<br>virtual size: 185900 (0x2d62c)<br><br>entry number 2:<br>...............<br><br>characteristics:<br>    * The section contains initialized data.<br><br>name: .rdata<br>number of line numbers: 0 (0x0)<br>number of relocations: 0 (0x0)<br>pointer to line numbers: 0 (0x0)<br>pointer to raw data: 187392 (0x2dc00)<br>pointer to relocations: 0 (0x0)<br>size of raw data: 74752 (0x12400)<br>virtual address: 192512 (0x2f000)<br>virtual size: 74282 (0x1222a)<br><br>entry number 3:<br>...............<br><br>characteristics:<br>    * The section contains initialized data.<br>    * The section can be written to.<br><br>name: .data<br>number of line numbers: 0 (0x0)<br>number of relocations: 0 (0x0)<br>pointer to line numbers: 0 (0x0)<br>pointer to raw data: 262144 (0x40000)<br>pointer to relocations: 0 (0x0)<br>size of raw data: 2560 (0xa00)<br>virtual address: 270336 (0x42000)<br>virtual size: 11696 (0x2db0)<br><br>entry number 4:<br>...............<br><br>characteristics:<br>    * The section contains initialized data.<br><br>name: .pdata<br>number of line numbers: 0 (0x0)<br>number of relocations: 0 (0x0)<br>pointer to line numbers: 0 (0x0)<br>pointer to raw data: 264704 (0x40a00)<br>pointer to relocations: 0 (0x0)<br>size of raw data: 18432 (0x4800)<br>virtual address: 282624 (0x45000)<br>virtual size: 17928 (0x4608)<br><br>entry number 5:<br>...............<br><br>characteristics:<br>    * The section contains initialized data.<br><br>name: .rsrc<br>number of line numbers: 0 (0x0)<br>number of relocations: 0 (0x0)<br>pointer to line numbers: 0 (0x0)<br>pointer to raw data: 283136 (0x45200)<br>pointer to relocations: 0 (0x0)<br>size of raw data: 1024 (0x400)<br>virtual address: 303104 (0x4a000)<br>virtual size: 784 (0x310)</div></blockquote>[/spoiler]<br><br>As you can see, you are able to view header information and section entries. I.e. you can see which architecture this executable is made for, what kind of file it is (.exe, .dll, other), when it was created and a lot more.<br><br>Future versions may include viewing the section entries (which might be more suitable with a GUI, so you don't get a wall of text).<br><br>As always: tell me, if you find any bugs so I can remove them.<br>I searched after other PE viewer software to compare my results and make searching for bugs easier, but I only found software I have to pay for. No one should pay for this shit.<br><br><span style="color: #E0FFFF;">Download:</span><br>Source and .jar included<br><a class="postlink" rel="nofollow" href="http://www.mediafire.com/?ah2nttj134t4zxy">http://www.mediafire.com/?ah2nttj134t4zxy</a><br><br><span style="color: #E0FFFF;">License:</span><br>[spoiler]<br>Copyright 2012 Deque at <a class="postlink" rel="nofollow" href="http://www.iexploit.org">http://www.iexploit.org</a> All rights reserved.<br><br>Redistribution and use in source and binary forms, with or without modification, are<br>permitted provided that the following conditions are met:<br><br>1. Redistributions of source code must retain the above copyright notice, this list of<br>conditions and the following disclaimer.<br><br>2. Redistributions in binary form must reproduce the above copyright notice, this list<br>of conditions and the following disclaimer in the documentation and/or other materials<br>provided with the distribution.<br><br>THIS SOFTWARE IS PROVIDED BY Deque at <a class="postlink" rel="nofollow" href="http://www.iexploit.org">http://www.iexploit.org</a> ``AS IS'' AND ANY EXPRESS OR IMPLIED<br>WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND<br>FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Deque at <a class="postlink" rel="nofollow" href="https://haxme.org">https://haxme.org</a> OR<br>CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br>CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR<br>SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON<br>ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING<br>NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF<br>ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br><br>The views and conclusions contained in the software and documentation are those of the<br>authors and should not be interpreted as representing official policies, either expressed<br>or implied, of Deque at <a class="postlink" rel="nofollow" href="http://www.iexploit.org">http://www.iexploit.org</a><br>[/spoiler]<br><br><span style="color: #E0FFFF;">Lines of code:</span> 535 without empty lines and comments<br>669 with empty lines and comments<br><br>Have fun.<br>Deque]]></description>
   </item>
   <item>
      <title>[Java] EXIFRemover 0.1</title>
      <link>http://iexploit.org/index.php?p=/discussion/5974/java-exifremover-0-1</link>
      <pubDate>Fri, 09 Mar 2012 16:25:42 -0500</pubDate>
      <dc:creator>Deque</dc:creator>
      <guid isPermaLink="false">5974@/index.php?p=/discussions</guid>
      <description><![CDATA[Hello iExploit,<br><br>this is a command line program for removing EXIF data from images. EXIF data is saved into your pictures by your digital camera, but also image editing software. With the EXIFRemover you can prepare images before publishing them, so they won't contain any information you don't want to publish.<br><br><span style="color: #00BFFF;"><span>Download jar:</span></span><br><br><a class="postlink" rel="nofollow" href="http://www.mediafire.com/?xycwdanv9ia1va3">http://www.mediafire.com/?xycwdanv9ia1va3</a><br><br><span><span style="color: #00BFFF;">Usage:</span></span><br><br>usage: exifremover -d &lt;filename/folder&gt; [-dest &lt;filename/folder&gt;]<br>-d,--delete-exif &lt;filename&gt;   delete all exif data of given file(s)<br>-dest &lt;filename&gt;              save changed image(s) into file<br>-h,--help                     print help message<br>-s,--show-exif &lt;filename&gt;     show exif data<br>-v,--version                  show version<br><br>show-exif example: <span style="color: #FFA500;">java -jar exifremover -s B:\Sonstiges\test.jpg</span><br><br>[spoiler]<blockquote class="Quote"><div class="QuoteText">Exif metadata:<br>        Root:<br>            Image Description: 'JENOPTIK DIGITAL CAMERA'<br>            Make: 'JENOPTIK OPTICAL CO,LTD'<br>            Model: 'JD5200Z'<br>            Orientation: 1<br>            XResolution: 72<br>            YResolution: 72<br>            Resolution Unit: 2<br>            Software: 'VJ305060'<br>            Modify Date: '2006:08:16 11:56:11'<br>            YCbCr Positioning: 2<br>            Exif Offset: 254<br><br>        Exif:<br>            ISO: 100<br>            Exif Version: 48, 50, 49, 48<br>            Date Time Original: '2006:08:16 11:56:11'<br>            Create Date: '2006:08:16 11:56:14'<br>            Components Configuration: 1, 2, 3, 0<br>            Compressed Bits Per Pixel: 1100/9830 (0,112)<br>            Shutter Speed Value: 101/15 (6,733)<br>            Aperture Value: 35055/10000 (3,506)<br>            Exposure Compensation: 7/10 (0,7)<br>            Subject Distance: Invalid rational (0/0)<br>            Metering Mode: 2<br>            Flash: 1<br>            Focal Length: 21860/1000 (21,86)<br>            Maker Note: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 50... (264)<br>            Flashpix Version: 48, 49, 48, 48<br>            Color Space: 1<br>            Exif Image Width: 2560<br>            Exif Image Length: 1920<br>            Interop Offset: 840<br><br>        Interoperability:<br>            Interop Index: 'R98'<br>            Interop Version: 48, 49, 48, 48<br><br>        Sub:  (jpegImageData)<br>            Compression: 6<br>            XResolution: 72<br>            YResolution: 72<br>            Resolution Unit: 2<br>            Jpg From Raw Start: 964<br>            Jpg From Raw Length: 12117<br><br>Photoshop (IPTC) metadata:<br>        Keywords: SampleKeyword</div></blockquote>[/spoiler]<br><br><br>delete-exif example for a single file: <span style="color: #FFA500;">java -jar exifremover -d B:\Sonstiges\test.jpg -dest B:\Sonstiges\temp.jpg</span><br><br>[spoiler]<blockquote class="Quote"><div class="QuoteText">All EXIF data successfully removed from B:\Sonstiges\test.jpg<br>Result saved in B:\Sonstiges\temp.jpg</div></blockquote>[/spoiler]<br><br><br>delete-exif example for all files in a given folder: <span style="color: #FFA500;">java -jar exifremover -d B:\Sonstiges\</span><br>All files are saved into a temp folder within the given folder, unless you define a destination folder with -dest.<br><br>[spoiler]<blockquote class="Quote"><div class="QuoteText">created file B:\Sonstiges\temp\100_1788.JPG<br>created file B:\Sonstiges\temp\100_1789.JPG<br>created file B:\Sonstiges\temp\100_1790.JPG<br>created file B:\Sonstiges\temp\100_1791.JPG<br>created file B:\Sonstiges\temp\100_1792.JPG<br>created file B:\Sonstiges\temp\100_1793.JPG<br>created file B:\Sonstiges\temp\100_1796.JPG<br>created file B:\Sonstiges\temp\100_1797.JPG<br>created file B:\Sonstiges\temp\100_1799.JPG<br>created file B:\Sonstiges\temp\100_1800.JPG<br>created file B:\Sonstiges\temp\100_1801.JPG<br>created file B:\Sonstiges\temp\100_1802.JPG<br>created file B:\Sonstiges\temp\100_1939.JPG<br>Unable to remove EXIF data from B:\Sonstiges\Thumbs.db</div></blockquote>[/spoiler]<br><br><br><br><span style="color: #00BFFF;"><span>Source code:</span></span><br><br>I included Java docs for every class and method for a better understanding.<br><br>CLI.java<br><br>[spoiler]<div class="PreContainer"><pre>import java&amp;#46;io&amp;#46;File;<br>import java&amp;#46;io&amp;#46;IOException;<br><br>import org&amp;#46;apache&amp;#46;commons&amp;#46;cli&amp;#46;CommandLine;<br>import org&amp;#46;apache&amp;#46;commons&amp;#46;cli&amp;#46;CommandLineParser;<br>import org&amp;#46;apache&amp;#46;commons&amp;#46;cli&amp;#46;HelpFormatter;<br>import org&amp;#46;apache&amp;#46;commons&amp;#46;cli&amp;#46;Options;<br>import org&amp;#46;apache&amp;#46;commons&amp;#46;cli&amp;#46;ParseException;<br>import org&amp;#46;apache&amp;#46;commons&amp;#46;cli&amp;#46;PosixParser;<br>import org&amp;#46;apache&amp;#46;sanselan&amp;#46;ImageReadException;<br>import org&amp;#46;apache&amp;#46;sanselan&amp;#46;ImageWriteException;<br><br>import exifremover&amp;#46;exifremover&amp;#46;model&amp;#46;EXIFRemover;<br><br>/**<br>* Command line interface for exifremover&amp;#46;<br>*<br>* <a rel="nofollow" href="/index.php?p=/profile/author">@author</a> deque<br>*<br>*/<br>public class CLI {<br><br>    private static final String TEMP_DIR = \&quot;temp\&quot;;<br>    private static final String VERSION = \&quot;EXIFRemover 0&amp;#46;1\&quot;;<br>    private static final String USAGE = \&quot;exifremover -d &amp;lt;filename/folder&amp;gt;\&quot;<br>            + \&quot; &amp;#91;-dest &amp;lt;filename/folder&amp;gt;&amp;#93;\&quot;;<br><br>    private static final String FILE_SEPARATOR = System<br>            &amp;#46;getProperty(\&quot;file&amp;#46;separator\&quot;);<br><br>    public static void main(String&amp;#91;&amp;#93; args) {<br>        new CLI(args);<br>    }<br><br>    /**<br>     * Initializes options, invokes parsing of command line arguments&amp;#46;<br>     *<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> args<br>     *            the command line arguments<br>     */<br>    public CLI(String&amp;#91;&amp;#93; args) {<br>        Options options = initOptions();<br>        parseCommandLine(args, options);<br>    }<br><br>    /**<br>     * Parses arguments for available options&amp;#46;<br>     *<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> args<br>     *            the command line arguments<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> options<br>     *            the command line options for which the arguments are parsed<br>     */<br>    private void parseCommandLine(String&amp;#91;&amp;#93; args, Options options) {<br>        CommandLineParser parser = new PosixParser();<br>        try {<br>            CommandLine line = parser&amp;#46;parse(options, args);<br><br>            if (line&amp;#46;hasOption(\&quot;version\&quot;)) {<br>                System&amp;#46;out&amp;#46;println(VERSION);<br>            }<br>            if (line&amp;#46;hasOption(\&quot;help\&quot;) || args&amp;#46;length == 0) {<br>                showHelp(options);<br>            }<br>            if (line&amp;#46;hasOption(\&quot;show-exif\&quot;)) {<br>                showExif(line);<br>            }<br>            if (line&amp;#46;hasOption(\&quot;delete-exif\&quot;)) {<br>                deleteEXIF(line);<br>            }<br>        } catch (ParseException e) {<br>            System&amp;#46;err&amp;#46;println(e&amp;#46;getMessage());<br>        } catch (ImageWriteException e) {<br>            System&amp;#46;err&amp;#46;println(e&amp;#46;getMessage());<br>        } catch (IOException e) {<br>            System&amp;#46;err&amp;#46;println(e&amp;#46;getMessage());<br>        } catch (ImageReadException e) {<br>            System&amp;#46;err&amp;#46;println(e&amp;#46;getMessage());<br>        }<br>    }<br><br>    /**<br>     * Prints out all EXIF data found in given file&amp;#46;<br>     *<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> line<br>     *            command line that contains the image path<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> IOException<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> ImageReadException<br>     */<br>    private void showExif(CommandLine line) throws IOException,<br>            ImageReadException {<br>        File file = new File(line&amp;#46;getOptionValue(\&quot;show-exif\&quot;));<br>        EXIFRemover remover = new EXIFRemover(file);<br>        System&amp;#46;out&amp;#46;println(remover&amp;#46;getExifData());<br>    }<br><br>    /**<br>     * Prints out help information like usage and available options&amp;#46;<br>     *<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> options<br>     *            command line options to be shown<br>     */<br>    private void showHelp(Options options) {<br>        HelpFormatter formatter = new HelpFormatter();<br>        formatter&amp;#46;printHelp(USAGE, options);<br>    }<br><br>    /**<br>     * Removes EXIF data from a single image file or all image files in a folder<br>     * given as command line argument&amp;#46;<br>     *<br>     * If a folder is given, it saves the resulting images into destination<br>     * folder&amp;#46; A TEMP_DIR is created if no destination is given (this is mainly<br>     * for security reasons, so you are not able to overwrite a whole folder of<br>     * images by mistake)&amp;#46;<br>     *<br>     * If a single image file is given, it saves the resulting image into a<br>     * given destination&amp;#46; If there is no destination, the image file is<br>     * overwritten, which means EXIF data of the original file is lost unless<br>     * you have a copy&amp;#46;<br>     *<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> line<br>     *            command line that contains the paths for source and maybe<br>     *            destination<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> IOException<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> ImageReadException<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> ImageWriteException<br>     */<br>    private void deleteEXIF(CommandLine line) throws IOException,<br>            ImageReadException, ImageWriteException {<br>        File source = new File(line&amp;#46;getOptionValue(\&quot;delete-exif\&quot;));<br>        // if no destination folder given, assign source folder to dest<br>        File dest = line&amp;#46;hasOption(\&quot;dest\&quot;) ? new File(<br>                line&amp;#46;getOptionValue(\&quot;dest\&quot;)) &amp;#58; source;<br><br>        if (source&amp;#46;isDirectory()) {<br>            deleteEXIFFromDir(source, dest);<br>        } else {<br>            deleteEXIFForSingleFile(source, dest);<br>        }<br>    }<br><br>    /**<br>     * Removes EXIF data from all files in a given source directory and saves<br>     * new images into the destination directory&amp;#46; Destination directory is<br>     * created if it doesn't exist&amp;#46;<br>     *<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> source<br>     *            source folder that contains the image files<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> dest<br>     *            destination folder where the new images are saved to<br>     */<br>    private void deleteEXIFFromDir(File source, File dest) {<br>        assert source&amp;#46;isDirectory();<br>        if (!dest&amp;#46;isDirectory()) {<br>            if (dest&amp;#46;exists()) {<br>                System&amp;#46;err&amp;#46;println(\&quot;destination file is no directory\&quot;);<br>                return;<br>            } else {<br>                dest&amp;#46;mkdir();<br>            }<br><br>        }<br>        // create temp folder if destination folder equals source folder<br>        if (dest&amp;#46;equals(source)) {<br>            removeAllEXIFFromFolder(source, new File(dest&amp;#46;getAbsolutePath()<br>                    + FILE_SEPARATOR + TEMP_DIR));<br>        } else {<br>            removeAllEXIFFromFolder(source, dest);<br>        }<br>    }<br><br>    /**<br>     * Removes EXIF data from a single image file which is the source file&amp;#46;<br>     * Resulting images is saved into the destination file which may be the same<br>     * as the source file (in that case the image is overwritten)&amp;#46;<br>     *<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> source<br>     *            source folder that contains the image files<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> dest<br>     *            destination folder where the new images are saved to<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> IOException<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> ImageReadException<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> ImageWriteException<br>     */<br>    private void deleteEXIFForSingleFile(File source, File dest)<br>            throws IOException, ImageReadException, ImageWriteException {<br>        EXIFRemover remover = new EXIFRemover(source);<br>        remover&amp;#46;removeEXIFData(dest);<br>        System&amp;#46;out&amp;#46;println(\&quot;All EXIF data successfully removed from \&quot;<br>                + source&amp;#46;getAbsolutePath());<br>        System&amp;#46;out&amp;#46;println(\&quot;Result saved in \&quot; + dest&amp;#46;getAbsolutePath());<br>    }<br><br>    /**<br>     * Deletes EXIF information from every file in a given source folder&amp;#46;<br>     * Resulting images are saved the destination folder&amp;#46; The given arguments<br>     * files must be directories&amp;#46;<br>     *<br>     * Directories within the source folder are ignored&amp;#46; Everything else will be<br>     * treated as an image&amp;#46;<br>     *<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> srcFolder<br>     *            source folder that contains the image files<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> destFolder<br>     *            destination folder where the new images are saved to<br>     */<br>    private void removeAllEXIFFromFolder(File srcFolder, File destFolder) {<br>        assert srcFolder&amp;#46;isDirectory() &amp;&amp; destFolder&amp;#46;isDirectory();<br>        File&amp;#91;&amp;#93; files = srcFolder&amp;#46;listFiles();<br><br>        if (!destFolder&amp;#46;exists()) {<br>            destFolder&amp;#46;mkdir();<br>        }<br>        for (File file &amp;#58; files) {<br>            if (file&amp;#46;isFile()) { // make sure that file is no directory<br><br>                try {<br>                    EXIFRemover remover = new EXIFRemover(file);<br>                    File destFile = new File(destFolder&amp;#46;getAbsolutePath()<br>                            + FILE_SEPARATOR + file&amp;#46;getName());<br>                    remover&amp;#46;removeEXIFData(destFile);<br>                    System&amp;#46;out&amp;#46;println(\&quot;created file \&quot;<br>                            + destFile&amp;#46;getAbsolutePath());<br>                } catch (IOException e) {<br>                    System&amp;#46;err&amp;#46;println(\&quot;Can not convert or read file \&quot;<br>                            + file&amp;#46;getAbsolutePath());<br>                } catch (ImageReadException e) {<br>                    System&amp;#46;err&amp;#46;println(\&quot;Unable to remove EXIF data from \&quot;<br>                            + file&amp;#46;getAbsolutePath());<br>                } catch (ImageWriteException e) {<br>                    System&amp;#46;err&amp;#46;println(\&quot;Unable to remove EXIF data from \&quot;<br>                            + file&amp;#46;getAbsolutePath());<br>                }<br>            }<br>        }<br>    }<br><br>    /**<br>     * Initializes command line options like d, s, dest, help&amp;#46;<br>     *<br>     * <a rel="nofollow" href="/index.php?p=/profile/return">@return</a> initialized options<br>     */<br>    private Options initOptions() {<br>        Options options = new Options();<br><br>        options&amp;#46;addOption(\&quot;v\&quot;, \&quot;version\&quot;, false, \&quot;show version\&quot;);<br>        options&amp;#46;addOption(\&quot;h\&quot;, \&quot;help\&quot;, false, \&quot;print help message\&quot;);<br><br>        options&amp;#46;addOption(\&quot;s\&quot;, \&quot;show-exif\&quot;, true, \&quot;show exif data\&quot;);<br>        options&amp;#46;getOption(\&quot;s\&quot;)&amp;#46;setArgName(\&quot;filename\&quot;);<br><br>        options&amp;#46;addOption(\&quot;d\&quot;, \&quot;delete-exif\&quot;, true,<br>                \&quot;delete all exif data of given file(s)\&quot;);<br>        options&amp;#46;getOption(\&quot;d\&quot;)&amp;#46;setArgName(\&quot;filename\&quot;);<br><br>        options&amp;#46;addOption(\&quot;dest\&quot;, true, \&quot;save changed image(s) into file\&quot;);<br>        options&amp;#46;getOption(\&quot;dest\&quot;)&amp;#46;setArgName(\&quot;filename\&quot;);<br><br>        return options;<br>    }<br><br>}</pre></div>[/spoiler]<br><br><br>FileIO.java<br><br>[spoiler]<div class="PreContainer"><pre><br>import java&amp;#46;io&amp;#46;File;<br>import java&amp;#46;io&amp;#46;FileInputStream;<br>import java&amp;#46;io&amp;#46;IOException;<br><br>/**<br>* A helper class for file input and output&amp;#46;<br>*<br>* <a rel="nofollow" href="/index.php?p=/profile/author">@author</a> deque<br>*<br>*/<br>public class FileIO {<br><br>    /**<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> file<br>     *            file to get the bytes from<br>     * <a rel="nofollow" href="/index.php?p=/profile/return">@return</a> byte array that represents the given file<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> IOException<br>     */<br>    public static byte&amp;#91;&amp;#93; getBytesFromFile(File file) throws IOException {<br>        byte&amp;#91;&amp;#93; data = null;<br>        FileInputStream fileInputStream = null;<br>        try {<br>            fileInputStream = new FileInputStream(file);<br>            data = new byte&amp;#91;(int) file&amp;#46;length()&amp;#93;;<br>            fileInputStream&amp;#46;read(data);<br>        } finally {<br>            if (fileInputStream != null) {<br>                try {<br>                    fileInputStream&amp;#46;close();<br>                } catch (IOException e) {<br>                    e&amp;#46;printStackTrace();<br>                }<br>            }<br>        }<br>        return data;<br>    }<br><br>}<br></pre></div>[/spoiler]<br><br><br>EXIFRemover.java<br><br>[spoiler]<div class="PreContainer"><pre>import java&amp;#46;io&amp;#46;File;<br>import java&amp;#46;io&amp;#46;FileOutputStream;<br>import java&amp;#46;io&amp;#46;IOException;<br>import java&amp;#46;io&amp;#46;OutputStream;<br><br>import org&amp;#46;apache&amp;#46;sanselan&amp;#46;ImageReadException;<br>import org&amp;#46;apache&amp;#46;sanselan&amp;#46;ImageWriteException;<br>import org&amp;#46;apache&amp;#46;sanselan&amp;#46;Sanselan;<br>import org&amp;#46;apache&amp;#46;sanselan&amp;#46;common&amp;#46;IImageMetadata;<br>import org&amp;#46;apache&amp;#46;sanselan&amp;#46;formats&amp;#46;jpeg&amp;#46;exifRewrite&amp;#46;ExifRewriter;<br><br>import exifremover&amp;#46;exifremover&amp;#46;FileIO;<br><br>/**<br>* A class that utilizes the sanselan library to show or remove EXIF data<br>*<br>* <a rel="nofollow" href="/index.php?p=/profile/author">@author</a> deque<br>*<br>*/<br>public class EXIFRemover {<br><br>    private final File image;<br>    private final byte&amp;#91;&amp;#93; imageBytes;<br><br>    /**<br>     * Constructor&amp;#46; Retrieves image bytes from given image file&amp;#46;<br>     *<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> image<br>     *            file that shall be treated<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> IOException<br>     */<br>    public EXIFRemover(File image) throws IOException {<br>        this&amp;#46;image = image;<br>        imageBytes = FileIO&amp;#46;getBytesFromFile(image);<br>    }<br><br>    /**<br>     * <a rel="nofollow" href="/index.php?p=/profile/return">@return</a> String that describes the meta data of the given image file&amp;#46;<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> ImageReadException<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> IOException<br>     */<br>    public String getExifData() throws ImageReadException, IOException {<br>        IImageMetadata metdata = Sanselan&amp;#46;getMetadata(imageBytes);<br>        return metdata&amp;#46;toString();<br>    }<br><br>    /**<br>     * <a rel="nofollow" href="/index.php?p=/profile/return">@return</a> image file<br>     */<br>    public File getImageFile() {<br>        return image;<br>    }<br><br>    /**<br>     * Completely deletes EXIF data from the extracted image bytes&amp;#46; Saves the<br>     * resulting images bytes into the destination file&amp;#46;<br>     *<br>     * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> dest<br>     *            the destination file<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> ImageReadException<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> ImageWriteException<br>     * <a rel="nofollow" href="/index.php?p=/profile/throws">@throws</a> IOException<br>     */<br>    public void removeEXIFData(File dest) throws ImageReadException,<br>            ImageWriteException, IOException {<br>        OutputStream os = null;<br>        try {<br>            os = new FileOutputStream(dest);<br>            ExifRewriter exifWriter = new ExifRewriter();<br>            exifWriter&amp;#46;removeExifMetadata(imageBytes, os);<br>        } finally {<br>            if (os != null) {<br>                try {<br>                    os&amp;#46;close();<br>                } catch (IOException e) {<br>                    e&amp;#46;printStackTrace();<br>                }<br>            }<br>        }<br>    }<br><br>}</pre></div>[/spoiler]<br><br><br><b>LOC:</b> 213 lines (without comments and empty lines)<br><br><b>License:</b><br><br>[spoiler]<blockquote class="Quote"><div class="QuoteText">Copyright 2012 Deque at <a class="postlink" rel="nofollow" href="http://iexploit.org">http://iexploit.org</a> All rights reserved.<br><br>Redistribution and use in source and binary forms, with or without modification, are<br>permitted provided that the following conditions are met:<br><br>1. Redistributions of source code must retain the above copyright notice, this list of<br>conditions and the following disclaimer.<br><br>2. Redistributions in binary form must reproduce the above copyright notice, this list<br>of conditions and the following disclaimer in the documentation and/or other materials<br>provided with the distribution.<br><br>THIS SOFTWARE IS PROVIDED BY Deque at <a class="postlink" rel="nofollow" href="http://iexploit.org">http://iexploit.org</a> ``AS IS'' AND ANY EXPRESS OR IMPLIED<br>WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND<br>FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Deque at <a class="postlink" rel="nofollow" href="http://iexploit.org">http://iexploit.org</a> OR<br>CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br>CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR<br>SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON<br>ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING<br>NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF<br>ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br><br>The views and conclusions contained in the software and documentation are those of the<br>authors and should not be interpreted as representing official policies, either expressed<br>or implied, of Deque at <a class="postlink" rel="nofollow" href="http://iexploit.org">http://iexploit.org</a></div></blockquote>[/spoiler]<br><br><br>If you encounter any bugs or problems, please tell me.<br>If you want to improve this software, you are free to do so.<br><br>Features for future versions could be: GUI, filters for removal, EXIF editing<br><br>Deque]]></description>
   </item>
   <item>
      <title>Little brother of Paint</title>
      <link>http://iexploit.org/index.php?p=/discussion/5879/little-brother-of-paint</link>
      <pubDate>Tue, 20 Sep 2011 21:17:53 -0400</pubDate>
      <dc:creator>Deque</dc:creator>
      <guid isPermaLink="false">5879@/index.php?p=/discussions</guid>
      <description><![CDATA[Hi iExploit,<br><br>this little project is a nice way for beginners to learn graphics and OOP in Java. It can draw points, lines, circles and rectangles. You can choose an outline color and a filling color. You are also able to save your pictures and reload them into the program. That's it. However, the program itself it is not that useful, so I only load it up for learning purposes.<br><br>http&#58;//s7&#46;directupload&#46;net/images/110920/si5mspj7&#46;png<br><br>Download: <a class="postlink" rel="nofollow" href="http://www.mediafire.com/?zns9bqd0olq4bb4">http://www.mediafire.com/?zns9bqd0olq4bb4</a><br><br>Deque]]></description>
   </item>
   <item>
      <title>Drawing plants with Lindenmayer</title>
      <link>http://iexploit.org/index.php?p=/discussion/5689/drawing-plants-with-lindenmayer</link>
      <pubDate>Sun, 14 Aug 2011 14:10:24 -0400</pubDate>
      <dc:creator>Deque</dc:creator>
      <guid isPermaLink="false">5689@/index.php?p=/discussions</guid>
      <description><![CDATA[Hello guys,<br><br>the following is a little program that draws an l-system (or Lindenmayer system).<br>L-systems can be and are used to generate plants. It is nice to experiment a bit with the rules. Here is an example: <br><br>[spoiler]http&#58;//s1&#46;directupload&#46;net/images/110814/oug6qtee&#46;png[/spoiler]<br><br><br>You see on the right side how it works. There are two rules you can edit. Let's say the first rule is "A is replaced with AA". The second: "B is replaced with (B)A"<br>You specify how the program starts and the depth.<br><br>Now let's say you start with B. That means the program will draw a little line, because B is "forward". <br><br>In the next level B is replaced.<br>(B)A<br>That means we save the state and turn left ("("), go one line forward ("B"). Now there is a ")" which means we go back to the point where we started drawing B and we draw A.<br><br>Next level the string (B)A is replaced with<br>((B)A)AA<br>And so on.<br><br>Download: <a class="postlink" rel="nofollow" href="http://www.mediafire.com/?d5r7rxoda9cs5zf">http://www.mediafire.com/?d5r7rxoda9cs5zf</a><br>LOC: 291 (without empty lines and comments)<br><br>Deque]]></description>
   </item>
   <item>
      <title>[Java] Boids - swarm intelligence</title>
      <link>http://iexploit.org/index.php?p=/discussion/5669/java-boids-swarm-intelligence</link>
      <pubDate>Wed, 10 Aug 2011 19:01:04 -0400</pubDate>
      <dc:creator>Deque</dc:creator>
      <guid isPermaLink="false">5669@/index.php?p=/discussions</guid>
      <description><![CDATA[Hello guys,<br><br>Boids is a well known artificial life algorithm, developed by Craig Reynolds in 1986. It simulates the behaviour of swarms by three simple rules:<br>[list=1]<br>[*]separation: steer to avoid crowding local flockmates[/*:m]<br>[*]alignment: steer towards the average heading of local flockmates[/*:m]<br>[*]cohesion: steer to move toward the average position (center of mass) of local flockmates[/*:m][/list:o]<br>I made no pictures for the boids, just colored circles. So it looks a bit like flying confetti or bouncy balls. There are several possibilities to improve it farther and I know there are much better implementations out there, but once I got this working I have not much interest in improving it anymore. I stumbled over it reading AI Game Programming Wisdom and wanted to try it out since then. A challenge on poisonhack made me doing so.<br><br>Have a look here for a video preview: <a class="postlink" rel="nofollow" href="http://tinypic.com/r/246kwwl/7">http://tinypic.com/r/246kwwl/7</a><br>This sample is with a low flock radius. <br><br>Download: <a class="postlink" rel="nofollow" href="http://www.mediafire.com/?1qx9kafo59nd14c">http://www.mediafire.com/?1qx9kafo59nd14c</a><br><br>The program has some settings at startup. You can experiment a bit with them. <br><br><span style="color: #00FFFF;">number of boids:</span> should be clear<br><span style="color: #00FFFF;">velocity limit:</span> maximum speed<br><span style="color: #00FFFF;">radius limit:</span> the radius in which another boid is declared as too near, so the actual boid has to move away from it. <br><span style="color: #00FFFF;">speed reduction:</span> boids would be too fast without it. The higher the number, the lower the speed.<br><span style="color: #00FFFF;">flock radius:</span> the radius in which other boids are seen as of the same flock<br><br>Not every possible setting is reasonable. Have fun and maybe make a better one.<br><br>LOC: 504 only source<br>640 with comments and empty lines<br><br>Main algorithm:<br>[spoiler]<div class="PreContainer"><pre>package model;<br><br>import java&amp;#46;awt&amp;#46;Color;<br>import java&amp;#46;awt&amp;#46;Graphics;<br>import java&amp;#46;util&amp;#46;LinkedList;<br>import java&amp;#46;util&amp;#46;List;<br>import java&amp;#46;util&amp;#46;Random;<br><br>public class Boid {<br><br>	private static int boidNr;<br>	private final int panelWidth;<br>	private final int panelHeight;<br>	private Vector position;<br>	private Vector positionToDraw;<br>	private Vector velocity = new Vector(0, 0);<br>	private Color color;<br>	private final static List&amp;lt;Boid&amp;gt; boids = new LinkedList&amp;lt;Boid&amp;gt;();<br>	private static int updateSkip;<br>	private static int updates = 1;<br>	private static int velocityLimit;<br>	private static int radiusLimit;<br>	private static int flockRadius;<br><br>	public Boid(int pwidth, int pheight) {<br>		this&amp;#46;panelWidth = pwidth;<br>		this&amp;#46;panelHeight = pheight;<br>		setRandomPosition();<br>		setRandomColor();<br>	}<br><br>	public Boid(Boid boid) {<br>		this&amp;#46;panelWidth = boid&amp;#46;panelWidth;<br>		this&amp;#46;panelHeight = boid&amp;#46;panelHeight;<br>		this&amp;#46;position = new Vector(boid&amp;#46;position);<br>		this&amp;#46;positionToDraw = new Vector(boid&amp;#46;positionToDraw);<br>		this&amp;#46;velocity = new Vector(boid&amp;#46;velocity);<br>		this&amp;#46;color = boid&amp;#46;color;<br>	}<br><br>	public static void initBoids(int pwidth, int pheight) {<br>		for (int i = 0; i &amp;lt; boidNr; i++) {<br>			boids&amp;#46;add(new Boid(pwidth, pheight));<br>		}<br>	}<br><br>	public static void drawBoids(Graphics g) {<br>		for (Boid boid &amp;#58; boids) {<br>			boid&amp;#46;draw(g);<br>		}<br>	}<br><br>	public static void updateBoids() {<br>		updates++;<br>		if (updates == updateSkip) {<br>			updates = 1;<br>			for (Boid boid &amp;#58; boids) {<br>				boid&amp;#46;updateWithBounds();<br>			}<br>		}<br>		for (Boid boid &amp;#58; boids) {<br>			// makes the boids move slowlier<br>			boid&amp;#46;positionToDraw = new Vector(boid&amp;#46;position);<br>			boid&amp;#46;positionToDraw&amp;#46;subtract(boid&amp;#46;velocity);<br>			Vector ivel = new Vector(boid&amp;#46;velocity);<br>			ivel&amp;#46;multiply(updates / (double) updateSkip);<br>			boid&amp;#46;positionToDraw&amp;#46;add(ivel);<br>		}<br>	}<br><br>	private void setRandomPosition() {<br>		Random rand = new Random();<br>		position = new Vector();<br>		position&amp;#46;x = rand&amp;#46;nextInt(panelWidth);<br>		position&amp;#46;y = rand&amp;#46;nextInt(panelHeight);<br>	}<br><br>	private void draw(Graphics g) {<br>		g&amp;#46;setColor(color);<br>		g&amp;#46;fillOval((int) positionToDraw&amp;#46;x, (int) positionToDraw&amp;#46;y, 10, 10);<br>	}<br><br>	private void setRandomColor() {<br>		Random rand = new Random();<br>		this&amp;#46;color = new Color(rand&amp;#46;nextInt(256), rand&amp;#46;nextInt(256),<br>				rand&amp;#46;nextInt(256));<br>	}<br><br>	private void updateWithoutBounds() {<br>		velocity&amp;#46;add(rule1(), rule2(), rule3());<br>		limitVelocity();<br>		position&amp;#46;add(velocity);<br><br>		if (position&amp;#46;x &amp;gt; panelWidth) {<br>			position&amp;#46;x = 0;<br>		}<br>		if (position&amp;#46;x &amp;lt; 0) {<br>			position&amp;#46;x = panelWidth;<br>		}<br>		if (position&amp;#46;y &amp;gt; panelHeight) {<br>			position&amp;#46;y = 0;<br>		}<br>		if (position&amp;#46;y &amp;lt; 0) {<br>			position&amp;#46;y = panelHeight;<br>		}<br>	}<br><br>	private void updateWithBounds() {<br>		velocity&amp;#46;add(rule1(), rule2(), rule3());<br>		limitVelocity();<br>		position&amp;#46;add(velocity);<br><br>		if (position&amp;#46;x &amp;gt; panelWidth) {<br>			position&amp;#46;x = panelWidth;<br>			velocity&amp;#46;x = -velocity&amp;#46;x;<br>		}<br>		if (position&amp;#46;x &amp;lt; 0) {<br>			position&amp;#46;x = 0;<br>			velocity&amp;#46;x = -velocity&amp;#46;x;<br>		}<br>		if (position&amp;#46;y &amp;gt; panelHeight) {<br>			position&amp;#46;y = panelHeight;<br>			velocity&amp;#46;y = -velocity&amp;#46;y;<br>		}<br>		if (position&amp;#46;y &amp;lt; 0) {<br>			position&amp;#46;y = 0;<br>			velocity&amp;#46;y = -velocity&amp;#46;y;<br>		}<br>	}<br><br>	/**<br>	 * boids try to fly towards the centre of mass of neighbouring boids<br>	 * <br>	 * <a rel="nofollow" href="/index.php?p=/profile/return">@return</a> resulting vector<br>	 */<br>	private Vector rule1() {<br>		Vector center = new Vector(0, 0);<br>		List&amp;lt;Boid&amp;gt; flock = flock();<br>		for (Boid boid &amp;#58; flock) {<br>			if (!boid&amp;#46;equals(this)) {<br>				center&amp;#46;add(boid&amp;#46;position);<br>			}<br>		}<br>		center&amp;#46;divide(flock&amp;#46;size() - 1);<br>		Vector result = new Vector(center);<br>		result&amp;#46;subtract(this&amp;#46;position);<br>		result&amp;#46;divide(100);<br>		return result;<br>	}<br><br>	/**<br>	 * try to keep a small distance away from other objects<br>	 * <br>	 * <a rel="nofollow" href="/index.php?p=/profile/return">@return</a><br>	 */<br>	private Vector rule2() {<br>		Vector result = new Vector(0, 0);<br>		for (Boid boid &amp;#58; flock()) {<br>			if (!boid&amp;#46;equals(this)) {<br>				if (isClose(boid&amp;#46;position)) {<br>					Vector sub = new Vector(boid&amp;#46;position);<br>					sub&amp;#46;subtract(position);<br>					result&amp;#46;subtract(sub);<br>				}<br>			}<br>		}<br>		return result;<br>	}<br><br>	/**<br>	 * boids try to match velocity with near boids<br>	 * <br>	 * <a rel="nofollow" href="/index.php?p=/profile/return">@return</a><br>	 */<br>	private Vector rule3() {<br>		Vector pvj = new Vector(0, 0);<br>		List&amp;lt;Boid&amp;gt; flock = flock();<br>		for (Boid boid &amp;#58; flock) {<br>			if (!boid&amp;#46;equals(this)) {<br>				pvj&amp;#46;add(boid&amp;#46;velocity);<br>			}<br>		}<br>		pvj&amp;#46;divide(flock&amp;#46;size() - 1);<br>		pvj&amp;#46;subtract(velocity);<br>		pvj&amp;#46;divide(&amp;#58;);<br>		return pvj;<br>	}<br><br>	private void limitVelocity() {<br>		if (velocity&amp;#46;length() &amp;gt; velocityLimit) {<br>			velocity&amp;#46;divide(velocity&amp;#46;length());<br>			velocity&amp;#46;multiply(velocityLimit);<br>		}<br>	}<br><br>	public List&amp;lt;Boid&amp;gt; flock() {<br>		List&amp;lt;Boid&amp;gt; flock = new LinkedList&amp;lt;Boid&amp;gt;();<br>		for (Boid boid &amp;#58; boids) {<br>			if (isInFlock(boid&amp;#46;position)) {<br>				flock&amp;#46;add(boid);<br>			}<br>		}<br>		return flock;<br>	}<br><br>	private boolean isInFlock(final Vector pos) {<br>		Vector range = new Vector(position);<br>		range&amp;#46;subtract(pos);<br>		return range&amp;#46;length() &amp;lt; flockRadius;<br>	}<br><br>	private boolean isClose(final Vector pos) {<br>		Vector range = new Vector(position);<br>		range&amp;#46;subtract(pos);<br>		return range&amp;#46;length() &amp;lt; radiusLimit;<br>	}<br><br>	public static void setOptions(Options options) {<br>		velocityLimit = options&amp;#46;velocityLimit;<br>		radiusLimit = options&amp;#46;radiusLimit;<br>		boidNr = options&amp;#46;boidNr;<br>		updateSkip = options&amp;#46;speedReduction;<br>		flockRadius = options&amp;#46;flockRadius;<br>	}<br><br>}<br></pre></div>[/spoiler]<br><br>Deque]]></description>
   </item>
   <item>
      <title>[Java] CAna v0.5 a cryptography program</title>
      <link>http://iexploit.org/index.php?p=/discussion/2851/java-cana-v0-5-a-cryptography-program</link>
      <pubDate>Thu, 30 Jun 2011 22:19:42 -0400</pubDate>
      <dc:creator>Deque</dc:creator>
      <guid isPermaLink="false">2851@/index.php?p=/discussions</guid>
      <description><![CDATA[Hello iexploit,<br><br>since I have not worked on it in a while now I decided to release this. I took the time to write Javadocs everywhere. The eclipse project files are included, so you should be able to open the source there. (If someone prefers to use this with Maven, just tell)<br><br>Small Download: <a class="postlink" rel="nofollow" href="http://www.mediafire.com/?2so5042nr6h3ucf">http://www.mediafire.com/?2so5042nr6h3ucf</a><br><br>I used the FreeChart library to show a barchart in coincidence counting analysis which made my program pretty big. If you want the big one here it is, but I figured it is not worth it for one chart.<br>Big Download: <a class="postlink" rel="nofollow" href="http://www.2shared.com/file/nZt65vlE/CAnaWithFreechart.html">http://www.2shared.com/file/nZt65vlE/CA ... chart.html</a><br><br>Screenshot<br>[spoiler]http&#58;//s1&#46;directupload&#46;net/images/110602/8kutaxrf&#46;png[/spoiler]<br><br><br><span style="color: #00BFFF;">Ciphers:</span> including keysize options, key generation<br><br>[list]<br>[*]AES[/*:m]<br>[*]DES[/*:m]<br>[*]Triple DES[/*:m]<br>[*]ARCFOUR[/*:m]<br>[*]Blowfish[/*:m]<br>[*]RC2[/*:m]<br>[*]RC4[/*:m]<br>[*]Rijndael[/*:m]<br>[*]Shift Cipher[/*:m][/list:u]<br><br><span style="color: #00BFFF;">Analyses:</span><br><br>[list]<br>[*]Coincidence Counting[/*:m]<br>[*]Frequency Analyses (for A to Z and for arbitrary characters) [/*:m]<br>[*]Index of Coincidence [/*:m]<br>[*]Friedman Test[/*:m]<br>[*]Transposition Detection(for A to Z only)[/*:m][/list:u]<br><br><span style="color: #00BFFF;">Cracking Helpers:</span> not much by now but I want to extend this<br><br>[list]<br>[*]Replace Characters (with undo, redo)[/*:m]<br>[*]Get Ns Message (useful for cracking VigenÃ¨re)[/*:m]<br>[*]Shift Cipher crack (automatic cracking)[/*:m][/list:u]<br><br>If you get a message dialog on startupt that some ciphers are not available, please tell me (I need to test this). Thanks.<br>If anyone wants to contribute by adding more ciphers, cracks or analyses just tell me.<br><br><span style="color: #00BFFF;">LOC:</span> <br>1670 (only source)<br>2496 (includes 447 lines of comments and 379 empty lines)<br><br><span style="color: #00BFFF;">License:</span><br>[spoiler]<blockquote class="Quote"><div class="QuoteText">Copyright 2011 Deque at <a class="postlink" rel="nofollow" href="http://haxme.org/">http://haxme.org/</a>, <a class="postlink" rel="nofollow" href="http://www.iexploit.org/">http://www.iexploit.org/</a>, <a class="postlink" rel="nofollow" href="http://poisonhack.info/">http://poisonhack.info/</a>. All rights reserved.<br><br>Redistribution and use in source and binary forms, with or without modification, are<br>permitted provided that the following conditions are met:<br><br>1. Redistributions of source code must retain the above copyright notice, this list of<br>conditions and the following disclaimer.<br><br>2. Redistributions in binary form must reproduce the above copyright notice, this list<br>of conditions and the following disclaimer in the documentation and/or other materials<br>provided with the distribution.<br><br>THIS SOFTWARE IS PROVIDED BY Deque at <a class="postlink" rel="nofollow" href="http://haxme.org/">http://haxme.org/</a>, <a class="postlink" rel="nofollow" href="http://www.iexploit.org/">http://www.iexploit.org/</a>, <a class="postlink" rel="nofollow" href="http://poisonhack.info/">http://poisonhack.info/</a> ``AS IS'' AND ANY EXPRESS OR IMPLIED<br>WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND<br>FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Deque at <a class="postlink" rel="nofollow" href="http://haxme.org/">http://haxme.org/</a>, <a class="postlink" rel="nofollow" href="http://www.iexploit.org/">http://www.iexploit.org/</a>, <a class="postlink" rel="nofollow" href="http://poisonhack.info/">http://poisonhack.info/</a> OR<br>CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br>CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR<br>SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON<br>ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING<br>NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF<br>ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br><br>The views and conclusions contained in the software and documentation are those of the<br>authors and should not be interpreted as representing official policies, either expressed<br>or implied, of Deque at <a class="postlink" rel="nofollow" href="http://haxme.org/">http://haxme.org/</a>, <a class="postlink" rel="nofollow" href="http://www.iexploit.org/">http://www.iexploit.org/</a>, <a class="postlink" rel="nofollow" href="http://poisonhack.info/">http://poisonhack.info/</a>.</div></blockquote>[/spoiler]<br><br><br>Deque]]></description>
   </item>
   <item>
      <title>[Java] WikiWords Crawler v1.1</title>
      <link>http://iexploit.org/index.php?p=/discussion/2951/java-wikiwords-crawler-v1-1</link>
      <pubDate>Sat, 23 Jul 2011 16:36:22 -0400</pubDate>
      <dc:creator>Deque</dc:creator>
      <guid isPermaLink="false">2951@/index.php?p=/discussions</guid>
      <description><![CDATA[Hello iExploit.<br><br>Here is Release 1.1 of my WikiWords Crawler. This program allows you to create wordlists with real words that it finds in Wikipedia articles. The knowledge of what is a real world may help you in coding cipher-cracking-programs. It may also be used as a base for topic specific passwords.<br><br>Download: <a class="postlink" rel="nofollow" href="http://www.mediafire.com/?emql7r80gr6c16r">http://www.mediafire.com/?emql7r80gr6c16r</a><br><br>A startword is needed, e.g. "Room" (if you want words belonging to a specific topic just choose the appropriate startword). So the program gets all words that are used within the article "Room" and afterwards it uses all these words as searchwords in wikipedia and so on until you press the "Stop" button or the word maximum is reached.<br>The crawler eliminates duplicate words and also marks, if it already has used a word for searching.<br><br>http&#58;//s7&#46;directupload&#46;net/images/110430/lvp8899p&#46;png<br><br>The options should be self explaining (if not, just ask). You can also edit the URL e.g. to get words in another language.<br>I wish you fun. If you find any bugs or have suggestions, please tell me. <br><br><b>Lines of Code:</b> 520 without empty lines<br><br><b>License:</b><br>[spoiler]Copyright 2011 Deque at <a class="postlink" rel="nofollow" href="http://haxme.org">http://haxme.org</a>, <a class="postlink" rel="nofollow" href="http://www.iexploit.org/">http://www.iexploit.org/</a>. All rights reserved.<br><br>Redistribution and use in source and binary forms, with or without modification, are<br>permitted provided that the following conditions are met:<br><br>1. Redistributions of source code must retain the above copyright notice, this list of<br>conditions and the following disclaimer.<br><br>2. Redistributions in binary form must reproduce the above copyright notice, this list<br>of conditions and the following disclaimer in the documentation and/or other materials<br>provided with the distribution.<br><br>THIS SOFTWARE IS PROVIDED BY Deque at <a class="postlink" rel="nofollow" href="http://haxme.org">http://haxme.org</a>, <a class="postlink" rel="nofollow" href="http://www.iexploit.org/">http://www.iexploit.org/</a> ``AS IS'' AND ANY EXPRESS OR IMPLIED<br>WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND<br>FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Deque at <a class="postlink" rel="nofollow" href="http://haxme.org">http://haxme.org</a>, http:/ OR<br>CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br>CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR<br>SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON<br>ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING<br>NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF<br>ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br><br>The views and conclusions contained in the software and documentation are those of the<br>authors and should not be interpreted as representing official policies, either expressed<br>or implied, of Deque at <a class="postlink" rel="nofollow" href="http://haxme.org">http://haxme.org</a>, <a class="postlink" rel="nofollow" href="http://www.iexploit.org/">http://www.iexploit.org/</a>.[/spoiler]<br><br><br>Deque]]></description>
   </item>
   <item>
      <title>[Java] IRC Connection</title>
      <link>http://iexploit.org/index.php?p=/discussion/2836/java-irc-connection</link>
      <pubDate>Sat, 25 Jun 2011 17:44:03 -0400</pubDate>
      <dc:creator>GT3X</dc:creator>
      <guid isPermaLink="false">2836@/index.php?p=/discussions</guid>
      <description><![CDATA[nothing special just a simple IRC connection in java <br><div class="PreContainer"><pre><br>import java&amp;#46;io&amp;#46;*;<br>import java&amp;#46;net&amp;#46;*;<br><br>public class IRCConnection {<br><br>    private String tmp = null;<br>    private String nick = \&quot;Test5000\&quot;;<br>    private String channel = \&quot;#back2hack\&quot;;<br><br>    public void connectToIRC(String url, int port) {<br>        try {<br>            Socket sock = new Socket(url, port);<br>            BufferedReader br = new BufferedReader(new InputStreamReader(sock<br>                    &amp;#46;getInputStream()));<br>            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(sock<br>                    &amp;#46;getOutputStream()));<br><br>            // Connection shizzl<br>            bw&amp;#46;write(\&quot;NICK \&quot; + nick + \&quot;\r\n\&quot;);<br>            bw&amp;#46;write(\&quot;USER \&quot; + nick + \&quot; aaa bbb ccc\r\n\&quot;);<br><br>            // Ping Pong Shizzle<br><br>            while ((tmp = br&amp;#46;readLine()) != null) {<br>                System&amp;#46;out&amp;#46;println(tmp);<br>                if (tmp&amp;#46;startsWith(\&quot;PING \&quot;)) {<br>                    bw&amp;#46;write(\&quot;PONG \&quot; + tmp&amp;#46;substring(5) + \&quot;\r\n\&quot;);<br>                    bw&amp;#46;flush();<br>                }<br><br>                // 004 = erfolgreich connected<br>                if (tmp&amp;#46;indexOf(\&quot;004\&quot;) &amp;gt;= 0) {<br>                    break;<br>                }<br>                // Falls nick schon in use is<br>                else if (tmp&amp;#46;indexOf(\&quot;433\&quot;) &amp;gt;= 0) {<br>                    System&amp;#46;out&amp;#46;println(\&quot;Nickname already in use\&quot;);<br>                    return;<br>                }<br><br>            }<br><br>            // join channel<br><br>            bw&amp;#46;write(\&quot;JOIN \&quot; + channel + \&quot;\r\n\&quot;);<br>            bw&amp;#46;write(\&quot;PRIVMSG \&quot; + channel + \&quot; &amp;#58;blaaa\r\n\&quot;);<br>            bw&amp;#46;flush();<br><br>            // chat weiterhin einlesen<br>            while ((tmp = br&amp;#46;readLine()) != null) {<br>                System&amp;#46;out&amp;#46;println(tmp);<br>                // antworten auf bla<br>                if ((tmp&amp;#46;contains(\&quot;PRIVMSG\&quot;))) {<br>                    if ((tmp&amp;#46;contains(\&quot;bla\&quot;))) {<br>                        bw&amp;#46;write(\&quot;PRIVMSG \&quot; + channel + \&quot; &amp;#58;blaaaaaaa\r\n\&quot;);<br>                    }<br>                }<br>                // Still looking for ping pong shizzle<br>                else if (tmp&amp;#46;startsWith(\&quot;PING \&quot;)) {<br>                    bw&amp;#46;write(\&quot;PONG \&quot; + tmp&amp;#46;substring(5) + \&quot;\r\n\&quot;);<br>                    bw&amp;#46;flush();<br>                }<br><br>            }<br><br>        } catch (UnknownHostException e) {<br>            System&amp;#46;out&amp;#46;println(\&quot;host fail\&quot;);<br>        } catch (IOException e) {<br><br>        }<br>    }<br><br>    public static void main(String&amp;#91;&amp;#93; args) {<br>        new IRCConnection()&amp;#46;connectToIRC(\&quot;irc&amp;#46;freenode&amp;#46;org\&quot;, 6667);<br>    }<br><br>}<br></pre></div>]]></description>
   </item>
   <item>
      <title>[Java] ImageSteg V0.2, hide one image within another</title>
      <link>http://iexploit.org/index.php?p=/discussion/2823/java-imagesteg-v0-2-hide-one-image-within-another</link>
      <pubDate>Wed, 22 Jun 2011 10:57:50 -0400</pubDate>
      <dc:creator>Deque</dc:creator>
      <guid isPermaLink="false">2823@/index.php?p=/discussions</guid>
      <description><![CDATA[Hello guys,<br><br>I made a little steganography program. It uses the last 2-4 bits of every pixelcolor to save one image in another. Because the information is in the least significant bits you can't see the hidden image with the eye. <br><br>Of course the image quality suffers since some bits are lost in both pictures. Depending on the quality you choose in the program either the hidden image looks good and the image you see looks bad (good quality setting) or the other way around (bad quality setting). Once you have prepared an image, you can reveal the hidden image again. You have to choose the same quality option for extraction that has done the hiding, otherwise you will get whoosh.<br><br><b>Screenshot:</b><br>[spoiler]http&#58;//s7&#46;directupload&#46;net/images/110620/bsa9epnd&#46;png[/spoiler]<br><br><br><b>The main algorithm (excerpt):</b><br>[spoiler]<br><div class="PreContainer"><pre>package control;<br><br>import gui&amp;#46;MainFrame;<br><br>import java&amp;#46;awt&amp;#46;Color;<br>import java&amp;#46;awt&amp;#46;Graphics2D;<br>import java&amp;#46;awt&amp;#46;RenderingHints;<br>import java&amp;#46;awt&amp;#46;Transparency;<br>import java&amp;#46;awt&amp;#46;image&amp;#46;BufferedImage;<br>import java&amp;#46;io&amp;#46;IOException;<br>import java&amp;#46;lang&amp;#46;reflect&amp;#46;InvocationTargetException;<br><br>import javax&amp;#46;swing&amp;#46;SwingUtilities;<br><br>public class ImageSteno {<br><br>	public static final int ALPHA = 0;<br>	public static final int RED = 1;<br>	public static final int GREEN = 2;<br>	public static final int BLUE = 3;<br><br>	private BufferedImage mask;<br>	private BufferedImage toHide;<br>	private BufferedImage toExtract;<br><br>	private Quality quality = Quality&amp;#46;GOOD;<br><br>	public static void main(String&amp;#91;&amp;#93; args) throws IOException {<br><br>		try {<br>			SwingUtilities&amp;#46;invokeAndWait(new Runnable() {<br>				<a rel="nofollow" href="/index.php?p=/profile/Override">@Override</a><br>				public void run() {<br>					new MainFrame();<br>				}<br>			});<br>		} catch (InterruptedException e) {<br>			e&amp;#46;printStackTrace();<br>		} catch (InvocationTargetException e) {<br>			e&amp;#46;printStackTrace();<br>		}<br>	}<br><br>	public void setQuality(Quality quality) {<br>		this&amp;#46;quality = quality;<br>	}<br><br>	public BufferedImage extractHiddenImage() throws NoImageException {<br>		if (toExtract == null) {<br>			throw new NoImageException();<br>		}<br>		return extractHiddenImage(toExtract);<br>	}<br><br>	public BufferedImage extractHiddenImage(BufferedImage img) {<br>		BufferedImage imgCopy = copyImage(img);<br>		for (int x = 0; x &amp;lt; imgCopy&amp;#46;getWidth(); x++) {<br>			for (int y = 0; y &amp;lt; imgCopy&amp;#46;getHeight(); y++) {<br>				int rgb = imgCopy&amp;#46;getRGB(x, y);<br>				rgb = extractRGB(rgb);<br>				imgCopy&amp;#46;setRGB(x, y, rgb);<br>			}<br>		}<br>		return imgCopy;<br>	}<br><br>	public static BufferedImage copyImage(BufferedImage image) {<br>		BufferedImage destImage = new BufferedImage(image&amp;#46;getWidth(),<br>				image&amp;#46;getHeight(), BufferedImage&amp;#46;TYPE_INT_ARGB);<br><br>		Graphics2D g = destImage&amp;#46;createGraphics();<br>		g&amp;#46;drawImage(image, null, 0, 0);<br>		g&amp;#46;dispose();<br>		return destImage;<br>	}<br><br>	public BufferedImage hideImage() throws NoImageException {<br>		if (mask == null || toHide == null) {<br>			throw new NoImageException();<br>		}<br>		BufferedImage maskCopy = getScaledInstance(copyImage(mask),<br>				toHide&amp;#46;getWidth(), toHide&amp;#46;getHeight(),<br>				RenderingHints&amp;#46;VALUE_INTERPOLATION_BICUBIC, false);<br><br>		for (int x = 0; x &amp;lt; toHide&amp;#46;getWidth(); x++) {<br>			for (int y = 0; y &amp;lt; toHide&amp;#46;getHeight(); y++) {<br>				int destRGB = toHide&amp;#46;getRGB(x, y);<br>				int oldRGB = maskCopy&amp;#46;getRGB(x, y);<br>				int newRGB = computeNewRGB(oldRGB, destRGB);<br>				maskCopy&amp;#46;setRGB(x, y, newRGB);<br>			}<br>		}<br>		return maskCopy;<br>	}<br><br>	private int extractRGB(int rgb) {<br>		int&amp;#91;&amp;#93; rgbArr = getRGBArray(rgb);<br>		for (int i = 1; i &amp;lt;= 3; i++) {<br>			rgbArr&amp;#91;i&amp;#93; = rgbArr&amp;#91;i&amp;#93; &amp; quality&amp;#46;leastBitsSum;<br>			rgbArr&amp;#91;i&amp;#93; = rgbArr&amp;#91;i&amp;#93; &amp;lt;&amp;lt; quality&amp;#46;shift;<br>		}<br>		return getRGBFromArray(rgbArr);<br>	}<br><br>	private int computeNewRGB(int oldRGB, int destRGB) {<br>		int&amp;#91;&amp;#93; dest = getRGBArray(destRGB);<br>		int&amp;#91;&amp;#93; old = getRGBArray(oldRGB);<br>		for (int i = 1; i &amp;lt;= 3; i++) {<br>			old&amp;#91;i&amp;#93; = old&amp;#91;i&amp;#93; &amp; quality&amp;#46;cuttingMask;<br>			dest&amp;#91;i&amp;#93; = dest&amp;#91;i&amp;#93; &amp;gt;&amp;gt; quality&amp;#46;shift;<br>			old&amp;#91;i&amp;#93; += dest&amp;#91;i&amp;#93;;<br>		}<br>		return getRGBFromArray(old);<br>	}<br><br>	private int getRGBFromArray(int&amp;#91;&amp;#93; rgbArr) {<br>		return new Color(rgbArr&amp;#91;RED&amp;#93;, rgbArr&amp;#91;GREEN&amp;#93;, rgbArr&amp;#91;BLUE&amp;#93;)&amp;#46;getRGB();<br>	}<br><br>	private int&amp;#91;&amp;#93; getRGBArray(int rgb) {<br>		return new int&amp;#91;&amp;#93; { (rgb &amp;gt;&amp;gt; 24) &amp; 0xff, (rgb &amp;gt;&amp;gt; 16) &amp; 0xff,<br>				(rgb &amp;gt;&amp;gt; 8) &amp; 0xff, rgb &amp; 0xff };<br>	}<br>}<br><br>public enum Quality {<br>	<br>	GOOD(4), MEDIUM(3), BAD(2);<br>	<br>	public int leastBitsSum;<br>	public int shift;<br>	public int cuttingMask;<br>	<br>	private Quality(int bits){<br>		computeLeastBitsSum(bits);<br>		computeCuttingMask(bits);<br>		computeShift(bits);<br>	}<br><br>	private void computeShift(int bits) {<br>		shift = 8 - bits;<br>	}<br><br>	private void computeLeastBitsSum(int bits) {<br>		leastBitsSum = 0;<br>		for(int i = 0; i &amp;lt; bits; i++){<br>			leastBitsSum += Math&amp;#46;pow(2, i);<br>		}<br>	}<br><br>	private void computeCuttingMask(int bits) {<br>		cuttingMask = 255 - leastBitsSum;<br>	}<br>}</pre></div><br>[/spoiler]<br><br><br><b>LOC: </b><br>600 without empty lines and comments<br>733 with empty lines and comments<br><br><b>License:</b><br>[spoiler]<blockquote class="Quote"><div class="QuoteText">Copyright 2011 Deque at <a class="postlink" rel="nofollow" href="http://haxme.org">http://haxme.org</a>, <a class="postlink" rel="nofollow" href="http://poisonhack.info/">http://poisonhack.info/</a>, <a class="postlink" rel="nofollow" href="http://www.iexploit.org/">http://www.iexploit.org/</a>. All rights reserved.<br><br>Redistribution and use in source and binary forms, with or without modification, are<br>permitted provided that the following conditions are met:<br><br>1. Redistributions of source code must retain the above copyright notice, this list of<br>conditions and the following disclaimer.<br><br>2. Redistributions in binary form must reproduce the above copyright notice, this list<br>of conditions and the following disclaimer in the documentation and/or other materials<br>provided with the distribution.<br><br>THIS SOFTWARE IS PROVIDED BY Deque at <a class="postlink" rel="nofollow" href="http://haxme.org">http://haxme.org</a>, <a class="postlink" rel="nofollow" href="http://poisonhack.info/">http://poisonhack.info/</a>, <a class="postlink" rel="nofollow" href="http://www.iexploit.org/">http://www.iexploit.org/</a> ``AS IS'' AND ANY EXPRESS OR IMPLIED<br>WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND<br>FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL &lt;COPYRIGHT HOLDER&gt; OR<br>CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br>CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR<br>SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON<br>ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING<br>NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF<br>ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br><br>The views and conclusions contained in the software and documentation are those of the<br>authors and should not be interpreted as representing official policies, either expressed<br>or implied, of Deque at <a class="postlink" rel="nofollow" href="http://haxme.org">http://haxme.org</a>, <a class="postlink" rel="nofollow" href="http://poisonhack.info">http://poisonhack.info</a>, <a class="postlink" rel="nofollow" href="http://www.iexploit.org//">http://www.iexploit.org//</a>.</div></blockquote>[/spoiler]<br><br><br>Have fun.<br><br>Deque<br><br>Download: <a class="postlink" rel="nofollow" href="http://www.mediafire.com/?na7d13i32gc7981">http://www.mediafire.com/?na7d13i32gc7981</a>]]></description>
   </item>
   <item>
      <title>[Java] Persisting Objects</title>
      <link>http://iexploit.org/index.php?p=/discussion/2824/java-persisting-objects</link>
      <pubDate>Wed, 22 Jun 2011 15:53:13 -0400</pubDate>
      <dc:creator>Deque</dc:creator>
      <guid isPermaLink="false">2824@/index.php?p=/discussions</guid>
      <description><![CDATA[<span><span style="color: #1E90FF;"><b>Persisting Objects</b></span></span><br><br>This tutorial shows you three approaches to persist objects in Java without using a database. Persistence means you save the objects in way that they outlive the program that created them. <br><br>At first you should know how to do a simple FileIO with Strings. This is a correct way:<br><br>[spoiler]<div class="PreContainer"><pre>import java&amp;#46;io&amp;#46;BufferedReader;<br>import java&amp;#46;io&amp;#46;BufferedWriter;<br>import java&amp;#46;io&amp;#46;DataInputStream;<br>import java&amp;#46;io&amp;#46;FileInputStream;<br>import java&amp;#46;io&amp;#46;FileNotFoundException;<br>import java&amp;#46;io&amp;#46;FileWriter;<br>import java&amp;#46;io&amp;#46;IOException;<br>import java&amp;#46;io&amp;#46;InputStreamReader;<br><br>public class FileIO {<br><br>	public static void main(String&amp;#91;&amp;#93; args) {<br>		writeFile(\&quot;test&amp;#46;txt\&quot;);<br>		readFile(\&quot;test&amp;#46;txt\&quot;);<br>	}<br><br>	/**<br>	 * reads a given textfile and prints it out<br>	 * <br>	 * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> filename<br>	 */<br>	public static void readFile(String filename) {<br>		FileInputStream fin = null;<br>		DataInputStream din = null;<br>		try {<br>			fin = new FileInputStream(filename);<br>			din = new DataInputStream(fin);<br>			BufferedReader reader = new BufferedReader(new InputStreamReader(<br>					din));<br>			String line;<br><br>			while ((line = reader&amp;#46;readLine()) != null) { // read line by line<br>				System&amp;#46;out&amp;#46;println(line); // print the content<br>			}<br>		} catch (FileNotFoundException e) {<br>			System&amp;#46;err&amp;#46;println(\&quot;File \&quot; + filename + \&quot; not found\&quot;);<br>		} catch (IOException e) {<br>			e&amp;#46;printStackTrace();<br>		} finally {<br>			try {<br>				if (fin != null) {<br>					fin&amp;#46;close();<br>				}<br>				if (din != null) {<br>					din&amp;#46;close(); // always close your streams within finally<br>				}<br>			} catch (IOException e) {<br>				e&amp;#46;printStackTrace();<br>			}<br>		}<br>	}<br><br>	/**<br>	 * writes \&quot;Hello World\&quot; into a textfile<br>	 * <br>	 * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> filename<br>	 */<br>	public static void writeFile(String filename) {<br>		FileWriter writer = null;<br>		BufferedWriter out = null;<br>		try {<br>			writer = new FileWriter(filename);<br>			out = new BufferedWriter(writer);<br>			out&amp;#46;write(\&quot;Hello World\&quot;);<br>		} catch (IOException e) {<br>			e&amp;#46;printStackTrace();<br>		} finally {<br>			try {<br>                                if (out != null) {<br>					out&amp;#46;close();<br>				}<br>				if (writer != null) { <br>					writer&amp;#46;close();<br>				}<br>			} catch (IOException e) {<br>				e&amp;#46;printStackTrace();<br>			}<br>		}<br>	}<br>}<br></pre></div> [/spoiler]<br><br>This code writes Hello World into a textfile named "test.txt" and afterwards reads the file and prints its content on your console. Please make sure to close your streams correctly. There are so many wrong samples you will find with google. Streams have to be closed within finally to make sure it is also done after an exception occured. It is ugly to have another try-catch nested in the finally clause, but necessary.<br><br>Now you want to save an object in a file. This object may look like this:<br><br><div class="PreContainer"><pre><br>public class Person {<br>	<br>	private String name;<br>	private int age;<br>	<br>	public Person(String name, int age) {<br>		this&amp;#46;name = name;<br>		this&amp;#46;age = age;<br>	}<br>	<br>	public void setName(String name) {<br>		this&amp;#46;name = name;<br>	}<br>	public String getName() {<br>		return name;<br>	}<br>	public void setAge(int age) {<br>		this&amp;#46;age = age;<br>	}<br>	public int getAge() {<br>		return age;<br>	}<br>}</pre></div> <br><br><span><b><br>1. Customize the common file writing methods</b></span><br><br>Your first approach may be to write a textfile like this:<br><div class="PreContainer"><pre>name&amp;#58;Peter<br>age&amp;#58;12</pre></div><br><br>You have to change the above FileIO methods for doing this.<br><br>Get a system independend newline at first, because "\n" won't work on every system:<br><br><div class="PreContainer"><pre>public static String newline = System&amp;#46;getProperty(\&quot;line&amp;#46;separator\&quot;);</pre></div><br><br>Change writeFile line 64 to this:<br><br><div class="PreContainer"><pre>out&amp;#46;write(\&quot;name&amp;#58;\&quot; + person&amp;#46;getName() + newline + \&quot;age&amp;#58;\&quot;<br>					+ person&amp;#46;getAge());</pre></div><br><br>Reading is more complicated. We have to identify the attributes by their names ("name" and "age") and afterwards get the value after ":". The method split(":") returns an array with the Strings which are splitted by ":".<br><br><div class="PreContainer"><pre>String name = null; //initialize variables for the Person attributes<br>Integer age = null;<br>try {<br>	fin = new FileInputStream(filename);<br>	din = new DataInputStream(fin);<br>	BufferedReader reader = new BufferedReader(new InputStreamReader(din));<br>	String line;<br>	while ((line = reader&amp;#46;readLine()) != null) { <br>		String&amp;#91;&amp;#93; attributes = line&amp;#46;split(\&quot;&amp;#58;\&quot;); //split the line<br>		if(attributes != null &amp;&amp; attributes&amp;#46;length == 2){ //make sure not to go over bounds <br>                                                                      //there may be an empty line<br>			if(attributes&amp;#91;0&amp;#93;&amp;#46;equals(\&quot;name\&quot;)){ //get name attribute<br>				name = attributes&amp;#91;1&amp;#93;;<br>			}<br>			if(attributes&amp;#91;0&amp;#93;&amp;#46;equals(\&quot;age\&quot;)){ //get age attribute<br>				age = Integer&amp;#46;parseInt(attributes&amp;#91;1&amp;#93;);<br>			}<br>		}<br>	}<br>	return new Person(name, age); //return the new person object<br></pre></div><br><br>Here is the whole code again:<br><br>[spoiler]<div class="PreContainer"><pre>import java&amp;#46;io&amp;#46;BufferedReader;<br>import java&amp;#46;io&amp;#46;BufferedWriter;<br>import java&amp;#46;io&amp;#46;DataInputStream;<br>import java&amp;#46;io&amp;#46;FileInputStream;<br>import java&amp;#46;io&amp;#46;FileNotFoundException;<br>import java&amp;#46;io&amp;#46;FileWriter;<br>import java&amp;#46;io&amp;#46;IOException;<br>import java&amp;#46;io&amp;#46;InputStreamReader;<br><br>public class FileIO {<br><br>	public static String newline = System&amp;#46;getProperty(\&quot;line&amp;#46;separator\&quot;);<br><br>	public static void main(String&amp;#91;&amp;#93; args) {<br>		Person peter = new Person(\&quot;Peter\&quot;, 12);<br>		writeFile(\&quot;peter&amp;#46;txt\&quot;, peter);<br>		Person readPerson = readFile(\&quot;peter&amp;#46;txt\&quot;);<br>		System&amp;#46;out&amp;#46;println(\&quot;Persons name&amp;#58; \&quot; + readPerson&amp;#46;getName());<br>		System&amp;#46;out&amp;#46;println(\&quot;Persons age&amp;#58; \&quot; + readPerson&amp;#46;getAge());<br>	}<br><br>	/**<br>	 * reads a given textfile and prints it out<br>	 * <br>	 * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> filename<br>	 */<br>	public static Person readFile(String filename) {<br>		FileInputStream fin = null;<br>		DataInputStream din = null;<br>		String name = null;<br>		Integer age = null;<br>		try {<br>			fin = new FileInputStream(filename);<br>			din = new DataInputStream(fin);<br>			BufferedReader reader = new BufferedReader(new InputStreamReader(<br>					din));<br>			String line;<br>			while ((line = reader&amp;#46;readLine()) != null) { <br>				String&amp;#91;&amp;#93; attributes = line&amp;#46;split(\&quot;&amp;#58;\&quot;);<br>				if(attributes != null &amp;&amp; attributes&amp;#46;length == 2){<br>					if(attributes&amp;#91;0&amp;#93;&amp;#46;equals(\&quot;name\&quot;)){<br>						name = attributes&amp;#91;1&amp;#93;;<br>					}<br>					if(attributes&amp;#91;0&amp;#93;&amp;#46;equals(\&quot;age\&quot;)){<br>						age = Integer&amp;#46;parseInt(attributes&amp;#91;1&amp;#93;);<br>					}<br>				}<br>			}<br>			return new Person(name, age);<br>		} catch (FileNotFoundException e) {<br>			System&amp;#46;err&amp;#46;println(\&quot;File \&quot; + filename + \&quot; not found\&quot;);<br>		} catch (IOException e) {<br>			e&amp;#46;printStackTrace();<br>		} catch (NumberFormatException e){<br>			System&amp;#46;err&amp;#46;println(\&quot;Value after age was no number\&quot;);<br>		} finally {<br>			try {<br>				if (fin != null) {<br>					fin&amp;#46;close();<br>				}<br>				if (din != null) {<br>					din&amp;#46;close(); // always close your streams within finally<br>				}<br>			} catch (IOException e) {<br>				e&amp;#46;printStackTrace();<br>			}<br>		}<br>		return null;<br>	}<br><br>	/**<br>	 * writes \&quot;Hello World\&quot; into a textfile<br>	 * <br>	 * <a rel="nofollow" href="/index.php?p=/profile/param">@param</a> filename<br>	 */<br>	public static void writeFile(String filename, Person person) {<br>		FileWriter writer = null;<br>		BufferedWriter out = null;<br>		try {<br>			writer = new FileWriter(filename);<br>			out = new BufferedWriter(writer);<br>			out&amp;#46;write(\&quot;name&amp;#58;\&quot; + person&amp;#46;getName() + newline + \&quot;age&amp;#58;\&quot;<br>					+ person&amp;#46;getAge());<br>		} catch (IOException e) {<br>			e&amp;#46;printStackTrace();<br>		} finally {<br>			try {<br>				if (out != null) {<br>					out&amp;#46;close();<br>				}<br>				if (writer != null) {<br>					writer&amp;#46;close();<br>				}<br>			} catch (IOException e) {<br>				e&amp;#46;printStackTrace();<br>			}<br>		}<br>	}<br>}</pre></div>[/spoiler]<br><br>Now imagine you want to persist more Objects. You have to code new methods to do this for every Object you want to persist. You also have to change your methods if you extend or change the Person class. This is a pain in the ass.<br>But there is a simpler approach.<br><br><span><b>2. Use ObjectStreams</b></span><br><br>At first implement the Serializable Interface for Person:<br><br><div class="PreContainer"><pre>public class Person implements Serializable {</pre></div><br><br>Now look at those methods:<br><br>[spoiler]<div class="PreContainer"><pre>import java&amp;#46;io&amp;#46;BufferedReader;<br>import java&amp;#46;io&amp;#46;BufferedWriter;<br>import java&amp;#46;io&amp;#46;DataInputStream;<br>import java&amp;#46;io&amp;#46;FileInputStream;<br>import java&amp;#46;io&amp;#46;FileNotFoundException;<br>import java&amp;#46;io&amp;#46;FileOutputStream;<br>import java&amp;#46;io&amp;#46;FileWriter;<br>import java&amp;#46;io&amp;#46;IOException;<br>import java&amp;#46;io&amp;#46;InputStream;<br>import java&amp;#46;io&amp;#46;InputStreamReader;<br>import java&amp;#46;io&amp;#46;ObjectInput;<br>import java&amp;#46;io&amp;#46;ObjectInputStream;<br>import java&amp;#46;io&amp;#46;ObjectOutputStream;<br><br>public class FileIO {<br><br>	public static String newline = System&amp;#46;getProperty(\&quot;line&amp;#46;separator\&quot;);<br><br>	public static void main(String&amp;#91;&amp;#93; args) {<br>		Person peter = new Person(\&quot;Peter\&quot;, 12);<br>		writeFileByObjectStream(\&quot;peter&amp;#46;txt\&quot;, peter);<br>		Object obj = readFileByObjectStream(\&quot;peter&amp;#46;txt\&quot;);<br>		if (obj instanceof Person) { //do a save typecast<br>			Person person = (Person) obj;<br>			System&amp;#46;out&amp;#46;println(\&quot;Persons name&amp;#58; \&quot; + person&amp;#46;getName());<br>			System&amp;#46;out&amp;#46;println(\&quot;Persons age&amp;#58; \&quot; + person&amp;#46;getAge());<br>		}<br>	}<br><br>	public static void writeFileByObjectStream(String filename, Object object) {<br>		ObjectOutputStream oos = null;<br>		FileOutputStream fos = null;<br>		try {<br>			fos = new FileOutputStream(filename);<br>			oos = new ObjectOutputStream(fos);<br><br>			oos&amp;#46;writeObject(object);<br>		} catch (FileNotFoundException e) {<br>			e&amp;#46;printStackTrace();<br>		} catch (IOException e) {<br>			e&amp;#46;printStackTrace();<br>		} finally {<br>			try {<br>				if (oos != null) {<br>					oos&amp;#46;close();<br>				}<br>				if (fos != null) {<br>					fos&amp;#46;close();<br>				}<br>			} catch (IOException e) {<br>				e&amp;#46;printStackTrace();<br>			}<br>		}<br>	}<br><br>	public static Object readFileByObjectStream(String filename) {<br>		Object obj = null;<br>		ObjectInput in = null;<br>		InputStream fis = null;<br>		try {<br>			fis = new FileInputStream(filename);<br>			in = new ObjectInputStream(fis);<br>			obj = in&amp;#46;readObject();<br><br>		} catch (FileNotFoundException e) {<br>			e&amp;#46;printStackTrace();<br>		} catch (IOException e) {<br>			e&amp;#46;printStackTrace();<br>		} catch (ClassNotFoundException e) {<br>			e&amp;#46;printStackTrace();<br>		} finally {<br>			try {<br>				if (in != null) {<br>					in&amp;#46;close();<br>				}<br>				if (fis != null) {<br>					fis&amp;#46;close();<br>				}<br>			} catch (IOException e) {<br>				e&amp;#46;printStackTrace();<br>			}<br>		}<br>		return obj;<br>	}<br>}</pre></div>[/spoiler]<br><br>It doesn't matter anymore what kind of object it is. You can read or write anything you want, just implement Serializable. There is just one big disadvantage. This solution is only suitable for temporary files. If you make a program and save important files like this which are not temporary and you change your program sometime later and compile it again, it possibly won't work with the old files.<br><br>What now?<br><br><span><b>3. Use XML</b></span><br><br>A nice and easy way to do this is using xstream. This is a library you have to download and add xstream.jar and xpp-min.jar to your project first. You find it here: <a class="postlink" rel="nofollow" href="http://xstream.codehaus.org/">http://xstream.codehaus.org/</a><br><br>Our code:<br>[spoiler]<div class="PreContainer"><pre>import java&amp;#46;io&amp;#46;BufferedReader;<br>import java&amp;#46;io&amp;#46;BufferedWriter;<br>import java&amp;#46;io&amp;#46;DataInputStream;<br>import java&amp;#46;io&amp;#46;FileInputStream;<br>import java&amp;#46;io&amp;#46;FileNotFoundException;<br>import java&amp;#46;io&amp;#46;FileOutputStream;<br>import java&amp;#46;io&amp;#46;FileReader;<br>import java&amp;#46;io&amp;#46;FileWriter;<br>import java&amp;#46;io&amp;#46;IOException;<br>import java&amp;#46;io&amp;#46;InputStream;<br>import java&amp;#46;io&amp;#46;InputStreamReader;<br>import java&amp;#46;io&amp;#46;ObjectInput;<br>import java&amp;#46;io&amp;#46;ObjectInputStream;<br>import java&amp;#46;io&amp;#46;ObjectOutputStream;<br><br>import com&amp;#46;thoughtworks&amp;#46;xstream&amp;#46;XStream;<br><br>public class FileIO {<br><br>	public static String newline = System&amp;#46;getProperty(\&quot;line&amp;#46;separator\&quot;);<br><br>	public static void main(String&amp;#91;&amp;#93; args) {<br>		Person peter = new Person(\&quot;Peter\&quot;, 12);<br>		writeXML(\&quot;peter&amp;#46;txt\&quot;, peter);<br>		Object obj = readXML(\&quot;peter&amp;#46;txt\&quot;);<br>		if (obj instanceof Person) {<br>			Person person = (Person) obj;<br>			System&amp;#46;out&amp;#46;println(\&quot;Persons name&amp;#58; \&quot; + person&amp;#46;getName());<br>			System&amp;#46;out&amp;#46;println(\&quot;Persons age&amp;#58; \&quot; + person&amp;#46;getAge());<br>		}<br>	}<br>	<br>	public static void writeXML(String filename, Object object) {<br>		XStream xstream = new XStream();<br>		FileWriter writer = null;<br><br>		try {<br>			writer = new FileWriter(filename);<br>			xstream&amp;#46;toXML(object, writer);<br><br>		} catch (IOException e) {<br>			e&amp;#46;printStackTrace();<br>		} finally {<br>			try {<br>				if (writer != null) {<br>					writer&amp;#46;close();<br>				}<br>			} catch (IOException e) {<br>				e&amp;#46;printStackTrace();<br>			}<br>		}<br>	}<br><br>	public static Object readXML(String filename) {<br>		FileReader reader = null;<br>		Object obj = null;<br><br>		try {<br>			reader = new FileReader(filename);<br>			XStream xstream = new XStream();<br>			obj = xstream&amp;#46;fromXML(reader);<br>		} catch (FileNotFoundException e) {<br>			e&amp;#46;printStackTrace();<br>		} finally {<br>			try {<br>				if (reader != null) {<br>					reader&amp;#46;close();<br>				}<br>			} catch (IOException e) {<br>				e&amp;#46;printStackTrace();<br>			}<br>		}<br><br>		return obj;<br>	}<br>}<br></pre></div>[/spoiler]<br><br>This is in my opinion the best solution for saving objects in non-temporary files. <br><br>Here is the whole code with all methods from today to persist objects:<br>[spoiler]<div class="PreContainer"><pre>import java&amp;#46;io&amp;#46;BufferedReader;<br>import java&amp;#46;io&amp;#46;BufferedWriter;<br>import java&amp;#46;io&amp;#46;DataInputStream;<br>import java&amp;#46;io&amp;#46;FileInputStream;<br>import java&amp;#46;io&amp;#46;FileNotFoundException;<br>import java&amp;#46;io&amp;#46;FileOutputStream;<br>import java&amp;#46;io&amp;#46;FileReader;<br>import java&amp;#46;io&amp;#46;FileWriter;<br>import java&amp;#46;io&amp;#46;IOException;<br>import java&amp;#46;io&amp;#46;InputStream;<br>import java&amp;#46;io&amp;#46;InputStreamReader;<br>import java&amp;#46;io&amp;#46;ObjectInput;<br>import java&amp;#46;io&amp;#46;ObjectInputStream;<br>import java&amp;#46;io&amp;#46;ObjectOutputStream;<br><br>import com&amp;#46;thoughtworks&amp;#46;xstream&amp;#46;XStream;<br><br>public class FileIO {<br><br>	public static String newline = System&amp;#46;getProperty(\&quot;line&amp;#46;separator\&quot;);<br><br>	public static void main(String&amp;#91;&amp;#93; args) {<br>		Person peter = new Person(\&quot;Peter\&quot;, 12);<br>		writeXML(\&quot;peter&amp;#46;txt\&quot;, peter);<br>		Object obj = readXML(\&quot;peter&amp;#46;txt\&quot;);<br>		if (obj instanceof Person) {<br>			Person person = (Person) obj;<br>			System&amp;#46;out&amp;#46;println(\&quot;Persons name&amp;#58; \&quot; + person&amp;#46;getName());<br>			System&amp;#46;out&amp;#46;println(\&quot;Persons age&amp;#58; \&quot; + person&amp;#46;getAge());<br>		}<br>	}<br>	<br>	public static void writeXML(String filename, Object object) {<br>		XStream xstream = new XStream();<br>		FileWriter writer = null;<br><br>		try {<br>			writer = new FileWriter(filename);<br>			xstream&amp;#46;toXML(object, writer);<br><br>		} catch (IOException e) {<br>			e&amp;#46;printStackTrace();<br>		} finally {<br>			try {<br>				if (writer != null) {<br>					writer&amp;#46;close();<br>				}<br>			} catch (IOException e) {<br>				e&amp;#46;printStackTrace();<br>			}<br>		}<br>	}<br><br>	public static Object readXML(String filename) {<br>		FileReader reader = null;<br>		Object obj = null;<br><br>		try {<br>			reader = new FileReader(filename);<br>			XStream xstream = new XStream();<br>			obj = xstream&amp;#46;fromXML(reader);<br>		} catch (FileNotFoundException e) {<br>			e&amp;#46;printStackTrace();<br>		} finally {<br>			try {<br>				if (reader != null) {<br>					reader&amp;#46;close();<br>				}<br>			} catch (IOException e) {<br>				e&amp;#46;printStackTrace();<br>			}<br>		}<br><br>		return obj;<br>	}<br><br>	public static Person readFile(String filename) {<br>		FileInputStream fin = null;<br>		DataInputStream din = null;<br>		String name = null;<br>		Integer age = null;<br>		try {<br>			fin = new FileInputStream(filename);<br>			din = new DataInputStream(fin);<br>			BufferedReader reader = new BufferedReader(new InputStreamReader(<br>					din));<br>			String line;<br>			while ((line = reader&amp;#46;readLine()) != null) {<br>				String&amp;#91;&amp;#93; attributes = line&amp;#46;split(\&quot;&amp;#58;\&quot;);<br>				if (attributes != null &amp;&amp; attributes&amp;#46;length == 2) {<br>					if (attributes&amp;#91;0&amp;#93;&amp;#46;equals(\&quot;name\&quot;)) {<br>						name = attributes&amp;#91;1&amp;#93;;<br>					}<br>					if (attributes&amp;#91;0&amp;#93;&amp;#46;equals(\&quot;age\&quot;)) {<br>						age = Integer&amp;#46;parseInt(attributes&amp;#91;1&amp;#93;);<br>					}<br>				}<br>			}<br>			return new Person(name, age);<br>		} catch (FileNotFoundException e) {<br>			System&amp;#46;err&amp;#46;println(\&quot;File \&quot; + filename + \&quot; not found\&quot;);<br>		} catch (IOException e) {<br>			e&amp;#46;printStackTrace();<br>		} catch (NumberFormatException e) {<br>			System&amp;#46;err&amp;#46;println(\&quot;Value after age was no number\&quot;);<br>		} finally {<br>			try {<br>				if (fin != null) {<br>					fin&amp;#46;close();<br>				}<br>				if (din != null) {<br>					din&amp;#46;close(); // always close your streams within finally<br>				}<br>			} catch (IOException e) {<br>				e&amp;#46;printStackTrace();<br>			}<br>		}<br>		return null;<br>	}<br><br>	public static void writeFile(String filename, Person person) {<br>		FileWriter writer = null;<br>		BufferedWriter out = null;<br>		try {<br>			writer = new FileWriter(filename);<br>			out = new BufferedWriter(writer);<br>			out&amp;#46;write(\&quot;name&amp;#58;\&quot; + person&amp;#46;getName() + newline + \&quot;age&amp;#58;\&quot;<br>					+ person&amp;#46;getAge());<br>		} catch (IOException e) {<br>			e&amp;#46;printStackTrace();<br>		} finally {<br>			try {<br>				if (out != null) {<br>					out&amp;#46;close();<br>				}<br>				if (writer != null) {<br>					writer&amp;#46;close();<br>				}<br>			} catch (IOException e) {<br>				e&amp;#46;printStackTrace();<br>			}<br>		}<br>	}<br><br>	public static void writeFileByObjectStream(String filename, Object object) {<br>		ObjectOutputStream oos = null;<br>		FileOutputStream fos = null;<br>		try {<br>			fos = new FileOutputStream(filename);<br>			oos = new ObjectOutputStream(fos);<br><br>			oos&amp;#46;writeObject(object);<br>		} catch (FileNotFoundException e) {<br>			e&amp;#46;printStackTrace();<br>		} catch (IOException e) {<br>			e&amp;#46;printStackTrace();<br>		} finally {<br>			try {<br>				if (oos != null) {<br>					oos&amp;#46;close();<br>				}<br>				if (fos != null) {<br>					fos&amp;#46;close();<br>				}<br>			} catch (IOException e) {<br>				e&amp;#46;printStackTrace();<br>			}<br>		}<br>	}<br><br>	public static Object readFileByObjectStream(String filename) {<br>		Object obj = null;<br>		ObjectInput in = null;<br>		InputStream fis = null;<br>		try {<br>			fis = new FileInputStream(filename);<br>			in = new ObjectInputStream(fis);<br>			obj = in&amp;#46;readObject();<br><br>		} catch (FileNotFoundException e) {<br>			e&amp;#46;printStackTrace();<br>		} catch (IOException e) {<br>			e&amp;#46;printStackTrace();<br>		} catch (ClassNotFoundException e) {<br>			e&amp;#46;printStackTrace();<br>		} finally {<br>			try {<br>				if (in != null) {<br>					in&amp;#46;close();<br>				}<br>				if (fis != null) {<br>					fis&amp;#46;close();<br>				}<br>			} catch (IOException e) {<br>				e&amp;#46;printStackTrace();<br>			}<br>		}<br>		return obj;<br>	}<br>}</pre></div>[/spoiler]<br><br>I wish you success with coding.<br><br>Deque]]></description>
   </item>
   </channel>
</rss>