XboxHacker BBS
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 20, 2013, 01:44:07 AM


Login with username, password and session length


Pages: 1 2 »
  Print  
Author Topic: Hight level vector shaders.  (Read 23695 times)
tser
Member
**
Posts: 46


View Profile WWW
« on: December 27, 2005, 05:31:39 PM »

one of the Demo disc floating around contains the game "King Kong". This game uses vector shaders, compiled with Microsoft (R) D3DX9 Shader Compiler 9.04.91.0000

I don't know anythingt about vector shaders... But is there maybe an expert on it in the room ?

Both Vector Source and a .Bin files are there.  and the demo runs when burned onto a dvd-r.

Not that it will lead to anything, but it would be intersting if we can modify the shaders of that game...

specially because it is rumoured that high level vector shaders have access tot the system memory as well
« Last Edit: December 28, 2005, 01:48:32 AM by tser » Logged
tser
Member
**
Posts: 46


View Profile WWW
« Reply #1 on: December 28, 2005, 06:11:05 PM »

The final version of king kong still has this shader directory,with a binary inside, which contains several shaders.

according to the reference model of shader languages,  shaders can contain array of variables, like ints.

technically that sounds like, creating a array of say 2, and trying to see what will happen if you touch position [3]

I got my direct X December 2005 sdk (legally, downloadable at msdn.microsoft.com) which contains the correct high level shader compiler.

continues digging.

Logged
tser
Member
**
Posts: 46


View Profile WWW
« Reply #2 on: December 28, 2005, 06:56:29 PM »

i am trying to figure out 3 things here
- one, is it possible at all to mess with the shaders  (simple replace blue water by red water)
- two is it possible, to read from any memory location at all ,using an array overrun
- Three is it possible to write to that memory also

one has been done as of 30-12-2005
two would really be useful, but i doubt if the gpu has no overrun protection
and three sounds currently to  impossible to believe for myself Smiley
« Last Edit: December 30, 2005, 07:22:50 PM by tser » Logged
tser
Member
**
Posts: 46


View Profile WWW
« Reply #3 on: December 30, 2005, 04:58:34 PM »

!!!!
It is Possible to Alter the shaders!
AO created All yellow shaders. and..

It worked!

http://tser.org/album/index.php?imagesize=640&d=d.html&image=z2005_12_30.jpg&Album=35

We modified the shaders of the king kong demo.

the shaders are compiled run time..... so you just can edit script files..

for example, to let it be all white :
return float4( 1.0f, 1.0f, 1.0f, 1.0f);
to reproduce :

- load the game
- select the first live
- wait for the loading screen has finished
- and enjoy the new world  : Your code is now in the gpu Smiley


« Last Edit: December 30, 2005, 08:31:22 PM by tser » Logged
ppu
Newbie
*
Posts: 1


View Profile
« Reply #4 on: December 30, 2005, 05:48:32 PM »

now the race to find the memexport instruction encoding? :]

you should loop through all addresses, MEMEXPORT'ing break instructions,
printing out the mem addresses as you go in the shader texture :]

Logged
dirtysanchez
Hacker
***
Posts: 85


View Profile
« Reply #5 on: December 31, 2005, 01:21:16 PM »

Very interesting indeed. I'm not sure about this but can you inject code into a shader to run code other than a shader? If its compiled at runtime, the compiler might just throw out extraneous code and throw up a flag to the hypervisor.
Logged
streko
Newbie
*
Posts: 3


View Profile
« Reply #6 on: December 31, 2005, 03:28:31 PM »

Very interesting indeed. I'm not sure about this but can you inject code into a shader to run code other than a shader? If its compiled at runtime, the compiler might just throw out extraneous code and throw up a flag to the hypervisor.

The cpu won't be running any of the compiled code even though it shares memory with the gpu.  The compiled code will be used only by the gpu.  I think the goal here is to modify code in memory that the cpu uses, through the gpu, but the kernel will catch things like this.  I don't see any way the gpu can modify anything running in the kernel, which is what we want.
Logged
caustik
Newbie
*
Posts: 1


View Profile
« Reply #7 on: December 31, 2005, 06:03:54 PM »

