BadImageFormatException on some obfuscated executables
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- csharp
- Ambito
- backend-api-design, devtools
Direzione di ricerca
Start with the ILSpyCmd reproduction command and the stack traces, then compare the failing paths in ReflectionDisassembler.WriteParameters and InstructionOutputExtensions.WriteTo with the workaround in issue #4203. Reproduce both the original and DE4dot-processed samples to identify where metadata reads go out of bounds. Done means ILSpyCmd handles these malformed signatures without crashing and has regression coverage for both paths.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
There are some other obfuscated .NET executables which still cause ILSpyCmd version 11.2 to crash.
One such sample is: https://www.virustotal.com/gui/file/9ff205599b9eea5e561170ef0e9843a31578cbb117759d32e3c1df96d7bc9838
This issue appears similar to https://github.com/icsharpcode/ILSpy/issues/4203. (which I've confirmed has been fixed), but with a different stack trace.
Could a similar workaround be implemented like with the previous issue?
Steps to reproduce
Attempt to disassemble an obfuscated sample, such as the above:
ilspycmd -il -o disasm 9ff205599b9eea5e561170ef0e9843a31578cbb117759d32e3c1df96d7bc9838
Error message shown
On the sample as-is:
System.BadImageFormatException: Read out of bounds.
at System.Reflection.Throw.OutOfBounds() + 0x27
at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.WriteParameters(MetadataReader, IEnumerable`1, MethodSignature`1) + 0x734
at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.DisassembleMethodHeaderInternal(MetadataFile, MethodDefinitionHandle, MetadataGenericContext) + 0xdcb
at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.DisassembleMethod(MetadataFile, MethodDefinitionHandle) + 0xd7
at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.DisassembleType(MetadataFile, TypeDefinitionHandle) + 0xcfd
at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.WriteModuleContents(MetadataFile) + 0x9c
at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.ShowIL(String assemblyFileName, TextWriter output, CommandLineApplication app) + 0x17e
at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.<OnExecuteAsync>g__PerformPerFileAction|118_0(String fileName, ILSpyCmdProgram.<>c__DisplayClass118_0&, ILSpyCmdProgram.<>c__DisplayClass118_1&) + 0x784
at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.<OnExecuteAsync>d__118.MoveNext() + 0x38c
On the sample deobfuscated with DE4Dot:
System.BadImageFormatException: Read out of bounds.
at System.Reflection.Throw.OutOfBounds() + 0x27
at System.Reflection.Metadata.Ecma335.SignatureDecoder`2.DecodeMethodSignature(BlobReader&) + 0x27f
at ICSharpCode.Decompiler.IL.InstructionOutputExtensions.WriteTo(EntityHandle, MetadataFile, ITextOutput, MetadataGenericContext, ILNameSyntax) + 0xc01
at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.DisassembleMethodBlock(MetadataFile, MethodDefinitionHandle, MetadataGenericContext) + 0x130
at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.DisassembleType(MetadataFile, TypeDefinitionHandle) + 0xcfd
at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.WriteModuleContents(MetadataFile) + 0x9c
at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.ShowIL(String assemblyFileName, TextWriter output, CommandLineApplication app) + 0x17e
at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.<OnExecuteAsync>g__PerformPerFileAction|118_0(String fileName, ILSpyCmdProgram.<>c__DisplayClass118_0&, ILSpyCmdProgram.<>c__DisplayClass118_1&) + 0x784
at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.<OnExecuteAsync>d__118.MoveNext() + 0x38c
Details
- Product in use: ILSpyCmd
- Version in use: 11.2.0.10050
- Lingua principale
- C#
- Stelle
- 27.1k
- Fork
- 3.8k
- Merge medio
- 1g 23h
- PR unite (30g)
- 44
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di icsharpcode/ILSpy
-
AvaloniaEdit Issues to dateApertaExternal UI
Difficoltà 1/5 1-3 ore Idoneità per principianti 75/100
icsharpcode/ILSpy#4284 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
icsharpcode/ILSpy#4357 ·
I maintainer di solito rispondono entro 1 giorno
-
Misdecompilation of a lazy initialization patternForse già presa @siegfriedpammer l’ha presa 5 giorni fa. ApertaBug Decompiler
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
icsharpcode/ILSpy#4349 ·
I maintainer di solito rispondono entro 1 giorno
-
AI
Difficoltà 4/5 1-2 giorni Idoneità per principianti 55/100
icsharpcode/ILSpy#4300 ·
I maintainer di solito rispondono entro 1 giorno
-
Enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
icsharpcode/ILSpy#4298 · 1 commento · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di icsharpcode/ILSpy
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
umbraco/Umbraco.Automate#612 ·
I maintainer di solito rispondono entro 1 giorno
-
崩溃日志只按 CRLF 分行Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
PCL-Community/PCL-CE#3872 ·
I maintainer di solito rispondono entro 1 giorno
-
type:task ux
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
elsa-workflows/elsa-foundation#5253 ·
I maintainer di solito rispondono entro 1 giorno