exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

dumpenv.c

dumpenv.c
Posted Apr 9, 2001
Authored by vade79, realhalo | Site realhalo.org

dumpenv.c is a simple system tool for dumping all processes environmental data, requires root to run.

tags | root
systems | unix
SHA-256 | 837b6324dabe2be451fc4279bd41a788062fe26188d356de7ee2e6b1487651ac

dumpenv.c

Change Mirror Download
/* [ DUMPENV: system tool -- version 1.1. ] **********************************
* simple system tool for dumping all processes environmental data, requires *
* root to run. *
* *
* AUTHOR: *
* v9/vade79@realhalo.org, realhalo.org. *
* *
* dumpenv.c: program source code for dumpenv, for linux. (98l!220w!2849b) *
*****************************************************************************/
#include <stdio.h>
#include <sys/stat.h>
#include <glob.h>
char id[]="$Id: dumpenv.c,v 1.1 2001/04/04 01:21:02 EST vade79 Exp $";
int main(){
int i=0;
glob_t gb;
setuid(geteuid());
if(getuid())
printe("dumpenv must run as root to process correctly",1);
gb.gl_offs=1;
glob("/proc/*",0,0,&gb);
while(gb.gl_pathc>i){
if(atoi((char *)basename(gb.gl_pathv[i]))
||!strcmp((char *)basename(gb.gl_pathv[i]),"0"))
getenviron((char *)basename(gb.gl_pathv[i]));
i++;
}
globfree(&gb);
exit(0);
}
int getenviron(char *pid){
int i=0;
int chr=0;
char *envfile;
char *cmdfile;
char cmd[256];
char string[4096];
FILE *fd;
struct stat mod;
if(!(envfile=(char *)malloc(strlen(pid)+15)))
printe("getenviron(): allocating memory",0);
sprintf(envfile,"/proc/%s/environ",pid);
if(!(cmdfile=(char *)malloc(strlen(pid)+15)))
printe("getenviron(): allocating memory",0);
sprintf(cmdfile,"/proc/%s/cmdline",pid);
if(!(fd=fopen(cmdfile,"r")))
printe("command line of the pid doesn't exist or isn't readable",0);
else{
bzero(cmd,sizeof(cmd));
while((chr=fgetc(fd))!=0x0&&chr!=0x20&&chr!=EOF)
if(isprint(chr))
if(i<sizeof(cmd))
cmd[i++]=chr;
}
fclose(fd);
if(!strlen(cmd))
sprintf(cmd,"UNKNOWN%c",0x0);
else
cmd[i]=0x0;
i=0;
if(stat(envfile,&mod))
printe("could not get stats of the environemnt for the pid",0);
else{
if(!(fd=fopen(envfile,"r")))
printe("environment of the pid doesn't exist or isn't readable",0);
else{
bzero(string,sizeof(string));
while((chr=fgetc(fd))!=EOF){
if(isprint(chr)){
string[i++]=chr;
if(i>sizeof(string)){
bzero(string,sizeof(string));
i=0;
}
}
else if(chr==0x0){
if(strlen(string))
printf("P:%s C:%s U:%u G:%u E:%s\n",pid,basename(cmd),mod.st_uid,
mod.st_gid,string);
bzero(string,sizeof(string));
i=0;
}
}
if(strlen(string))
printf("P:%s C:%s U:%u G:%u E:%s\n",pid,basename(cmd),mod.st_uid,
mod.st_gid,string);
}
}
fclose(fd);
free(envfile);
free(cmdfile);
return(0);
}
int printe(char *err,int quit){
printf("error: %s.\n",err);
if(quit)
exit(1);
}
Login or Register to add favorites

File Archive:

June 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jun 1st
    0 Files
  • 2
    Jun 2nd
    0 Files
  • 3
    Jun 3rd
    18 Files
  • 4
    Jun 4th
    21 Files
  • 5
    Jun 5th
    0 Files
  • 6
    Jun 6th
    57 Files
  • 7
    Jun 7th
    6 Files
  • 8
    Jun 8th
    0 Files
  • 9
    Jun 9th
    0 Files
  • 10
    Jun 10th
    12 Files
  • 11
    Jun 11th
    27 Files
  • 12
    Jun 12th
    38 Files
  • 13
    Jun 13th
    16 Files
  • 14
    Jun 14th
    14 Files
  • 15
    Jun 15th
    0 Files
  • 16
    Jun 16th
    0 Files
  • 17
    Jun 17th
    0 Files
  • 18
    Jun 18th
    0 Files
  • 19
    Jun 19th
    0 Files
  • 20
    Jun 20th
    0 Files
  • 21
    Jun 21st
    0 Files
  • 22
    Jun 22nd
    0 Files
  • 23
    Jun 23rd
    0 Files
  • 24
    Jun 24th
    0 Files
  • 25
    Jun 25th
    0 Files
  • 26
    Jun 26th
    0 Files
  • 27
    Jun 27th
    0 Files
  • 28
    Jun 28th
    0 Files
  • 29
    Jun 29th
    0 Files
  • 30
    Jun 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close