zoukankan      html  css  js  c++  java
  • 破解php-screw加密过的文件有效方法

    今天终于搞定更改过密钥的php-screw解密问题,乐呵一下!

    改进下

    这样就可以解密任何加密过的PHP源码(包括更改过密钥的),解密的原理稍后具体列出,先说下如何加密

    列出之前写使用php screw加密PHP的自动加密代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    #include <stdio.h>
    #include <stdlib.h>
    #include <stdarg.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <unistd.h>
    #include "php_screw.h"
    #include "my_screw.h"
     
    main(int argc, char**argv)
    {
        FILE    *fp;
        struct  stat    stat_buf;
        char    *datap, *newdatap;
        int datalen, newdatalen;
        int cryptkey_len = sizeof pm9screw_mycryptkey / 2;
        char    newfilename[256];
        int i;
     
        if (argc != 2) {
            fprintf(stderr, "Usage: filename. ");
            exit(0);
        }
     
        fp = fopen(argv[1], "r");
        if (fp == NULL) {
            fprintf(stderr, "File not found(%s) ", argv[1]);
            exit(0);
        }
     
        fstat(fileno(fp), &stat_buf);
        datalen = stat_buf.st_size;
        datap = (char*)malloc(datalen + PM9SCREW_LEN);
        fread(datap, datalen, 1, fp);
        fclose(fp);
     
        if (memcmp(datap, PM9SCREW, PM9SCREW_LEN) == 0) {
            fprintf(stderr, "Already Crypted(%s) ", argv[1]);
            exit(0);
        }
     
        sprintf(newfilename, "%s.screw", argv[1]);
     
        fp = fopen(newfilename, "w");
        if (fp == NULL) {
            fprintf(stderr, "Can not create file(%s) ", newfilename);
            exit(0);
        }
     
        newdatap = zencode(datap, datalen, &newdatalen);
     
        for(i=0; i<newdatalen; i++) {
            newdatap[i] = (char)pm9screw_mycryptkey[(newdatalen - i) % cryptkey_len] ^ (~(newdatap[i]));
        }
     
        fwrite(PM9SCREW, PM9SCREW_LEN, 1, fp);
        fwrite(newdatap, newdatalen, 1, fp);
        fclose(fp);
        fprintf(stderr, "Success Crypting(%s) ", argv[1]);
        free(newdatap);
        free(datap);
    }
  • 相关阅读:
    在main函数中使用django模型(附django正反向的外键关联查询)
    使用正则表达式替换文本内容
    spring 上下文和spring mvc上下文和web应用上下文servletContext之间的关系
    idea快捷键
    Spring MVC的jar包版本问题
    Spring MVC的参数类型转换
    HiddenHttpMethodFilter进行请求过滤,实现Rest风格的url
    Spring MVC的异常处理
    Spring MVC 的拦截器
    @ResponseBody&@RequestBody
  • 原文地址:https://www.cnblogs.com/wangluochong/p/4890850.html
Copyright © 2011-2022 走看看