2017-02-14 10 views
1

Visual Studio 2015 Update 3과 함께 Dotfuscator CE를 사용하여 .Net 어셈블리를 난독 화합니다. 공개 형식과 멤버는 기본적으로 난독 화되지 않습니다. 친구 클래스를 제외 목록에 추가하여 그 사람들이 난독 화되어서는 안된다는 것을 알고 싶습니다.난독 화 목록에서 제외 목록에 친구 클래스 추가

여기 내 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 메소드를 통해 객체를 게시합니다. 요청 및 모델을 수신

Friend Class LoginModel 

    Public AccessKey As String 

    Public Password As String 
End Class 

API 방법 : 여기

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

는 친구 클래스입니다

API가 요청을 받아 LoginModel도 해당 필드가 null입니다
[HttpPost] 
     [Route("authenticate")] 
     public async Task<JsonResult> Authenticate([FromBody] LoginViewModel lvm) 
// Here lvm.Accesskey is null 

. 내 LoginModel을 public으로 만들면 작동합니다. 참고 : 이것은 DLL을 난처하게 할 때만 발생합니다. 그렇지 않으면 구현이 Friend 클래스에서도 작동합니다.

참고 : VB.Net에서는 프렌드 클래스가 일반적입니다. 어셈블리 내에서 액세스 할 때 공용 클래스처럼 작동하지만 어셈블리 외부에서는 private입니다.

답변

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> 

당신은 또한 당신이 이름을 바꿀 때 문제가 발생할 알고 형식과 멤버를 제외하는 대신 수 접근성에 기반한 규칙을 사용하여 많은 수의 이름을 제외합니다. 여기에 예제가 LoginModel 가정의 조립 YourAssembly와 네임 스페이스 YourNamespace.Here에 정의되어

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

가 (난 당신이 다중 입력 어셈블리에 대한이 같은 구성을 사용하고있는 눈치지만,이 규칙은 여전히 ​​안전 입력 어셈블리 아무튼 경우 때문에 ' 특정 유형이 포함 된 경우 규칙은 무시됩니다.)

the Professional Edition documentation on Exclusion Rules (해당 페이지의 하위 주제) - Community Edition 및 Professional Edition은 동일한 구성 파일 형식을 공유합니다. 두 버전에서 모두 지원됩니다.

공개 : 나는 사전 감정적 인 해결책을 위해 Dotfuscator 팀에서 일합니다.

1

어셈블리에 Friend Assembly이 있기 때문에 입력 어셈블리의 Friend 유형 및 멤버를 제외하려는 경우 Dotfuscator는 해당 코드 요소의 이름 바꾸기를 자동으로 제외합니다 (Dotfuscator CE에서 제공하는 유일한 난독 화). 다음과 같은 경고를 발행 :

경고 : NameOfYourInputAsssembly 비 입력 친구 어셈블리를 가지고 도서관 모드에; 내부 구성원의 이름을 바꾸거나 정리하지 않습니다. 증가 된 난독 화를 위해 친구 어셈블리를 입력으로 고려하십시오.

(여기에서 "내부"라는 용어는 VB의 "Friend"키워드와 동일한 C#입니다.)

경고에서 알 수 있듯이 Friend Assembly를 Dotfuscator의 또 다른 입력으로 포함 할 수 있습니다. 이렇게하면 Dotfuscator는 프렌드 유형 및 멤버의 이름을 바꾸고 프렌드 어셈블리를 업데이트하여 새 이름으로 이러한 유형 및 멤버를 참조 할 수 있습니다.

<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> 태그의 자식으로 추가

편집 :이 답변의 이전 개정판에서 중첩 된 유형을 놓쳤습니다.

Disclosure : 저는 PreEmptive Solutions를위한 Dotfuscator 팀에서 일합니다.

+0

자세한 내용은 @Joe 감사하지만 해결책이 작동하지 않았습니다. 자세한 내용을 제공하기 위해 제 질문을 업데이트하고 있습니다. 간단히 말해, 답변에 언급 된 제외 규칙은 친구 클래스가 난독 화되는 것을 제외하지 않았습니다. –

+0

Idasm에서 난독 화 된 DLL을 보면 Friend 클래스의 공용 데이터 멤버가 a 및 b 이름으로 난독 화되었음을 알 수 있습니다. –

+0

@AzazulHaq 귀하의 설명에 비추어 별도의 답변을 게시했습니다. –