There are a few possibilities I see here:

1) MEMEXPORT may allow access to arbitrary memory locations. This could be used to overwrite code and/or data in key places, allowing for execution of native code (perhaps the code could exist in a texture, or within the shader code itself, or the shader could deposit some code using MEMEXPORT.). There could be two things here that prevent this from working: a) Microsoft saw this and they limit the addresses you can MEMEXPORT to. b) The hypervisor will notice whats going on and foil your plans.

2) There could be a bug in the compilation from HLSL -> Native shader. There could be an exploit here. Once again, the hypervisor might notice whats going on and foil your plans again.

3) There could be unexpected exceptions during the GPU's interpretation of shader instructions. It's most likely the XB360 will handle these gracefully, but possibly not.

4) The library that opens the HLSL from disk could have bugs. Meaning, perhaps the file format itself has edge conditions that could leave an opening for an exploit.

I know i'm probably just stating the obvious, but I figure some people reading this forum might want some explicit explanations :]

caustik
Logged
streko
Newbie
*
Posts: 3


View Profile
« Reply #8 on: December 31, 2005, 06:12:05 PM »

We should put the hypervisor to the test, it's never been confirmed to actually exist.  MEMEXPORT would be a good start
Logged
tser
Member
**
Posts: 46


View Profile WWW
« Reply #9 on: January 01, 2006, 04:55:41 PM »

AO did some technical research :
http://www.gamedev.no/xbox360_shaders.jsp

We might be out of luck here.. but AO and i keep on digging Smiley

BTW : we noted that on a HDTV the altered shaders did not get loaded !



« Last Edit: January 01, 2006, 05:01:30 PM by tser » Logged
j005u
Member
**
Posts: 28


View Profile
« Reply #10 on: January 03, 2006, 05:34:46 AM »

AO did some technical research :
http://www.gamedev.no/xbox360_shaders.jsp

We might be out of luck here.. but AO and i keep on digging Smiley

BTW : we noted that on a HDTV the altered shaders did not get loaded !


well. here's my theory about why:
the 'standard' for the 360 is 720p right? and did you not find both compiled and uncompiled shaders in the shaders folder?

so wouldn't it make a little bit of sense if for 720p they'd use the compiled shaders and otherwise (pal, ntsc) compile new shaders at runtime?

i don't have any technical knoweledge of shaders so my point might be completely invalid but aslong as we don't have an expert here it's worth a try:
compile the shaders and replace both the sources and the binaries on the disk and see what happens then on a hdtv tv...
Logged
tser
Member
**
Posts: 46


View Profile WWW
« Reply #11 on: January 03, 2006, 06:32:57 PM »

I have now Experienced 2 fatal Crashes already on my xbox, during my shader experiment.
When the Xbox crashes ...
* It Halt's itself with a freeze : the Screen which was active, remains.
  (one time, black screen, 1 time the loading.wmv file of king kong on a halt - )
* eject does not do anything
* USB Devices are not longer working
* Wireless Controler does not get connected
* Plugin in a USB Controler only lights up Left Corner, and Right Down Corner
* Unconnected Video Out Cable results in red flash, Reconnecting removes red light
* The only way to get your box back is to unplug the power cable

Logged
G0t m4xx 21
Master Hacker
****
Posts: 187

t('.'t)


View Profile
« Reply #12 on: January 04, 2006, 12:34:20 AM »

what did you change to make it crash?
Logged

"Absolute freedom can exist only in a state of anarchy"
dirtysanchez
Hacker
***
Posts: 85


View Profile
« Reply #13 on: January 04, 2006, 08:41:28 AM »

Nice work guys....

We know that the CPU is designed by IBM, and could be a close cousin of the type found in their pSeries servers.

Going by what I've read about how the hypervisor separates running code into individual virtual machines (maybe some type of LPAR)

The POWER4 microprocessor supports an enhanced form of system call, known as Hypervisor mode, that allows a privileged program access to certain hardware facilities. The support also includes protection for those facilities in the processor. This special mode allows the processor to access information about systems located outside the boundaries of the partition where the processor is located.

