[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ossec-cvs] ossec-hids: common.c (NEW) favicon.ico (NEW) make.bat (NEW) os_win32ui.c (NEW) os_win32ui.h (NEW) win32ui.rc (NEW) [dcid]




Module name:	ossec-hids
Changes by:	dcid	07/07/11 01:05:08

Added files:
	common.c favicon.ico make.bat os_win32ui.c os_win32ui.h win32ui.rc

Log message:
Description: Adding UI for the windows agent (basic config and stop/start
functions).
Bug: none
Approved: dcid

--- NEW FILE: common.c ---
/* @(#) $Id: common.c,v 1.1 2007/07/11 04:05:07 dcid Exp $ */

/* Copyright (C) 2007 Daniel B. Cid <dcid@xxxxxxxxx>
 * All rights reserved.
 *
 * This program is a free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public
 * License (version 2) as published by the FSF - Free Software
 * Foundation
 */
       

#include "os_win32ui.h"
#include "os_win.h"
#include "os_xml/os_xml.h"
#include "os_xml/os_xml_writer.h"
#include "validate_op.h"


/* Generate server info (for the main status */
int gen_server_info(HWND hwnd)
{
    memset(ui_server_info, '\0', 2048 +1);
    snprintf(ui_server_info, 2048, 
            "Agent: %s (%s)  -  %s\r\n\r\n"
            "Status: %s",
            config_inst.agentname, 
            config_inst.agentid, 
            config_inst.agentip,
            config_inst.status);


    /* Initializing top */
    if(config_inst.version)
    {
        SetDlgItemText(hwnd, UI_SERVER_TOP, config_inst.version);
        SetDlgItemText(hwnd, UI_SERVER_INFO, ui_server_info);
    }
    
    /* Initializing auth key */
    SetDlgItemText(hwnd, UI_SERVER_AUTH, config_inst.key);

    /* Initializing server ip */
    SetDlgItemText(hwnd, UI_SERVER_TEXT, config_inst.server);

    SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"http://www.ossec.net";);                                                                                    
    return(0);
}


/* Reads the first line of a specific file  --must free after */
char *cat_file(char *file, FILE *fp2)
{
    FILE *fp;

    if(!fp2)
    {
        fp = fopen(file, "r");
    }
    else
    {
        fp = fp2;
    }

    if(fp)
    {
        char buf[1024 +1];
        char *ret = NULL;

        buf[1024] = '\0';
        if(fgets(buf, 1024, fp) != NULL)
        {
            ret = strchr(buf, '\n');
            if(ret)
            {
                *ret = '\0';
            }
            ret = strchr(buf, '\r');
            if(ret)
            {
                *ret = '\0';
            }

            ret = strdup(buf);
        }

        if(!fp2)
        {
            fclose(fp);
        }
        return(ret);
    }

    return(NULL);
}


/* Check if a file exists */
int is_file(char *file)
{
    FILE *fp;
    fp = fopen(file, "r");
    if(fp)
    {
        fclose(fp);
        return(1);
    }
    return(0);
}


/* Clear configuration */
void config_clear()
{
    if(config_inst.version)
    {
        free(config_inst.version);
    }

    if(config_inst.key)
    {
        free(config_inst.key);
    }

    if(config_inst.agentid)
    {
        free(config_inst.agentid);
    }

    if(config_inst.server)
    {
        free(config_inst.server);
    }


    /* Initializing config instance */
    config_inst.dir = NULL;
    config_inst.key = FL_NOKEY;
    config_inst.server = strdup(FL_NOSERVER);
    config_inst.config = NULL;

    config_inst.agentid = NULL;
    config_inst.agentname= NULL;
    config_inst.agentip = NULL;

    config_inst.version = NULL;
    config_inst.install_date = NULL;
    config_inst.status = ST_UNKNOWN;
    config_inst.msg_sent = 0;
}


