i guess this reply comes too late but, bioshacker001 its obvious you are new to cpp. (no flaming intended
)
what i meant was
Code:
#include <cstdio>
#include <cstdlib>
#include <string.h>
#define BUFFER_SIZE 4096
char buffer[BUFFER_SIZE];
char token[BUFFER_SIZE + 1];
int lookAhead;
int bufferPos;
int bufferLen;
int nextChar(FILE *file){
if (bufferPos == bufferLen){
bufferLen = fread(buffer, 1, BUFFER_SIZE, file);
if (bufferLen <= 0)
return -1;
bufferPos = 0;
}
return buffer[bufferPos++];
}
void readUntil(FILE *file, char *buf, int &nowAt, char targetCh){
bool inStr = false;
lookAhead = nextChar(file);
while ((lookAhead != targetCh) || inStr){
buf[nowAt++] = lookAhead;
if (lookAhead == '"') inStr = !inStr;
lookAhead = nextChar(file);
if (lookAhead < 0) return;
}
}
void nextToken(FILE *file){
int nowAt = 0;
token[nowAt++] = lookAhead;
if (lookAhead == '<'){
readUntil(file, token, nowAt, '>');
token[nowAt++] = lookAhead;
lookAhead = nextChar(file);
} else
readUntil(file, token, nowAt, '<');
token[nowAt] = '\0';
}
bool beginWith(char *str, char *head){
int len = strlen(head);
if (strlen(str) < len) return false;
for (int i = 0; i < len; i++)
if (str[i] != head[i])
return false;
return true;
}
bool endWith(char *str, char *tail){
int len = strlen(tail);
int slen = strlen(str);
if (slen < len) return false;
for (int i = 0; i < len; i++)
if (str[slen - i - 1] != tail[len - i - 1])
return false;
return true;
}
void printLogbankHead(char *head, FILE *file){
int i = 0;
while (head[i] != ' '){
fprintf(file, "%c", head[i]);
i++;
}
fprintf(file, " count=\"0\" ");
do{
i++;
} while (head[i] != ' ');
i++;
while ((head[i] != '/') && (head[i] != '>')){
fprintf(file, "%c", head[i]);
i++;
}
fprintf(file, "/>");
}
int main(int argc, char* argv[]){
if (argc != 3)
{
printf("\nusage:\n");printf(argv[0]);printf("\"input file\" \"output file\"");
return 1;
}
FILE *xmlFile = fopen(argv[1], "r");
FILE *outputFile = fopen(argv[2], "w");
bufferPos = 0;
bufferLen = 0;
lookAhead = nextChar(xmlFile);
while (lookAhead >= 0){
nextToken(xmlFile);
if (beginWith(token, "<logbank ")){
printLogbankHead(token, outputFile);
if (!endWith(token, "/>"))
do{
nextToken(xmlFile);
}while(strcmp(token, "</logbank>"));
} else
fprintf(outputFile, "%s", token);
}
fclose(xmlFile);
fclose(outputFile);
}
now you can call the exe from cmd, and the files can be anywhere you want
example:
OnlinkLogNuker.exe "C:\Users\Hans Henrik\Desktop\Hacked.xml" "C:\Users\Hans Henrik\Desktop\Hacked.LogsNuked.xml"