-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunescape.cpp
More file actions
50 lines (45 loc) · 925 Bytes
/
unescape.cpp
File metadata and controls
50 lines (45 loc) · 925 Bytes
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
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <vector>
using namespace std;
//cl unescape.cpp /O2 /EHsc /GA /MT /Feunescape.exe
int main(int argc,char* argv[])
{
struct _stati64 statbuff;
vector<BYTE> buff;
if(argc<2)
{
printf("Usage:\nunescape <filename> - unescapes \\x type escapes\n");
return 0;
}
if(-1==_stati64(argv[1],&statbuff))
{
printf("Couldn't get info on file\n");
return -1;
}
buff.resize(statbuff.st_size);
FILE*fp=fopen(argv[1],"rb");
fread(&buff[0],1,statbuff.st_size,fp);
fclose(fp);
for(__int64 i=0;i<statbuff.st_size;)
{
if( (i<(statbuff.st_size-3)) && (buff[i]=='\\') && (buff[i+1]=='x') )
{
char slask[10];
slask[0]=buff[i+2];
slask[1]=buff[i+3];
slask[2]=0;
int val=strtol(slask,NULL,16);
i+=4;
printf("%c",(char)val);
}
else
{
printf("%c",buff[i++]);
}
}
return 0;
}