2012-02-23 29 views
0

我想模擬蠻力攻擊(解釋它是如何工作的)。我想顯示進程以破解「abc」的密碼。這需要我顯示當時正在嘗試破解「abc」密碼的密碼(所以從「a」開始,然後是「b」,然後是「c」,直到它到達「abc」。)Java android,代碼運行時顯示信息?

我的問題是我怎樣才能得到密碼正在嘗試在那一刻,顯示在屏幕上,而代碼運行的代碼?

難道是容易使顯示這一過程的視頻?

感謝

Jamie

編輯 這裏是我寫的代碼,解釋每個部分的註釋。希望這有助於我解釋問題。

感謝您的答案迄今

// the simulation 

    Button btnSim = (Button) findViewById(R.id.btnSim); 
    btnSim.setOnClickListener(new View.OnClickListener() { 

     public void onClick(View v) { 

      TextView currentSimPword = (TextView) findViewById(R.id.currentSimPword); 

      int i = 0;//i would be replaced by the string it is trying e.g. a then b then c 
         //until it reaches abc 

      while (i < 100) {//this would loop until i reaches abc 

       //this would show what the brute force attack is attempting against the real password 
       currentSimPword.setText("comparing password " + i + " against the real password 'abc'"); 
       //at this point i want it to be displayed on screen (and at every time it reaches here) 

       //here i would need a way to pause it long enough for the user to see what is being tried 

       //this increases the password tried by one each time in the loop 
       i = i + 1; 
      } 
     } 

    }); 
+0

你就不能寫出來日誌文件和尾巴呢? – 2012-02-23 14:27:00

+0

然後b然後c是電影的東西!您應該顯示排列的數量(密碼長度)以及已嘗試的數量。 – 2012-02-23 14:49:37

回答

0

你可以運行在您的AsyncTask暴力破解的方法,只需更新與您當前的企圖UI。

在每一次嘗試中,您都會使用當前密碼字符串調用publishProgress並更新onProgressUpdate中的UI。

不過我可能誤解了問題^^

順便說一句,如果這是一個演示文稿,視頻是不是一個壞主意,因爲你的工具可能總是有一些錯誤,在演示過程中準確顯示。

0

我認爲這將是整齊顯示所有的嘗試滾動,因爲他們通過。這很容易實現。請參閱this question.的回答

0

只需使用TextView並且每次您嘗試新的「密碼」時都會將其文本更新爲當前正在嘗試的密碼。如果要快速觀察進程,則可能需要使用時間戳連續追加密碼。

TextView mLabel = findViewById(R.id.yourtextview); 

// do some sort of loop that would simulate your brute force attack 

mLabel.append(currentPassword + "\n"); 

// end loop that simulates brute force attack