Created
December 15, 2018 17:29
-
-
Save Ge0rg3/4703ae46df0882281abf65fedb4661e2 to your computer and use it in GitHub Desktop.
A redacted file from the Waldo machine on HTB.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************* | |
* | |
*This is an application to print out common log files | |
* | |
********************************************/ | |
#include "logMonitor.h" | |
void printUsage() { | |
printf("Usage: %s [-aAbdDfhklmsw] [--help]\n", PROGRAMNAME); | |
} | |
int main(int argc, char** argv){ | |
int opt = 0; | |
char filename[26]; | |
{ | |
//temporary variables for parsing | |
static struct option long_options[] ={ | |
/* These options don’t set a flag. | |
We distinguish them by their indices. */ | |
{"auth", no_argument, 0, 'a'}, | |
[...] | |
{"wtmp", no_argument, 0, 'w'}, | |
{0,0,0,0} | |
}; | |
//parse the command line arguments | |
int option_index = 0; | |
while((opt = getopt_long (argc, argv, "aAbdDfhklmsw", long_options, &option_index)) != -1 ){ | |
switch (opt) { | |
case 'a' : | |
strncpy(filename, "/var/log/auth.log", sizeof(filename)); | |
printFile(filename); | |
break; | |
[...] | |
case 'w' : | |
strncpy(filename, "/var/log/wtmp",sizeof(filename)); | |
printFile(filename); | |
break; | |
default: | |
printUsage(); | |
exit(EXIT_FAILURE); | |
} | |
} | |
} | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment