改用AES256
This commit is contained in:
parent
d420e58926
commit
9c77d9ecc2
2
Makefile
2
Makefile
@ -7,7 +7,7 @@ OBJ := sha
|
|||||||
|
|
||||||
all: aes.o sha.o
|
all: aes.o sha.o
|
||||||
$(CC) $(CFLAGS) -o $(OBJ) $^ $(LDFLAGS)
|
$(CC) $(CFLAGS) -o $(OBJ) $^ $(LDFLAGS)
|
||||||
$(STRIP) $(OBJ)
|
: $(STRIP) $(OBJ)
|
||||||
.c.o:
|
.c.o:
|
||||||
$(CC) $(CFLAGS) -c $<
|
$(CC) $(CFLAGS) -c $<
|
||||||
|
|
||||||
|
@ -20,13 +20,11 @@
|
|||||||
|
|
||||||
SHA
|
SHA
|
||||||
Shell Strict AES 128 bit encryption tool
|
Shell Strict AES 128 bit encryption tool
|
||||||
Author: AIXIAO@AIXIAO.ME
|
AUTHOR: AIXIAO@AIXIAO.ME
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
sha [-kfh?]
|
-k : key
|
||||||
-k : Key
|
-f : Script file
|
||||||
-f : Script File
|
|
||||||
-h -? : Print Help
|
|
||||||
|
|
||||||
|
|
||||||
静态链接:
|
静态链接:
|
||||||
|
4
aes.h
4
aes.h
@ -21,9 +21,9 @@
|
|||||||
#define CTR 1
|
#define CTR 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AES128 1
|
//#define AES128 1
|
||||||
//#define AES192 1
|
//#define AES192 1
|
||||||
//#define AES256 1
|
#define AES256 1
|
||||||
|
|
||||||
#define AES_BLOCKLEN 16 // Block length in bytes - AES is 128b block only
|
#define AES_BLOCKLEN 16 // Block length in bytes - AES is 128b block only
|
||||||
|
|
||||||
|
60
sha.c
60
sha.c
@ -21,7 +21,7 @@ long file_size;
|
|||||||
|
|
||||||
static void hex2str(uint8_t * input, uint16_t input_len, char *output)
|
static void hex2str(uint8_t * input, uint16_t input_len, char *output)
|
||||||
{
|
{
|
||||||
char *hexEncode = "0123456789ABCDEF";
|
const char *hexEncode = "0123456789ABCDEF";
|
||||||
int i = 0, j = 0;
|
int i = 0, j = 0;
|
||||||
|
|
||||||
for (i = 0; i < input_len; i++) {
|
for (i = 0; i < input_len; i++) {
|
||||||
@ -84,9 +84,9 @@ char *source_c[] = {
|
|||||||
"#define CTR 1",
|
"#define CTR 1",
|
||||||
"#endif",
|
"#endif",
|
||||||
"",
|
"",
|
||||||
"#define AES128 1",
|
"//#define AES128 1",
|
||||||
"//#define AES192 1",
|
"//#define AES192 1",
|
||||||
"//#define AES256 1",
|
"#define AES256 1",
|
||||||
"",
|
"",
|
||||||
"#define AES_BLOCKLEN 16 // Block length in bytes - AES is 128b block only",
|
"#define AES_BLOCKLEN 16 // Block length in bytes - AES is 128b block only",
|
||||||
"",
|
"",
|
||||||
@ -603,7 +603,8 @@ char *source_c[] = {
|
|||||||
" if (0 == strncmp(shbin, \"#!\", 2))",
|
" if (0 == strncmp(shbin, \"#!\", 2))",
|
||||||
" {",
|
" {",
|
||||||
" p1 = strchr(shbin, '/');",
|
" p1 = strchr(shbin, '/');",
|
||||||
" strcpy(shbin, p1);",
|
" memcpy(shbin, p1, (p - shll_text) - 2);",
|
||||||
|
" shbin[(p - shll_text) - 2] = '\\0';",
|
||||||
" }",
|
" }",
|
||||||
" else if (0 == strncmp(shbin, \":\", 1))",
|
" else if (0 == strncmp(shbin, \":\", 1))",
|
||||||
" {",
|
" {",
|
||||||
@ -656,14 +657,14 @@ char *source_c[] = {
|
|||||||
"int main(int argc, char *argv[])",
|
"int main(int argc, char *argv[])",
|
||||||
"{",
|
"{",
|
||||||
" char *argvs[BUFFER_SIZE];",
|
" char *argvs[BUFFER_SIZE];",
|
||||||
|
" char *shbin = NULL;",
|
||||||
" int l=1;",
|
" int l=1;",
|
||||||
" int i=4;",
|
" int i=4;",
|
||||||
"",
|
"",
|
||||||
" struct AES_ctx ctx;",
|
" struct AES_ctx ctx;",
|
||||||
" uint8_t *Hex_string = (uint8_t *) malloc(encrypted_text_len*2);",
|
" uint8_t *Hex_string = (uint8_t *) malloc(encrypted_text_len*2);",
|
||||||
" char *shbin = NULL;",
|
|
||||||
"",
|
|
||||||
|
|
||||||
|
"",
|
||||||
" reverse_string((char *)Encrypted_data, encrypted_text_len*2);",
|
" reverse_string((char *)Encrypted_data, encrypted_text_len*2);",
|
||||||
" memset(Hex_string, 0, encrypted_text_len*2);",
|
" memset(Hex_string, 0, encrypted_text_len*2);",
|
||||||
"",
|
"",
|
||||||
@ -722,28 +723,21 @@ char *source_c[] = {
|
|||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
void reverse_string(char *str)
|
void reverse_string(char *str, int length)
|
||||||
{
|
{
|
||||||
int length;
|
if (str == NULL) {
|
||||||
char *p1;
|
|
||||||
char *p2;
|
|
||||||
|
|
||||||
length = strlen(str); //获取字符串长度
|
|
||||||
p1 = str; //p1指向字符串首地址
|
|
||||||
p2 = str + length - 1; //p2指向字符串尾地址
|
|
||||||
if (!str) {
|
|
||||||
printf("空指针错误!");
|
printf("空指针错误!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (p1 < p2) //当p1地址小于p2地址时执行循环
|
|
||||||
{
|
|
||||||
char c = *p1;
|
|
||||||
*p1 = *p2; //完成指针指向地址的值的交换
|
|
||||||
*p2 = c;
|
|
||||||
p1++; //交换完毕后p1指针指向下一个字符地址
|
|
||||||
p2--; //交换完毕后p2指针指向上一个字符地址
|
|
||||||
}
|
|
||||||
|
|
||||||
|
char *start = str;
|
||||||
|
char *end = str + length - 1;
|
||||||
|
|
||||||
|
while (start < end) {
|
||||||
|
char temp = *start;
|
||||||
|
*start++ = *end;
|
||||||
|
*end-- = temp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void usage(void)
|
void usage(void)
|
||||||
@ -774,12 +768,12 @@ char pool[] = {
|
|||||||
|
|
||||||
int rand_key(char *key)
|
int rand_key(char *key)
|
||||||
{
|
{
|
||||||
int PASSWD_LEN = 16;
|
int PASSWD_LEN = 32;
|
||||||
struct timeval tpstart;
|
struct timeval tpstart;
|
||||||
char password[17];
|
char password[33];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
memset(password, 0, 17);
|
memset(password, 0, 33);
|
||||||
gettimeofday(&tpstart, NULL);
|
gettimeofday(&tpstart, NULL);
|
||||||
srand(tpstart.tv_usec);
|
srand(tpstart.tv_usec);
|
||||||
|
|
||||||
@ -794,7 +788,7 @@ int rand_key(char *key)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
static uint8_t key[17] = "";
|
static uint8_t key[33] = "";
|
||||||
char sh_file[1024];
|
char sh_file[1024];
|
||||||
int indx = 0;
|
int indx = 0;
|
||||||
|
|
||||||
@ -866,15 +860,15 @@ int main(int argc, char *argv[])
|
|||||||
//转16进制字符串
|
//转16进制字符串
|
||||||
hex2str(text_content, file_size, (char *)hexString);
|
hex2str(text_content, file_size, (char *)hexString);
|
||||||
|
|
||||||
reverse_string((char *)hexString);
|
reverse_string((char *)hexString, text_content_length*2);
|
||||||
|
|
||||||
//拼接
|
//拼接
|
||||||
strcat((char *)encrypted_text, "char Encrypted_data[]=\"");
|
strncat((char *)encrypted_text, "char Encrypted_data[]=\"", 24);
|
||||||
strcat((char *)encrypted_text, (const char *)hexString);
|
strncat((char *)encrypted_text, (const char *)hexString, text_content_length*2);
|
||||||
strcat((char *)encrypted_text, "\";");
|
strcat((char *)encrypted_text, "\";");
|
||||||
|
|
||||||
strcpy(encrypted_key, "const char key[17] = \"");
|
memcpy(encrypted_key, "const char key[33] = \"", 23);
|
||||||
strcat((char *)encrypted_key, (char *)key);
|
strncat((char *)encrypted_key, (char *)key, 32);
|
||||||
strcat((char *)encrypted_key, "\";");
|
strcat((char *)encrypted_key, "\";");
|
||||||
|
|
||||||
// 长度
|
// 长度
|
||||||
@ -916,6 +910,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
//remove(sourcefile);
|
//remove(sourcefile);
|
||||||
free(buff);
|
free(buff);
|
||||||
|
free(hexString);
|
||||||
|
|
||||||
|
|
||||||
// 压缩
|
// 压缩
|
||||||
if (system("which upx 1> /dev/null") == 0) {
|
if (system("which upx 1> /dev/null") == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user