Various other system components have the ability to limit the impact of hardware errors to a single partition. Generally, this is achieved by turning most hardware error reporting into "bad" data packets that flow back to the requesting processor. In many cases this will cause a machine check interrupt that may or may not be recoverable within the partition. No other partitions are affected.

Partition isolation and security
Applications run inside partitions the same way they run on a standalone server. The design of the pSeries family is such that one partition is isolated from software running in the other partitions, including protection against natural software defects and deliberate software attempts to break the LPAR barriers. It has the following security features:

    * Interpartition data access: the design of pSeries prevents any data access between partitions, other than using regular networks. This isolates the partitions against unauthorized access between boundaries.
    * Unexpected partition crash: a software partition crash should not cause any disruption to other partitions. Neither an application failure nor the operating system failure inside a partition interfere with the operation of other partitions.
    * Denial of Service across shared resources: the pSeries design prevents partitions from making extensive use of a shared resource so that other partitions using that resource become starved. This means that partitions sharing the same PCI bridge chips, for example, cannot lock the bus indefinitely.

The above statement could explain why we're not getting any error reporting whatsoever when the "partition" crashes
« Last Edit: January 04, 2006, 08:43:19 AM by dirtysanchez » Logged
BassACE
Newbie
*
Posts: 1


View Profile
« Reply #14 on: January 04, 2006, 11:16:27 AM »

Though my experience is anything but with the PowerPC, I'm gonna throw in my two cents.