/* Initializes the config */
void init_config()
{
    /* Initializing config instance */
    config_inst.dir = NULL;
    config_inst.key = FL_NOKEY;
    config_inst.server = NULL;
    config_inst.config = NULL;

    config_inst.agentid = NULL;
    config_inst.agentname= NULL;
    config_inst.agentip = NULL;

    config_inst.version = NULL;
    config_inst.install_date = NULL;
    config_inst.status = ST_UNKNOWN;
    config_inst.msg_sent = 0;

}


/* Reads ossec config */
int config_read(HWND hwnd)
{
    char *tmp_str;

    
    /* Clearing config */
    config_clear();


    /* Getting OSSEC status */
    if(CheckServiceRunning())
    {
        config_inst.status = ST_RUNNING;
    }
    else
    {
        config_inst.status = ST_STOPPED;
    }


    /* Checking if ui is on the right path */	
    if(!is_file(CONFIG))
    {
        chdir(DEFDIR);
        if(!is_file(CONFIG))
        {
            MessageBox(hwnd, "Unable to find OSSEC Config.","Warning",MB_OK);
        }
    }


    /* Getting version/install date */
    config_inst.version = cat_file(VERSION_FILE, NULL); 
    if(config_inst.version)
    {
        config_inst.install_date = strchr(config_inst.version, '-');
        if(config_inst.install_date)
        {
            *config_inst.install_date = '\0';
            config_inst.install_date++;
        }
    }


    /* Getting number of messages sent */
    tmp_str = cat_file(SENDER_FILE, NULL); 
    if(tmp_str)
    {
        unsigned long int tmp_val = 0;
        char *to_free = tmp_str;

        tmp_val = atol(tmp_str);
        if(tmp_val)
        {
            config_inst.msg_sent = tmp_val * 9999;

            tmp_str = strchr(tmp_str, ':');
            if(tmp_str)
            {
                tmp_str++;
                tmp_val = atol(tmp_str);
                config_inst.msg_sent += tmp_val;
            }
        }

        free(to_free);
    }


    /* Getting agent id, name and ip */
    tmp_str = cat_file(AUTH_FILE, NULL);
    if(tmp_str)
    {
        /* Getting base 64 */
        config_inst.key = encode_base64(strlen(tmp_str),tmp_str);
        if(config_inst.key == NULL)
        {
            config_inst.key = FL_NOKEY;
        }

        /* Getting id */
        config_inst.agentid = tmp_str;

        tmp_str = strchr(tmp_str, ' ');
        if(tmp_str)
        {
            *tmp_str = '\0';
            tmp_str++;

            /* Getting name */
            config_inst.agentname = tmp_str;
            tmp_str = strchr(tmp_str, ' ');
            if(tmp_str)
            {
                *tmp_str = '\0';
                tmp_str++;

                /* Getting ip */
                config_inst.agentip = tmp_str;

                tmp_str = strchr(tmp_str, ' ');
                if(tmp_str)
                {
                    *tmp_str = '\0';
                }
            }
        }
    }


    if(config_inst.agentip == NULL)	
    {
        config_inst.agentid = strdup(ST_NOTSET);
        config_inst.agentname = strdup("Auth key not imported.");
        config_inst.agentip = ST_NOTSET;

        config_inst.status = ST_MISSING_IMPORT;
    }


    /* Getting server ip */
    if(!get_ossec_server())
    {
        if(config_inst.status == ST_MISSING_IMPORT)
        {
            config_inst.status = ST_MISSING_ALL;
        }
        else
        {
            config_inst.status = ST_MISSING_SERVER;
        }
    }

    return(0);
}


/* Get OSSEC Server IP */
int get_ossec_server()
{
    OS_XML xml;

    char *str = NULL;

    /* Definitions */
    char *(xml_serverip[])={"ossec_config","client","server-ip", NULL};


    /* Reading XML */
    if(OS_ReadXML(CONFIG, &xml) < 0)
    {
        return(0);
    }


    /* run as a daemon */
    str = OS_GetOneContentforElement(&xml, xml_serverip);
    if(str)
    {
        if(OS_IsValidIP(str, NULL) == 1)
        {
            if(config_inst.server)
            {
                free(config_inst.server);
                config_inst.server = NULL;
            }
                                                            
            config_inst.server = str;
        
            OS_ClearXML(&xml);
            return(1);
        }

        free(str);
    }

    OS_ClearXML(&xml);
    return(0);
}


/* Set OSSEC Server IP */
int set_ossec_server(char *ip, HWND hwnd)
{
    char *(xml_serverip[])={"ossec_config","client","server-ip", NULL};
    
    /* Verifying IP Address */
    if(OS_IsValidIP(ip, NULL) != 1)
    {
        MessageBox(hwnd, "Invalid Server IP Address.\r\n"
                   "It must be the valid Ipv4 address of the "
                   "OSSEC server.",
                   "Invalid Server IP Address",MB_OK);
        return(0);
    }


    /* Reading the XML. Printing error and line number */
    if(OS_WriteXML(CONFIG, NEWCONFIG, xml_serverip, 
                   NULL, NULL, ip, 0) != 0)
    {
        MessageBox(hwnd, "Unable to set OSSEC Server IP Address.\r\n"
                   "(Internal error on the XML Write).",
                   "Unable to set Server IP Address.",MB_OK);
        return(0);
    }

    /* Renaming config files */
    unlink(LASTCONFIG);
    rename(CONFIG, LASTCONFIG);
    rename(NEWCONFIG, CONFIG);


    return(1);
}


/* EOF */

--- NEW FILE: favicon.ico ---

uttŰnmmçééę?¨ňu&GćýPiéĘëíűB^éŰd{ě˛üüý
üüý

--- NEW FILE: make.bat ---
echo Making windows agent UI

"C:\MinGW\bin\windres.exe" -o resource.o win32ui.rc
"C:\MinGW\bin\gcc.exe" -o "os_win32ui" -Wall -DARGV0=\"ossec-agent\" -DCLIENT -DWIN32 resource.o ../os_xml/*.c ../addagent/b64.c ../shared/validate_op.c ../shared/debug_op.c ../win_service.c *.c -I../headers/ -I../ -lcomctl32 -mwindows -lwsock32

--- NEW FILE: os_win32ui.c ---
/* @(#) $Id: os_win32ui.c,v 1.1 2007/07/11 04:05:07 dcid Exp $ */

/* Copyright (C) 2007 Daniel B. Cid <dcid@xxxxxxxxx>
 * All rights reserved.
 *
 * This program is a free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public
 * License (version 2) as published by the FSF - Free Software
 * Foundation
 */
       


#include "os_win32ui.h"
#include <process.h>
#include "os_win.h"


/* Dialog -- About OSSEC */
BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT Message, 
                           WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_CREATE:
        case WM_INITDIALOG:

            return TRUE;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case UI_ID_CLOSE:
                    EndDialog(hwnd, IDOK);
                    break;
            }
            break;

        case WM_CLOSE:
            EndDialog(hwnd, IDOK);
            break;
        default:
            return FALSE;
    }
    return TRUE;
}


/* Main Dialog */
BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    int ret_code = 0;
    
    switch(Message)
    {
        case WM_INITDIALOG:
        {
            int statwidths[] = {130, -1};
            HMENU hMenu, hSubMenu;

            hMenu = CreateMenu();

            /* Creating management menu */
            hSubMenu = CreatePopupMenu();
            AppendMenu(hSubMenu, MF_STRING,UI_MENU_MANAGE_START,"&Start OSSEC");
            AppendMenu(hSubMenu, MF_STRING,UI_MENU_MANAGE_STOP,"&Stop OSSEC");
            AppendMenu(hSubMenu, MF_SEPARATOR, UI_MENU_NONE,"");
            AppendMenu(hSubMenu, MF_STRING,UI_MENU_MANAGE_RESTART,"&Restart");
            AppendMenu(hSubMenu, MF_STRING,UI_MENU_MANAGE_STATUS,"&Status");
            AppendMenu(hSubMenu, MF_SEPARATOR, UI_MENU_NONE,"");
            AppendMenu(hSubMenu, MF_STRING,UI_MENU_MANAGE_EXIT,"&Exit");
            AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu,"&Manage");

            /* Create view menu */
            hSubMenu = CreatePopupMenu();
            AppendMenu(hSubMenu, MF_STRING, UI_MENU_VIEW_LOGS, "&View Logs");
            AppendMenu(hSubMenu, MF_STRING, UI_MENU_VIEW_CONFIG,"V&iew Config");
            AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu,"&View");

            hSubMenu = CreatePopupMenu();
            AppendMenu(hSubMenu, MF_STRING, UI_MENU_HELP_ABOUT, "A&bout");
            AppendMenu(hSubMenu, MF_STRING, UI_MENU_HELP_HELP, "Help");
            AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&Help");


            AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
            SetMenu(hwnd, hMenu);


            hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL,
                    WS_CHILD|WS_VISIBLE|SBARS_SIZEGRIP, 
                    0, 0, 0, 0,
                    hwnd, (HMENU)IDC_MAIN_STATUS, 
                    GetModuleHandle(NULL), NULL);

            SendMessage(hStatus, SB_SETPARTS, 
                    sizeof(statwidths)/sizeof(int), 
                    (LPARAM)statwidths);
            SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"http://www.ossec.net";);


            /* Initializing config */
            config_read(hwnd);
            gen_server_info(hwnd);


            /* Setting the icons */
            SendMessage(hwnd, WM_SETICON, ICON_SMALL, 
                    (LPARAM)LoadIcon(GetModuleHandle(NULL), 
                                     MAKEINTRESOURCE(IDI_OSSECICON)));
            SendMessage(hwnd, WM_SETICON, ICON_BIG, 
                    (LPARAM)LoadIcon(GetModuleHandle(NULL), 
                                     MAKEINTRESOURCE(IDI_OSSECICON)));
        }
        break;

        case WM_COMMAND:
        switch(LOWORD(wParam))
        {
            /* In case of SAVE */
            case IDC_ADD:
            {
                int chd = 0;
                int len;


                /** Getting values from the user (if chosen save) 
                 * We should probably create another function for it...
                 **/
                
                /* Getting server ip */
                len = GetWindowTextLength(GetDlgItem(hwnd, UI_SERVER_TEXT));
                if(len > 0)
                {
                    char *buf;


                    /* Allocating buffer */
                    buf = (char*)GlobalAlloc(GPTR, len + 1);
                    if(!buf)
                    {
                        exit(-1);
                    }
                    
                    GetDlgItemText(hwnd, UI_SERVER_TEXT, buf, len + 1);

                    /* If auth key changed, set it */
                    if(strcmp(buf, config_inst.server) != 0)
                    {
                        if(set_ossec_server(buf, hwnd))
                        {
                            chd = 1;
                        }
                    }
                    else
                    {
                        GlobalFree(buf);
                    }
                }
                
                
                /* Getting auth key */
                len = GetWindowTextLength(GetDlgItem(hwnd, UI_SERVER_AUTH));
                if(len > 0)
                {
                    char *buf;

                    /* Allocating buffer */
                    buf = (char*)GlobalAlloc(GPTR, len + 1);
                    if(!buf)
                    {
                        exit(-1);
                    }

                    GetDlgItemText(hwnd, UI_SERVER_AUTH, buf, len + 1);

                    /* If auth key changed, set it */
                    if(strcmp(buf, config_inst.key) != 0)
                    {
                        int ret;
                        char *tmp_str;
                        char *decd_buf = NULL;
                        char *decd_to_write = NULL;
                        char *id = NULL;
                        char *name = NULL;
                        char *ip = NULL;


                        /* Getting new fields */
                        decd_buf = decode_base64(buf);
                        if(decd_buf)
                        {
                            decd_to_write = strdup(decd_buf);

                            /* Getting id, name and ip */
                            id = decd_buf;
                            name = strchr(id, ' ');
                            if(name)
                            { 
                                *name = '\0'; 
                                name++;

                                ip = strchr(name, ' ');
                                if(ip)
                                {
                                    *ip = '\0';
                                    ip++;

                                    tmp_str = strchr(ip, ' ');
                                    if(tmp_str)
                                    {
                                        *tmp_str = '\0';
                                    }
                                }
                            }
                        }

                        /* If ip isn't set, it is because we have an invalid
                         * auth key.
                         */
                        if(!ip)
                        {
                            MessageBox(hwnd, "Unable to import "
                                             "authentication key. Invalid.", 
                                             "Error Saving.", MB_OK);
                        }
                        else
                        {
                            char mbox_msg[1024 +1];
                            mbox_msg[1024] = '\0';
                            
                            snprintf(mbox_msg, 1024, "Adding key for:\r\n\r\n"
                                               "Agent ID: %s\r\n" 
                                               "Agent Name: %s\r\n" 
                                               "IP Address: %s\r\n",
                                               id, name, ip);
                             
                            ret = MessageBox(hwnd, mbox_msg, 
                                         "Confirm Importing Key", MB_OKCANCEL);
                            if(ret == IDOK)
                            {
                                FILE *fp;
                                fp = fopen(AUTH_FILE, "w");
                                if(fp)
                                {
                                    chd+=2;
                                    fprintf(fp, "%s", decd_to_write);
                                    fclose(fp);
                                }
                            }

                            
                        }

                        /* Free used memory */
                        if(decd_buf)
                        {
                            free(decd_to_write);
                            free(decd_buf);
                        }
                    }
                    else
                    {
                        GlobalFree(buf);
                    }

                } /* Finished adding AUTH KEY */

                /* Re-printing messages */
                if(chd)
                {
                    config_read(hwnd);

                    /* Set status to restart */
                    if(strcmp(config_inst.status,ST_RUNNING) == 0)
                    {
                        config_inst.status = ST_RUNNING_RESTART;
                    }

                    gen_server_info(hwnd);

                    if(chd == 1)
                    {
                        SendMessage(hStatus, SB_SETTEXT, 0,
                                (LPARAM)"Server IP Saved ..");
                    }
                    else if(chd == 2)
                    {
                        SendMessage(hStatus, SB_SETTEXT, 0,
                                (LPARAM)"Auth key imported ..");

                    }
                    else
                    {
                        SendMessage(hStatus, SB_SETTEXT, 0,
                                (LPARAM)"Auth key and server ip saved ..");

                    }
                }         
            }
            break;
            
            case UI_MENU_MANAGE_EXIT:
                PostMessage(hwnd, WM_CLOSE, 0, 0);
                break;

            case UI_MENU_VIEW_LOGS:
                _spawnlp( _P_NOWAIT, "notepad", "notepad " OSSECLOGS, NULL );
                break;
            case UI_MENU_VIEW_CONFIG:    
                _spawnlp( _P_NOWAIT, "notepad", "notepad " CONFIG, NULL );
                break;
            case UI_MENU_HELP_HELP:
                system("doc.html");
                break;
            case UI_MENU_HELP_ABOUT:
                {
                    DialogBox(GetModuleHandle(NULL), 
                            MAKEINTRESOURCE(IDD_ABOUT), hwnd, AboutDlgProc);
                }
                break;
            case IDC_CANCEL:
                config_read(hwnd);    
                gen_server_info(hwnd);
                break;
                
            case UI_MENU_MANAGE_START:
            
                /* Starting OSSEC  -- must have a valid config before. */
                if((strcmp(config_inst.key, FL_NOKEY) != 0) &&
                   (strcmp(config_inst.server, FL_NOSERVER) != 0))
                {
                    ret_code = os_start_service();
                }
                else
                {
                    ret_code = 0;
                }
                
                if(ret_code == 0)
                {
                    MessageBox(hwnd, "Unable to start OSSEC (check config).",
                                     "Error -- Unable to start", MB_OK);
                }
                else if(ret_code == 1)
                {
                    config_read(hwnd);
                    gen_server_info(hwnd);

                    SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Started..");

                    MessageBox(hwnd, "OSSEC Agent Started.",
                                     "Started..", MB_OK);
                }
                else
                {
                    MessageBox(hwnd, "Agent already running (try restart).",
                                     "Already running..", MB_OK);
                }
                break;    
            case UI_MENU_MANAGE_STOP:
                
                /* Stopping OSSEC */
                ret_code = os_stop_service();
                if(ret_code == 1)
                {
                    config_read(hwnd);
                    gen_server_info(hwnd);

                    SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Stopped..");
                    MessageBox(hwnd, "OSSEC Agent Stopped.",
                                     "Stopped..", MB_OK);
                }
                else
                {
                    MessageBox(hwnd, "Agent already stopped.",
                                     "Already stopped..", MB_OK);
                }
                break;
            case UI_MENU_MANAGE_STATUS:
                if(CheckServiceRunning())
                {
                    MessageBox(hwnd, "OSSEC Agent running.",
                                     "Agent running..", MB_OK);

                }
                else
                {
                    MessageBox(hwnd, "OSSEC Agent stopped.",
                                     "Agent stopped.", MB_OK);
                }
                break;
            case UI_MENU_MANAGE_RESTART:
                
                if((strcmp(config_inst.key, FL_NOKEY) == 0) ||
                   (strcmp(config_inst.server, FL_NOSERVER) == 0))
                {
                    MessageBox(hwnd, "Unable to restart OSSEC (check config).",
                                     "Error -- Unable to restart", MB_OK);
                    break;
                    
                }
                                                                            
                ret_code = os_stop_service();
                
                /* Starting OSSEC */
                ret_code = os_start_service();
                if(ret_code == 0)
                {
                    MessageBox(hwnd, "Unable to restart OSSEC (check config).",
                                     "Error -- Unable to restart", MB_OK);
                }
                else
                {
                    config_read(hwnd);
                    gen_server_info(hwnd);

                    SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Restarted..");
                    MessageBox(hwnd, "OSSEC Agent Restarted.",
                                     "Restarted..", MB_OK);
                }
                break;        
        }
        break;
        
        case WM_CLOSE:
            EndDialog(hwnd, 0);
            break;
        
        default:
            return FALSE;
    }
    return TRUE;
}




int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{

    /* Initializing config */
    init_config();

    /* Initializing controls */
    InitCommonControls();

    /* Creating main dialogbox */
    return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc);
}


/* EOF */

--- NEW FILE: os_win32ui.h ---
/* @(#) $Id: os_win32ui.h,v 1.1 2007/07/11 04:05:07 dcid Exp $ */

/* Copyright (C) 2007 Daniel B. Cid <dcid@xxxxxxxxx>
 * All rights reserved.
 *
 * This program is a free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public
 * License (version 2) as published by the FSF - Free Software
 * Foundation
 */
       

#ifndef WIN_32UI_H
#define WIN_32UI_H

#include <stdio.h>
#include <unistd.h>
#include <windows.h>
#include <winresrc.h>



/* Default values */
#define CONFIG          "ossec.conf"
#define NEWCONFIG       "new-ossec.conf"
#define LASTCONFIG      "last-ossec.conf"
#define VERSION_FILE    "VERSION.txt"
#define OSSECLOGS       "ossec.log"
#define AUTH_FILE       "client.keys"
#define SENDER_FILE     "rids\\sender_counter"
#define DEFDIR          "C:\\Program Files\\ossec-agent"


/* Status messages */
#define ST_RUNNING          "Running..."
#define ST_RUNNING_RESTART  "Running (pending restart)"
#define ST_STOPPED          "Stopped."
#define ST_UNKNOWN          "Unknown."
#define ST_NOTSET           "0"
#define ST_MISSING_IMPORT   "Require import of authentication key.\r\n" \
                            "            - Not Running..."
#define ST_MISSING_SERVER   "Require OSSEC Server IP address.\r\n" \
                            "            - Not Running..."
#define ST_MISSING_ALL      "Require import of authentication key.\r\n" \
                            "            Missing OSSEC Server IP address.\r\n" \
                            "            - Not Running..."
                        


/* Pre-def fields */
#define FL_NOKEY        "<insert_auth_key_here>"
#define FL_NOSERVER     "<insert_server_ip_here>"


/* Prototypes */
char *decode_base64(const char *src);
char *encode_base64(int size, char *src);


/* Global ossec config structure */
typedef struct _ossec_config
{
    unsigned long int msg_sent;
    char *dir;
    char *config;
    char *key;
    char *server;

    char *agentid;
    char *agentname;
    char *agentip;

    char *version;
    char *install_date;
    char *status;
}ossec_config;


/** Global variables **/

/* Agent status */
char ui_server_info[2048 +1];

/* Configuration */
ossec_config config_inst;

/* Status bar */
HWND hStatus;



/* Ossec icon */
#define IDI_OSSECICON 201

/* User input */
#define UI_SERVER_TEXT      1501
#define UI_SERVER_AUTH      1502
#define UI_SERVER_MSG       1503
#define UI_SERVER_TOP       1504
#define UI_SERVER_INFO      1505
#define UI_ID_CLOSE         1510


/* Menu values */
#define UI_MENU_MANAGE_STOP     1601
#define UI_MENU_MANAGE_START    1602
#define UI_MENU_MANAGE_STATUS   1603
#define UI_MENU_MANAGE_RESTART  1604
#define UI_MENU_MANAGE_EXIT     1605
#define UI_MENU_VIEW_LOGS       1606
#define UI_MENU_VIEW_CONFIG     1607
#define UI_MENU_HELP_HELP       1608
#define UI_MENU_HELP_ABOUT      1609
#define UI_MENU_NONE            1610


#define IDD_MAIN                1700
#define IDC_MAIN_STATUS         1701
#define IDC_ADD                 1702
#define IDC_CANCEL              1703
#define IDD_ABOUT               1704
#define IDC_STATIC -1


/** Prototypes **/

/* Generate server info */
int gen_server_info(HWND hwnd);

/* cat file */
char *cat_file(char *file, FILE *fp2);

/* is_file present */
int is_file(char *file);

/* Reads ossec config */
int config_read(HWND hwnd);

/* Initializes the config */
void init_config();

/* Set OSSEC Server IP */
int set_ossec_server(char *ip, HWND hwnd);

/* Get OSSEC Server IP */
int get_ossec_server();


#endif

/* EOF */

--- NEW FILE: win32ui.rc ---
#include <windows.h>

#include "os_win32ui.h"

IDI_OSSECICON ICON "favicon.ico"


IDD_ABOUT DIALOG DISCARDABLE  0, 0, 259, 106
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About OSSEC"
FONT 8, "MS Sans Serif"
BEGIN
    DEFPUSHBUTTON  "&Close",UI_ID_CLOSE,90,90,50,14
    GROUPBOX       " Copyright (C) 2003-2007 Daniel B. Cid <dcid@xxxxxxxxx>",
                   IDC_STATIC,7,7,245,82
    CTEXT   "This program is a free software; you can redistribute it" \
            " and/or modify it under the terms of the GNU General" \
            " Public License (GPL) version 2 as published by the FSF" \
            " - Free Software Foundation\r\n\r\n" \
            "For more information, visit us online at http://www.ossec.net";,
            IDC_STATIC,16,18,200,63
END


IDD_MAIN DIALOG DISCARDABLE  0, 0, 207, 156
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "OSSEC Agent Manager"
FONT 8, "MS Sans Serif"
BEGIN
    GROUPBOX  " ~OSSEC Windows Agent Manager~ ", UI_SERVER_TOP, 7,7, 193, 57
    LTEXT     " No Information available.", UI_SERVER_INFO, 16, 22, 150, 40

    LTEXT     "OSSEC Server IP: ",IDC_STATIC,7,76,62,8
    EDITTEXT  UI_SERVER_TEXT,75,74,105,12,ES_AUTOHSCROLL

    LTEXT     "Authentication key: ",IDC_STATIC,7,92,62,8
    EDITTEXT  UI_SERVER_AUTH,75,90,105,12,ES_AUTOHSCROLL

    PUSHBUTTON "&Save",IDC_ADD,50,112,50,14
    PUSHBUTTON "&Refresh",IDC_CANCEL,105,112,50,14
END


OSSEC home | Main Index | Thread Index


OSSEC project: www.ossec.net.
Mailling list information: http://www.ossec.net/en/mailing_lists.html.