Vengono presentate, in breve, le tecniche di protezione utilizzate in Goliath .NET Obfuscator
La maggior parte di queste tecniche sono state poi "copiate" ed inserite in prodotti concorrenti (tecniche "spudoratamente" simili verrano -adeguatamente- segnalate).
ENCRYPTION DELLE STRINGHE:
è un'ulteriore tecnica da adottare per la protezione del ns codice. In Goliath .NET Obfuscator si è avuta una naturale evoluzione tra le varie release 1.x, 2.x, 3.x e 4.x.
Nella release 2.x -invece di cifrare la stringa byte-per-byte- si è scelto di implementare un'evoluzione di StackCrypt (tecnica rilasciata pubblicamente su CodeProject qui e qui a luglio'2004...da notare, all'epoca, la mia mente ancora "inquinata" da codice vb6!
) che consente anche la "compressione" delle stesse.
Quindi, per ogni stringa, viene creato un metodo contenente la stringa da ricostruire a runtime. Ad esempio per una generica stringa "hello world!":
Dim txt As String = CryptMethod()
Function CryptMethod() As String
Dim stack As New Stack(2)
Dim startCode As Integer = &H29BCA4A
'<<<
With stack
startCode = startCode Xor 1895280235
.Push(startCode)
startCode = startCode Xor 491524942
.Push(startCode)
startCode = startCode Xor 121969411
.Push(startCode)
End With
'+++
Dim retValue As Byte() = STACKED_BYTES(stack)
Return System.Text.Encoding.UTF8.GetString(retValue)
End Function
Private Function STACKED_BYTES(ByVal st As Stack) As Byte()
Dim asmPos As Integer = 0
Dim tempValue((st.Count * 4) - 1) As Byte
'<<<
For ik As Integer = 1 To st.Count
Dim arr As Byte() = BitConverter.GetBytes(DirectCast(st.Pop, Integer))
'---------------------------------------------------------------------
For ij As Integer = 3 To 0 Step -1
If arr(ij) > 0 Then
tempValue(asmPos) = arr(ij)
asmPos += 1
End If
Next
Next
'<<<
Dim retValue(asmPos - 1) As Byte
Array.Copy(tempValue, retValue, asmPos)
Return retValue
End Function
...la generazione casuale impedisce -anche al sottoscritto- qualsiasi previsione dei risultati di codifica! Ne consegue che ad un aggressore non basta "invertire" un solo algoritmo ma deve ricostruire N-metodi (metodi offuscati) contenenti N-stringhe! 
Nelle successive release l'encryption delle stringhe è legato all'offuscazione del codice! 
CONTROL-FLOW OBFUSCATION (Spaghetti-Code)
[continua]
Nessun commento trovato.