2017-02-14 9 views
1

私は、Visual Studio 2015 Update 3でDotfuscator CEを使用して、.NETアセンブリを難読化しています。 パブリックタイプとメンバーはデフォルトでは難読化されていません。 Friend Classes in Exclusionリストをどのように追加して難読化するべきでないかを知りたいのですが、興味がありますか?難読化の除外リストにフレンドクラスを追加

私のDLLを難読化するために使用している設定ファイルファイルは次のとおりです。

<?xml version="1.0" encoding="utf-8" standalone="no"?> 
<!DOCTYPE dotfuscator SYSTEM "http://www.preemptive.com/dotfuscator/dtd/dotfuscator_v2.3.dtd"> 
<dotfuscator version="2.3"> 
    <propertylist> 
    <property name="SourceDirectory" value="This Path Will Be Replaced By Visual Studio" /> 
    <property name="SourceFile" value="This Filename Will Be Replaced By Visual Studio" /> 
    </propertylist> 
    <global> 
    <option>quiet</option> 
    </global> 
    <input> 
    <asmlist> 
     <inputassembly refid="e4ca1ab5-26cb-4ab7-9621-87063f75a38f"> 
     <option>honoroas</option> 
     <option>stripoa</option> 
     <option>library</option> 
     <option>transformxaml</option> 
     <file dir="${SourceDirectory}" name="${SourceFile}" /> 
     </inputassembly> 
    </asmlist> 
    </input> 
    <output> 
    <file dir="${SourceDirectory}" /> 
    </output> 
    <renaming> 
    <option>xmlserialization</option> 
    <mapping> 
     <mapoutput overwrite="true"> 
     <file dir="${SourceDirectory}\Dotfuscated" name="Map.xml" /> 
     </mapoutput> 
    </mapping> 
    <referencerulelist> 
     <referencerule rulekey="{6655B10A-FD58-462d-8D4F-5B1316DFF0FF}" /> 
     <referencerule rulekey="{7D9C8B02-2383-420f-8740-A9760394C2C1}" /> 
     <referencerule rulekey="{229FD6F8-5BCC-427b-8F72-A7A413ECDF1A}" /> 
     <referencerule rulekey="{2B7E7C8C-A39A-4db8-9DFC-6AFD38509061}" /> 
     <referencerule rulekey="{494EA3BA-B947-44B5-BEE8-A11CC85AAF9B}" /> 
     <referencerule rulekey="{89769974-93E9-4e71-8D92-BE70E855ACFC}" /> 
     <referencerule rulekey="{4D81E604-A545-4631-8B6D-C3735F793F80}" /> 
    </referencerulelist> 
    </renaming> 
    <sos mergeruntime="true"> 
    <option>version:v4</option> 
    <option>sendanalytics</option> 
    <option>dontsendtamper</option> 
    </sos> 
    <smartobfuscation> 
    <smartobfuscationreport verbosity="all" overwrite="false" /> 
    </smartobfuscation> 
</dotfuscator> 

実際に私はFriendアクセス指定子を持つModelクラスを持っています。私はそのオブジェクトをPostAsJsonAsyncメソッド経由で投稿します。ここで

Dim result As HttpResponseMessage = client.PostAsJsonAsync(APIEndPoints.LOGIN, _LoginModel).Result 

友達クラスです:要求とモデルを受け取る

Friend Class LoginModel 

    Public AccessKey As String 

    Public Password As String 
End Class 

API方法:APIがあまりにも要求してLoginModelを受信すると

[HttpPost] 
     [Route("authenticate")] 
     public async Task<JsonResult> Authenticate([FromBody] LoginViewModel lvm) 
// Here lvm.Accesskey is null 

、そのフィールドはNULLです。 LoginModelをpublicにすると、それが動作します。 注:これは私のDLLを難読化するときにのみ起こります。そうでなければ、実装はフレンドクラスでも機能します。

注:フレンドクラスはVB.Netで一般的です。アセンブリ内でアクセスされるとパブリッククラスのように機能しますが、アセンブリの外ではプライベートクラスです。

答えて

2

あなたの説明に基づいて、フレンドタイプの名前だけでなく、それらのタイプ内のパブリックフィールドの名前も除外したいように思えます。私はあなたの元の質問を、文脈にかかわらずFriendとマークされたものを除外したいと解釈していました。

ここで重要な点は、Dotfuscatorの規則の点で、タイプを除いてはメンバーを自動的に除外しないことです。

ここではトップレベルの友達の種類とそれらのタイプの公開や友達のフィールドを除外除外ルールのセットです:名前を変更するときに知っているが、トラブルの原因となりますあなたはまた、単に型とメンバーを除外することができ

