1 Description: The mod_nvram module was developed specifically to monitor
2 configuration settings stored in nvram on Linksys devices.
3 In the future, this module could be used to monitor other
4 attributes of similar devices.
7 --- osiris-4.1.8-orig/src/osirisd/modules/mod_nvram/Makefile 1970-01-01 01:00:00.000000000 +0100
8 +++ osiris-4.1.8-1/src/osirisd/modules/mod_nvram/Makefile 2005-04-22 23:11:32.000000000 +0200
16 +module: ${SRCS} ${OBJS}
18 +INCS=-I../.. -I../../../libosiris -I../../../libfileapi -I../../../..
20 +# meta-rule for compiling any "C" source file.
22 + $(CC) $(DEFS) $(DEFAULT_INCLUDES) ${INCLUDES} ${INCS} $(AM_CPPFLAGS) \
23 + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $(SRCS)
26 --- osiris-4.1.8-orig/src/osirisd/modules/mod_nvram/README 1970-01-01 01:00:00.000000000 +0100
27 +++ osiris-4.1.8-1/src/osirisd/modules/mod_nvram/README 2005-04-22 23:11:32.000000000 +0200
31 +Author: Brian Wotring (brian@shmoo.com)
37 +The mod_nvram module reads the key=value pairs stored in nvram. This
38 +is primarily for Linksys routers, but could be modified to run on
39 +other systems if necessary. On the routers like the WRT54G, the
40 +nvram settings hold sensitive information that needs to be monitored.
41 +The format for the record structure is as follows:
47 +To use this module, all that is needed is to include it in the System
48 +block of a scan configuration, e.g.:
59 +There are no parameters for this module.
63 +Currently, only for the Linksys WRT54G and WRT54GS devices.
69 --- osiris-4.1.8-orig/src/osirisd/modules/mod_nvram/mod_nvram.c 1970-01-01 01:00:00.000000000 +0100
70 +++ osiris-4.1.8-1/src/osirisd/modules/mod_nvram/mod_nvram.c 2005-04-22 23:11:32.000000000 +0200
73 +/******************************************************************************
75 +** This program is free software; you can redistribute it and/or
76 +** modify it, however, you cannot sell it.
78 +** This program is distributed in the hope that it will be useful,
79 +** but WITHOUT ANY WARRANTY; without even the implied warranty of
80 +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
82 +** You should have received a copy of the license attached to the
83 +** use of this software. If not, visit www.shmoo.com/osiris for
86 +******************************************************************************/
88 +/*****************************************************************************
91 +** Date: January 1, 2004
93 +** Author: Brian Wotring
94 +** Purpose: platform specific methods for reading user file information.
96 +******************************************************************************/
98 +#include "libosiris.h"
99 +#include "libfileapi.h"
100 +#include "rootpriv.h"
102 +#include "version.h"
104 +#include "scanner.h"
105 +#include "logging.h"
108 +#define NVRAM_PATH "/usr/sbin/nvram"
109 +#define NVRAM_ARG "show"
111 +static const char *MODULE_NAME = "mod_nvram";
114 +void mod_nvram( SCANNER *scanner )
119 + char temp_line[4096];
121 + SCAN_RECORD_TEXT_1 record;
125 + log_error( "mod_nvram: error creating pipe!" );
131 + log_error( "mod_nvram: error creating pipe!" );
135 + /* Create a child to run nvram command. */
137 + switch( pid = fork() )
140 + log_error( "nvram: fork error!" );
152 + execl( NVRAM_PATH, NVRAM_PATH, NVRAM_ARG, NULL );
162 + file = fdopen( cp[0], "r" );
169 + line = fgets( temp_line, sizeof( temp_line ), file );
176 + line = trim_white_space( line );
178 + /* skip commented and empty lines. */
180 + if( ( line == NULL ) || ( line[0] == '#' ) )
185 + /* locate the username, this is the first item in the colon list. */
187 + if( ( key_end = strchr( line, '=' ) ) == NULL )
192 + initialize_scan_record( (SCAN_RECORD *)&record,
193 + SCAN_RECORD_TYPE_TEXT_1 );
195 + osi_strlcpy( record.module_name, MODULE_NAME,
196 + sizeof( record.module_name ) );
198 + /* user the key as a key/path for this record. */
202 + osi_strlcpy( record.name, "nvram:", sizeof( record.name ) );
203 + osi_strlcat( record.name, line, sizeof( record.name ) );
205 + /* now copy in the value into the data portion. */
206 + /* and send this record on its way. */
208 + osi_strlcpy( record.data, key_end, sizeof( record.data ) );
209 + send_scan_data( scanner, (SCAN_RECORD *)&record );