litlle feeling of dex

« Older   Newer »
 
  Share  
.
  1. doctor_m
        +1   Like  
     
    .

    User deleted


    Been playing around as i always do :)

    been bugging me there arent any disasemplers that can view any code, only dissasemply.

    and some interesting stuff came up

    first you should build all the samples and projects in the sdk.

    you would need to do an batch build with both debug and release.

    after build you would have debug and an realese folder.

    now open up tuner software from the sdk.

    Choose open static analyze

    now if you open any elf from the build, and open them in the tuner it looks like this after
    using sample from libsecure release build.
    Aes.obj
    right click it, then it shows disasemply
    AVEGX
    now this is okay since you can get some info in tuner what the functions are for.

    but now comes the neat part if you do the same with the debug buils
    Aes.obj

    right click it.

    shows all the source code insteed :D

    CODE
    /* SCE CONFIDENTIAL
    * Copyright (C) 2011 Sony Computer Entertainment Inc.
    * All Rights Reserved.
    */

    /*
    *                   libsecure encryption/decryption sample file
    *
    *                               - libsecure -
    *
    *                       samples/ps3/cipher/source/aes.c
    *
    *       Version        Date            Design      Log
    *  --------------------------------------------------------------------
    *      2.00            Nov,19,2010     Emmanuel Poitier    Naming changes
    *      1.00            Apr,04,2008     David Carter        Initial version
    */

    // ---------------------------------------------------------------------
    // Includes
    // ---------------------------------------------------------------------

    #include "libsecure.h"
    #include "main.h"

    /*E A symmetric key */
    static unsigned char s_symmetricKeyArray[16]= {
           0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11,
           0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99
    };

    static SceLibSecureSymmetricKey s_symmetricKey = {
           sizeof(s_symmetricKeyArray), (void*)(&s_symmetricKeyArray)
    };

    /* The plaintext message */
    static char s_message[] = "AES testing message.";


    // ---------------------------------------------------------------------
    // Functions
    // ---------------------------------------------------------------------

    SceLibSecureErrorType processAesEcbNoPadding()
    {
           SceLibSecureErrorType err;

           printf("--------------------------------------------------\n\n");

           /*E ECB encryption / decryption */
           err = encryptDecryptNoPadding(SCE_LIBSECURE_CIPHER_AES, SCE_LIBSECURE_BLOCKCIPHERMODE_ECB,
                   SCE_LIBSECURE_PADDING_NONE, &s_symmetricKey, s_message, 0);
           if (err != SCE_LIBSECURE_OK) return err;

           printf("--------------------------------------------------\n\n");

           /*E ECB encryption / decryption */
           err = encryptDecryptNoPadding(SCE_LIBSECURE_CIPHER_AES, SCE_LIBSECURE_BLOCKCIPHERMODE_ECB,
                   SCE_LIBSECURE_PADDING_NONE_NORMAL, &s_symmetricKey, s_message, 0);
           if (err != SCE_LIBSECURE_OK) return err;

           printf("--------------------------------------------------\n\n");

           /*E ECB encryption / decryption */
           err = encryptDecryptNoPadding(SCE_LIBSECURE_CIPHER_AES, SCE_LIBSECURE_BLOCKCIPHERMODE_ECB,
                   SCE_LIBSECURE_PADDING_NONE_STEALING, &s_symmetricKey, s_message, 0);
           if (err != SCE_LIBSECURE_OK) return err;

           printf("--------------------------------------------------\n\n");

       return SCE_LIBSECURE_OK;
    }

    SceLibSecureErrorType processAesEcbWithPadding()
    {
           SceLibSecureErrorType err;

           printf("--------------------------------------------------\n\n");

           /*E ECB encryption / decryption */
           err = encryptDecryptWithPadding(SCE_LIBSECURE_CIPHER_AES, SCE_LIBSECURE_BLOCKCIPHERMODE_ECB,
                   SCE_LIBSECURE_PADDING_NIL, &s_symmetricKey, s_message, 0);
           if (err != SCE_LIBSECURE_OK) return err;

           printf("--------------------------------------------------\n\n");

           /*E ECB encryption / decryption */
           err = encryptDecryptWithPadding(SCE_LIBSECURE_CIPHER_AES, SCE_LIBSECURE_BLOCKCIPHERMODE_ECB,
                   SCE_LIBSECURE_PADDING_RANDOM, &s_symmetricKey, s_message, 0);
           if (err != SCE_LIBSECURE_OK) return err;

           printf("--------------------------------------------------\n\n");

       return SCE_LIBSECURE_OK;
    }

    SceLibSecureErrorType processAesCbcNoPadding()
    {
           SceLibSecureErrorType err;

           printf("--------------------------------------------------\n\n");

           /*E CBC encryption / decryption */
           err = encryptDecryptNoPadding(SCE_LIBSECURE_CIPHER_AES, SCE_LIBSECURE_BLOCKCIPHERMODE_CBC,
                   SCE_LIBSECURE_PADDING_NONE, &s_symmetricKey, s_message, 0);
           if (err != SCE_LIBSECURE_OK) return err;

           printf("--------------------------------------------------\n\n");

           /*E CBC encryption / decryption */
           err = encryptDecryptNoPadding(SCE_LIBSECURE_CIPHER_AES, SCE_LIBSECURE_BLOCKCIPHERMODE_CBC,
                   SCE_LIBSECURE_PADDING_NONE_NORMAL, &s_symmetricKey, s_message, 0);
           if (err != SCE_LIBSECURE_OK) return err;

           printf("--------------------------------------------------\n\n");

           /*E CBC encryption / decryption */
           err = encryptDecryptNoPadding(SCE_LIBSECURE_CIPHER_AES, SCE_LIBSECURE_BLOCKCIPHERMODE_CBC,
                   SCE_LIBSECURE_PADDING_NONE_STEALING, &s_symmetricKey, s_message, 0);
           if (err != SCE_LIBSECURE_OK) return err;

           printf("--------------------------------------------------\n\n");

           /*E CBC encryption / decryption */
           err = encryptDecryptNoPadding(SCE_LIBSECURE_CIPHER_AES, SCE_LIBSECURE_BLOCKCIPHERMODE_CBC,
                   SCE_LIBSECURE_PADDING_NONE_BLKTERM, &s_symmetricKey, s_message, 0);
           if (err != SCE_LIBSECURE_OK) return err;

           printf("--------------------------------------------------\n\n");

       return SCE_LIBSECURE_OK;
    }

    SceLibSecureErrorType processAesCbcWithPadding()
    {
           SceLibSecureErrorType err;

           printf("--------------------------------------------------\n\n");

           /*E CBC encryption / decryption */
           err = encryptDecryptWithPadding(SCE_LIBSECURE_CIPHER_AES, SCE_LIBSECURE_BLOCKCIPHERMODE_CBC,
                   SCE_LIBSECURE_PADDING_NIL, &s_symmetricKey, s_message, 0);
           if (err != SCE_LIBSECURE_OK) return err;

           printf("--------------------------------------------------\n\n");

           /*E CBC encryption / decryption */
           err = encryptDecryptWithPadding(SCE_LIBSECURE_CIPHER_AES, SCE_LIBSECURE_BLOCKCIPHERMODE_CBC,
                   SCE_LIBSECURE_PADDING_RANDOM, &s_symmetricKey, s_message, 0);
           if (err != SCE_LIBSECURE_OK) return err;

           printf("--------------------------------------------------\n\n");

       return SCE_LIBSECURE_OK;
    }

    SceLibSecureErrorType processAesCtrNoPadding()
    {
           SceLibSecureErrorType err;

           printf("--------------------------------------------------\n\n");

           /*E CTR encryption / decryption */
           err = encryptDecryptNoPadding(SCE_LIBSECURE_CIPHER_AES, SCE_LIBSECURE_BLOCKCIPHERMODE_CTR,
                   SCE_LIBSECURE_PADDING_NONE, &s_symmetricKey, s_message, 0);
           if (err != SCE_LIBSECURE_OK) return err;

           printf("--------------------------------------------------\n\n");

           /*E CTR encryption / decryption */
           err = encryptDecryptNoPadding(SCE_LIBSECURE_CIPHER_AES, SCE_LIBSECURE_BLOCKCIPHERMODE_CTR,
                   SCE_LIBSECURE_PADDING_NONE_NORMAL, &s_symmetricKey, s_message, 0);
           if (err != SCE_LIBSECURE_OK) return err;

           printf("--------------------------------------------------\n\n");

       return SCE_LIBSECURE_OK;
    }

    SceLibSecureErrorType processAes()
    {
           SceLibSecureErrorType err;

           /*E ECB with no padding encryption / decryption */
           err = processAesEcbNoPadding();
           if (err != SCE_LIBSECURE_OK) return err;

           /*E CBC with no padding encryption / decryption */
           err = processAesCbcNoPadding();
           if (err != SCE_LIBSECURE_OK) return err;

           /*E CTR with no padding encryption / decryption */
           err = processAesCtrNoPadding();
           if (err != SCE_LIBSECURE_OK) return err;

           /*E ECB with padding encryption / decryption */
           err = processAesEcbWithPadding();
           if (err != SCE_LIBSECURE_OK) return err;

           /*E CBC with padding encryption / decryption */
           err = processAesCbcWithPadding();
           if (err != SCE_LIBSECURE_OK) return err;

       return SCE_LIBSECURE_OK;
    }


    this works on all the debug objects files in debug build.

    could be off use when looking at big builds
    and when building you own

    and one more thing the tuner can take alot off the extracted files that i posted,
    and show there build too.
    also some of the files if you used dev_blinds to copy intire dev flash/2/3 from ps3
    the elf files there are debugs and the pic files are also shown and how there build there.
    And work also if you take all the *.a files extract them with 7zip you have alot off *.o files they work there also.

    so for exampel libguard.a extarcted there are alot of *.o inside
    just one in the tuner with sources
    CODE
    C:\HOME\KANEE\SVNWORK\PS3-SVN\SVN\SYS\TRUNK\SDK\TARGET\SPU\INCLUDE\SPU_INTERNALS.H
         si_wrch(MFC_EAH,si_from_uint(eahi));
    00000324 40800026 il r038,0x0000                            EVN
    C:\HOME\KANEE\SVNWORK\PS3-SVN\SVN\SYS\TRUNK\SPU_RUNTIME\IMPLEMENTATION\SRC\SPURS3\JM2\SPU\JOB_CRT_AUXILIARY.C
    00000328 340004A3 lqd r035,0x0000(r009)                     ODD
    0000032C 8482C2A7 selb r036,r005,r011,r039                  EVN
    C:\HOME\KANEE\SVNWORK\PS3-SVN\SVN\SYS\TRUNK\SDK\TARGET\SPU\INCLUDE\SPU_INTERNALS.H
    [...]
    {
         si_wrch(MFC_LSA,si_from_ptr(ls));
         si_wrch(MFC_EAL,si_from_uint(ea));
         si_wrch(MFC_Size,si_from_uint(size));
         si_wrch(MFC_TagID,si_from_uint(tagid));
         si_wrch(MFC_Cmd,si_from_uint(cmd));
    }
    static __inline__ void
    spu_mfcdma64(volatile void *ls, unsigned int eahi, unsigned int ealow, unsigned int size, unsigned int tagid, unsigned int cmd)
    {
         si_wrch(MFC_LSA,si_from_ptr(ls));
    00000330 21A00802 wrch $MFC_LSA,r002                        ODD
         si_wrch(MFC_EAH,si_from_uint(eahi));
    00000334 21A008A6 wrch $MFC_EAH,r038
         si_wrch(MFC_Size,si_from_uint(size));
    00000338 04001225 lr r037,r036
    C:\HOME\KANEE\SVNWORK\PS3-SVN\SVN\SYS\TRUNK\SPU_RUNTIME\IMPLEMENTATION\SRC\SPURS3\JM2\SPU\JOB_CRT_AUXILIARY.C
    0000033C 08015205 sf r005,r036,r005                         EVN
    C:\HOME\KANEE\SVNWORK\PS3-SVN\SVN\SYS\TRUNK\SDK\TARGET\SPU\INCLUDE\SPU_INTERNALS.H
         si_wrch(MFC_EAL,si_from_uint(ealow));
    00000340 21A0090A wrch $MFC_EAL,r010                        ODD
    C:\HOME\KANEE\SVNWORK\PS3-SVN\SVN\SYS\TRUNK\SPU_RUNTIME\IMPLEMENTATION\SRC\SPURS3\JM2\SPU\JOB_CRT_AUXILIARY.C
    00000344 18090387 a r007,r007,r036                          EVN
    C:\HOME\KANEE\SVNWORK\PS3-SVN\SVN\SYS\TRUNK\SDK\TARGET\SPU\INCLUDE\SPU_INTERNALS.H
         si_wrch(MFC_Size,si_from_uint(size));
    00000348 21A009A5 wrch $MFC_Size,r037                       ODD
    C:\HOME\KANEE\SVNWORK\PS3-SVN\SVN\SYS\TRUNK\SPU_RUNTIME\IMPLEMENTATION\SRC\SPURS3\JM2\SPU\JOB_CRT_AUXILIARY.C
    0000034C 18090306 a r006,r006,r036                          EVN
    00000350 3B8251A2 rotqby r034,r035,r009                     ODD
    C:\HOME\KANEE\SVNWORK\PS3-SVN\SVN\SYS\TRUNK\SDK\TARGET\SPU\INCLUDE\SPU_INTERNALS.H
         si_wrch(MFC_TagID,si_from_uint(tagid));
    00000354 21A00A22 wrch $MFC_TagID,r034                     03 (00000350) REG
         si_wrch(MFC_Cmd,si_from_uint(cmd));
    00000358 21A00A8F wrch $MFC_Cmd,r015                        ODD
    [...]
    {
         si_wrch(MFC_LSA,si_from_ptr(ls));
         si_wrch(MFC_EAL,si_from_uint(ea));
         si_wrch(MFC_Size,si_from_uint(size));
         si_wrch(MFC_TagID,si_from_uint(tagid));
         si_wrch(MFC_Cmd,si_from_uint(cmd));
    }
    static __inline__ void
    spu_mfcdma64(volatile void *ls, unsigned int eahi, unsigned int ealow, unsigned int size, unsigned int tagid, unsigned int cmd)
    {
         si_wrch(MFC_LSA,si_from_ptr(ls));
    0000035C 04000382 lr r002,r007                              EVN
         si_wrch(MFC_EAL,si_from_uint(ealow));
    00000360 3FE0030A shlqbyi r010,r006,0x00                    ODD
    C:\HOME\KANEE\SVNWORK\PS3-SVN\SVN\SYS\TRUNK\SPU_RUNTIME\IMPLEMENTATION\SRC\SPURS3\JM2\SPU\JOB_CRT_AUXILIARY.C
    00000364 1C092889 ai r009,r081,0x0024                       EVN
    00000368 217FF685 brnz r005,0x0000031C                      ODD
    0000036C 1C020408 ai r008,r008,0x0008                       EVN
    00000370 40800083 il r003,0x0001
    00000374 34000429 lqd r041,0x0000(r008)                    01 (0000036C) REG
    00000378 3B821486 rotqby r006,r041,r008                    05 (00000374) REG ODD
    0000037C 7CFFC328 ceqi r040,r006,-0x0001                   03 (00000378) REG EVN
    00000380 207FEC28 brz r040,0x000002E0                      01 (0000037C) REG ODD ?HINT
    00000384 20000503 brz r003,0x000003AC                       ?HINT
    00000388 1C0928AF ai r047,r081,0x0024
    0000038C 408000AC il r044,0x0001                            EVN
    00000390 340017AE lqd r046,0x0000(r047)                     ODD
    00000394 4080012A il r042,0x0002                            EVN
    00000398 3B8BD72D rotqby r045,r046,r047                    04 (00000390) REG ODD
    0000039C 0B6B562B shl r043,r044,r045                       03 (00000398) REG EVN
    000003A0 21A00B2B wrch $MFC_WrTagMask,r043                 03 (0000039C) REG ODD
    000003A4 21A00BAA wrch $MFC_WrTagUpdate,r042
    000003A8 01A00C02 rdch r002,$MFC_RdTagStat                  ODD
    000003AC 408000B2 il r050,0x0001                            EVN
    000003B0 34010731 lqd r049,0x0040(r014)                     ODD
    000003B4 3EC100B3 cwd r051,0x04(r001)
    000003B8 B60C5933 shufb r048,r050,r049,r051                04 (000003B0) REG ODD
    000003BC 24010730 stqd r048,0x0040(r014)                   03 (000003B8) REG
    000003C0 1C0B2838 ai r056,r080,0x002C
    000003C4 1C0E6837 ai r055,r080,0x0039                       EVN
    000003C8 34001C36 lqd r054,0x0000(r056)                     ODD
    000003CC 3B8DDB35 rotqby r053,r054,r055                    05 (000003C8) REG
    000003D0 14009AB4 andi r052,r053,0x0002                    03 (000003CC) REG
    000003D4 200006B4 brz r052,0x00000408                      02 (000003D0) REG ?HINT
    000003D8 3400683F lqd r063,0x0010(r080)                     ODD
    C:\HOME\KANEE\SVNWORK\PS3-SVN\SVN\SYS\TRUNK\SPU_RUNTIME\IMPLEMENTATION\SRC\SPURS3\JM2\SPU\JOB_MEMORY_CHECK.H
    000003DC 408000B9 il r057,0x0001                            EVN
    000003E0 33800041 lqr r065,0x000003E0                       ODD

    and that aint in the wiki ;)

    Edited by Zrandi - 7/6/2012, 00:39
     
    .
  2.     Like  
     
    .
    Avatar

    Lo que empiezo, lo termino.

    Group
    FUNDaDoR
    Posts
    12,533
    Location
    En algún lugar del Espacio

    Status
    Offline
    hahaha :) wiki deslombras me with much information

    I approve
     
    .
  3. doctor_m
        Like  
     
    .

    User deleted


    could be off use when your stuck with libary functions etc, when developing new apps
    specially spu functions since, there are none that shows that.

    Edited by doctor_m - 5/6/2012, 20:58
     
    .
  4.     Like  
     
    .
    Avatar

    Lo que empiezo, lo termino.

    Group
    FUNDaDoR
    Posts
    12,533
    Location
    En algún lugar del Espacio

    Status
    Offline
    ok I'll see
     
    .
  5. mostneo
        Like  
     
    .

    User deleted


    doctor_m is a Zadow28??? Good Work!!!
     
    .
4 replies since 5/6/2012, 17:52   169 views
  Share  
.