tser's crashes imply to me two things:  One, that the Hypervisor sees that King Kong is going out of its virtual machine memory space, thereby causing Kong's VM to lock up.  Two: because the rest of the system freezes, it implys to me that it's getting into some important VM's memory space (at first I thought the kernel, but since it detected hot swap, I'm going to add the dashboard to my list of VM's that Kong's VM is adjacent to; also see the paragraph after the next), and the hypervisor is crashing that adjacent VM.

What if that next VM is for something important, such as the kernel or dashboard.  What if the system crashes because that VM's memory has been tampered with...  by King Kong, but the hypervisor doesn't realize this until it's too late?  This assumes that the kernel memory is adjacent to that VM's memory space of course.  This explains (to me at least) why more or less nothing worked at all, and tser had to pulll the plug to unfreeze his box.

Or, what if the kernel runs in two virtual machines?  One for higher level functions (such as system calls, function calls, device interfacing, etc), and one for lower level functions (such as hotswap, device detection, etc.).  This could explain the controllers and the video cable being detected, but the controllers not working.

I haven't tried any of these experiments, and I could be completely wrong in all of my assumptions, and if I am, please delete this post.  I just wanted to throw in my two cents to help the cause...  And without knowing what tser changed, all this could be compete BS.
Logged
dirtysanchez
Hacker
***
Posts: 85


View Profile
« Reply #15 on: January 04, 2006, 12:05:50 PM »

BassACE... you're on the right track.

The Hypervisor doesn't really know if the code running is valid or not. It does know that if a memory overrun does occur, due to crappy coding, it throws out the entire execution within the problem VM and dumps. Dumps where? I have no idea... possibly a CPU instruction resets that specific VM.

This would explain why what tser did with the RETAIL xex file and the demo disc sorta kinda worked.
Logged
annerajb
Newbie
*
Posts: 2


View Profile
« Reply #16 on: January 05, 2007, 11:45:56 AM »

hey i dont know if u still need help on shaders but i do shader programming so if u need help or explanation on somehting just ask me
Logged
TheSpecialist
Global Moderator
Xbox Hacker
*****
Posts: 782


View Profile
« Reply #17 on: February 28, 2007, 09:00:53 AM »

In light of recent developments, I think this thread needs a bump Smiley Especially this post is VERY interesting:

I have now Experienced 2 fatal Crashes already on my xbox, during my shader experiment.
When the Xbox crashes ...
* It Halt's itself with a freeze : the Screen which was active, remains.
  (one time, black screen, 1 time the loading.wmv file of king kong on a halt - )
* eject does not do anything
* USB Devices are not longer working
* Wireless Controler does not get connected
* Plugin in a USB Controler only lights up Left Corner, and Right Down Corner
* Unconnected Video Out Cable results in red flash, Reconnecting removes red light
* The only way to get your box back is to unplug the power cable

Does anybody have some more info on how to mod shader code to replicate such crash ?
« Last Edit: February 28, 2007, 09:03:53 AM by TheSpecialist » Logged
Zenofex
Member
**
Posts: 18


View Profile WWW
« Reply #18 on: February 28, 2007, 01:11:53 PM »

In light of recent developments, I think this thread needs a bump Smiley Especially this post is VERY interesting:

I have now Experienced 2 fatal Crashes already on my xbox, during my shader experiment.
When the Xbox crashes ...
* It Halt's itself with a freeze : the Screen which was active, remains.
  (one time, black screen, 1 time the loading.wmv file of king kong on a halt - )
* eject does not do anything
* USB Devices are not longer working
* Wireless Controler does not get connected
* Plugin in a USB Controler only lights up Left Corner, and Right Down Corner
* Unconnected Video Out Cable results in red flash, Reconnecting removes red light
* The only way to get your box back is to unplug the power cable

Does anybody have some more info on how to mod shader code to replicate such crash ?

TS-

I dont know if youve looked at tsers shader test shader but heres it is in case not.

Code:
//-----------------------------------------------------------------------------
// tser's test shader.
//-----------------------------------------------------------------------------
uniform sampler g_TextureSampler[8] : register( s0 );
struct PSIN
{
    float4 Position         : POSITION;
    float4 Color : COLOR0_centroid;
    float3 TexCoord0        : TEXCOORD0_centroid;
    float3 TexCoord1        : TEXCOORD1_centroid;
    float3 TexCoord2        : TEXCOORD2_centroid;
    float3 TexCoord3        : TEXCOORD3_centroid;
    float3 TexCoord4        : TEXCOORD4_centroid;
    float3 TexCoord5        : TEXCOORD5_centroid;
};





float4 ProcessPixel ( PSIN Input,
int iGodRayShaderId,
int iRemananceShaderId,
int iZoomSmoothId,
int iBlackWhiteId,
int iFogShaderId,
int iBlitShaderId,
int iColorDiffusion,
int iMotionBlur,
int iBigBlur,
int iColorBalance,
int iBKQuad,
int iUnused12,
int iUnused13,
int iUnused14,
int iUnused15)
{

float4 FinalColor = float4(0.0f, 1.0f, 0.0f, 0.0f);
if (iGodRayShaderId ==3)
{
           if (Input.TexCoord0.y<0.9f)
           {
              if (Input.TexCoord0.x>0.1f)
              {
               if (Input.TexCoord0.x<0.9f)
                {  
                 FinalColor = float4 (1.0f,1.0f,0.0f,0.4f);
                }
              }
           }
    }
   

return FinalColor;
}

// Test shader entry points for various configurations of shaders
float4 PSTest( PSIN Input ) : COLOR
{
    return ProcessPixel(Input, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}

\

Although i think this may be part of his "all yellow" test as displayed here
http://tser.org/album/index.php?imagesize=640&d=d.html&image=z2005_12_30.jpg&Album=35
I dont see anything related to MEMEXPORT, so i doubt this is what made it crash (if the crashing actually was due to him trying to read the "unprivledged memory"). I'll keep looking and see if i cant find anything else. GLUCK!

Thanks -Zenofex-
« Last Edit: February 28, 2007, 01:19:09 PM by Zenofex » Logged

---------------------------------------------------------------------------
Check out my website http://www.gtvhacker.com/
tser
Member
**
Posts: 46


View Profile WWW
« Reply #19 on: March 01, 2007, 02:32:22 PM »

alloc is a wonderfull thing.

For example :

float4 AnexportAddress : register(c2);
static float4 Justaconst01= {0, 1, 0, 0};

void main(int index:INDEX)
{
    float4 output = float4(0.5, 0.5 , 1.0, 1.0);
    asm {
      alloc export=1
        mad eA, index, Justaconst01, AnexportAddress
        mov eM0, output
    };
}
Logged
Pages: 1 2 »
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM