2011-05-23 63 views
11

假设您了解到某位开发人员将一堆用户名和密码硬编码到应用程序中,并将其转化为Production。哦,哦..!检查.class文件中的内容

你知道用户名和密码 - 有没有办法扫描字节码,并确定是否实际上用户名,密码是硬编码?

回答

19

查看在“.class”文件中使用什么字符串文字的简单方法是在JDK安装中使用javap实用程序使用“-v”选项转储文件。然后grep为看起来像<String "...">的文本,其中...是您正在查找的字符串。

UPDATE

javap的最新文档here,但老版看起来更好IMO。

+0

这真是太棒了!谢谢 – JAM 2011-05-23 01:26:35

+0

不客气! – 2011-05-23 01:38:08

+0

我的工作很好! – 2011-10-03 12:45:45

7

您可以使用Java反编译器进行反编译你的类(并检查类是否包含硬编码的用户名/密码) 看一看:

7

有无你看着JD-GUI?你可以看到那里是否已经硬编码到任何类文件中。

+2

我第二个这个建议。 JD-GUI是检查Java类文件的好工具。 – rickumali 2011-05-23 01:42:11

4

未来可能对他人有帮助。 (从How can I open Java .class files in a human-readable way?

Usage: javap <options> <classes>... 

where options include: 
    -c      Disassemble the code 
    -classpath <pathlist>  Specify where to find user class files 
    -extdirs <dirs>   Override location of installed extensions 
    -help      Print this usage message 
    -J<flag>     Pass <flag> directly to the runtime system 
    -l      Print line number and local variable tables 
    -public     Show only public classes and members 
    -protected    Show protected/public classes and members 
    -package     Show package/protected/public classes 
          and members (default) 
    -private     Show all classes and members 
    -s      Print internal type signatures 
    -bootclasspath <pathlist> Override location of class files loaded 
          by the bootstrap class loader 
    -verbose     Print stack size, number of locals and args for methods 
          If verifying, print reasons for failure 
+0

Erm ...此答案必须针对不知道如何点击链接的人:http://download.oracle.com/javase/8/docs/technotes/tools/windows/javap.html – 2015-06-04 22:40:44

+1

ha哈..我可以理解。根据我之前对oracle文档的介绍,这些链接最终显现出来。它很好,有适当的地方。 Offcourse,没有人会拿出你的学分,并且已经看到了参考:)放轻松。 +1为您的答案 – 2015-06-05 22:56:57

+0

StackOverflow答案中的链接断开得到修复。如果问答是值得的。 – 2015-06-05 23:01:52