<excludelist> 
    <type name=".*" regex="true" speclist="+notpublic"> 
    <comment>Exclude top-level types that are only accessible to the assembly ("Friend" in VB, "internal" in C#, or "private" in IL).</comment> 
    <field name=".*" speclist="+public" regex="true"> 
     <comment>Exclude public fields of types the parent rule matches</comment> 
    </field> 
    </type> 
</excludelist> 

ではなく、アクセシビリティに基づいたルールを使用して多数の名前を除外します。 (私はあなたが複数の入力アセンブリのために、この同じ構成を使用している気づいたが、入力されたアセンブリは「doesnの場合ので、このルールはまだ安全です

<excludelist> 
    <type name="YourAssembly.YourNamespace.Here.LoginModel"> 
    <field name="AccessKey" signature="string" /> 
    <field name="Password" signature="string" /> 
    </type> 
</excludelist> 

:ここLoginModelが組み立てYourAssemblyと名前空間YourNamespace.Hereで定義されていると仮定すると、一例です)特定のタイプが含まれている場合、ルールは無視されます。

the Professional Edition documentation on Exclusion Rules(およびそのページのサブトピック)は、コミュニティ・エディションとプロフェッショナル・エディションが同じ構成ファイル・フォーマットを共有する場合に便利です。両方のエディションでサポートされています。

開示:私はPreEmptive SolutionsのDotfuscatorチームで働いています。

1

アセンブリにFriend Assemblyが含まれているため、入力アセンブリのフレンドタイプとメンバを除外しようとしている場合、Dotfuscatorはそのようなコード要素を自動的に名前変更から除外します(Dotfuscator CEによって提供される唯一の難読化タイプ)。次の警告を発行します。

WARNING:NameOfYourInputAsssembly非入力フレンドアセンブリを持っており、ライブラリモードです。内部メンバーの名前の変更や削除は行われません。増加する難読化のための入力としてFriend Assemblyを追加することを検討してください。

(ここでは "internal"という用語はVBの "Friend"キーワードのC#に相当します)。

警告が示唆するように、Friend Assemblyを別のInput to Dotfuscatorとして含めることができます。 これを行うと、Dotfuscatorはフレンドの種類とメンバーの名前を変更し、Friend Assemblyを更新して、新しい名前でそれらの種類とメンバーを参照できます。

<excludelist> 
    <type name=".*" regex="true" speclist="+notpublic"> 
    <comment>Exclude types that are only accessible to the assembly ("Friend" in VB, "internal" in C#, or "private" in IL).</comment> 
    </type> 
    <type name=".*" regex="true" speclist="+nestedassembly"> 
    <comment>Exclude nested types that are only accessible to the assembly ("Friend" in VB, "internal" in C#, or "private" in IL).</comment> 
    </type> 
    <type name=".*" regex="true" excludetype="false"> 
    <comment>Select, but do not exclude, all types.</comment> 
    <method name=".*" speclist="+assembly" regex="true"> 
     <comment>Exclude methods that are only accessible to the assembly ("Friend" in VB, "internal" in C#, or "assembly" in IL).</comment> 
    </method> 
    <field name=".*" speclist="+assembly" regex="true"> 
     <comment>Exclude fields that are only accessible to the assembly ("Friend" in VB, "internal" in C#, or "assembly" in IL).</comment> 
    </field> 
    <propertymember name=".*" speclist="+assembly" regex="true"> 
     <comment>Exclude properties that are only accessible to the assembly ("Friend" in VB, "internal" in C#, or "assembly" in IL).</comment> 
    </propertymember> 
    <eventmember name=".*" speclist="+assembly" regex="true"> 
     <comment>Exclude events that are only accessible to the assembly ("Friend" in VB, "internal" in C#, or "assembly" in IL).</comment> 
    </eventmember> 
    </type> 
</excludelist> 


あなたはまだあなたが以下のリネーム除外ルールセットで行うことができ、友達の種類とメンバーを除外したい場合は、設定ファイル内<renaming>タグの子として追加

編集:この回答の前回の改訂では、ネストされた型が見つかりませんでした。

開示:私はPreEmptive SolutionsのDotfuscatorチームで働いています。

+0

詳細は@Joeに感謝しますが、解決策は機能しませんでした。私は詳細を提供するために私の質問を更新しています。つまり、あなたの答えに記載されている除外ルールは、Friend Classesが難読化されることを排除しませんでした。 –

+0

Idasmで難読化されたDLLを見ると、フレンドクラスのパブリックデータメンバーが名前aとbに難読化されていることがわかります。 –

+0

@AzazulHaq私はあなたの説明を踏まえて別の回答を掲載しました。 –