Skip to content
Advertisement

Search for a String inside all files inside a war

Where I work someone had Java project and used Eclipse to export that project into a .war package.

Now I need to search for a string inside all the files that make that .war package. I know that a .war package is just a .zip file, and I have extracted its contents, however, now I have bunch of of .class java files (among images, xmls and other stuff) and I have no idea on how to search strings inside them.

I am a Linux Mint user, so I tried using the “grep -R stringHere .” command without success (I am not an advanced user), this command only searches inside text files.

I also searched and found the crgrep project but it is currently bugged and it does not work.

Does anyone know a linux command that can search inside all the contents of a .war package and check if those contents contain a specific string or code sample?

I really need to find a way to search through the content of the .class files. That is my only priority so far. I don’t care about images nor about any other type of text files.

It would help a lot. Thanks in advance, Pedro.

Advertisement

Answer

Unzip your war like any regular zip and from the root search with

find . -name "*.class" -print0 |xargs -0 strings -f |grep -i <your string>

Pray that your string got encoded in clear text inside the binaries.

Advertisement