Masthash

#reversing

Lobsters
12 hours ago
Cindʎ Xiao :breathe:
22 hours ago

@dzervas The decompiler in all of the screenshots in this thread is @binaryninja !

There are a few additional things which make the decompilation look nicer here:

The Microsoft symbol servers provide symbols for these Rust binaries too; those have been downloaded and applied (automatically by Binary Ninja; IDA and Ghidra should also just do this automatically) to this binary.
The symbols have additionally been demangled by me, just using this plugin: https://github.com/inspier/BinjaRustDemangler

On top of that I have applied some additional type information, renamed variables and fields, etc. In general having symbols makes it a lot easier though!

The actual binaries I'm looking at are also available for download from the Microsoft Symbol Server, if you wanted to take a look at the binaries for yourself too; you can get them easily from there without needing an insider preview build of Windows. Details at https://infosec.exchange/@cxiao/110360594370994764

#rust #rustlang #reversing #reverseengineering #microsoft #windows #binaryninja

Cindʎ Xiao :breathe:
1 day ago

Finally, here's what's actually inside that custom panic handler function seh_unwind::implementation::raise_exception: setting up an EXCEPTION_RECORD structure using the information provided by Rust's panic implementation up to here, then calling RtlRaiseExceptionwith that EXCEPTION_RECORDpassed in.

#rust #rustlang #windows #microsoft #reversing #reverseengineering

A screenshot of the decompilation of the function `seh_unwind::implementation::raise_exception`, with the following code contents:

```
int64_t seh_unwind::implementation::raise_exception::hc52a1220c03bdc19(int32_t exception_code, char* exception_message, int64_t exception_NumberParameters) __noreturn

{
    int32_t var_ac = exception_code;
    int32_t status_code_ = win_defs::ntstatus::NTSTATUSError::status::h71e417d20a1a2c45(&var_ac);
    struct EXCEPTION_RECORD exception_record;
    __builtin_memset(&exception_record.ExceptionInformation, 0, 0x78);
    exception_record.ExceptionCode = status_code_;
    exception_record.ExceptionFlags = 0;
    exception_record.ExceptionRecord = 0;
    exception_record.ExceptionAddress = 0;
    *(uint32_t*)((char*)exception_record.ExceptionAddress)[4] = 0;
    exception_record.NumberParameters = exception_NumberParameters;
    int64_t* exception_info_ptr;
    int64_t exception_info_len;
    exception_info_ptr = core::slice::index::impl$4::index_mut<usize>(exception_NumberParameters, &exception_record.ExceptionInformation);
    core::slice::<impl [T]>::copy_from_slice::h17325824e865690e(exception_info_ptr, exception_info_len, exception_message, exception_NumberParameters, &str_"seh_unwind\src\lib.rs");
     RtlRaiseException(&exception_record);
    trap(6);  // ud2 instruction (invalid opcode panic)
}
```
Cindʎ Xiao :breathe:
1 day ago

The rust_begin_unwind function - more specifically, the rust_begin_unwind symbol - is a bit special. It is actually a symbol that the panic implementation in Rust's core library (specifically, the panic_impl function) expects to be resolved at link time, for any binary which doesn't just unconditionally abort upon panic: https://rustc-dev-guide.rust-lang.org/panic-implementation.html#core-definition-of-panic

For binaries which are using Rust's standard library, rust_begin_unwind normally just links against an implementation in the standard library (begin_panic_handler, in library/std/src/panicking.rs)

However, the Windows kernel code here is not using Rust's standard library - it has to be this way, because Rust's standard library assumes that it's running in an environment where an operating system is present underneath it to give it nice abstractions, which is clearly not the case here as the code is implementing part of the Windows operating system...

Rust programs which do not use the standard library are built with the attribute #[no_std], which means that they link against Rust's core library only, rather than both the core library and std library. The core library only provides a very limited set of APIs, does not do heap allocations, and makes no assumptions that your code is running on top of an operating system.

In this case, because the implementation of rust_begin_unwind doesn't have an implementation that the Rust core library can link against, the programmer must either provide one, or change the panic strategy to abort on panic instead (i.e. set panic = "abort" in Cargo.toml).

Luckily, other code in the kernel provides some facilities for handling and recording exceptions, via RtlRaiseException, so the code here can provide an implementation which calls that (via the wrapper function seh_unwind::implementation::raise_exception, which AFAIK is not part of any public crate)

The Rust Embedonomicon book, which is about writing Rust for embedded systems and similar restricted environments, has a chapter called "The smallest #![no_std] program" which explains this in a bit more detail, including the requirement for a panic handler implementation: https://docs.rust-embedded.org/embedonomicon/smallest-no-std.html

#rust #rustlang #windows #microsoft #reversing #reverseengineering

Cindʎ Xiao :breathe:
1 day ago

The Rust code in the new win32kbase_rs.sys in the Windows Kernel can also panic. What happens when it does?

There are several places where a panic is invoked in the code - they include bounds check failures (core::panicking::panic_bounds_check), indexing into a slice outside of the length of that slice (core::slice::index::slice_start_index_len_fail_rt), and assertion failures (core::panicking::assert_failed). These all eventually take a common code path through the following series of function calls:

core::panicking::panic_fmt::hd60a775b92204b91
-> rust_begin_unwind
--> seh_unwind::implementation::raise_exception::hc52a1220c03bdc19

This calls into a custom panic handler, seh_unwind::implementation::raise_exception, which calls RtlRaiseException, imported from the main ntoskrnl binary!

#rust #rustlang #windows #microsoft #reversing #reverseengineering

Lobsters
6 days ago

AR glasses USB protocols: the Good, the Bad and the Ugly https://voidcomputing.hu/blog/good-bad-ugly/ | https://lobste.rs/s/j5nvbe #hardware #reversing

Lobsters
1 week ago

Rust to Assembly: Understanding the Inner Workings of Rust https://eventhelix.com/rust/ | https://lobste.rs/s/bykhdz #reversing #rust

Washi
3 weeks ago

#AsmResolver 5.3.0 is out!

More performance and #pe reader bugfixes, new docs, and we also made it easier to ignore errors when writing #dotnet modules.

Changelog and download links:
👉 https://github.com/Washi1337/AsmResolver/releases/tag/v5.3.0

#malware #reversing

Lobsters
3 weeks ago

The Group Decode ROM: The 8086 processor's first step of instruction decoding http://www.righto.com/2023/05/8086-processor-group-decode-rom.html | https://lobste.rs/s/ndo4ko #hardware #historical #reversing

Cindʎ Xiao :breathe:
3 weeks ago

The Rust Windows kernel GDI code also has symbols for fallible_vec::FallibleVec<T,A> , which looks like a non-panicking Vec implementation. try_extend, try_extend_from_slice, try_splice_in, and try_insert are all implemented.

In fact it looks suspiciously similar to the rust_fallible_vec crate, which Microsoft recently open-sourced: https://github.com/microsoft/rust_fallible_vec :thonking:
( @TehPenguin 👋 )

The methods are generic over the allocator type A; some of these FallibleVec method implementations use the registered global allocator gdi_alloc::Win32Allocator , and others use the gdi_alloc::TaggedAllocator with the GDI-specific pool tags.

#rust #rustlang #windows #microsoft #reversing #reverseengineering

Symbols in win32kbase_rs.sys, showing the try_extend, try_splic_in, try_extend_from_slice, and try_insert methods of the trait fallible_vec::FallibleVec<T, A>
An annotated implementation, in Binary Ninja, of a function named fallible_vec::FallibleVec<T,A>::try_extend, where A is likely the allocator type gdi_alloc::Win32Allocator.
Cindʎ Xiao :breathe:
4 weeks ago

For the specific GDI objects, there are still allocations made with the existing GDI-specific pool tags.

It looks like the rgncore::scan::ScanBuilder<gdi_alloc::TaggedAllocator<_>> object uses the existing GDI pool tag Gscn ( i.e. GDITAG_SCAN_ARRAY) for vector allocations. (Probably gdi_alloc::TaggedAllocator<_> requires specifying a pool tag)

I also see Gedg (i.e. GDITAG_EDGE) being used in gdi_rust::region::from_path::GlobalEdgeTable::add_edge, and gdi_rust::region::from_path::ActiveEdgeTable::new
, among other places.

#rust #rustlang #windows #microsoft #reversing #reverseengineering

Cindʎ Xiao :breathe:
4 weeks ago

In the new Rust Windows kernel GDI code, there is a new global allocator registered named gdi_alloc::Win32Allocator . It calls Win32AllocPool with a fun new pool tag name, "Rust"!

#rust #rustlang #windows #microsoft #reversing #reverseengineering

The implementation of a new global allocator registered in the new Rust code in the Windows 11 kernel's implementation of GDI Regions. It is named gdi_alloc::Win32Allocator. It calls the function Win32AllocPool with the pool tag name "Rust".
Cindʎ Xiao :breathe:
4 weeks ago

For the new Windows kernel Rust GDI stuff that is all the rage now (win32kbase_rs.sys, win32kfull_rs.sys): here are the links to download copies of those binaries, from the Microsoft Symbol Server:

https://msdl.microsoft.com/download/symbols/win32kbase_rs.sys/272C4A031b000/win32kbase_rs.sys

https://msdl.microsoft.com/download/symbols/win32kfull_rs.sys/8264C482a000/win32kfull_rs.sys

These should be the versions that are in Windows 11 Insider Preview 25357.1 (zn_release) amd64 . The SHA-256 hashes are:

87ee0235caf2c97384581e74e525756794fa91b666eaacc955fc7859f540430d win32kbase_rs.sys
2efb9ea4032b3dfe7bf7698bd35e3ea3817d52f4d9a063b966f408e196957208 win32kfull_rs.sys

(I first extracted these files myself from the update package for build 25357.1, then generated the symbol server download URLs from the PE metadata in the files)

Of course, in addition to the actual executables, symbols are available from the symbol server as well (see screenshot).

@analog_feelings already did some reversing of win32kbase_rs.sys several weeks ago, here: https://tech.lgbt/@analog_feelings/110232321999960466 🤘

Now, time for me to go figure out how to actually reverse Rust 🦀

#rust #rustlang #windows #reversing #reverseengineering #microsoft

Alexandre Dulaunoy
1 month ago

Trying to find hashes for Snake (at least to see if it's different from the previous Snake samples).

https://media.defense.gov/2023/May/09/2003218554/-1/-1/0/JOINT_CSA_HUNTING_RU_INTEL_SNAKE_MALWARE_20230509.PDF

So I was wondering if the YARA rule mentioned would help to find some recent samples in VirusTotal. Obviously the rule is too broad and it's quite common to have such non-standard icon size.

Will they share the samples at some point? or at least the hashes? Another good point that having the sample hashes is important (even if the pyramid of pain said the opposite).

#infosec #snake #reversing #reverseengineering

10+ Matches on non standard ico
Chema Alonso :verified:
1 month ago

El lado del mal - 5ª Edición del Máster en Reversing, Análisis de Malware y Bug Hunting https://www.elladodelmal.com/2023/05/5-edicion-del-master-en-reversing.html #malware #reversing #CSIRT #master #formación #bughunting #CampusCiberseg

Lobste.rs
1 month ago

Nintendo reportedly issues DMCA takedown for Switch homebrew projects, Skyline Switch emulator development ceased https://gbatemp.net/threads/nintendo-reportedly-issues-dmca-takedown-for-switch-homebrew-projects-skyline-switch-emulator-development-ceased.632406/ #reversing #law

Lobsters
1 month ago
Rairii
1 month ago

thanks @winload_exe for mirroring a 2016 build of Windows (x86) with private symbols

it's not 100% private symbols (there's a few public symbols only in there afaik), but the majority of them have full type/locals/params info, most of which is still relevant today depending on what components you are looking at.

having private symbols definitely helped with my windows bootloader research, for example.

https://archive.org/details/10.0.14361.1000.rs1_release_prs.160603-2123_x86PlusPrivateSyms

#infosec #reversing #ReverseEngineering #windows

Cindʎ Xiao :breathe:
1 month ago

I've been experimenting with reversing Rust binaries recently. To help with this, I wrote a little @binaryninja plugin which imports type layout information from the Rust compiler: https://github.com/cxiao/rust_type_layout_helper_bn

You can install it now through the Binary Ninja plugin manager, by searching for "Rust Type Layout Helper".

The nightly versions of the Rust compiler support the print-type-sizes flag, which emit information about how types are laid out in memory. Its output looks like this:

print-type-size type: std::sys::windows::c::OBJECT_ATTRIBUTES: 48 bytes, alignment: 8 bytes
print-type-size field .Length: 4 bytes
print-type-size padding: 4 bytes
print-type-size field .RootDirectory: 8 bytes, alignment: 8 bytes
print-type-size field .ObjectName: 8 bytes0
print-type-size field .Attributes: 4 bytes
print-type-size padding: 4 bytes
print-type-size field .SecurityDescriptor: 8 bytes, alignment: 8 bytes
print-type-size field .SecurityQualityOfService: 8 bytes

The plugin parses that output from the Rust compiler, and creates the following type in Binary Ninja:

struct std::sys::windows::c::OBJECT_ATTRIBUTES __packed
{
int32_t .Length;
int32_t _padding;
int64_t .RootDirectory;
int64_t .ObjectName;
int32_t .Attributes;
int32_t _padding;
int64_t .SecurityDescriptor;
int64_t .SecurityQualityOfService;
};

This is an experimental plugin because the layout of data types in Rust is not stable, and can change between compilations; therefore, I'm not sure how useful this plugin will be for reversing targets for which you do not have the source code.

However, I think it will be useful if you're compiling your own Rust code, then examining the resulting binary in Binary Ninja as an exercise to get more familiar with certain core data types, or to get more familiar with how Rust lays out types in memory in general.

Happy reversing!

#rust #rustlang #binaryninja #malware #reverseengineering #reversing

A screenshot of the Binary Ninja Types window, showing types under the `std::sys::windows` namespace that were imported and created from Rust types.
Lobste.rs
1 month ago

A CTF Challenge using the Nintendo 3DS' unique features https://reswitched-weekly-reboot.github.io/posts/3ds-ctf/ #reversing #education

Lobsters
1 month ago
Lobste.rs
2 months ago

Realtek WiFi Firmware and a Fully 8051-based Keylogger Using RealWOW Technology (2021) https://8051enthusiast.github.io/2021/07/05/002-wifi_fun.html #hardware #reversing

Lobsters
2 months ago

Realtek WiFi Firmware and a Fully 8051-based Keylogger Using RealWOW Technology (2021) https://8051enthusiast.github.io/2021/07/05/002-wifi_fun.html | https://lobste.rs/s/r6mnn8 #hardware #reversing

Lobste.rs
2 months ago
Lobste.rs
2 months ago

Reverse-engineering the division microcode in the Intel 8086 processor http://www.righto.com/2023/04/reverse-engineering-8086-divide-microcode.html #hardware #reversing #historical

Lobsters
2 months ago

The microcode and hardware in the 8086 processor that perform string operations http://www.righto.com/2023/04/8086-microcode-string-operations.html | https://lobste.rs/s/2ls8pg #hardware #historical #reversing

Lobsters
2 months ago

Source code archives of several video games for classic consoles http://shrigley.com/source_code_archive/#comments | https://lobste.rs/s/rs69wv #games #historical #reversing

beSpacific
2 months ago

#FDA approves #overdose #reversing #Narcan for sale without #prescription. Move seen as a key strategy to control the US #overdose #crisis, which has been linked to more than 100,000 deaths a year https://www.fda.gov/news-events/press-announcements/fda-approves-first-over-counter-naloxone-nasal-spray #OTC #naloxone #opiod #overdoses

Lobsters
2 months ago
Lobsters
3 months ago
Washi
3 months ago

#AsmResolver 5.2.0 is out now.

This version includes read support for many more #PDB symbols, #dotnet AppHost patching, .NET TypeSignature::IsAssignableTo(type), QoL improvements and bug fixes.

👉 Full changelog and download links:
https://github.com/Washi1337/AsmResolver/releases/tag/v5.2.0

#reversing #malware

Lobsters
3 months ago

Printing real headline news on the Commodore 64 with The Newsroom's Wire Service https://oldvcr.blogspot.com/2023/03/printing-real-headline-news-on.html?m=1 | https://lobste.rs/s/l0j0wi #historical #reversing

Lobsters
3 months ago

Printing real headline news on the Commodore 64 with The Newsroom's Wire Service https://oldvcr.blogspot.com/2023/03/printing-real-headline-news-on.html | https://lobste.rs/s/khlxxz #historical #reversing

Lobsters
3 months ago

Tutorial for extracting the GameBoy ROM from photographs of the die https://github.com/travisgoodspeed/gbrom-tutorial | https://lobste.rs/s/odoals #hardware #reversing

Lobsters
3 months ago

Reverse-engineering the multiplication algorithm in the Intel 8086 processor http://www.righto.com/2023/03/8086-multiplication-microcode.html | https://lobste.rs/s/dwziof #hardware #historical #reversing

Lobsters
3 months ago

Reverse-engineering the register codes for the 8086 processor's microcode http://www.righto.com/2023/03/8086-register-codes.html | https://lobste.rs/s/1wiec3 #hardware #historical #reversing

lorddimwit
4 months ago

The kids just got home from school.

11yo: Dad, the TV’s not working!

Me: Oh yeah sorry. I moved it to a new network because I’m investigating its UPnP responses.

11yo: Stop breaking things for nerd reasons!

#reversing #protocols #infosec

Lobsters
5 months ago

Reverse Prompt Engineering for Fun and (no) Profit https://lspace.swyx.io/p/reverse-prompt-eng | https://lobste.rs/s/ohgntv #ai #reversing

J. A. Guerrero-Saade
6 months ago

Bro. I just stumbled upon the Bob Ross of Malware analysis. #Reversing #MalwareAnalysis #ChillAF
https://www.youtube.com/watch?v=uAb9aupRJ14

I just realised 6 months passed since my last #introduction (https://fosstodon.org/@mala/108340283629018455) so here is an updated one!

Names: +mala, Davide, da, Eddie, AiTTaLaM

Job: yes please 🙂 (aka formerly @ the birds place). #AI, #ML, but above all #teaching are my passions

Projects: 3564020356.org is the longest lasting one (~22yrs 😅), #PicoGopher the most recent... You go look and find the rest! 😜

Sports: #bouldering

Interests: #gopher #selfhosting #micropython #raspberrypi #opensource #reversing