パスワード定期変更云々検証用コード(VB.NET)
VB2008で書いた検証用コードです。
間違いがあったらツッコミ大歓迎です。
でも変数の名前がおかしいとか、センス無いとか、コードが汚いとか言うのは勘弁してね!!
Public Class Form1 Class P90Inf Public total_time As Decimal Public change_interval As Decimal Public text As String Public try_time As Decimal Public Sub New( _ ByVal total_time As Decimal, _ ByVal change_interval As Decimal, _ ByVal try_time As Decimal, _ ByVal text As String _ ) Me.total_time = total_time Me.change_interval = change_interval Me.try_time = try_time Me.text = text End Sub End Class Private Sub Pass90() Dim aryList As New ArrayList() If True Then '総当りに必要な時間=100日;総当りさせる時間=100日;パスワード変更間隔=1〜100日; For i As Integer = 1 To 100 aryList.Add(New P90Inf(100, i, 100, i.ToString())) Next '総当りに必要な時間=100日;総当りさせる時間=100日;パスワード変更間隔=0.1〜0.00001日; aryList.Add(New P90Inf(100, 1D / 10D, 100, "1/10day")) aryList.Add(New P90Inf(100, 1D / 100D, 100, "1/100day")) aryList.Add(New P90Inf(100, 1D / 1000D, 100, "1/1000day")) aryList.Add(New P90Inf(100, 1D / 10000D, 100, "1/10000day")) '総当りに必要な時間=100日;総当りさせる時間=5日;パスワード変更間隔=0.1〜0.00001日(および変更無しの場合); aryList.Add(New P90Inf(100, 1D / 1D, 5, "1/1day(5%)")) aryList.Add(New P90Inf(100, 1D / 10D, 5, "1/10day(5%)")) aryList.Add(New P90Inf(100, 1D / 100D, 5, "1/100day(5%)")) aryList.Add(New P90Inf(100, 1D / 1000D, 5, "1/1000day(5%)")) aryList.Add(New P90Inf(100, 1D / 10000D, 5, "1/10000day(5%)")) aryList.Add(New P90Inf(100, 100, 5, "no_change(5%)")) '総当りに必要な時間=100日;総当りさせる時間=10日;パスワード変更間隔=0.1〜0.00001日(および変更無しの場合); aryList.Add(New P90Inf(100, 1D / 1D, 10, "1/1day(10%)")) aryList.Add(New P90Inf(100, 1D / 10D, 10, "1/10day(10%)")) aryList.Add(New P90Inf(100, 1D / 100D, 10, "1/100day(10%)")) aryList.Add(New P90Inf(100, 1D / 1000D, 10, "1/1000day(10%)")) aryList.Add(New P90Inf(100, 1D / 10000D, 10, "1/10000day(10%)")) aryList.Add(New P90Inf(100, 100, 10, "no_change(10%)")) '総当りに必要な時間=100日;総当りさせる時間=20日;パスワード変更間隔=0.1〜0.00001日(および変更無しの場合); aryList.Add(New P90Inf(100, 1D / 1D, 20, "1/1day(20%)")) aryList.Add(New P90Inf(100, 1D / 10D, 20, "1/10day(20%)")) aryList.Add(New P90Inf(100, 1D / 100D, 20, "1/100day(20%)")) aryList.Add(New P90Inf(100, 1D / 1000D, 20, "1/1000day(20%)")) aryList.Add(New P90Inf(100, 1D / 10000D, 20, "1/10000day(20%)")) aryList.Add(New P90Inf(100, 100, 20, "no_change(20%)")) '総当りに必要な時間=100日;総当りさせる時間=50日;パスワード変更間隔=0.1〜0.00001日(および変更無しの場合); aryList.Add(New P90Inf(100, 1D / 1D, 50, "1/1day(50%)")) aryList.Add(New P90Inf(100, 1D / 10D, 50, "1/10day(50%)")) aryList.Add(New P90Inf(100, 1D / 100D, 50, "1/100day(50%)")) aryList.Add(New P90Inf(100, 1D / 1000D, 50, "1/1000day(50%)")) aryList.Add(New P90Inf(100, 1D / 10000D, 50, "1/10000day(50%)")) aryList.Add(New P90Inf(100, 100, 50, "no_change(50%)")) '総当りに必要な時間=100日;総当りさせる時間=80日;パスワード変更間隔=0.1〜0.00001日(および変更無しの場合); aryList.Add(New P90Inf(100, 1D / 1D, 80, "1/1day(80%)")) aryList.Add(New P90Inf(100, 1D / 10D, 80, "1/10day(80%)")) aryList.Add(New P90Inf(100, 1D / 100D, 80, "1/100day(80%)")) aryList.Add(New P90Inf(100, 1D / 1000D, 80, "1/1000day(80%)")) aryList.Add(New P90Inf(100, 1D / 10000D, 80, "1/10000day(80%)")) aryList.Add(New P90Inf(100, 100, 80, "no_change(80%)")) End If If False Then For i As Integer = 1 To 100 For x As Decimal = 1D To 100D aryList.Add(New P90Inf(100, i, x, i.ToString() & "day:" & x.ToString())) Next Next End If If False Then Dim xxx As Decimal() = {1D, 2D, 5D, 10D, 20D, 25D, 50D, 75D, 90D, 100D} For Each i As Decimal In xxx For x As Integer = 1 To 100 aryList.Add(New P90Inf(100, i, x, i.ToString() & "day:" & x.ToString())) Next Next End If For Each m As P90Inf In aryList Call Pass90ss(m.total_time, m.change_interval, m.try_time, m.text) Next End Sub Private Sub Pass90ss( _ ByVal total_time As Decimal, _ ByVal change_interval As Decimal, _ ByVal try_time As Decimal, _ ByVal text As String _ ) Dim elapsed_time As Decimal = 0D Dim total_escape As Decimal = 1D Dim count = 1D Do Until elapsed_time > try_time 'calc Dim current_escape = calc_escape(total_time, try_time, elapsed_time, change_interval) total_escape = total_escape * current_escape 'count up elapsed_time = elapsed_time + change_interval 'print If elapsed_time > try_time Then 'final printData(text, "E", count, current_escape, total_escape) ElseIf count = 1D Then 'first 'printData(text, "S", count, current_escape, total_escape) Else 'printData(text, " ", count, current_escape, total_escape) End If 'count up count = count + 1D Loop End Sub Private Function calc_escape(ByVal total_time As Decimal, ByVal try_time As Decimal, ByVal transit_time As Decimal, ByVal change_interval As Decimal) As Decimal Dim r As Decimal Dim work_time As Decimal If (try_time - transit_time) > change_interval Then work_time = change_interval Else work_time = (try_time - transit_time) End If r = calc_newpass_no_target(total_time, transit_time) + _ calc_newpass_target(total_time, transit_time) * calc_no_hit(total_time, work_time) Return r End Function Private Function calc_newpass_no_target(ByVal total_time As Decimal, ByVal transit_time As Decimal) As Decimal Return transit_time / total_time End Function Private Function calc_newpass_target(ByVal total_time As Decimal, ByVal transit_time As Decimal) As Decimal Return 1D - calc_newpass_no_target(total_time, transit_time) End Function Private Function calc_hit(ByVal total_time As Decimal, ByVal time As Decimal) As Decimal Return time / total_time End Function Private Function calc_no_hit(ByVal total_time As Decimal, ByVal time As Decimal) As Decimal Return 1D - calc_hit(total_time, time) End Function Private Sub printData(ByVal text1 As String, ByVal text2 As String, ByVal count As Decimal, ByVal current_escape As Decimal, ByVal total_escape As Decimal) Dim strBuf As New System.Text.StringBuilder() strBuf.Append(text1) strBuf.Append(vbTab) strBuf.Append(text2) strBuf.Append(vbTab) strBuf.Append(count) strBuf.Append(vbTab) strBuf.Append(current_escape) strBuf.Append(vbTab) strBuf.Append(total_escape) Console.WriteLine(strBuf.ToString()) End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Pass90() End Sub End Class