2011-05-23 89 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