64 lines
1.3 KiB
C++
64 lines
1.3 KiB
C++
U8 key[4][256];
|
|
|
|
U0 InitKey()
|
|
{
|
|
I64 i,j;
|
|
for (i=0;i<4;i++) {
|
|
for (j=0;j<256;j++)
|
|
key[i][j]=j;
|
|
for (j=0;j<255;j++)
|
|
SwapU8(&key[i][j],&key[i][j+RandU32%(256-j)]);
|
|
}
|
|
}
|
|
|
|
U0 LogScrambleFile(U8 *name)
|
|
{
|
|
CDoc *doc=DocRead(name,DOCF_PLAIN_TEXT);
|
|
CDocEntry *doc_e=doc->root.next;
|
|
I64 i;
|
|
U32 num;
|
|
U8 *st,*st2;
|
|
"Scrambling: %s\n",name;
|
|
while (doc_e!=doc) {
|
|
if (doc_e->type_u8==DOCT_TEXT) {
|
|
st=MAlloc(StrLen(doc_e->tag)+1);
|
|
st2=MAlloc(StrLen(doc_e->tag)+1);
|
|
StrFirstRem(doc_e->tag," ",st);
|
|
|
|
for (i=3;i>=0;i--) {
|
|
StrFirstRem(st,".",st2);
|
|
num.u8[i]=key[i][A2I(st2)&255];
|
|
}
|
|
|
|
Free(st);
|
|
Free(st2);
|
|
|
|
st=MSPrintF("%d.%d.%d.%d %s",num.u8[3],num.u8[2],num.u8[1],num.u8[0],doc_e->tag);
|
|
Free(doc_e->tag);
|
|
doc_e->tag=st;
|
|
}
|
|
doc_e=doc_e->next;
|
|
}
|
|
DocWrite(doc);
|
|
DocDel(doc);
|
|
}
|
|
|
|
U0 WebLogScramble(U8 *wild)
|
|
{
|
|
CDirEntry *tempm=FilesFind(wild,FUF_RECURSE|FUF_JUST_FILES),
|
|
*tempm1;
|
|
InitKey;
|
|
while (tempm) {
|
|
tempm1=tempm->next;
|
|
LogScrambleFile(tempm->full_name);
|
|
CDirEntryDel(tempm);
|
|
tempm=tempm1;
|
|
}
|
|
}
|
|
|
|
//Danger scrambles all log files in the /SparrowOS tree
|
|
|
|
ST_WARN_ST "This will scramble all .LOG.Z files in the /SparrowOS Tree.\n\n";
|
|
if (AreYouSure)
|
|
WebLogScramble("/SparrowOS/*.LOG.Z");
|