Created
June 13, 2023 08:10
-
-
Save dscp46/baf743a451415d12b362428a57c8560d to your computer and use it in GitHub Desktop.
Decode Type 7 string
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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #define TYPE7_LUT_SZ 53 | |
| const unsigned char type7_lut[] = "dsfd;kfoA,.iyewrkldJKDHSUBsgvca69834ncxv9873254k;fg87"; | |
| void deobfuscate( const char* in, char* out) | |
| { | |
| int in_sz = strlen( in)/2; | |
| unsigned char val; | |
| char offset_str[3] = { 0, 0, 0}; | |
| // Read LUT offset (stored in decimal form in 2 first bytes) | |
| memcpy( offset_str, in, 2); | |
| int offset = atoi( offset_str); | |
| for( int i=1; i<in_sz; ++i) | |
| { | |
| sscanf( in+(i*2), "%2hhx", &val); // Read and decode hex byte | |
| out[i-1] = val ^ type7_lut[offset]; // XOR read byte and LUT byte | |
| if( ++offset >= TYPE7_LUT_SZ) // Increment LUT offset | |
| offset = 0; | |
| } | |
| } | |
| int main( int argc, char** argv) | |
| { | |
| if( argc != 2 ) | |
| { | |
| printf( "Usage: %s type7_secret\n", argv[0] ); | |
| return 1; | |
| } | |
| // Allocate result string | |
| int clear_len = strlen( argv[1]) / 2; | |
| char *result = (char*) malloc( clear_len); | |
| memset( result, clear_len, 0); | |
| deobfuscate( argv[1], result); | |
| printf( "Decoded password: %s\n", result); | |
| free(result); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment