Created
October 27, 2021 03:17
-
-
Save cpuwolf/7a9424c923ecde397ea1629d3ef62fa7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* written by Wei Shuai <[email protected]> 2021-Oct | |
*/ | |
#include <stdio.h> | |
#include <inttypes.h> | |
#include <string.h> | |
typedef struct { | |
uint64_t b1; | |
uint64_t b2; | |
} SS64; | |
typedef struct { | |
uint64_t buff; | |
uint8_t data[8]; | |
} SS; | |
SS ss; | |
//d3c4d6eb c3c3d5cf | |
const int64_t biglc = -0x302a3c3c14293b2d; | |
int main(int argn, void * argv) | |
{ | |
register int32_t arg2 asm ("esi") = 0xFFFFFFFF; | |
register int32_t arg1 asm ("edi") = 0xAAAAAAAA; | |
printf("readlonly input=0x%lX\n", biglc ); | |
asm("endbr64\n\t" | |
"movq %8,%%xmm0\n\t" | |
"add %%edi,%%esi\n\t" | |
"mov %%esi,%%eax\n\t" | |
"movzbl %%sil,%%edx\n\t" | |
"shl $0x8,%%eax\n\t" | |
"or %%edx,%%eax\n\t" | |
"mov %%esi,%%edx\n\t" | |
"movd %%eax,%%xmm2\n\t" | |
"mov %%esi,%%eax\n\t" | |
"xor $0xffffffa7,%%edx\n\t" | |
"xor $0xffffffa3,%%eax\n\t" | |
"pshuflw $0x0,%%xmm2,%%xmm1\n\t" | |
"mov %%dl,%0\n\t" | |
"mov %%al,%1\n\t" | |
"mov %%esi,%%eax\n\t" | |
"pxor %%xmm1,%%xmm0\n\t" | |
"movq %%xmm0,%2\n\t" | |
"xor $0xffffffe8,%%eax\n\t" | |
"mov %%al,%3\n\t\n\t" | |
"mov %%esi,%%eax\n\t" | |
"xor $0xffffffa1,%%eax\n\t" | |
"mov %%al,%4\n\t\n\t" | |
"mov %%esi,%%eax\n\t" | |
"xor $0xffffffed,%%esi\n\t" | |
"xor $0xffffffa5,%%eax\n\t" | |
"mov %%sil,%5\n\t" | |
"mov %%al,%6\n\t" | |
"mov %%al,%7" | |
: "=m" (ss.data[4]), "=m" (ss.data[0]), "=m" (ss.buff), "=m" (ss.data[1]), "=m" (ss.data[2]), "=m" (ss.data[6]), "=m" (ss.data[3]), "=m" (ss.data[5]) | |
: "m" (biglc)); | |
printf("HEX=0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", ss.data[0], ss.data[1], ss.data[2],ss.data[3],ss.data[4], ss.data[5], ss.data[6]); | |
printf("STR=%c %c %c %c %c %c %c\n", ss.data[0], ss.data[1], ss.data[2],ss.data[3],ss.data[4], ss.data[5], ss.data[6]); | |
printf("buff=0x%lX\n\n", ss.buff ); | |
SS64 a; | |
memcpy(&a, &ss, sizeof(a)); | |
a.b1 = ~a.b1; | |
a.b2 = ~a.b2; | |
printf("0x%lX 0x%lX\n", a.b1, a.b2); | |
//string terminal | |
((SS *)&a)->data[7]=0; | |
printf("%s\n", (char *)&a); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment