hello need help

This is a discussion on hello need help within the C++ Programming forums, part of the General Programming Boards category; ive got a source code for a program i used to like to use it was a client that emulated ...

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    3

    hello need help

    ive got a source code for a program i used to like to use
    it was a client that emulated yahoo chat

    well they changed the log in technique and things since then
    and its open source
    and very simple

    i would like to figure out how to make it work again
    so i can use it

    but i dont know c++ so if anyone would like to help me look over the code
    and figure this out it would be greatly appreciated


    (its only 12kb)


    my icq# is 211241210

  2. #2
    Registered User
    Join Date
    Jun 2004
    Posts
    3
    its source is in two files dos_c.txt
    Code:
    /*
     * copyright David J. Binette
     * ALL RIGHTS RESERVED
     */
    
    /* ------------------------------------------------------------------------ */
    
    #include "dos.h"
    
    /* ------------------------------------------------------------------------ */
    
    #define TRAPCONTROLC 0
    
    /* ------------------------------------------------------------------------ */
    
    #if TRAPCONTROLC
    static SESSION * GlobalSessionHook = NULL;
    #endif
    
    /* ------------------------------------------------------------------------ */
    
    static void clearToEndOfScreen(SESSION *sess)
    {
        int     num_chars;
        DWORD   written;
        CONSOLE_SCREEN_BUFFER_INFO info;
        GetConsoleScreenBufferInfo(sess->o ,&info);
        num_chars = info.dwSize.X-info.dwCursorPosition.X + info.dwSize.X*(info.dwSize.Y-info.dwCursorPosition.Y-1);
        FillConsoleOutputCharacter(sess->o ,' ',num_chars ,info.dwCursorPosition ,&written);
        FillConsoleOutputAttribute(sess->o ,info.wAttributes ,num_chars ,info.dwCursorPosition ,&written);
    }
    
    /* ------------------------------------------------------------------------ */
    
    void ClearScreen(SESSION *sess)
    {
        if(sess->ansi)
            fprintf(sess->o ,"\033[H\033[2J");
        else
        {   COORD   coord   = {0 ,0};
            /* home */
            SetConsoleCursorPosition(sess->o ,coord);
            /* erase to end of screen */
            clearToEndOfScreen(sess);
        }
    }
    
    /* ------------------------------------------------------------------------ */
    
    char *Ask(SESSION *sess ,const char *prompt ,char *buf ,int n ,short hide)
    {
        char *p;
        DWORD omode=0;
        DWORD b;
    
        /* save cursor position */
        if(sess->ansi)  fprintf(sess->o ,"\033[s");
    
        fprintf(sess->o ,"%s" ,prompt);
    
        if(hide)
        {   GetConsoleMode(sess->i ,&omode);
            SetConsoleMode(sess->i ,omode &~ ENABLE_ECHO_INPUT);
        }
    
        ReadFile( sess->i ,buf ,n ,&b ,0 );
    
        if(hide)
            SetConsoleMode(sess->i ,omode);
        if(hide>1)
            fprintf(sess->o ,"\n");
    
        buf[b] = EOS;
        p=strchr(buf ,'\r'); if(p) *p = EOS;
        p=strchr(buf ,'\n'); if(p) *p = EOS;
    
        /* restore cursor position */
        if(sess->ansi)
        {   fprintf(sess->o ,"\033[u");
            clearToEndOfScreen(sess);
        }
    
        return buf;
    }
    
    /* ------------------------------------------------------------------------ */
    
    BOOL KeybDataAvailable(SESSION *sess)
    {
        INPUT_RECORD inrec;
        DWORD num_keys;
    
        if(GetNumberOfConsoleInputEvents(sess->i ,&num_keys)
        && num_keys
        && ReadConsoleInput(sess->i ,&inrec ,1UL ,&num_keys)
        && num_keys
        && (inrec.EventType == KEY_EVENT)
        && inrec.Event.KeyEvent.bKeyDown
        )
        {   switch(inrec.Event.KeyEvent.wVirtualScanCode) {
            case VK_RETURN  :   FlushConsoleInputBuffer(sess->i);
            case VK_NUMLOCK :
            case VK_CAPITAL :
            case VK_SHIFT   :
            case VK_CONTROL :
            case VK_MENU    :
            case VK_LWIN    :
            case VK_RWIN    :
            case VK_APPS    :
                    break;
            default:
                return TRUE;
            }
        }
        return FALSE;
    }
    
    /* ------------------------------------------------------------------------ */
    /* DOS version of a signal handler
     * traps ^C
     * return TRUE to continue
     * return FALSE for default signal handling
     */
    #if TRAPCONTROLC
    static BOOL WINAPI control_c_handler(DWORD whathappened)
    {
        BOOL r = FALSE;
    
        if(whathappened == CTRL_C_EVENT)
        {   if(GlobalSessionHook->sock != INVALID_SOCKET)
            {   closesocket(GlobalSessionHook->sock);
                GlobalSessionHook->sock = INVALID_SOCKET;
                GlobalSessionHook->quit = 1;
            }
            r = TRUE;
        }
        return r;
    }
    #endif /*TRAPCONTROLC*/
    
    /* ------------------------------------------------------------------------ */
    
    int SessionHook(SESSION *sess ,short state ,short argc ,void* args)
    {
        int r = TRUE;
    
        switch(state) {
        /* the program has started */
        /* user data has not yet been entered */
        case SHOOK_PROG:
            sess->i = GetStdHandle(STD_INPUT_HANDLE);
            sess->o = GetStdHandle(STD_OUTPUT_HANDLE);
    #if TRAPCONTROLC
            GlobalSessionHook = sess;
    #endif /*TRAPCONTROLC*/
            break;
    
        /* user data is complete */
        /* prepare to start networking */
        /* login follows this */
        case SHOOK_NET: /* validation complete ,ready to start networking */
            SetConsoleTitle("Yahmini");
            {   WSADATA wsaData;
                if(WSAStartup(0x101 ,&wsaData))
                {   fprintf(sess->o ,"WSAStartup failed\n");
                    r = FALSE;  /* fail */
                }
            }
            break;
    
        /* login was successful */
        /* next is login to chat */
        case SHOOK_CHAT:
            break;
    
        /* connected to chat */
        /* ready to start receiving data */
        case SHOOK_RECV:    
            {   char tmp[CHATNAMESIZE+CHATROOMSIZE+32];
                sprintf(tmp ,"%s: %s" ,"Yahmini",sess->user);
                SetConsoleTitle(tmp);
                fprintf(sess->o ,"waiting for yahoo greeting\n");
    #if TRAPCONTROLC
                SetConsoleCtrlHandler(control_c_handler ,TRUE);
    #endif /*TRAPCONTROLC*/
            }
            break;
    
        /* yahoo data packet has arrived */
        case SHOOK_DATA:
            /* on a login packet ,do a room join */
            if(sess->yin.type == 0x01)
            {   char tmp[CHATNAMESIZE+CHATROOMSIZE+32];
                sprintf(tmp ,"%s: %s: %s" ,"Yahmini",sess->user ,sess->room);
                SetConsoleTitle(tmp);
                fprintf(sess->o ,"Chat started, type /help for help\n");
                YahooTextCommand(sess ,"join " ,sess->room);
                /* set the return value for the program */
                sess->rval = 0;
            }
            break;
    
        /* an optional hook fron the parser/decoder
         * return TRUE if we displayed it here
         * return FALSE for the default display handler
         */
        case SHOOK_DECODE:
            r = FALSE;
            break;
    
        /* the user has entered chat text
         * args points to the NULL delimited string
         * if you return FALSE it wont be sent
         * this would be a good place to make macro
         * substitutions etc.
         */
        case SHOOK_INPUT:
            break;
    
        /* all sockets closed */
        /* end all networking */
        case SHOOK_NETEND:
    #if TRAPCONTROLC
            SetConsoleCtrlHandler(control_c_handler ,FALSE);
    #endif /*TRAPCONTROLC*/
            WSACleanup();
            break;
    
        /* program is exiting */
        case SHOOK_EXIT:
            SetConsoleTitle("Yahmini");
            fprintf(sess->o ,"done\n");
            r = sess->rval;
            break;
        }
    
        return r;
    
        UNREFERENCED_PARAMETER(argc);
        UNREFERENCED_PARAMETER(args);
    }
    
    /* ------------------------------------------------------------------------ */
    /* end */

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    3
    and dos_h.txt
    Code:
    /*
     * copyright David J. Binette
     * ALL RIGHTS RESERVED
     */
    
    /* ------------------------------------------------------------------------ */
    /* tab stops are set to 4 */
    /* ------------------------------------------------------------------------ */
    
    /* useful compiler options
     * eliminate duplicate strings
     * place strings in read-only memory
     *
     * (win32 VC6.0 compiler options)
     * /nologo /Gr /Zp2 /ML /W4 /O1 /I
     * /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_SBCS"
     * /D "STRICT" /D "WIN32_LEAN_AND_MEAN" /D "NOGDI"
     * /FAs /J /FD /GF /c
     *
     * (win32 VC6.0 linker options)
     * kernel32.lib libctiny.lib wsock32.lib
     * /nologo /stack:0x4000 /heap:0x10000
     * /subsystem:console /pdb:none /machine:I386 /nodefaultlib /out:"yahmini.exe"
     * /OPT:REF /OPT:ICF,99 /OPT:NOWIN98
     */
    
    /* ------------------------------------------------------------------------ */
    
    #define USETINYCRT 1
    
    /* ------------------------------------------------------------------------ */
    
    #include <windows.h>
    #include <winsock.h>
    #include <stdarg.h>
    
    #if USETINYCRT
    # include <libctiny.h>
    typedef HANDLE IOHAND;
    #else
    # include <stdio.h>
    # include <stdlib.h>
    # include <malloc.h>
    typedef FILE* IOHAND;
    #endif
    
    
    /* ------------------------------------------------------------------------ */
    
    #include "yahmini.h"
    
    /* ------------------------------------------------------------------------ */
    
    #define SockErrNum()      WSAGetLastError()
    
    #define CHATPROMPT ">"
    
    /* ------------------------------------------------------------------------ */
    /* end */

  4. #4
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    How are we supposed to know how the log in works? It may be proprietary, ie, they dont say how it works. A good, secure logon would encrypt the username and password with a key that only Yahoo knows, and they would never give that away, because then the logon is no longer secure. I doubt this is possible. Sorry.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  5. #5
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by kaukasion
    and its open source
    and very simple
    ...
    but i dont know c++
    if you don't know C++ how can you tell us it's a simple program?

    secondly, this is the whole reason Y! changed their logon procedures... they didn't want programs like these (trillian,gaim,this thing) latching on to their protocols, so they changed their protocols in a way that would break these programs

    >>A good, secure logon would encrypt the username and password with a key that only Yahoo knows

    yeah, but a program like this sends the unencrypted username/password to the Y! server, which then takes the login process from there and sends information to/gets information from the program that sent the username/password... all the authentication is done on Y!'s servers... the client program just sends it what it needs to do that authentication.
    Last edited by major_small; 06-17-2004 at 09:48 AM. Reason: more added
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21