The Wayback Machine -

EAR Search

The "EAR Search" tool searches for text and regular expressions within a given JAVA archive file (EAR, WAR, JAR and ZIP). The tool does recursively search within included archive files.

Command syntax is very simple, similar to grep:

Syntax: java -jar EARScanner.jar [-c] [-E] [-k] [-n] fileToAnalyze searchPattern
    -c: search within comments (following java.util.Properties definition)
    -E: treat searchPattern as a regular expression
    -k: keep exploded files and directories
    -n: show line number

This small utility is written in JAVA and runs on JAVA 1.4 and upper versions.

Download EAR Search

Source code Download from SourceForge

Details on the Search Algorithm

  • Only ASCII search patterns have been tested so far
  • Files are exploded (unzipped) in the current directory. Unless option -k is specified, the files are deleted as soon as they are not used
  • Search works line by line. It is not possible to search accross lines
  • For a .class file, when a byte 0x00 is found, it is changed to LF (ASCII 10). It is then treated as a new line
  • Unless option -c is specified, comments are ignored. For .java and .class files, all lines are searched, there is no concept of comment

Sample Output

This tool can be used for example to search IP addresses inside an EAR file, using the classic regular expression "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}".

Update: for IPv4 address in decimal format, use this regular expression "((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]? \d)".

D:\>java -jar EARSearch.jar -n -E testcase3.ear "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
EAR File: testcase3.ear (2122 bytes). Search for (in '): '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
EAR explosion process starts at Fri Apr 11 22:56:07 GMT 2014. Options: -E -n
Exploding directory: D:\testcase3.ear_

testcase3.ear_\FileUNIXDir\FileUNIX.txt:16: is an IP
testcase3.ear_\FileUNIXDir\FileUNIX.txt:17: and are IPs
testcase3.ear_\FileUNIXDir\FileUNIX.txt:18: end
testcase3.ear_\FileWindows.war_\FileWindows.txt:16: is an IP
testcase3.ear_\FileWindows.war_\FileWindows.txt:17: and are IPs
testcase3.ear_\FileWindows.war_\FileWindows.txt:18: end
testcase3.ear_\TestIPs.txt:4:IP3: 123.234.345.456 for example

Search completed. Files searched: 5 (2343 bytes). Files matching: 3. Lines matching: 12


Version History

Version Date Notes
0.9 11-apr-2014 Initial release