Changeset 17243


Ignore:
Timestamp:
07/20/12 21:30:36 (11 years ago)
Author:
nit
Message:

[titan] add screen serial

Location:
titan/titan
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • titan/titan/global.h

    r17242 r17243  
    617617}
    618618
    619 void checkserial(char* input, char* buf)
    620 {
    621         char* filename = "xxxxxxxxxxxxx", *pw = NULL;
    622         unsigned char* authbuf = NULL;
    623         int count = 0, i = 0;
    624         off64_t len = 0;
    625         struct splitstr* ret = NULL;
    626 
    627         if(input == NULL) return;
    628 
    629         if(buf == NULL)
    630         {
    631                 buf = readfiletomem(filename, 0);
    632                 len = getfilesize(filename);
    633         }
    634         else
    635                 len = strlen(buf);
     619char* getserialpw()
     620{
     621        char* pw = NULL;
    636622
    637623        pw = ostrcat(pw, "/", 1, 0);
     
    650636        pw = ostrcat(pw, "}", 1, 0);
    651637
     638        return pw;
     639}
     640
     641int writeserial(char* cpuid)
     642{
     643        debug(1000, "in");
     644
     645        char* filename = "xxxxxxxxxxxxxxxxxxx", *pw = NULL;
     646        unsigned char* buf = NULL;
     647        FILE *fd = NULL;
     648        int ret = 0;
     649
     650        pw = getserialpw();
     651        buf = oencrypt(pw, cpuid, strlen(cpuid));
     652        free(pw); pw = NULL;
     653        if(buf == NULL) return 1;
     654
     655        fd = fopen(filename, "wbt");
     656        if(fd == NULL)
     657        {
     658                perr("can't open %s", filename);
     659                free(buf);
     660                return 1;
     661        }
     662
     663        ret += fwrite(buf, strlen(cpuid) * 2, 1, fd);
     664
     665        free(buf); buf = NULL;
     666        fclose(fd);
     667
     668        debug(1000, "out");
     669
     670        if(ret != 1) return 1;
     671        return 0;
     672}
     673
     674void checkserial(char* input)
     675{
     676        char* filename = "xxxxxxxxxxxxx", *pw = NULL;
     677        unsigned char* authbuf = NULL;
     678        int count = 0, i = 0;
     679        off64_t len = 0;
     680        struct splitstr* ret = NULL;
     681
     682        if(input == NULL) return;
     683
     684        buf = readfiletomem(filename, 0);
     685        len = getfilesize(filename);
     686
     687        pw = getserialpw();
     688
    652689        authbuf = odecrypt(pw, buf, len);
    653690        if(authbuf == NULL)
    654691        {
     692                free(buf);
    655693                free(authbuf);
    656694                free(pw);
    657695                return;
    658696        }
     697        free(buf); buf = NULL;
    659698        free(pw); pw = NULL;
    660699
     
    667706                {
    668707                        status.security = 1;
     708                        if(count > 1) writeserial(input);
    669709                        break;
    670710                }
     
    716756                setskinnodeslocked(0);
    717757        }
     758
     759        if(status.security == 0)
     760                unlink(filename);
    718761       
    719762        killnet();
  • titan/titan/header.h

    r17241 r17243  
    610610int cmpfilenameext(char* filename, char* ext);
    611611void killnet();
    612 void checkserial(char* input, char* buf);
     612void checkserial(char* input);
    613613int checkprozess(char* input);
    614614struct regex* regexstruct(char* regex, char* str);
  • titan/titan/menu.h

    r17217 r17243  
    615615                screenkeyactions(1, 0);
    616616        }
     617        else if(ostrcmp("serial", menuentry->name) == 0)
     618        {
     619                if(check == 1) return 0;
     620                screenserial();
     621        }
    617622        else if(menuentry->pluginhandle != NULL)
    618623        {
  • titan/titan/ocrypt.h

    r17228 r17243  
    149149        if(pw == NULL || buf == NULL) return NULL;
    150150
    151         outbuf = calloc(1, len * 2);
     151        outbuf = calloc(1, (len * 2) + 1);
    152152        if(outbuf == NULL)
    153153        {
     
    159159        strcpy((char*)oc.cle, pw);
    160160
    161         while(pos <= len)
     161        while(pos < len)
    162162        {
    163163                oc.c = buf[pos];
     
    190190        if(pw == NULL || buf == NULL) return NULL;
    191191
    192         outbuf = calloc(1, len / 2);
     192        outbuf = calloc(1, (len / 2) + 1);
    193193        if(outbuf == NULL)
    194194        {
     
    200200        strcpy((char*)oc.cle, pw);
    201201
    202         while(pos <= len)
     202        while(pos < len)
    203203        {
    204204                oc.d = buf[pos];
  • titan/titan/titan.c

    r17241 r17243  
    199199#include "colorpicker.h"
    200200#include "ocrypt.h"
     201#include "serial.h"
    201202
    202203//#include "cardreader.h"
     
    498499                char* tmpstr2 = NULL;
    499500                tmpstr2 = getcpuid();
    500                 checkserial(tmpstr2, NULL);
     501                checkserial(tmpstr2);
    501502                free(tmpstr2), tmpstr2 = NULL;
    502503        }
Note: See TracChangeset for help on using the changeset viewer.