xb@dnxb:/tmp$ java -verbose |& grep rt.jar | head -1 #to find out java runtime path
[Opened /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar]
xb@dnxb:/tmp$ unzip /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar -d /tmp/rt #unzip the rt.jar
creating: /tmp/rt/META-INF/
extracting: /tmp/rt/META-INF/MANIFEST.MF
extracting: /tmp/rt/com/oracle/net/Sdp$1.class
extracting: /tmp/rt/com/oracle/net/Sdp$SdpSocket.class
...
extracting: /tmp/rt/java/io/Serializable.class
extracting: /tmp/rt/java/lang/String.class
extracting: /tmp/rt/java/lang/Object.class
xb@dnxb:/tmp$
xb@dnxb:/tmp$ find /tmp/rt > /tmp/rt.map #create list path as map
xb@dnxb:/tmp$ cp /tmp/rt.map ~/CRITICAL/ #save as permanent map
bash function:
jgrep ()
{
OPTS=`getopt -o iva --long case-insensitive,verbose,all -n 'parse-options' -- "$@"`;
if [ $? != 0 ]; then
echo "Failed parsing options." 1>&2;
return;
fi;
eval set -- "$OPTS";
i=;
in=;
prefix='/';
postfix='\.class';
javap_cmd=:;
while true; do
case "$1" in
-i | --case-insensitive)
i='i';
in='in';
shift
;;
-v | --verbose)
javap_cmd=javap;
shift
;;
-a | --all)
prefix=;
postfix=;
shift
;;
--)
shift;
break
;;
*)
break
;;
esac;
done;
rt_p=~/CRITICAL/rt.map;
grep -a --color=auto --color=never -a"$i" "$prefix$1$postfix" "$rt_p" | cut -c 9- | sed 's/\//./g' | while read -r line; do
if [[ "$line" =~ '.class'$ ]]; then
line="$(echo "$line" | rev | cut -c7- | rev )";
fi;
echo "$line" | grep -a --color=auto --color=always -a"$i" "$1";
"$javap_cmd" "$line";
echo;
done
}
No comments:
Post a Comment