Skip to content

Instantly share code, notes, and snippets.

@vanhoavn
Created November 6, 2017 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanhoavn/ace3ccbbfa89fb36c44983b1b66acf39 to your computer and use it in GitHub Desktop.
Save vanhoavn/ace3ccbbfa89fb36c44983b1b66acf39 to your computer and use it in GitHub Desktop.
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned __int64 v3; // rax
size_t len_input; // rax
int v5; // [rsp+Ch] [rbp-64h]
FILE *stream; // [rsp+10h] [rbp-60h]
void *file_content; // [rsp+18h] [rbp-58h]
char n; // [rsp+20h] [rbp-50h]
char result; // [rsp+30h] [rbp-40h]
char e; // [rsp+40h] [rbp-30h]
char m; // [rsp+50h] [rbp-20h]
unsigned __int64 v12; // [rsp+68h] [rbp-8h]
v12 = __readfsqword(0x28u);
initial();
__gmpz_init((__int64)&n);
__gmpz_init((__int64)&result);
__gmpz_init((__int64)&e);
__gmpz_init((__int64)&m);
puts("File list:");
system("ls");
while ( 1 )
{
printf("Input filename(txt) : ", argv);
argv = (const char **)filename;
v5 = read(0, filename, 0xFuLL);
if ( filename[v5 - 1] == 10 )
filename[v5 - 1] = 0;
if ( filename[0] )
{
if ( (unsigned int)check(filename) )
{
v3 = strlen(filename) + 0x602120;
*(_DWORD *)v3 = 'txt.';
*(_BYTE *)(v3 + 4) = 0;
argv = (const char **)"rb";
stream = fopen(filename, "rb");
if ( stream )
{
file_content = malloc(80uLL);
if ( !file_content )
{
puts("something wrong!!");
exit(0);
}
memset(file_content, 0, 80uLL);
fread(file_content, 80uLL, 1uLL, stream);
__gmpz_set_str(&n, &rsa_n, 10LL);
__gmpz_set_ui(&e, rsa_e);
len_input = strlen((const char *)file_content);
__gmpz_import(&m, len_input, 1LL, 1LL, 0LL, 0LL);// m = file_content
__gmpz_powm(&result, &m, &e, &n); // m ** e % n
argv = (const char **)&result;
__gmp_printf("Result: %Zd\n", &result);
free(file_content);
fclose(stream);
}
else
{
puts("error");
}
}
else
{
puts("error");
}
}
}
}
Sign up for free
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment